Clustered forward shading
Divide the view frustum into a 3D grid of clusters, assign each light to the clusters it overlaps, and let each shaded fragment loop only over its cluster's lights.
Also known as clustered shading, clustered forward
In the family Performance, LOD & compression, light culling
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | Official add-on | import { ClusteredLighting } from 'three/addons/lighting/ClusteredLighting.js' docs WebGPURenderer. |
| Babylon.js 9.38.0 | Built in | new BABYLON.ClusteredLightContainer('c', lights, scene) docs |
| Godot 4.7 | Built in | Project Settings > Rendering > Renderer > Rendering Method = forward_plus docs |
| Unity | Built in | URP Renderer > Rendering Path = Forward+ docs URP Forward+; HDRP uses its own tiled/cluster light list. |
| Unreal 5.7 | Built in | Project Settings > Rendering > Forward Renderer > Forward Shading (with MSAA support) docs |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
The frustum is sliced into screen tiles and depth slices, usually exponential in depth. A compute pass tests each light's bounding volume against cluster bounds and writes light indices into per-cluster lists, optionally restricted to clusters containing visible geometry.
In the fragment shader, the pixel's position and depth give its cluster id; the shader reads that list and accumulates lighting. Unlike 2D tiling, depth splits mean far-apart surfaces at the same pixel do not share a long list, which handles depth discontinuities and transparent objects.
When to choose it
Reach for it when
- too many dynamic lights tank the frame rate
- forward renderer needs hundreds of point lights
- need transparent objects lit by many lights
- deferred g-buffer is too heavy for msaa or vr
Choose it for many dynamic lights with forward rendering, MSAA or transparencies. Prefer Tiled deferred shading when deferred is already in place and depth ranges per tile are tight. Prefer a handful of per-object lights when light count stays small.
Field marks
- Large lights fall in many clusters, bloating lists and overflowing fixed list capacity
- Lights near cluster boundaries cause popping if bounds are too tight
- Slice distribution mismatched to scene depth leaves clusters under- or over-populated
- Per-fragment light loops diverge across a wavefront
Presets
Toy top-down frustum clusters with per-cluster light counts
{
"LIGHTS": 14,
"SLICES": 8,
"BINS": 8,
"HALF_FOV_TAN": 0.8
}Show GLSL (41 lines)
// Toy top-down view of a frustum cut into clusters (angular bins x exponential depth slices); colour = lights overlapping each cluster.
const int LIGHTS = 14;
const int SLICES = 8;
const int BINS = 8;
const float NEAR = 0.1, FAR = 10.0;
const float HALF_FOV_TAN = 0.8;
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = fragCoord / iResolution.xy;
vec2 v = vec2((uv.x - 0.5) * 2.0 * 3.2, 0.0); // view-space x
float z = 0.02 + uv.y * 0.0; // placeholder, set below
// map screen y to depth with exponential spacing so slice cells look equal height
float sl = uv.y * float(SLICES);
z = NEAR * pow(FAR / NEAR, sl / float(SLICES));
v.x = (uv.x - 0.5) * 2.0 * z * HALF_FOV_TAN;
float bin = floor(uv.x * float(BINS));
float s = floor(sl);
float z0 = NEAR * pow(FAR / NEAR, s / float(SLICES)), z1 = NEAR * pow(FAR / NEAR, (s + 1.0) / float(SLICES));
float t0 = (bin / float(BINS) - 0.5) * 2.0 * HALF_FOV_TAN, t1 = ((bin + 1.0) / float(BINS) - 0.5) * 2.0 * HALF_FOV_TAN;
vec2 lo = vec2(min(min(t0 * z0, t0 * z1), min(t1 * z0, t1 * z1)), z0);
vec2 hi = vec2(max(max(t0 * z0, t0 * z1), max(t1 * z0, t1 * z1)), z1);
int cnt = 0; float lit = 0.0; float dm = 1e9;
for (int i = 0; i < LIGHTS; i++) {
float f = float(i);
float lz = NEAR * pow(FAR / NEAR, fract(f * 0.381 + 0.1 * sin(iTime * 0.5 + f)) * 0.95 + 0.03);
float lx = lz * HALF_FOV_TAN * (2.0 * fract(f * 0.618 + 0.2) - 1.0) * 0.9;
float r = 0.35 * lz + 0.1;
vec2 c = vec2(lx, lz);
if (distance(clamp(c, lo, hi), c) < r) cnt++;
lit += smoothstep(r, 0.0, distance(vec2(v.x, z), c));
dm = min(dm, abs(distance(vec2(v.x, z), c) - r) / z);
}
float x = float(cnt) / 5.0;
vec3 heat = clamp(vec3(1.5 * x, 1.5 - abs(3.0 * x - 1.5), 1.5 - 1.5 * x), 0.0, 1.0);
vec3 col = mix(vec3(0.04, 0.05, 0.08), heat * 0.6, cnt > 0 ? 1.0 : 0.0);
col += vec3(1.0, 0.9, 0.7) * lit * 0.15;
vec2 g = fract(vec2(uv.x * float(BINS), sl));
col = mix(col, vec3(0.0), (g.x < 0.03 || g.y < 0.03) ? 0.6 : 0.0);
col = mix(col, vec3(1.0), smoothstep(0.012, 0.004, dm) * 0.8);
fragColor = vec4(pow(col, vec3(0.8)), 1.0);
}
Attribution: written for this index
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| clustered-forward-shading-specimen | Tesla T4 1920x1080 | 9.75× baseline (moderate) · 0.321 ms / 0.338 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| clustered-forward-shading-specimen | NVIDIA L4 1920x1080 | 9.94× baseline (moderate) · 0.158 ms / 0.158 ms · 2.0× faster on L4 | opengl-timer-query · Cross-architecture validation |
| clustered-forward-shading-specimen | NVIDIA A100-SXM4-40GB 1920x1080 | 6.44× baseline (moderate) · 0.185 ms / 0.185 ms · 1.7× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
Crosses
- Hierarchical-Z occlusion culling: A depth pre-pass used for cluster culling also feeds the pyramid used for object culling.
Sources
- primaryOla Olsson, Markus Billeter, Ulf Assarsson (2012). Tiled and clustered forward shading. ACM SIGGRAPH 2012 Posters on - SIGGRAPH '12.Verified via crossref · 2026-11-29doi:10.1145/2343045.2343095
- implementationpezcode (2019). pezcode/Cluster. Clustered shading implementation with bgfxGitHub API · license MIT · 2026-11-29