---
id: "omnidirectional-shadow-maps"
title: "Omnidirectional (cube) shadow maps for point lights"
aliases: [cube shadow maps, point light shadows, omni shadows]
domain: "visibility"
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"
cost: "heavy"
authority: "Gerasimov"
url: "https://texelatlas.vercel.app/t/omnidirectional-shadow-maps/"
sources_verified_at: "2026-11-29"
---
# Omnidirectional (cube) shadow maps for point lights (Gerasimov)

> 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.

## Reach for it when

- 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

## 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 it

Choose it for dynamic point and omnidirectional lights (lamps, explosions, spotlights wider than ~120 degrees). Prefer a single perspective [Shadow Mapping](https://texelatlas.vercel.app/t/shadow-mapping.md) map for narrow spotlights, [Cascaded Shadow Maps](https://texelatlas.vercel.app/t/cascaded-shadow-maps.md) for the sun, [Shadow Volumes](https://texelatlas.vercel.app/t/shadow-volumes.md) when exact hard edges matter, and [Ray-Traced Shadows](https://texelatlas.vercel.app/t/ray-traced-shadows.md) or [Screen-Space Contact Shadows](https://texelatlas.vercel.app/t/contact-shadows.md) when many small lights cannot afford six passes each. Tame cost with [Clustered forward shading](https://texelatlas.vercel.app/t/clustered-forward-shading.md) so only lights touching visible clusters get maps.

## Cost

heavy — 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.
Measured GPU Weight: 34.33× baseline (heavy) — 1.1293 ms median / 1.2152 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 36.96× baseline (heavy) — 0.5876 ms median (1.92× faster on L4).
Ampere A100 scaling: 21.93× baseline (heavy) — 0.6315 ms median (1.79× faster on A100).

## 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

## Engine support

- babylonjs: builtin — `new ShadowGenerator(size, pointLight)` (evidence: https://github.com/BabylonJS/Babylon.js/blob/9.38.0/packages/dev/core/src/Lights/Shadows/shadowGenerator.ts, checked 2026-12-01)
- blender: builtin — `EEVEE > Point Light omnidirectional virtual shadow map` (evidence: https://docs.blender.org/manual/en/5.2/render/lights/light_object.html, checked 2026-12-01)
- godot: builtin — `OmniLight3D.shadow_enabled = true; omni_shadow_mode = SHADOW_CUBE` (evidence: https://github.com/godotengine/godot/blob/4.7.2-stable/doc/classes/OmniLight3D.xml, checked 2026-12-01)
- threejs: builtin — `pointLight.castShadow = true` (evidence: https://github.com/mrdoob/three.js/blob/r187/src/lights/PointLightShadow.js, checked 2026-12-01)
- unity: builtin — `Light > Type = Point > Shadow Type; HDRP Punctual shadows` (evidence: https://github.com/Unity-Technologies/Graphics/blob/557f6ac22b948284f57ffae6a789751fd1f63620/Packages/com.unity.render-pipelines.high-definition/Documentation~/Shadows-in-HDRP.md, checked 2026-12-01)
- unreal: builtin — `Point Light > Cast Shadows (omnidirectional cubemap or Virtual Shadow Map point-light shadows)` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/point-lights-in-unreal-engine, checked 2026-12-01)

## Dataflow

- Inputs: mesh, depth
- Outputs: visibility-mask
- Platforms: webgl2, webgpu, desktop-gpu, mobile-gpu, unity, unreal, godot

## Presets

### Omnidirectional (Cube) Shadow Maps — 6 cubemap face sectors & radial depth (left) vs 360-deg PCF point-light shadows (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_LIGHT_ORBIT": 0.6,
  "P_PCF_SOFT": 0.55,
  "P_FACE_VIS": 0.65,
  "P_SPLIT": 0.48
}
```

```glsl
const float P_LIGHT_ORBIT = 0.60; // P Point-Light Orbit [0.0, 1.6, 0.05]
const float P_PCF_SOFT = 0.55; // P Cube PCF Softness [0.1, 1.2, 0.05]
const float P_FACE_VIS = 0.65; // P Cube Face Tint [0.0, 1.0, 0.05]
const float P_SPLIT = 0.48; // P Cube Faces / Final [0.0, 1.0, 0.02]

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);
}

// Enclosed gallery chamber with pillars & floating blocks so point light casts radial shadows on all 6 faces
vec2 mapChamber(vec3 p) {
  // Inverted room box
  vec3 q = abs(p - vec3(0.0, 0.25, 0.0)) - vec3(1.55, 0.95, 1.55);
  float dRoom = -max(q.x, max(q.y, q.z));
  vec2 res = vec2(dRoom, 1.0);

  // 4 octagonal-arranged pillars casting radial shadows outward
  for (int i = 0; i < 4; i++) {
    float ang = float(i) * 1.570796 + 0.7854;
    vec3 pc = vec3(cos(ang) * 0.62, -0.05, sin(ang) * 0.62);
    float dP = sdBox(p - pc, vec3(0.11, 0.65, 0.11));
    if (dP < res.x) res = vec2(dP, 2.0);
  }
  // Floating central frame bar above point light
  float dRing = sdBox(p - vec3(0.0, 0.48, -0.15), vec3(0.45, 0.06, 0.12));
  if (dRing < res.x) res = vec2(dRing, 3.0);
  return res;
}

vec3 calcNormal(vec3 p) {
  vec2 e = vec2(0.0025, 0.0);
  return normalize(vec3(
    mapChamber(p + e.xyy).x - mapChamber(p - e.xyy).x,
    mapChamber(p + e.yxy).x - mapChamber(p - e.yxy).x,
    mapChamber(p + e.yyx).x - mapChamber(p - e.yyx).x
  ));
}

// Trace omnidirectional cube-map ray from point light toward surface point
float pointShadow(vec3 p, vec3 lPos, float soft) {
  vec3 toL = lPos - p;
  float distL = length(toL);
  vec3 dir = toL / max(distL, 1e-4);
  float sh = 1.0;
  float t = 0.04;
  for (int i = 0; i < 24; i++) {
    float h = mapChamber(p + dir * t).x;
    if (h < 0.003) return 0.0;
    sh = min(sh, (8.0 / max(soft, 0.15)) * h / t);
    t += max(h, 0.03);
    if (t > distL - 0.08) break;
  }
  return clamp(sh, 0.0, 1.0);
}

// Identify dominant cubemap face (+X,-X,+Y,-Y,+Z,-Z) and seam proximity for direction v
void cubeFaceInfo(vec3 v, out vec3 faceCol, out float seam) {
  vec3 a = abs(v);
  float m = max(a.x, max(a.y, a.z));
  vec3 r = a / max(m, 1e-4);
  // Seam occurs where two coordinates tie for largest magnitude
  float second = (a.x >= a.y && a.x >= a.z) ? max(r.y, r.z)
               : ((a.y >= a.z) ? max(r.x, r.z) : max(r.x, r.y));
  seam = smoothstep(0.95, 0.995, second);

  if (a.x >= a.y && a.x >= a.z) {
    faceCol = (v.x > 0.0) ? vec3(0.95, 0.30, 0.25) : vec3(0.20, 0.85, 0.92);
  } else if (a.y >= a.z) {
    faceCol = (v.y > 0.0) ? vec3(0.30, 0.92, 0.42) : vec3(0.88, 0.32, 0.88);
  } else {
    faceCol = (v.z > 0.0) ? vec3(0.32, 0.56, 0.98) : vec3(0.98, 0.78, 0.24);
  }
}

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;
  float screenX = fragCoord.x / max(iResolution.x, 1.0);
  float split = clamp(P_SPLIT, 0.0, 1.0);
  float t = iTime * max(P_LIGHT_ORBIT, 0.0);
  float soft = clamp(P_PCF_SOFT, 0.1, 1.4);
  float faceVis = clamp(P_FACE_VIS, 0.0, 1.0);

  vec3 lPos = vec3(0.34 * cos(t * 0.95), 0.14 + 0.22 * sin(t * 1.35), 0.34 * sin(t * 0.95));
  vec3 ro = vec3(0.0, 0.18, 1.44);
  vec3 rd = normalize(vec3(uv.x, uv.y - 0.06, -1.25));
  vec3 col = vec3(0.04, 0.05, 0.08);

  // Raymarch chamber geometry
  float dist = 0.04;
  vec2 hit = vec2(10.0, 0.0);
  for (int i = 0; i < 64; i++) {
    vec2 h = mapChamber(ro + rd * dist);
    if (h.x < 0.0025) { hit = vec2(dist, h.y); break; }
    dist += h.x;
    if (dist > 6.5) break;
  }

  // Test glowing point-light bulb sphere
  vec3 oc = ro - lPos;
  float b = dot(oc, rd), d = b * b - (dot(oc, oc) - 0.075 * 0.075);
  float tBulb = (d > 0.0 && (-b - sqrt(d)) > 0.05) ? (-b - sqrt(d)) : 1e5;

  if (tBulb < hit.x) {
    col = vec3(2.8, 2.2, 1.4);
  } else if (hit.y > 0.5) {
    vec3 p = ro + rd * hit.x;
    vec3 n = calcNormal(p);
    vec3 lightToFrag = p - lPos;
    float dLight = length(lightToFrag);
    vec3 lDir = -lightToFrag / max(dLight, 1e-4);

    float sh = pointShadow(p + n * 0.008, lPos, soft);
    float atten = 1.65 / (0.35 + dLight * dLight * 1.25);
    float ndl = max(dot(n, lDir), 0.0);

    vec3 alb = (hit.y < 1.5) ? vec3(0.70, 0.68, 0.65)
             : ((hit.y < 2.5) ? vec3(0.84, 0.78, 0.70) : vec3(0.32, 0.58, 0.74));
    vec3 lit = alb * (vec3(0.07, 0.09, 0.14) + vec3(1.45, 1.15, 0.80) * ndl * sh * atten);

    if (screenX < split) {
      // Left: Overlay 6 cubemap projection faces (+/-X, +/-Y, +/-Z) & face-edge seams from point light!
      vec3 fCol;
      float seam;
      cubeFaceInfo(lightToFrag, fCol, seam);
      float linDepthRing = smoothstep(0.04, 0.01, abs(fract(dLight * 2.5) - 0.5));
      col = mix(lit, fCol * (0.35 + 0.65 * sh), faceVis * 0.52);
      col = mix(col, vec3(0.98, 0.99, 1.0), seam * faceVis * 0.85 + linDepthRing * faceVis * 0.22);
    } else {
      col = lit;
    }
  }

  // Subtle volumetric glow around point light
  float glowD = length(cross(lPos - ro, rd));
  col += vec3(1.2, 0.85, 0.45) * exp(-glowD * 9.0) * 0.28;

  float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));
  col = mix(col, vec3(0.95, 0.98, 1.0), sep);
  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}
```

Attribution: MIT — written for this index.

## Lineage

- extends [Shadow Mapping](https://texelatlas.vercel.app/t/shadow-mapping.md)

## Combines with

- [Clustered forward shading](https://texelatlas.vercel.app/t/clustered-forward-shading.md): Cluster light lists identify which point lights affect visible pixels, so only those need cube maps this frame.

## Sources

1. [primary] Philipp S. Gerasimov Chapter 12. Omnidirectional Shadow Mapping. developer.nvidia.com. https://developer.nvidia.com/gpugems/gpugems/part-ii-lighting-and-shadows/chapter-12-omnidirectional-shadow-mapping (verified via http on 2026-11-29)
2. [implementation] mrdoob (2010) mrdoob/three.js. https://github.com/mrdoob/three.js License: MIT. (verified via github on 2026-11-29)

## Cite this entry

Texel. "Omnidirectional (cube) shadow maps for point lights." https://texelatlas.vercel.app/t/omnidirectional-shadow-maps/ (accessed 2026-12-01).
