Built-in Variables

Built-in variables are frequently used in Shader code. There are two types: per-vertex attribute variables and per-shader uniform variables.

Below are the engine's built-in variables for reference when writing Shaders:

Vertex Inputs

Per-vertex DataAttribute NameData Type
VertexPOSITIONvec3
NormalNORMALvec3
TangentTANGENTvec4
Vertex ColorCOLOR_0vec4
Bone IndicesJOINTS_0vec4
Bone WeightsWEIGHTS_0vec4
First UV SetTEXCOORD_0vec2
Second UV SetTEXCOORD_1vec2

Properties

Renderer

NameTypeDescription
renderer_LocalMatmat4Model local coordinate matrix
renderer_ModelMatmat4Model world coordinate matrix
renderer_MVMatmat4Model view matrix
renderer_MVPMatmat4Model view projection matrix
renderer_NormalMatmat4Normal matrix

Camera

NameTypeDescription
camera_ViewMatmat4View matrix
camera_ProjMatmat4Projection matrix
camera_VPMatmat4View projection matrix
camera_ViewInvMatmat4Inverse view matrix
camera_Positionvec3Camera position
camera_DepthTexturesampler2DDepth information texture
camera_OpaqueTexturesampler2DOpaque texture
camera_DepthBufferParamsVec4Camera depth buffer parameters: (x: 1.0 - far / near, y: far / near, z: 0, w: 0)
camera_ProjectionParamsVec4Projection matrix parameters: (x: flipProjection ? -1 : 1, y: near, z: far, w: 0)

Time

NameTypeDescription
scene_ElapsedTimevec4Total time since engine started: (x: t, y: sin(t), z: cos(t), w: 0)
scene_DeltaTimevec4Time since last frame: (x: dt, y: 0, z: 0, w: 0)

Fog

NameTypeDescription
scene_FogColorvec4Fog color
scene_FogParamsvec4Fog parameters: (x: -1/(end-start), y: end/(end-start), z: density / ln(2), w: density / sqr(ln(2))

Was this page helpful?