Advertisement

Logarithmic Depth Buffer for Orthographic Camera

Started by December 01, 2018 04:25 AM
1 comment, last by MJP 6 years, 2 months ago

So I had tried to implement the logarithmic depth buffer solution, but I realised that my camera is orthographic. So the math should be different as compared to the one used for perspective camera.

From Outerra's article, The DirectX formula is z = log(C * w + 1) / log(C * Far + 1) * w

Does anyone know how to modify it for use with an orthographic camera?

After applying a D3D-style perspective projection, "w" is equivalent to the Z coordinate of the vertex is in view space (relative to the eye/camera). A typical orthographic projection does not produce an equivalent value, instead the "z" value is equivalent to (ViewSpaceZ - NearClip) / (FarClip - NearClip). So if you'd like you can reconstruct the view-space Z value from that using the Near/Far clip plane values that you used, or by directly using values from the orthographic matrix. Or alternatively, you can just compute ViewSpaceZ in the vertex shader by transforming the vertex into view space.
 

This topic is closed to new replies.

Advertisement