deferred_logo

Deferred Shading/Lighting is the process by which a scene is rendered to a texture which stores all of the information needed for the lighting model. This is sometimes referred to as a "Fat Buffer" or "G-Buffer". The advantage of deferred shading/lighting is that for vertex heavy scenes, the vertex information only needs to be processed once: positional information and other lighting parameters and packed into a texture which describes the visible scene, then lighting can either be done simultaneously for all visible lights to a single full screen textured quad, or the scene can be rendered to a series of textured full screen quads, one per light, and additively blend into the frame buffer.

During the course of the 2.5 months I had to research and implement deferred lighting, I ran into a number of 'bumps' in the road on the journey to my final implementation. I initially intended to build the g-buffer using simultaneous render targets for output. That is, I initially intended to pack my per pixel projection space coordinates, my diffuse, normal, and depth information, into textures in a single pass. Then I would read those textures in, extract the lighting information for each pixel, and perform standard phong lighting, outputting the resultant texture on a single full screen quad.

Unfortunately, I ran into technical issues with the support for MRT output using the video card in my laptop (a Mobile Radeon 9700). As The Guildhall mandates that all focus study projects to work on the laptop provided by the school, I worked around the issue. Firstly, I passed the projection space transformed xy pixel coordinates to the pixel shader using vertex shader interpolation. I then chose make three separate passes over my scene to build textures for each part of the G-buffer I would need to do the lighting. Finally, I chose to light the scene for all lights simultaneously and output the result into a single full screen quad. The end result was a scene which deferred the lighting calculation until all parts of the scenes information was known, albeit, not using the most optimal implementation.

  • Engine
    • Home grown
  • Language
    • C++
  • Graphics API
    • DirectX
  • Shading Language
    • HLSL
  • Duration
    • 2.5 months
  • Features:
    • Deferred Lighting/Shading for a scene of medium complexity for up to 3 lights