Built-in state variables in shader programs
Manual     Reference     Scripting   
Reference Manual > Shader Reference > Writing vertex and fragment shaders > Built-in state variables in shader programs

Built-in state variables in shader programs

Often in shader programs you need to access some global state, for example, the current model*view*projection matrix, the current ambient color, and so on. There's no need to declare these variables for the built-in state, you can just use them in shader programs.

Built-in matrices

Matrices (float4x4) supported:

UNITY_MATRIX_MVP
Current model*view*projection matrix
UNITY_MATRIX_MV
Current model*view matrix
UNITY_MATRIX_P
Current projection matrix
UNITY_MATRIX_T_MV
Transpose of model*view matrix
UNITY_MATRIX_IT_MV
Inverse transpose of model*view matrix
UNITY_MATRIX_TEXTURE0 to UNITY_MATRIX_TEXTURE3
Texture transformation matrices

Built-in vectors

Vectors (float4) supported:

UNITY_LIGHTMODEL_AMBIENT
Current ambient color.

Page last updated: 2010-08-18