Graphics‎ > ‎3D‎ > ‎

Deferred Rendering

It's like normal rendering but a little later

Before there where vertex and pixel shaders the the graphical pipeline on a GPU was fixed. It was possible to use functions to tweak a few parameters in different places but overall things moved forward in the GPU in a set order. You gave it the vertices, it did rasterization, put some texture on it, added some lightning and then triangles with colors fell out at the other end. With the ability to use shaders at the different stages it is no longer necessary follow the strict order of the old fixed function pipelines. Lighting can be done in the vertex shader, in the pixelshader or deferred to a second drawcall where we only do lighting. Rendering that is similar to the way fixed function graphical pipeline worked is called forward rendering, other techniques that shift things around are called deferred rendering. You can read up on some Deferred rendering history (2004) at Rich Geldreich website.

Pass: A pass is rendering of all the triangles in the scene.

Stages: Each step in rendering is called a stage. One or more of them can be a render pass that draw all the surfaces and update some information in the G-Buffer.

G-Buffer: The geometry buffer contains the data needed for the deferred rendering stages. It often need more then one render target to fit all data and it can get big.

L-Buffer: A buffer that accumulate the light of each pixel.

Forward Rendering - 19XY
The classic pipeline style is called forward rendering. When drawing the pixel shader texture and light the fragment and then it is written to the color buffer. So each triangle drawn need to have access to the lights that will affect it. On the CPU the geometry is grouped by what set of light affect them and each group is then drawn separately. This is easy for static light and geometry and harder when things start to move around. If a group is affected by more lights then can be used in single draw call blending need to be used and draw the geometry more then once.

for each object
    for each light that can affect object
        lighting += computeLighting(object, light)

Deferred shading - 2006
Deferred shading has three stages and need a G-Buffer and light accumulation buffer.

Geometry stage
The first stage is a pass that fills in the G-buffer with all the material data and the things needed lighting. This makes the G-Buffer a bit large to fit in all the things needed.

Lightning stage
A bounding volume is rendered for each light and the pixel shader use the G-Buffer data to calculate the lightning for the light source. The light output of all lights is gathered into a the L-Buffer.

Shading stage
The final stage is the shading stage. It takes the G-Buffer and L-Buffer as input and merge them to the final color buffer. This can be done with a single full screen quad.
Deferred lighting (light pre-pass rendering) - 2007

Deferred lighting do an extra pass to lower the size and bandwith off the G-Buffer.

Geometry stage
This pass fills in the G-Buffer with the data needed for lighting only. It makes the G-Buffer smaller.

Lightning stage
The same as in deferred shading.

Shading stage
A pass that renders all geometry again but this time it can use the L-Buffer to light each pixel.

Light Indexed Deferred Rendering - 2007
The first stage is a early-z pass used to fill in the depth values. The next stage renders the lights and write down the index of each light into a light buffer. The size of the buffer per fragments limits how many lights can be on a single fragment and also the whole screen. All the lights information then need to be put into a texture or constant where the last stage, a render pass can read it and use it to light the fragment.
Tiled deferred shading  - 2011
Create a G-Buffer like in normal deferred shading. Split the screen into tiles and the sort lights into the tiles they touch in screen space. As a final step, for each fragment sample the gbuffer and the use the lights in the tile the fragment is in to light and shade the pixel.

Clustered deferred shading - 2012
Create a G-Buffer like in normal deferred shading. Sort the fragments into clusters and then sort lights into the clusters they touch in 3D. As a final step, for each fragment sample the gbuffer and the use the lights in the clusters the fragment is in to light and shade the pixel.

Implicit Clustered Deferred Shading - 2015
Practical Clustered Deferred And Forward Shading - 2013. Part 1 and Part 2.
Clustered Deferred and Forward Shading - 2012
Tiled Forward / Forward+ - 2012
Bin lights into 2D tiles on the screen. Then a forward renderer use these bins in the pixel shaders to apply the lights.

Deferred Texturing - 2013
Only a material Id and the data for lighting is written down to the G-Buffer. Then a full screen shader is used to read the id and texture the screen. The upside is that only areas that are really visible need to access the data for textures.

Lighting transparent surfaces with deferred shading. - 2012 Part I , Part II


Deferred rendering Part 1 and Part 2. -  2008

A Primer On Efficient Rendering Algorithms & Clustered Shading - 2018