Graphics Reference
In-Depth Information
It is important to note that deferred rendering techniques require hardware support for
Multiple Render Targets (MRTs). Direct3D feature level 9.3 supports four simultaneous
render targets, while a feature level above 10 supports up to eight.
Filling the G-Buffer
A geometry buffer or G-Buffer is a collection of one or more textures that contain attributes
of the current frame necessary to render the final scene at a later stage, usually within
screen space. The attributes stored in the G-Buffer might consist of data, such as position,
normal vectors, diffuse, and other material properties.
This recipe prepares a G-Buffer that collects the information needed for a classic deferred
rendering technique (or deferred shading); however, the approach can be easily extended
to cache information for any deferred technique.
Getting ready
We will need a scene with a number of objects and varying materials. We will use the
MeshRenderer class and vertex structure from the Adding surface detail with normal
mapping recipe in Chapter 6 , Adding Surface Detail with Normal and Displacement Mapping .
We will assume that the second and third texture slots in both the loaded meshes and the
pixel shaders are used for normal maps and specular intensity maps, respectively.
The example scene used throughout this chapter is the Sponza Model made available to the
public by Crytek at http://www.crytek.com/cryengine/cryengine3/downloads .
The FBX version is available with the downloadable source for this chapter and the textures
can be retrieved from the previous URL.
The render targets required and the layout of the G-Buffer that we will use in this recipe
is shown in the following diagram. We will create three render targets and reconstruct the
position data from the depth buffer and screen coordinates. Although we only pack the
normals in this recipe, we could also pack everything into a single 128-bit render target.
Example G-Buffer render target layout representing a single pixel
 
Search WWH ::




Custom Search