Shader Constants

This section lists the GameMaker: Studio specific constants used for creating shaders.

Apart from the shader functions and constants defined in the OpenGL ES Shading Language (GLSL ES) Reference Pages, there are also a number of shader constants available to you that are unique to GameMaker: Studio.

Matrices

The following display matrix constants can be used as array indices when using the shader array constant gm_Matrices:

ConstantDescription
MATRIX_VIEWThis array index constant holds the index to the current view matrix. The index returned would be used as an array value when calling the gm_Matrices constant within the shader code.
MATRIX_PROJECTIONThis array index constant holds the index to the current projection matrix. The index returned would be used as an array value when calling the gm_Matrices constant within the shader code.
MATRIX_WORLDThis array index constant holds the index to the current world matrix. This can be used for things like lighting if you have light information in world-space. The index returned would be used as an array value when calling the gm_Matrices constant within the shader code.
MATRIX_WORLD_VIEWThis array index constant holds the index to the result of the world and view matrices multiplied together. This is often used for things like fog. The index returned would be used as an array value when calling the gm_Matrices constant within the shader code.
MATRIX_WORLD_VIEW_PROJECTIONThis array index constant holds the index to the result of the world, view and projection matrices multiplied together. This is the normal transformation matrix used for vertex positions. The index returned would be used as an array value when calling the gm_Matrices constant within the shader code.
MATRIX_MAXThis is not an array index, but rather returns the size of the matrix array in the vertex shader.
MAX_VS_LIGHTSThis is not an array index, but rather returns the number of the lights in the vertex shader.

Other Constants

The following pre-defined matrix uniforms and constants can be used in your shader to access GameMaker: Studio specific values:

ConstantDescription
gm_Matrices[matrix]This array constant returns a transform matrix and is one of the available pre-defined uniforms that GameMaker: Studio creates for you to use within the shader code editor. The array index is chosen from one of the above listed constants.
gm_BaseTextureThis is a 2D sampler constant that returns the texture of the current object, as set by GameMaker: Studio. So it would be the current sprite, surface or texture that would normally be used when drawing without the shader being called.
gm_LightingEnabledThis can be used to get or set the GameMaker: Studio lighting when using 3D.
gm_FogStartThis can be used to get the distance where polygons start to be blended with the fog colour.
gm_RcpFogRangeThis can be used to get the distance at which fog is maximal and nothing can be seen anymore.
gm_PS_FogEnabledThis will return true or false if the GPU has pixel fog enabled or not.
gm_FogColourThis can be used to get the fog colour used by GameMaker: Studio.
gm_VS_FogEnabledThis will return true or false if the GPU has vertex fog enabled or not.
gm_AlphaTestEnabledThis can be used to get alpha testing in the shader. See draw_set_alpha_test for more information on alpha testing.
gm_AlphaRefValueThis can be used to get the current alpha testing reference value. See draw_set_alpha_test_ref_value for more information on the alpha test reference.


Back: Shaders

© Copyright YoYo Games Ltd. 2018 All Rights Reserved