Omnidirectional (cube) shadow maps for point lights
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.
Also known as cube shadow maps, point light shadows, omni shadows
In the family Visibility, shadows & ambient occlusion, point-light shadow maps
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | Built in | pointLight.castShadow = true docs |
| Babylon.js 9.38.0 | Built in | new ShadowGenerator(size, pointLight) docs |
| Godot 4.7 | Built in | OmniLight3D.shadow_enabled = true; omni_shadow_mode = SHADOW_CUBE docs |
| Unity | Built in | Light > Type = Point > Shadow Type; HDRP Punctual shadows docs |
| Unreal 5.7 | Built in | Point Light > Cast Shadows (omnidirectional cubemap or Virtual Shadow Map point-light shadows) docs |
| Blender 5.2 | Built in | EEVEE > Point Light omnidirectional virtual shadow map docs |
| WebGPU W3C | None found | |
| Metal | None found |
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 choose it
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
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 Screen-Space 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.
Field marks
- 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
Presets
Omnidirectional (Cube) Shadow Maps — 6 cubemap face sectors & radial depth (left) vs 360-deg PCF point-light shadows (right)
{
"P_LIGHT_ORBIT": 0.6,
"P_PCF_SOFT": 0.55,
"P_FACE_VIS": 0.65,
"P_SPLIT": 0.48
}Show GLSL (146 lines)
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.
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| omnidirectional-shadow-maps-live | Tesla T4 1920x1080 | 34.3× baseline (heavy) · 1.13 ms / 1.22 ms | opengl-timer-query · 32 frames · GPU Weight Atlas · Colab T4 sweep |
| omnidirectional-shadow-maps-live | NVIDIA L4 1920x1080 | 37.0× baseline (heavy) · 0.588 ms / 0.597 ms · 1.9× faster on L4 | opengl-timer-query · Cross-architecture validation |
| omnidirectional-shadow-maps-live | NVIDIA A100-SXM4-40GB 1920x1080 | 21.9× baseline (heavy) · 0.631 ms / 0.642 ms · 1.8× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
Crosses
- Clustered forward shading: Cluster light lists identify which point lights affect visible pixels, so only those need cube maps this frame.
Sources
- primaryPhilipp S. Gerasimov. Chapter 12. Omnidirectional Shadow Mapping. developer.nvidia.com.Verified via live page · 2026-11-29
- implementationmrdoob (2010). mrdoob/three.js. JavaScript 3D Library.GitHub API · license MIT · 2026-11-29