480 10. The Rendering Engine
techniques are demonstrated in a DirectX sample program available in the
DirectX SDK—see htt p://msdn.microsoft .com/en-us/library/bb147287.aspx
for more details.
10.3.4. Deferred Rendering
In traditional triangle-rasterization–based rendering, all lighting and shad-
ing calculations are performed on the triangle fragments in view space. The
problem with this technique is that it is inherently ineffi cient. For one thing,
we potentially do work that we don’t need to do. We shade the vertices of tri-
angles, only to discover during the rasterization stage that the entire triangle
is being depth-culled by the z test. Early z tests help eliminate unnecessary
pixel shader evaluations, but even this isn’t perfect. What’s more, in order to
handle a complex scene with lots of lights, we end up with a proliferation of
diff erent versions of our vertex and pixel shaders—versions that handle dif-
Figure 10.57. Screenshots from Killzone 2, showing some of the typical components of the
G-buffer used in deferred rendering. The upper image shows the fi nal rendered image. Below
it, clockwise from the upper left, are the albedo (diffuse) color, depth, view-space normal,
screen space 2D motion vector (for motion blurring), specular power, and specular intensity.