The engine I am developing for my games uses deferred rendering so I’m posting about the basics of a deferred renderer which is actually a lot more straight forward than many people think.
A deferred renderer is basically a method for rendering graphics where the effects are not applied to the scene during the stage in which we draw polygons and map textures to them, instead all effects are applied to the resulting image of the scene. This provides many advantages, from a cleaner rendering pipeline to the decoupling of geometry complexity from effects. Many modern game engines use deferred rendering including Unreal Engine 3 and CryEngine 3.0.
To render many different types of effects using a deferred renderer we typically want some crucial information about the scene, most deferred render effects require three things: The colour, the normals and the depth. With these three combined we can implement many 3D effects on the scene using only 2D images and in doing so we avoid having to deal with polygons beyond the initial rendering stages.
At the core of most deferred renderers we have the ‘g-buffer’ which is three separate textures listed below.
The Diffuse Map
The diffuse map is the scene rendered with textures and nothing else, no effects or anything, just polygons and textures. It is typically the base image onto which we apply effects such as motion blur, bloom, lighting amongst many others.
The Depth Map
The depth map is typically a single floating point texture, typically of format D3DFMT_R16F (16 bit floating point precision) or D3DFMT_R32F (32 bit floating point precision) in which each pixel is a value between 0 and 1 where 0 is the point at the near clip of the projection matrix and 1 is the far clip of the projection matrix.
We can extract the x/y/z world coordinates of any given pixel from the depth map, for further information on achieving this visit this page.
The Normal Map
From the perspective of the camera the normal map is a texture where the r/g/b value of each pixel corresponds to the x/y/z unit vector coordinates of the normal of each vertex. Unsurprisingly the colours in a normal map varies based on the normal value of each vertex, we find that normals which have large x values produce redder colours while normals with larger y values produce greener values.
In the above screenshot of the scenes normal map you can see the ground on which the soldier is standing is green while towards her front it’s red. You should be able to easily derive from this that she is standing on the ground and facing in the ‘x’ direction.
Notice the gun and the fanblade in the background have much more detail in their normals, this is because they are using normal textures which compliment the vertex normals by chiseling further ‘detail’ into them. During the lighting stage this has no processing overhead since the deferred renderer doesn’t care, it works rapidly in a pixel by pixel basis while a forward renderer would have to continually be sampling the normal map texture and transforming vertices when calculating lighting.
The normal map can exist in world space or camera space, in the screenshot above it is displayed in world space. In camera space the normal colours will keep changing relative to the cameras view matrix.
When I started working on my deferred renderer I used Catalin Zimma’s XNA code, if you’re interested in an in-depth explanation of deferred renderers as well as code I highly recommend you visit his site.


