I’m using the R channel of a depth render to texture. The values start at the near clipping plane and extend all the way out to the far clipping plane. Is there a way to adjust this so that the closest object is 1 and the farthest is 0 without adjusting the clipping planes?
What I mean is that my objects only occupy the first 2% of the area between the near and far clip planes so everything appears black (in hrDepth.r) sans alpha. I have to bring the far clipping plane to the edge of the farthest object to see the full 0 - 1 range in the depth buffer.
However, I get the full 0 - 1 range with “hrDepth.g” and setting the far clipping plane to “5555”. I have no idea why this works, so I need to read up on it. I think I need to understand what’s going on more before I ask these questions ha
The depth in the buffer is non-linear, and mostly depends on the distance of your near plane.
Use these functions from UnityCG.cginc to linearize it: Linear01Depth(z) will return linear depth in 0…1 range; LinearEyeDepth(z) will return linear depth in world space units.