Graphics Reference
In-Depth Information
Figure 11.8. Post-perspective z/w vs. view space z .
in a depth buffer is non-linear with respect to the distance from the camera, and increases
exponentially. Figure 11.8 shows a graph of Z/W for a range of Z values between the near
clipping plane and far clipping plane (1 and 100 in this case).
Because of this non-linearity, more precision is used for depth ranges closer to the
near clipping plane than to the far clipping plane, as demonstrated by the fast rise in the
Z/W plot in Figure 11.8. This can cause error by causing reconstructed positions to become
high for surfaces that are close to the far clipping plane. It should be noted that D3D11
has 32-bit floating point depth stencil formats available. However floating point numbers
also have an inherent non-linear distribution of precision that causes error to increase as
values move away from zero(Goldberg, 1991), which can actually compound the errors.
To counteract this, it is possible to flip the distances for the near and far plane when creat-
ing a perspective projection(Persson, A couple of notes about Z, 2009), (Kemen, 2009).
With such a projection Z/W will begin at 1.0 at the near clipping plane and decrease to 0.0,
causing the two non-linear precision distributions to mostly balance out. It should be noted
that if this technique is used, the direction of the depth test will also need to be reversed.
11.4.2 Light Shading Optimizations
As mentioned in the previous sections, applying lighting in a deferred Tenderer requires sam-
pling the g-buffer textures, performing lighting calculations in a pixel shader, and summing
the results with the contents of the render target. Consequently, the performance of a particu-
lar scene is often directly tied to the number of pixels shaded during the lighting pass. This
Search WWH ::




Custom Search