In unity document https://docs.unity3d.com/Manual/SL-PlatformDifferences.html,saying "The clip space depth goes from +1.0 at the near plane to 0.0 at the far plane. “,I think it means Z in D3D CVV is from 1 to 0 with leaving camera from near to far;
However,in some graphic articles,like microsoft document https://learn.microsoft.com/en-us/windows/win32/direct3d9/projection-transform,saying"The limits of the z-direction are 0 for the front plane and 1 for the back plane.”,I think it means Z in D3D CVV is from 0 to 1 with leaving camera from near to far.
Can anyone explain how to understand this?It seems contradiction and I am really confused.
Unity uses reverse depth values on some platforms. See the paragraph “The Depth (Z) direction in Shaders” in the document, you mentioned.
DirectX usually expects NDC.z to be in the range 0 to 1.
OpenGL usually expects NDC.z to be in the range -1 to 1.
Whether 1 is interpreted as the near or far plane depends on the projection matrix that you are using and the depth comparison mode (ZTest) that you specify. The advantage of reverse depth is has a more even precision across the range.
1 Like
Thanks for the article link and I’ve read it.It’s very useful.I think that Unity choosing the reverse depth in DX also has help to resolve Z-Fighting.
1 Like