Skip to content
ExtendedSource checked

Deferred Shading

Separates geometry rendering from lighting by first storing surface data in screen-space buffers.

Quick Facts

Compact metadata for implementation and discovery.

Category
Rendering
Difficulty
Intermediate
Family
Raster Rendering Pipeline
Tier
Extended
Status
Verified
Review
Source Checked
Sources
1
Formulas
0
Relationships
8
Code example
Ready
Visualization
Ready

Overview

Deferred Shading fills a G-buffer with attributes such as normals, depth, and material values, then applies lighting in screen space.

Core Concepts

G-bufferlighting passscreen-space shadingmaterial attributes

Quick facts

Complexity

Runtime and memory behavior at a glance.

Best

O(pixels)

Average

O(geometry + pixels * lights)

Worst

O(geometry + pixels * lights)

Space

O(pixels * buffer_count)

When to Use

  • Use when many dynamic lights affect opaque geometry.
  • Use when scenes with many lights is a central requirement.

When Not to Use

  • Avoid when transparent materials or low memory bandwidth dominate the frame.
  • Avoid when the renderer cannot provide the buffers, samples, or lighting data the technique needs.

What It Does

  • Computes raster rendering pipeline within Raster Rendering Pipeline workloads (O(geometry + pixels * lights) time, O(pixels * buffer_count) space).
  • Works by Separates geometry rendering from lighting by first storing surface data in screen-space buffers.
  • Maintains key invariants across G-buffer, lighting pass, screen-space shading.

Use Cases

  • Scenes with many lights
  • Game rendering engines
  • Screen-space lighting effects

Inputs

  • Scene geometry
  • Materials
  • Lights
  • Camera

Outputs

  • Lit image
  • G-buffer attachments

Pseudocode

  1. 1.Render geometry into position, normal, and material buffers
  2. 2.For each light, shade affected pixels using G-buffer data
  3. 3.Combine lighting contributions
  4. 4.Apply post-processing

Canonical Example

Input
G-buffer = normals + albedo + depth
Output
output = lit image
Explanation
Lighting uses stored per-pixel surface data instead of reshading geometry.

Implementation Notes

  • Visualize each G-buffer channel during debugging.
  • Debug with simple geometry, known lights, and visualized intermediate buffers.
  • Keep a tiny example with expected output beside the implementation.

Common Pitfalls

  • Incorrectly encoded normals or depth can break every lighting pass.
  • Coordinate-space mismatches often cause artifacts that look like math errors.
  • Not defining boundary, empty, or degenerate inputs before implementation.

Interactive Mechanism Walkthrough

Spatial Primitive & Sweep-Line Canvas

Show geometry attributes stored in separate buffers before a lighting pass combines them.

Deferred Shading mechanism walkthrough step 1 of 4
Step 1 of 4: Render geometry into position, normal, and material buffers
rendering-pipeline

Notes

Transparency and high memory bandwidth are common deferred shading challenges.

Sources (1)

What each reference supports for this entry.

Real-Time Rendering

Book

Computer graphics reference for raster pipelines, shading, antialiasing, texture filtering, and real-time rendering techniques.

Open source

Explore Next

Good next jumps from the relationship graph, ranked for useful discovery.

Alternative toForward Rendering

Deferred shading separates geometry output from later lighting passes.

Deferred shading starts from rasterized geometry buffers.

Tags

GraphicsShadingScreen-SpaceLighting