What’s difference between UNITY_MATRIX_P and unity_CameraProjection.I found they have difference values in the same camera context.(marked in red color bellow)
unity_CameraProjection = float4x4
{ 1.73392,0,0,0,
0,1.69752,0,0,
0,0,-1,-0.18294,
0,0,-1,0 }
while
UNITY_MATRIX_P = float4x4{
1.73392,0,0,0,
0,-1.69752,0,0
0,0,0,0.09142
0,0,-1,0};
Please help, if someone get the answer,many thanks.
unity_CameraProjection
is equivalent to the Camera component’s .projectionMatrix
. and is always the “main” camera’s projection matrix. This is always using OpenGL’s projection matrix layout.
UNITY_MATRIX_P
is the current projection matrix being used for rendering, configured for the current API which may or may not be OpenGL, and which may or may not be rendering from the main camera’s view. OpenGL projection matrices result in a clip space that has a “-1.0 to +1.0” near to far range, where all other APIs use “+1.0 to 0.0” near to far range. The projection may also be flipped vertically on non-OpenGL graphics APIs … for reasons. Some examples of cases where you wouldn’t be rendering from the main camera’s view would be when rendering shadow maps when the view and projection matrices are overridden to be from that light’s “view(s)”, or during post processing when the view and projection matrices is overridden to be an unscaled orthographic matrix.
Thank you for your help!