Cascaded Shadow Maps
Splits the camera frustum into depth slices and gives each slice its own shadow map, so near surfaces get high texel density without exploding total resolution.
In the family Visibility, shadows & ambient occlusion, shadow map partitioning
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | Official add-on | import { CSM } from 'three/addons/csm/CSM.js' (WebGPU: CSMShadowNode) docs |
| Babylon.js 9.38.0 | Built in | new BABYLON.CascadedShadowGenerator(1024, directionalLight); csm.numCascades = 4 docs DirectionalLight only. |
| Godot 4.7 | Built in | DirectionalLight3D.directional_shadow_mode = DirectionalLight3D.SHADOW_PARALLEL_4_SPLITS docs |
| Unity | Built in | URP Asset > Shadows > Cascade Count; HDRP Volume > Shadows > Cascade Count docs Directional light cascades in URP and HDRP. |
| Unreal 5.7 | Built in | Directional Light > Cascaded Shadow Maps category (Dynamic Shadow Distance, Num Dynamic Shadow Cascades) docs |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
The view frustum is divided along depth into typically three to five cascades, with split planes chosen logarithmically, uniformly or by a blend of both (practical split scheme). For each slice an orthographic light-space projection is fitted around that sub-frustum and rendered into one layer of an array texture or atlas. At shading time the fragment's view depth selects a cascade, and the result is blended across a transition band to hide seams. Stabilisation snaps the projection to texel increments so shadows do not shimmer as the camera rotates, and tight depth-range fitting or sample-distribution analysis (SDSM) shrinks each map further.
When to choose it
Reach for it when
- shadows look blocky or pixelated far from the camera
- one shadow map can't cover a large outdoor scene
- sun shadows lose resolution in big open worlds
- near shadows blurry while the view distance is huge
Choose it for sun or moon light in open scenes with a long view distance. Prefer Virtual Shadow Maps when you need uniform sharp detail across the whole view with massive geometry, Shadow Mapping with a single map for small enclosed scenes, and Ray-Traced Shadows if hardware ray tracing replaces the sun map entirely.
Field marks
- Visible seams or resolution jumps at cascade borders
- Shadow swimming and shimmering when the fit is not stabilised
- Wasted resolution in the nearest cascade for oblique light directions
- Peter-panning near the camera from large biases chosen for far cascades
Presets
4-cascade Practical Split Scheme shadows — quantized cascade texel footprints and PCF
{
"SPLIT_LAMBDA": 0.65,
"PCF_RADIUS": 1.25,
"CASCADE_TINT": 0.38,
"SUN_ANGLE": 0.72
}Show GLSL (124 lines)
const float SPLIT_LAMBDA = 0.65; // P
const float PCF_RADIUS = 1.25; // P
const float CASCADE_TINT = 0.38; // P
const float SUN_ANGLE = 0.72; // P
float sdBox(vec3 p, vec3 b) {
vec3 q = abs(p) - b;
return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0);
}
float mapCasters(vec3 p) {
// Receding rows of architectural monoliths and lintel arches
vec3 q = p;
q.z = mod(q.z + 1.8, 3.6) - 1.8;
float pL = sdBox(vec3(p.x + 1.55, p.y - 1.05, q.z), vec3(0.32, 1.05, 0.32));
float pR = sdBox(vec3(p.x - 1.55, p.y - 1.05, q.z), vec3(0.32, 1.05, 0.32));
float arch = sdBox(vec3(p.x, p.y - 2.05, q.z), vec3(1.88, 0.22, 0.28));
// Center obelisk row with varying heights
float id = floor((p.z + 1.8) / 3.6);
float h = 0.55 + 0.35 * sin(id * 1.9);
float ob = sdBox(vec3(p.x - 0.35 * sin(id * 2.3), p.y - h, q.z - 0.8), vec3(0.22, h, 0.22));
return min(min(pL, pR), min(arch, ob));
}
float mapScene(vec3 p) {
return min(p.y, mapCasters(p));
}
vec3 calcNormal(vec3 p) {
vec2 e = vec2(0.004, 0.0);
return normalize(vec3(
mapScene(p + e.xyy) - mapScene(p - e.xyy),
mapScene(p + e.yxy) - mapScene(p - e.yxy),
mapScene(p + e.yyx) - mapScene(p - e.yyx)
));
}
// Shadow test snapped to cascade light-space texel grid
float traceCaster(vec3 ro, vec3 rd) {
float t = 0.04;
for (int i = 0; i < 28; i++) {
float d = mapCasters(ro + rd * t);
if (d < 0.006) return 0.0;
t += max(d, 0.04);
if (t > 14.0) break;
}
return 1.0;
}
vec3 aces(vec3 x) {
x = max(x, 0.0);
return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
vec3 ro = vec3(0.0, 2.35, 3.2);
vec3 rd = normalize(vec3(uv.x, uv.y - 0.24, -1.25));
float sunAz = SUN_ANGLE + 0.35 * sin(iTime * 0.4);
if (iMouse.z > 0.5 || length(iMouse.xy) > 1.0) {
sunAz = (iMouse.x / iResolution.x) * 2.4 - 0.5;
}
vec3 sunDir = normalize(vec3(cos(sunAz), 0.72, sin(sunAz) * 0.65));
vec3 lRight = normalize(cross(sunDir, vec3(0.0, 1.0, 0.0)));
vec3 lUp = cross(lRight, sunDir);
float t = 0.1;
bool hit = false;
for (int i = 0; i < 72; i++) {
float d = mapScene(ro + rd * t);
if (d < 0.004) { hit = true; break; }
t += d;
if (t > 38.0) break;
}
vec3 sky = mix(vec3(0.68, 0.78, 0.90), vec3(0.18, 0.36, 0.68), clamp(uv.y + 0.35, 0.0, 1.0));
vec3 col = sky;
if (hit) {
vec3 p = ro + rd * t;
vec3 n = calcNormal(p);
// Practical split scheme (Zhang et al. 2006) across 4 cascades in [zNear, zFar]
float zNear = 1.2, zFar = 34.0;
float lam = clamp(SPLIT_LAMBDA, 0.0, 1.0);
float s1 = mix(zNear + (zFar - zNear) * 0.25, zNear * pow(zFar / zNear, 0.25), lam);
float s2 = mix(zNear + (zFar - zNear) * 0.50, zNear * pow(zFar / zNear, 0.50), lam);
float s3 = mix(zNear + (zFar - zNear) * 0.75, zNear * pow(zFar / zNear, 0.75), lam);
float viewZ = -dot(p - ro, vec3(0.0, 0.0, -1.0));
int casc = (viewZ < s1) ? 0 : (viewZ < s2) ? 1 : (viewZ < s3) ? 2 : 3;
float texel = (casc == 0) ? 0.045 : (casc == 1) ? 0.11 : (casc == 2) ? 0.24 : 0.48;
vec3 cTint = (casc == 0) ? vec3(0.28, 0.92, 0.58) : (casc == 1) ? vec3(0.32, 0.72, 1.0) : (casc == 2) ? vec3(1.0, 0.78, 0.28) : vec3(0.98, 0.42, 0.38);
// Quantize light-space coordinates to cascade texel size + 4-tap PCF
vec3 pOff = p + n * (0.015 + texel * 0.25);
vec2 luv = vec2(dot(pOff, lRight), dot(pOff, lUp));
vec2 qBase = (floor(luv / texel) + 0.5) * texel;
float pcfR = max(PCF_RADIUS, 0.0) * texel;
float vis = 0.0;
vec2 offs[4];
offs[0] = vec2(-0.5, -0.5); offs[1] = vec2(0.5, -0.5);
offs[2] = vec2(-0.5, 0.5); offs[3] = vec2(0.5, 0.5);
for (int k = 0; k < 4; k++) {
vec2 tap = qBase + offs[k] * pcfR;
vec3 sp = pOff + lRight * (tap.x - luv.x) + lUp * (tap.y - luv.y);
vis += traceCaster(sp, sunDir);
}
vis *= 0.25;
// Subtle border line at exact cascade split planes
float dSplit = min(min(abs(viewZ - s1), abs(viewZ - s2)), abs(viewZ - s3));
float splitLine = smoothstep(0.14, 0.02, dSplit) * clamp(CASCADE_TINT, 0.0, 1.0);
vec2 tile = floor(p.xz * 1.25);
float chk = mod(tile.x + tile.y, 2.0);
vec3 baseAlb = (p.y < 0.01) ? mix(vec3(0.42, 0.44, 0.46), vec3(0.62, 0.63, 0.64), chk) : vec3(0.74, 0.71, 0.67);
vec3 alb = mix(baseAlb, baseAlb * cTint * 1.35, clamp(CASCADE_TINT, 0.0, 1.0));
float nl = max(dot(n, sunDir), 0.0);
vec3 lit = alb * (vec3(0.16, 0.22, 0.34) + vec3(1.55, 1.42, 1.22) * nl * vis);
lit = mix(lit, vec3(1.0), splitLine * 0.65);
col = mix(lit, sky, 1.0 - exp(-0.022 * t));
}
fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Attribution: MIT — written for this index
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| cascaded-shadow-maps-live | Tesla T4 1920x1080 | 65.4× baseline (extreme) · 2.15 ms / 2.21 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| cascaded-shadow-maps-live | NVIDIA L4 1920x1080 | 64.9× baseline (extreme) · 1.03 ms / 1.04 ms · 2.1× faster on L4 | opengl-timer-query · Cross-architecture validation |
| cascaded-shadow-maps-live | NVIDIA A100-SXM4-40GB 1920x1080 | 41.9× baseline (heavy) · 1.21 ms / 1.21 ms · 1.8× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): its primary source cites Shadow Volumes, Deep shadow maps.
Sources
- primaryFan Zhang, Hanqiu Sun, Leilei Xu, Lee Kit Lun (2006). Parallel-split shadow maps for large-scale virtual environments. Proceedings of the 2006 ACM international conference on Virtual reality continuum and its applications.Verified via crossref · 2026-11-29doi:10.1145/1128923.1128975
- tutorialRouslan Dimitrov. Cascaded Shadow Maps. developer.download.nvidia.com.Verified via live page · 2026-11-29
- implementationmrdoob (2010). mrdoob/three.js. JavaScript 3D Library.GitHub API · license MIT · 2026-11-29