{
 "id": "cascaded-shadow-maps",
 "title": "Cascaded Shadow Maps",
 "aliases": [],
 "domain": "visibility",
 "subdomain": "shadow map partitioning",
 "stage": "visibility",
 "realtime": "realtime",
 "platforms": [
  "webgl2",
  "webgpu",
  "desktop-gpu",
  "mobile-gpu",
  "unity",
  "unreal",
  "godot"
 ],
 "year_introduced": 2006,
 "inputs": [
  "mesh",
  "depth"
 ],
 "outputs": [
  "visibility-mask"
 ],
 "style": "both",
 "dynamic": "dynamic",
 "summary": "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.",
 "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_use": "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.",
 "cost": {
  "class": "medium",
  "notes": "Each cascade re-renders casters, so draw cost is roughly cascade count times the caster pass, mitigated by culling per cascade and updating far cascades less often."
 },
 "failure_modes": [
  "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"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1145/1128923.1128975",
   "type": "paper",
   "title": "Parallel-split shadow maps for large-scale virtual environments",
   "authors": [
    "Fan Zhang",
    "Hanqiu Sun",
    "Leilei Xu",
    "Lee Kit Lun"
   ],
   "year": 2006,
   "venue": "Proceedings of the 2006 ACM international conference on Virtual reality continuum and its applications",
   "url": "https://doi.org/10.1145/1128923.1128975",
   "ids": {
    "doi": "10.1145/1128923.1128975"
   },
   "license": null,
   "extra": {
    "csl_type": "proceedings-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1128923.1128975",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1128923.1128975",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1128923.1128975",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1128923.1128975",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1128923.1128975",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "zhang2006parallel"
  },
  {
   "role": "tutorial",
   "key": "url:https://developer.download.nvidia.com/SDK/10.5/opengl/src/cascaded_shadow_maps/doc/cascaded_shadow_maps.pdf",
   "type": "tutorial",
   "title": "Cascaded Shadow Maps",
   "authors": [
    "Rouslan Dimitrov"
   ],
   "year": null,
   "venue": "developer.download.nvidia.com",
   "url": "https://developer.download.nvidia.com/SDK/10.5/opengl/src/cascaded_shadow_maps/doc/cascaded_shadow_maps.pdf",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 200,
    "live": true,
    "archive": {
     "url": "http://web.archive.org/web/20261024103306/https://developer.download.nvidia.com/SDK/10.5/opengl/src/cascaded_shadow_maps/doc/cascaded_shadow_maps.pdf",
     "timestamp": "20261024103306"
    },
    "page_title": null,
    "host": "developer.download.nvidia.com",
    "title_confirmed_by_page": false,
    "title_unconfirmed": false
   },
   "provenance": {
    "title": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "http",
     "endpoint": "GET https://developer.download.nvidia.com/SDK/10.5/opengl/src/cascaded_shadow_maps/doc/cascaded_shadow_maps.pdf → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "http",
     "endpoint": "GET https://developer.download.nvidia.com/SDK/10.5/opengl/src/cascaded_shadow_maps/doc/cascaded_shadow_maps.pdf → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "dimitrovcascaded"
  },
  {
   "role": "implementation",
   "key": "gh:mrdoob/three.js",
   "type": "code",
   "title": "mrdoob/three.js",
   "description": "JavaScript 3D Library.",
   "authors": [
    "mrdoob"
   ],
   "year": 2010,
   "venue": "GitHub",
   "url": "https://github.com/mrdoob/three.js",
   "ids": {
    "repo": "mrdoob/three.js"
   },
   "license": "MIT",
   "extra": {
    "stars": 119718,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2026-11-29T11:39:51Z",
    "language": "JavaScript",
    "homepage": "https://threejs.org/",
    "license_name": "MIT License"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mrdoob/three.js",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mrdoob/three.js",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mrdoob/three.js",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mrdoob/three.js",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mrdoob/three.js",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mrdoob/three.js",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "mrdoob2010mrdoob"
  }
 ],
 "presets": [
  {
   "id": "cascaded-shadow-maps-live",
   "title": "4-cascade Practical Split Scheme shadows — quantized cascade texel footprints and PCF",
   "runtime": "glsl-fragment",
   "params": {
    "SPLIT_LAMBDA": 0.65,
    "PCF_RADIUS": 1.25,
    "CASCADE_TINT": 0.38,
    "SUN_ANGLE": 0.72
   },
   "basis": "original",
   "license_note": "MIT — written for this index",
   "code": "const float SPLIT_LAMBDA = 0.65; // P\nconst float PCF_RADIUS = 1.25; // P\nconst float CASCADE_TINT = 0.38; // P\nconst float SUN_ANGLE = 0.72; // P\n\nfloat sdBox(vec3 p, vec3 b) {\n  vec3 q = abs(p) - b;\n  return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0);\n}\n\nfloat mapCasters(vec3 p) {\n  // Receding rows of architectural monoliths and lintel arches\n  vec3 q = p;\n  q.z = mod(q.z + 1.8, 3.6) - 1.8;\n  float pL = sdBox(vec3(p.x + 1.55, p.y - 1.05, q.z), vec3(0.32, 1.05, 0.32));\n  float pR = sdBox(vec3(p.x - 1.55, p.y - 1.05, q.z), vec3(0.32, 1.05, 0.32));\n  float arch = sdBox(vec3(p.x, p.y - 2.05, q.z), vec3(1.88, 0.22, 0.28));\n  // Center obelisk row with varying heights\n  float id = floor((p.z + 1.8) / 3.6);\n  float h = 0.55 + 0.35 * sin(id * 1.9);\n  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));\n  return min(min(pL, pR), min(arch, ob));\n}\n\nfloat mapScene(vec3 p) {\n  return min(p.y, mapCasters(p));\n}\n\nvec3 calcNormal(vec3 p) {\n  vec2 e = vec2(0.004, 0.0);\n  return normalize(vec3(\n    mapScene(p + e.xyy) - mapScene(p - e.xyy),\n    mapScene(p + e.yxy) - mapScene(p - e.yxy),\n    mapScene(p + e.yyx) - mapScene(p - e.yyx)\n  ));\n}\n\n// Shadow test snapped to cascade light-space texel grid\nfloat traceCaster(vec3 ro, vec3 rd) {\n  float t = 0.04;\n  for (int i = 0; i < 28; i++) {\n    float d = mapCasters(ro + rd * t);\n    if (d < 0.006) return 0.0;\n    t += max(d, 0.04);\n    if (t > 14.0) break;\n  }\n  return 1.0;\n}\n\nvec3 aces(vec3 x) {\n  x = max(x, 0.0);\n  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n  vec3 ro = vec3(0.0, 2.35, 3.2);\n  vec3 rd = normalize(vec3(uv.x, uv.y - 0.24, -1.25));\n\n  float sunAz = SUN_ANGLE + 0.35 * sin(iTime * 0.4);\n  if (iMouse.z > 0.5 || length(iMouse.xy) > 1.0) {\n    sunAz = (iMouse.x / iResolution.x) * 2.4 - 0.5;\n  }\n  vec3 sunDir = normalize(vec3(cos(sunAz), 0.72, sin(sunAz) * 0.65));\n  vec3 lRight = normalize(cross(sunDir, vec3(0.0, 1.0, 0.0)));\n  vec3 lUp = cross(lRight, sunDir);\n\n  float t = 0.1;\n  bool hit = false;\n  for (int i = 0; i < 72; i++) {\n    float d = mapScene(ro + rd * t);\n    if (d < 0.004) { hit = true; break; }\n    t += d;\n    if (t > 38.0) break;\n  }\n\n  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));\n  vec3 col = sky;\n  if (hit) {\n    vec3 p = ro + rd * t;\n    vec3 n = calcNormal(p);\n    // Practical split scheme (Zhang et al. 2006) across 4 cascades in [zNear, zFar]\n    float zNear = 1.2, zFar = 34.0;\n    float lam = clamp(SPLIT_LAMBDA, 0.0, 1.0);\n    float s1 = mix(zNear + (zFar - zNear) * 0.25, zNear * pow(zFar / zNear, 0.25), lam);\n    float s2 = mix(zNear + (zFar - zNear) * 0.50, zNear * pow(zFar / zNear, 0.50), lam);\n    float s3 = mix(zNear + (zFar - zNear) * 0.75, zNear * pow(zFar / zNear, 0.75), lam);\n\n    float viewZ = -dot(p - ro, vec3(0.0, 0.0, -1.0));\n    int casc = (viewZ < s1) ? 0 : (viewZ < s2) ? 1 : (viewZ < s3) ? 2 : 3;\n    float texel = (casc == 0) ? 0.045 : (casc == 1) ? 0.11 : (casc == 2) ? 0.24 : 0.48;\n    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);\n\n    // Quantize light-space coordinates to cascade texel size + 4-tap PCF\n    vec3 pOff = p + n * (0.015 + texel * 0.25);\n    vec2 luv = vec2(dot(pOff, lRight), dot(pOff, lUp));\n    vec2 qBase = (floor(luv / texel) + 0.5) * texel;\n    float pcfR = max(PCF_RADIUS, 0.0) * texel;\n    float vis = 0.0;\n    vec2 offs[4];\n    offs[0] = vec2(-0.5, -0.5); offs[1] = vec2(0.5, -0.5);\n    offs[2] = vec2(-0.5,  0.5); offs[3] = vec2(0.5,  0.5);\n    for (int k = 0; k < 4; k++) {\n      vec2 tap = qBase + offs[k] * pcfR;\n      vec3 sp = pOff + lRight * (tap.x - luv.x) + lUp * (tap.y - luv.y);\n      vis += traceCaster(sp, sunDir);\n    }\n    vis *= 0.25;\n\n    // Subtle border line at exact cascade split planes\n    float dSplit = min(min(abs(viewZ - s1), abs(viewZ - s2)), abs(viewZ - s3));\n    float splitLine = smoothstep(0.14, 0.02, dSplit) * clamp(CASCADE_TINT, 0.0, 1.0);\n\n    vec2 tile = floor(p.xz * 1.25);\n    float chk = mod(tile.x + tile.y, 2.0);\n    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);\n    vec3 alb = mix(baseAlb, baseAlb * cTint * 1.35, clamp(CASCADE_TINT, 0.0, 1.0));\n    float nl = max(dot(n, sunDir), 0.0);\n    vec3 lit = alb * (vec3(0.16, 0.22, 0.34) + vec3(1.55, 1.42, 1.22) * nl * vis);\n    lit = mix(lit, vec3(1.0), splitLine * 0.65);\n    col = mix(lit, sky, 1.0 - exp(-0.022 * t));\n  }\n  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "conceptual-diagram",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "cascaded-shadow-maps",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T16:15:34.232Z",
     "renderer": "Chromium 145.0.7632.6 headless, WebGL2 via ANGLE/SwiftShader, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.7762,
      "std": 0.1005,
      "unique_colors": 52
     },
     "image": "/specimens/cascaded-shadow-maps-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "shadow-mapping",
  "virtual-shadow-maps",
  "percentage-closer-filtering"
 ],
 "extends": [
  "shadow-mapping"
 ],
 "supersedes": [],
 "combines_with": [],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/visibility/cascaded-shadow-maps.json"
 },
 "solves": [
  "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"
 ],
 "authority": "Zhang et al., 2006",
 "url": "https://texelatlas.vercel.app/t/cascaded-shadow-maps/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 65.4,
  "tier": "extreme",
  "p50_ms": 2.1515,
  "p95_ms": 2.211,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "cascaded-shadow-maps-live",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 64.86,
   "tier": "extreme",
   "p50_ms": 1.0312,
   "p95_ms": 1.0363,
   "speedup_x": 2.09,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 41.89,
   "tier": "heavy",
   "p50_ms": 1.2063,
   "p95_ms": 1.2141,
   "speedup_x": 1.78,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}