I am trying to retrieve depth it seems that there’s two way to do it, manually and using the _CameraDepthNormalsTexture.
Using _CameraDepthNormalsTexture, I can’t simply get any result.
Using the manual way I am having nice results but I am still facing some difficulties.
o.depth = -mul(UNITY_MATRIX_MV, v.vertex).z * _ProjectionParams.w;
With this formula, I have a nice result but it is link with the Camera clipping planes which is a bit annoying.
o.depth = 1.0 / (_ProjectionParams.x * -mul(UNITY_MATRIX_MV, v.vertex).z + _ProjectionParams.y);
With this forumula, the depth is no more related to the camera clipping planes but to the camera position… which is worse.
Is there a better way to retrieve depth ?
Thanks a lot !