{
 "id": "omnidirectional-shadow-maps",
 "title": "Omnidirectional (cube) shadow maps for point lights",
 "aliases": [
  "cube shadow maps",
  "point light shadows",
  "omni shadows"
 ],
 "domain": "visibility",
 "subdomain": "point-light shadow maps",
 "stage": "visibility",
 "realtime": "realtime",
 "platforms": [
  "webgl2",
  "webgpu",
  "desktop-gpu",
  "mobile-gpu",
  "unity",
  "unreal",
  "godot"
 ],
 "year_introduced": 2004,
 "inputs": [
  "mesh",
  "depth"
 ],
 "outputs": [
  "visibility-mask"
 ],
 "style": "both",
 "dynamic": "dynamic",
 "summary": "Renders scene depth from a point light into six perspective views (a cube map) and looks up shadows with the world-space direction from the light to the shaded point.",
 "how_it_works": "A point light radiates in all directions, so a single planar map is not enough. The scene is rendered six times from the light position with 90-degree perspective frusta aligned to the cube axes, storing either hardware depth or linear distance (distance from light divided by light range) in each face. During shading the vector from light to fragment is used to sample the cube; its dominant axis picks the face, and the stored distance is compared with the fragment's. Storing linear distance avoids perspective non-linearity so one bias works across the range. Filtering needs care at face edges: kernels must stay seamless, which cube sampling handles in hardware or via small offsets with PCF. Optimisations include culling casters per face, skipping static lights, rendering all six faces in one pass with layered targets or instancing, using an atlas of faces for engines without cube arrays, and resolution tiers by light importance.",
 "when_to_use": "Choose it for dynamic point and omnidirectional lights (lamps, explosions, spotlights wider than ~120 degrees). Prefer a single perspective `shadow-mapping` map for narrow spotlights, `cascaded-shadow-maps` for the sun, `shadow-volumes` when exact hard edges matter, and `ray-traced-shadows` or `contact-shadows` when many small lights cannot afford six passes each. Tame cost with `clustered-forward-shading` so only lights touching visible clusters get maps.",
 "cost": {
  "class": "heavy",
  "notes": "Up to six geometry passes per light; cost scales with light count, caster count and resolution, mitigated by culling, caching of static lights and per-light update rates."
 },
 "failure_modes": [
  "Visible seams or filtering discontinuities along cube-face boundaries with wide PCF kernels",
  "Large per-light cost: geometry is processed up to six times, which limits light count",
  "Resolution waste at face corners and low texel density at distance, producing blocky edges",
  "Bias tuned for one face direction leaks or acnes on others when depth is not linearised",
  "Shadows pop when culling casters outside the light radius or when a cached face goes stale"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "url:https://developer.nvidia.com/gpugems/gpugems/part-ii-lighting-and-shadows/chapter-12-omnidirectional-shadow-mapping",
   "type": "web",
   "title": "Chapter 12. Omnidirectional Shadow Mapping",
   "authors": [
    "Philipp S. Gerasimov"
   ],
   "year": null,
   "venue": "developer.nvidia.com",
   "url": "https://developer.nvidia.com/gpugems/gpugems/part-ii-lighting-and-shadows/chapter-12-omnidirectional-shadow-mapping",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 200,
    "live": true,
    "archive": null,
    "page_title": "Chapter 12. Omnidirectional Shadow Mapping",
    "host": "developer.nvidia.com",
    "title_confirmed_by_page": true,
    "title_unconfirmed": false
   },
   "provenance": {
    "title": {
     "authority": "http",
     "endpoint": "GET https://developer.nvidia.com/gpugems/gpugems/part-ii-lighting-and-shadows/chapter-12-omnidirectional-shadow-mapping → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "http",
     "endpoint": "GET https://developer.nvidia.com/gpugems/gpugems/part-ii-lighting-and-shadows/chapter-12-omnidirectional-shadow-mapping → 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.nvidia.com/gpugems/gpugems/part-ii-lighting-and-shadows/chapter-12-omnidirectional-shadow-mapping → 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": 1,
   "__bib": "gerasimovchapter"
  },
  {
   "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": "omnidirectional-shadow-maps-live",
   "title": "Omnidirectional (Cube) Shadow Maps — 6 cubemap face sectors & radial depth (left) vs 360-deg PCF point-light shadows (right)",
   "runtime": "glsl-fragment",
   "params": {
    "P_LIGHT_ORBIT": 0.6,
    "P_PCF_SOFT": 0.55,
    "P_FACE_VIS": 0.65,
    "P_SPLIT": 0.48
   },
   "basis": "original",
   "license_note": "MIT — written for this index.",
   "code": "const float P_LIGHT_ORBIT = 0.60; // P Point-Light Orbit [0.0, 1.6, 0.05]\nconst float P_PCF_SOFT = 0.55; // P Cube PCF Softness [0.1, 1.2, 0.05]\nconst float P_FACE_VIS = 0.65; // P Cube Face Tint [0.0, 1.0, 0.05]\nconst float P_SPLIT = 0.48; // P Cube Faces / Final [0.0, 1.0, 0.02]\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\n// Enclosed gallery chamber with pillars & floating blocks so point light casts radial shadows on all 6 faces\nvec2 mapChamber(vec3 p) {\n  // Inverted room box\n  vec3 q = abs(p - vec3(0.0, 0.25, 0.0)) - vec3(1.55, 0.95, 1.55);\n  float dRoom = -max(q.x, max(q.y, q.z));\n  vec2 res = vec2(dRoom, 1.0);\n\n  // 4 octagonal-arranged pillars casting radial shadows outward\n  for (int i = 0; i < 4; i++) {\n    float ang = float(i) * 1.570796 + 0.7854;\n    vec3 pc = vec3(cos(ang) * 0.62, -0.05, sin(ang) * 0.62);\n    float dP = sdBox(p - pc, vec3(0.11, 0.65, 0.11));\n    if (dP < res.x) res = vec2(dP, 2.0);\n  }\n  // Floating central frame bar above point light\n  float dRing = sdBox(p - vec3(0.0, 0.48, -0.15), vec3(0.45, 0.06, 0.12));\n  if (dRing < res.x) res = vec2(dRing, 3.0);\n  return res;\n}\n\nvec3 calcNormal(vec3 p) {\n  vec2 e = vec2(0.0025, 0.0);\n  return normalize(vec3(\n    mapChamber(p + e.xyy).x - mapChamber(p - e.xyy).x,\n    mapChamber(p + e.yxy).x - mapChamber(p - e.yxy).x,\n    mapChamber(p + e.yyx).x - mapChamber(p - e.yyx).x\n  ));\n}\n\n// Trace omnidirectional cube-map ray from point light toward surface point\nfloat pointShadow(vec3 p, vec3 lPos, float soft) {\n  vec3 toL = lPos - p;\n  float distL = length(toL);\n  vec3 dir = toL / max(distL, 1e-4);\n  float sh = 1.0;\n  float t = 0.04;\n  for (int i = 0; i < 24; i++) {\n    float h = mapChamber(p + dir * t).x;\n    if (h < 0.003) return 0.0;\n    sh = min(sh, (8.0 / max(soft, 0.15)) * h / t);\n    t += max(h, 0.03);\n    if (t > distL - 0.08) break;\n  }\n  return clamp(sh, 0.0, 1.0);\n}\n\n// Identify dominant cubemap face (+X,-X,+Y,-Y,+Z,-Z) and seam proximity for direction v\nvoid cubeFaceInfo(vec3 v, out vec3 faceCol, out float seam) {\n  vec3 a = abs(v);\n  float m = max(a.x, max(a.y, a.z));\n  vec3 r = a / max(m, 1e-4);\n  // Seam occurs where two coordinates tie for largest magnitude\n  float second = (a.x >= a.y && a.x >= a.z) ? max(r.y, r.z)\n               : ((a.y >= a.z) ? max(r.x, r.z) : max(r.x, r.y));\n  seam = smoothstep(0.95, 0.995, second);\n\n  if (a.x >= a.y && a.x >= a.z) {\n    faceCol = (v.x > 0.0) ? vec3(0.95, 0.30, 0.25) : vec3(0.20, 0.85, 0.92);\n  } else if (a.y >= a.z) {\n    faceCol = (v.y > 0.0) ? vec3(0.30, 0.92, 0.42) : vec3(0.88, 0.32, 0.88);\n  } else {\n    faceCol = (v.z > 0.0) ? vec3(0.32, 0.56, 0.98) : vec3(0.98, 0.78, 0.24);\n  }\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  float screenX = fragCoord.x / max(iResolution.x, 1.0);\n  float split = clamp(P_SPLIT, 0.0, 1.0);\n  float t = iTime * max(P_LIGHT_ORBIT, 0.0);\n  float soft = clamp(P_PCF_SOFT, 0.1, 1.4);\n  float faceVis = clamp(P_FACE_VIS, 0.0, 1.0);\n\n  vec3 lPos = vec3(0.34 * cos(t * 0.95), 0.14 + 0.22 * sin(t * 1.35), 0.34 * sin(t * 0.95));\n  vec3 ro = vec3(0.0, 0.18, 1.44);\n  vec3 rd = normalize(vec3(uv.x, uv.y - 0.06, -1.25));\n  vec3 col = vec3(0.04, 0.05, 0.08);\n\n  // Raymarch chamber geometry\n  float dist = 0.04;\n  vec2 hit = vec2(10.0, 0.0);\n  for (int i = 0; i < 64; i++) {\n    vec2 h = mapChamber(ro + rd * dist);\n    if (h.x < 0.0025) { hit = vec2(dist, h.y); break; }\n    dist += h.x;\n    if (dist > 6.5) break;\n  }\n\n  // Test glowing point-light bulb sphere\n  vec3 oc = ro - lPos;\n  float b = dot(oc, rd), d = b * b - (dot(oc, oc) - 0.075 * 0.075);\n  float tBulb = (d > 0.0 && (-b - sqrt(d)) > 0.05) ? (-b - sqrt(d)) : 1e5;\n\n  if (tBulb < hit.x) {\n    col = vec3(2.8, 2.2, 1.4);\n  } else if (hit.y > 0.5) {\n    vec3 p = ro + rd * hit.x;\n    vec3 n = calcNormal(p);\n    vec3 lightToFrag = p - lPos;\n    float dLight = length(lightToFrag);\n    vec3 lDir = -lightToFrag / max(dLight, 1e-4);\n\n    float sh = pointShadow(p + n * 0.008, lPos, soft);\n    float atten = 1.65 / (0.35 + dLight * dLight * 1.25);\n    float ndl = max(dot(n, lDir), 0.0);\n\n    vec3 alb = (hit.y < 1.5) ? vec3(0.70, 0.68, 0.65)\n             : ((hit.y < 2.5) ? vec3(0.84, 0.78, 0.70) : vec3(0.32, 0.58, 0.74));\n    vec3 lit = alb * (vec3(0.07, 0.09, 0.14) + vec3(1.45, 1.15, 0.80) * ndl * sh * atten);\n\n    if (screenX < split) {\n      // Left: Overlay 6 cubemap projection faces (+/-X, +/-Y, +/-Z) & face-edge seams from point light!\n      vec3 fCol;\n      float seam;\n      cubeFaceInfo(lightToFrag, fCol, seam);\n      float linDepthRing = smoothstep(0.04, 0.01, abs(fract(dLight * 2.5) - 0.5));\n      col = mix(lit, fCol * (0.35 + 0.65 * sh), faceVis * 0.52);\n      col = mix(col, vec3(0.98, 0.99, 1.0), seam * faceVis * 0.85 + linDepthRing * faceVis * 0.22);\n    } else {\n      col = lit;\n    }\n  }\n\n  // Subtle volumetric glow around point light\n  float glowD = length(cross(lPos - ro, rd));\n  col += vec3(1.2, 0.85, 0.45) * exp(-glowD * 9.0) * 0.28;\n\n  float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));\n  col = mix(col, vec3(0.95, 0.98, 1.0), sep);\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": "omnidirectional-shadow-maps",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T21:07:20.000Z",
     "renderer": "Headless EGL Tesla T4/PCIe/SSE2, OpenGL 3.30 Core, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.7509,
      "std": 0.183,
      "min": 0.2802,
      "max": 0.9846
     },
     "image": "/specimens/omnidirectional-shadow-maps-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "shadow-mapping",
  "cascaded-shadow-maps",
  "shadow-map-bias-slope-scale-normal-offset",
  "percentage-closer-filtering",
  "percentage-closer-soft-shadows",
  "clustered-forward-shading",
  "virtual-shadow-maps"
 ],
 "extends": [
  "shadow-mapping"
 ],
 "supersedes": [],
 "combines_with": [
  {
   "id": "clustered-forward-shading",
   "why": "Cluster light lists identify which point lights affect visible pixels, so only those need cube maps this frame."
  }
 ],
 "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/omnidirectional-shadow-maps.json"
 },
 "solves": [
  "need shadows from a point light that shines in all directions",
  "lamp or torch should cast shadows in every direction",
  "shadow map seams appear at cube face edges",
  "point light shadows are too expensive with many lights",
  "spot or point lights need shadow lookups from a direction vector"
 ],
 "authority": "Gerasimov",
 "url": "https://texelatlas.vercel.app/t/omnidirectional-shadow-maps/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 34.33,
  "tier": "heavy",
  "p50_ms": 1.1293,
  "p95_ms": 1.2152,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 32,
  "preset_id": "omnidirectional-shadow-maps-live",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 36.96,
   "tier": "heavy",
   "p50_ms": 0.5876,
   "p95_ms": 0.5968,
   "speedup_x": 1.92,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 21.93,
   "tier": "heavy",
   "p50_ms": 0.6315,
   "p95_ms": 0.642,
   "speedup_x": 1.79,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}