Deferred shading is a real-time rendering technique that splits drawing into two passes: a geometry pass that writes surface attributes of every visible pixel into a set of screen-sized textures called the G-buffer, and a lighting pass that reads those textures and computes illumination afterward. In Real-time 3D, it is also known as deferred rendering, and it became a standard approach in game engines because it decouples lighting cost from scene complexity.
The central idea is simple: shade only what the camera actually sees. Instead of evaluating every light for every fragment that might later be hidden, the renderer first resolves visibility with the Z-buffer and then spends lighting work once per visible pixel. This makes scenes with hundreds of dynamic lights practical, at the price of higher memory bandwidth and some restrictions on materials.
How deferred shading splits the frame
Deferred shading works by separating visibility from lighting. During the geometry pass, the vertex shader transforms meshes as usual, but the fragment shader does not calculate light. It writes material and surface data into multiple render targets at once, a capability that modern GPU pipelines support through MRT output.
During the lighting pass, the renderer draws screen-aligned shapes for each light: a full-screen quad for directional lights, and light volumes such as spheres or cones for point and spot lights. For every covered pixel, the lighting shader samples the G-buffer, reconstructs the world position from depth, and adds that light’s contribution to an accumulation buffer. A final composition pass then applies post-processing and tone mapping.
The following table lists a typical G-buffer layout. Exact formats differ between engines, and many renderers pack several attributes into one texture to save bandwidth.
| Render target | Stored data | Common format |
|---|---|---|
| Depth buffer | Scene depth for position reconstruction | D24S8 or D32F |
| Albedo target | Base color and ambient occlusion | RGBA8 |
| Normal target | Encoded surface normal | RGB10A2 or RG16F |
| Material target | Roughness, metalness, specular | RGBA8 |
| Emissive or velocity target | Self-illumination or motion vectors | RGBA16F or RG16F |
Deferred shading compared with forward rendering
The main alternative is forward rendering, which computes lighting directly in the fragment shader while each object is drawn. In classic forward rendering, cost grows roughly with objects multiplied by lights, and overdraw wastes lighting work on fragments that are later hidden. Deferred shading changes this to cost that grows with visible pixels multiplied by lights affecting them.
Neither approach is universally better. The table summarizes the main engineering trade-offs that guide the choice.
| Criterion | Forward rendering | Deferred shading |
|---|---|---|
| Many dynamic lights | Expensive without clustering | Efficient by design |
| Memory bandwidth | Low | High, several full-screen targets |
| Transparency | Handled natively | Requires a separate forward pass |
| Hardware MSAA | Straightforward | Costly or impractical |
| Material variety | Any shading model per object | Limited by G-buffer layout |
| Screen-space effects | Need an extra depth or normal prepass | G-buffer data available for free |
A useful side effect is that the G-buffer already contains depth and normals, so techniques such as screen space ambient occlusion and screen space reflections can reuse it without extra geometry passes.
Variants and modern refinements
Several variants address the bandwidth and material limits of the classic method. Engine developers usually pick a variant according to target hardware, light count and the importance of transparent or complex materials.
| Variant | Core idea | Typical use |
|---|---|---|
| Classic deferred shading | Fat G-buffer, light volumes | Desktop and console games |
| Deferred lighting (light prepass) | Thin G-buffer, geometry drawn twice | Older consoles with small memory |
| Tiled deferred | Lights culled per screen tile in a compute shader | Scenes with hundreds of lights |
| Clustered deferred | Lights culled in 3D view-space clusters | Large depth ranges, open worlds |
| Visibility buffer | Stores triangle and instance IDs only | Dense geometry, high resolutions |
Tiled and clustered approaches read the G-buffer once per pixel and loop over a short list of relevant lights, which greatly reduces repeated texture reads. On mobile GPUs with tile-based architectures, keeping the G-buffer in on-chip tile memory through subpasses avoids writing it to main memory at all, which makes deferred rendering viable on phones.
When to choose deferred shading
Deferred shading fits best when a scene has many local dynamic lights and mostly opaque surfaces. It is less attractive when bandwidth is scarce, when transparency dominates, or when the project depends on hardware antialiasing. The decision table below reflects common practice.
| Situation | Recommended path | Reason |
|---|---|---|
| Night city with hundreds of lights | Clustered or tiled deferred | Lighting cost scales with pixels |
| VR title needing sharp edges | Forward or clustered forward | MSAA works without G-buffer cost |
| Mobile game with few lights | Forward rendering | Saves memory bandwidth and power |
| Browser scene in WebGL | Usually forward | Limited render-target support and bandwidth |
| Mixed opaque and glass scene | Hybrid deferred plus forward | Transparent objects drawn afterward |
Most production engines are hybrid renderers: opaque geometry goes through a deferred path, while particles, glass, hair and other translucent elements are drawn in a forward pass on top of the lit result.
Limitations and common mistakes
The technique has well-known weaknesses that experienced graphics programmers plan around from the start. Ignoring them typically produces blurry edges, banding or poor performance on weaker hardware.
- Transparency cannot be stored in a single-layer G-buffer, so translucent objects need a separate forward pass.
- Antialiasing is usually handled with post-process methods such as FXAA or temporal antialiasing (TAA) rather than MSAA.
- Low-precision normals cause visible banding in specular highlights; octahedral encoding in 16-bit channels reduces it.
- Oversized light volumes waste fill rate; stencil or depth-bounds tests restrict lighting to pixels the light can reach.
- Too many material models bloat the G-buffer; engines usually store a small material ID and branch in the lighting shader.
In everyday language
Imagine painting a room full of furniture. One way is to light each piece as you place it. You might then hide it behind a sofa and waste the effort. Deferred shading works differently. It first notes what is visible. It records the color, angle and material of every visible spot. Only then does it add the light.
This saves work when there are many lamps. Each lamp only touches the spots it can reach. The cost is extra memory. Glass and smoke are also harder to handle. The key takeaway is simple: decide what is seen first, then light it.
Seen in the real world
A small studio builds a rainy night street for a third-person action game on current consoles. The scene has neon signs, car headlights, shop windows and streetlamps, adding up to about 300 dynamic point and spot lights. A plain forward renderer would evaluate many of these lights for every mesh and drop well below the 60 frames per second target.
The team uses clustered deferred shading. The geometry pass fills a G-buffer at 1440p, a compute shader assigns lights to view-space clusters, and each pixel processes only the eight to twelve lights that actually reach it. Wet asphalt reuses the G-buffer for screen space reflections, while rain particles and glass are drawn in a forward pass afterward. The frame stays within its 16.6 ms budget, and artists can add lights freely without rebaking anything.