Unexpected result when multiplying inverse view matrix and inverse projection matrix

I was kind of pulling out my hair for a while trying to get the world position from the depth buffer on a fullscreen quad. What worked in the end was the code from this gist: WorldPositionFromDepth thx d4rkpl4y3r and lox · GitHub

While this worked exactly the way I wanted, I was still very surprised about the inverse function however, because I felt like it should be possible to get the same result from just the build-in matrices.

I tried to replace the inverse function with mul(UNITY_MATRIX_I_V, unity_CameraInvProjection), but this yielded a completely broken result. Now my question is: why? Should the multiplication of the inverse view matrix and the inverse projection matrix not return the exact same matrix as calculating the inverse of the View*Projection matrix? I’m trying to figure out where my misunderstanding is and if there might be another way to get rid of that very heavy inverse function, that doesn’t rely on pre-computing the matrix in C#.

Thanks :slight_smile: