We, which would be me and Marriez finally finished the deferred shading renderer this week.
Deferred shading is different from standard rendering in that it renders the lighting after all the geometry has been rendered. Standard, also called forward rendering requires a geometry pass for every light that influences the rendered geometry. Of course optimization can be made by not doing a pass for a single light but for multiple lights. For every pass however, all the geometry has to be processed, which takes time especially when the geometry is very complex. Forward rendering has a complexity of O(NL) where N is number of objects and L the number of lights.
Deferred shading does a single geometry pass. The geometry pass stores, per pixel, data required for lighting the scene in buffers. The buffers maintain normal, color, depth and material properties. These buffers are then used to perform the final lighting stage in which a pass for every light is done. Because all geometry is only rendered once deferred rendering has a complexity of O(N+L).
Unfortunately deferred shading has some caveat. The geometry buffers only holds data per pixel for a single depth. You cannot store multiple layers of depth which means you cannot do transparency. We solved this by using a forward pass to render the transparent geometry.
I will probably write a more detailed description of how our deferred renderer works in my next post. In the mean time you can enjoy these screenshots.
-
-
With some debug information
-
-
-
Game level with 200 lights
-
-
Game level with a few lights
-