Deferred Rendering

DiaporamaXL.png

After finishing my previous project, Zombids, I wanted to improve the basic renderer into a more powerful graphic engine. Deferred rendering was attractive for its (apparent) simplicity.

This method consists in rendering the scene into a large buffer, called G-Buffer, storing all the information needed to apply lighting at a later stage. In most implementations, the G-Buffer is made of several textures, rendered using multiple render targets (MRT).

I chose the following set-up comprised of 4 buffers:

  • World space position: 64 bits
  • World space normal, Specular intensity: 32 bits
  • Diffuse color, Specular power: 32 bits
  • Emissive light: 32 bits

Although this set-up was successful on my computer, bit depth independance is not allowed while using MRT on some GPU, like the NVidia 7000 series. In this situation I had to default to four 64 bits buffers, resulting in a waste of video memory. Besides, a better option would have been to store position in a 24 bits depth buffer using some simple math to reconstruct the position when needed. We would then be able to use only 32 bits targets, with extra space to store additional material properties.

Most textures come from Allegorithmic's MapZone utility.

Framework:

  • C#
  • HLSL
  • XNA

Features:

  • Material system
    • Materials are described in external files
    • Diffuse, normal and emissive mapping
    • Specular power and intensity
  • Lighting
    • Point lights
    • Direction lights
    • Unlimited number of lights
  • Effects
    • Glow from emissive map to fake HDR lighting
    • Screen space ambient occlusion, as part of another project

Download:

Some run-time librairies are required to run the renderer:

Code samples:

Sources:

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License