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

  • layerRepeat number: 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

  • layerRepeat number: How many world units one tile of each ground texture covers.

Inherited Actions

22 actions from Libraries.Game.Graphics.Shaders.Programs.ShaderProgram
3 actions from Libraries.Language.Object