Previous
Predefined shader preprocessor macros
Next
Making multiple shader program variants
Suggest a change

Built-in state variables in shader programs

Often in shader programs you need to access some global state, for example, the current modelviewprojection 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_V: Current view matrix.

UNITY_MATRIX_P: Current projection matrix

UNITY_MATRIX_VP: Current view*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.

Previous
Predefined shader preprocessor macros
Next
Making multiple shader program variants
Your name (optional):
Your email (optional):
Please write your suggestion here: