Why do the following two lines of shaderlab code give me two different results?

o.pos = mul(UNITY_MATRIX_MVP, v.vertex);

o.pos = mul(UNITY_MATRIX_MV * UNITY_MATRIX_P, v.vertex); // Also tried reversing multiplication

Why do the following two lines of shaderlab code give me two different results?

o.pos = mul(UNITY_MATRIX_MVP, v.vertex);

o.pos = mul(UNITY_MATRIX_MV * UNITY_MATRIX_P, v.vertex); // Also tried reversing multiplication

Unity does the calculation backwards.

o.pos = mul (mul(UNITY_MATRIX_P,UNITY_MATRIX_MV),v.vertex);

I’d tried backwards but not using mul(). That seems to be key!

For reference it’s not “backwards”. It’s just how matrix-column vector multiplications work: the matrix needs to be on the left. The MVP matrix transforms a vector from object space to clip space. We compose the MVP matrix from the model matrix (object to world), the view matrix (world to eye), and the projection matrix (eye to clip). The matrices need to be left-multiplied onto the vector in that order:

P * V * M * x