Legacy Documentation: Version 4.6.2
Language: English
Predefined shader preprocessor macros
Making multiple shader program variants

Built-in state variables in shader programs

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

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.

Predefined shader preprocessor macros
Making multiple shader program variants