Manually calculate the UNITY_MATRIX_MVP matrix

For a test I am doing, I would like to calculate the built-in UNITY_MATRIX_MVP matrix that gets passed into shaders.

However the way I am calculating it isn’t quite correct because I see a significant visual difference when using the UNITY_MATRIX_MVP matrix in my shader vs my custom MVP matrix.

The way I am calculating the matrix is like so,

Matrix4x4 manualMvpMatrix = camera.projectionMatrix * camera.worldToCameraMatrix;

Can anyone tell me what I am doing wrong here? Thanks!

MVP = model * view * projection
You miss model part.
But I’m not sure.

Ah, I see what I did wrong. You were right. I need to multiply my model by the _Object2World matrix like so

C#

Matrix4x4 manualVpMatrix = camera.projectionMatrix * camera.worldToCameraMatrix;

Shader

OUT.position = mul( _manualVpMatrix, mul( _Object2World, position ) );

Thanks!