Skip to content
SpecializedSource checked

Clustered Shading

Groups screen space and depth into clusters so lights are culled in three dimensions.

Quick Facts

Compact metadata for implementation and discovery.

Category
Rendering
Difficulty
Advanced
Family
GPU Rendering Optimization
Tier
Specialized
Status
Verified
Review
Source Checked
Sources
1
Formulas
1
Relationships
4
Code example
Ready
Visualization
Ready

Overview

Clustered Shading extends tiled light culling by slicing depth, producing smaller 3D regions with more accurate light lists.

Core Concepts

view-space clusterdepth slicelight assignmentlocal light list

Quick facts

Complexity

Runtime and memory behavior at a glance.

Best

O(clusters + lights)

Average

O(clusters * lights + shaded pixels)

Worst

O(clusters * lights + shaded pixels)

Space

O(cluster light lists)

When to Use

  • Use when tiled rendering includes too many irrelevant lights because depth varies strongly.
  • Use when dense real-time lighting is a central requirement.

When Not to Use

  • Avoid when the added cluster setup cost outweighs saved shading work.
  • Avoid when the renderer cannot provide the buffers, samples, or lighting data the technique needs.

What It Does

  • Partitions view space into clusters
  • Assigns lights to 3D clusters
  • Shades pixels with cluster-local lights

Use Cases

  • Dense real-time lighting
  • Forward-plus renderers
  • VR scenes with depth variation

Inputs

  • Camera frustum
  • Depth slices
  • Light bounds

Outputs

  • Per-cluster light lists

Key Formulas (1)

Cluster index

cluster = tilex + tiley · tilesx + depthslice · tilesx · tilesy
cluster = tile_x + tile_y * tiles_x + depth_slice * tiles_x * tiles_y

Maps a pixel tile and depth slice to a cluster light list.

Pseudocode

  1. 1.Divide the view frustum into screen tiles and depth slices
  2. 2.Build cluster bounds
  3. 3.Assign each light to intersecting clusters
  4. 4.During shading, find the pixel's cluster
  5. 5.Loop only over that cluster's lights

Canonical Example

Input
pixel depth = far slice, screen tile = (3, 2)
Output
cluster lights = far lights in that tile
Explanation
The pixel ignores near lights that overlap the same screen tile but not its depth slice.

Implementation Notes

  • Debug cluster indices with false-color views before checking lighting.
  • Debug with simple geometry, known lights, and visualized intermediate buffers.
  • Keep a tiny example with expected output beside the implementation.

Common Pitfalls

  • Incorrect depth-slice mapping can assign pixels to the wrong light lists.
  • 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 a camera frustum cut into 3D clusters, each with its own light list.

Clustered Shading mechanism walkthrough step 1 of 5
Step 1 of 5: Divide the view frustum into screen tiles and depth slices
rendering-pipeline

Notes

Depth slicing improves culling for scenes with lights at different distances.

Sources (1)

What each reference supports for this entry.

Clustered Deferred and Forward Shading

Paper

Eurographics/HPG paper introducing clustered shading for light assignment.

Open source

Explore Next

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

Alternative toDeferred Shading

Clustered shading can keep forward-rendering material flexibility.

Improves onTiled Rendering

Clustered shading extends tiled ideas into 3D clusters.

Tags

GraphicsShadingScreen-SpaceOptimization