DirectX11 Deferred Shading

Deferred shading is a screen-space shading technique. It is called deferred because no shading is actually performed in the first pass of the vertex and pixel shaders, instead, shading is deferred until a second pass.
The first step is to render all scene geometry into a g-buffer, which typically consists of several render target textures. The individual channels of these textures are used to store geometry surface information per-pixel, such as surface normal or material properties.

Presentation

The second step is the lighting phase. In this step, geometry representing the light’s area of influence on the screen is rendered, and for each resulting fragment that is shaded, the g-buffer information is sampled from the render target textures.
The g-buffer information is then combined with the light properties to determine the resulting lighting contribution to that pixel. The contribution is then summed with the contribution of all other light sources affecting that pixel, to determine the final lit color of the surface.

Advantages 

  • Scene geometry decoupled from lighting
  • Shading/lighting only applied to visible fragments
  • Reduction in the Render States
  • G-Buffer already produces data required for post-processing

Disadvantages 

  • Significant engine rework
  • Requires more memory
  • Costly and complicated MSAA
  • Forward rendering required for translucent objects

Optimizations 

  • Octahedron normal vector encoding
  • Diffuse Albedo: Source data is typically a color value of the range [0, 1]. This means that we can use an unsigned, normalized, 8-bit integer format such as DXGI_FORMAT_R8G8B8A8_UNORM.
  • Specular Albedo and Power: Same than Diffuse Albedo
  • Position: It is a value that typically requires high precision, then we do not output positions in a render target. Instead we output depth in view space, and we compute world fragment position in lighting pass. Then we can use DXGI_FORMAT_R16_FLOAT format.
  • Culling with screen-aligned quads for directional and point lights.

Demo Scene 

  • Phenom II x4 965, 8GB Ram, Radeon 7850
  • 4 planes and 1 torus knot rendered with normal displacement mapping
  • 4096 point lights at 1080p at +60FPS (Fraps recorded at 30FPS)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s