TerrainSplatShaderProgram
Package: Libraries.Game.Graphics.Worlds · Inherits from: Libraries.Language.Object, Libraries.Game.Graphics.Shaders.Programs.ShaderProgram
TerrainSplatShaderProgram draws terrain with texture splatting. It uses the default 3D vertex shader, the TerrainSplatFragmentShader, and the default 3D shader mapping, so it fits anywhere the default 3D program does. Compile it with InstallAsProgram and give it to the terrain's models with SetShaderProgram (WorldTerrain's SetSplatProgram does this). Only those models are then drawn with it. InstallAsDefault is the older prototype: it compiles the program under the default 3D program's name, so every model is drawn with it, and its fragment shader draws models that aren't terrain as the default shader would. It is kept for now as a fallback, for painters that ignore SetShaderProgram.
Example Code
use Libraries.Game.Game
use Libraries.Game.Graphics.Worlds.TerrainSplatShaderProgram
class Main is Game
action Main
StartGame()
end
action CreateGame
TerrainSplatShaderProgram program
program:InstallAsProgram(4)
end
end
Actions
GetSplatFragmentShader()
This action returns the program's fragment shader.
Returns
Libraries.Game.Graphics.Worlds.TerrainSplatFragmentShader: The splat fragment shader.
InstallAsDefault(number layerRepeat)
This action compiles the program under the default 3D program's name, so the painter draws every 3D model with it. It must be called before the first frame is drawn, such as in CreateGame, since the painter keeps the default program it finds first.
Parameters
layerRepeatnumber: How many world units one tile of each ground texture covers.
Returns
boolean: True if the program is now the default 3D program.
InstallAsProgram(number layerRepeat)
This action compiles the program under its own name, for giving to models with SetShaderProgram once the painter honors it.
Parameters
layerRepeatnumber: How many world units one tile of each ground texture covers.
Inherited Actions
22 actions from Libraries.Game.Graphics.Shaders.Programs.ShaderProgram
- Add(Libraries.Game.Graphics.Shaders.Shader shader)
- Begin()
- Compile()
- Dispose()
- Draw(Libraries.Game.Graphics.Mesh mesh, Libraries.Game.Graphics.Camera camera, integer startIndex, integer totalIndices)
- Draw(Libraries.Game.Graphics.Drawable drawable, integer startIndex, integer totalIndices)
- Draw(Libraries.Game.Graphics.Mesh mesh, Libraries.Game.Graphics.Camera camera, integer startIndex, integer totalIndices, Libraries.Containers.Array<integer> vertexLocations)
- Draw(Libraries.Game.Graphics.Drawable drawable)
- End()
- GetID()
- GetName()
- GetShaderIterator()
- GetShaderMapping()
- GetShaderProgramStrategy()
- IsCompiled()
- IsOpenGLProgram()
- IsVulkanProgram()
- Reload()
- Remove(Libraries.Game.Graphics.Shaders.Shader shader)
- Render(Libraries.Game.Graphics.Renderable renderable)
- SetName(text name)
- SetShaderMapping(Libraries.Game.Graphics.Shaders.ShaderMapping shaderMapping)