Virtual Shadow Maps
A very high-resolution, sparsely allocated shadow map per light, where only pages the camera actually samples are rendered and cached, pairing with virtualised geometry.
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 | None found | |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | None found | |
| Unity | None found | |
| Unreal 5.7 | Built in | Project Settings > Rendering > Shadows > Shadow Map Method = Virtual Shadow Maps docs |
| Blender 5.2 | Built in | Light Properties > Shadow (EEVEE uses Virtual Shadow Mapping) docs |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
Each light owns a virtual depth texture many thousands of texels wide, divided into pages. A pass analyses the depth buffer to mark which pages are needed at the required resolution (a clipmap for directional lights, mip-style levels for local lights), allocates physical pages, and renders only geometry overlapping them, with Nanite-style culling. Pages whose content did not change are cached between frames and invalidated by moving casters, so static scenes cost almost nothing per frame. Filtering is built from a small number of taps against the fine map and often combined with a screen-space or ray-traced term for contact detail. This is documented as an Unreal Engine 5 feature rather than a published paper.
When to choose it
Reach for it when
- shadow resolution too low for big detailed scenes
- need film quality shadows on every light
- cascades flicker and waste memory
- shadows blurry near the camera in open worlds
Choose it when geometry is extremely dense and you need consistent sharp shadows from near to far without hand-tuned cascades, in an engine with virtualised geometry. Prefer Cascaded Shadow Maps on mobile, WebGL or lower-end GPUs, and Ray-Traced Shadows when physically soft penumbrae are required.
Field marks
- Page invalidation spikes from fast-moving or large dynamic casters
- Large memory pool for the physical page cache
- Needs a depth-buffer analysis pass and GPU-driven rendering infrastructure
- Alpha-tested or deforming geometry can force costly re-rendering
Presets
Virtual Shadow Maps (VSM) — sparse physical page table & dirty-page invalidation (left) vs 1:1 texel-crisp virtual shadows (right)
{
"P_PAGE_GRID": 10,
"P_CLIPMAP_VIS": 0.65,
"P_MOVER_SPEED": 0.6,
"P_SPLIT": 0.48
}Show GLSL (123 lines)
const float P_PAGE_GRID = 10.00; // P Virtual Page Grid [5.0, 16.0, 1.0]
const float P_CLIPMAP_VIS = 0.65; // P Page State Overlay [0.1, 1.0, 0.05]
const float P_MOVER_SPEED = 0.60; // P Dynamic Caster Speed [0.0, 1.8, 0.05]
const float P_SPLIT = 0.48; // P Page Table / VSM [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);
}
// Courtyard with static fine architectural railing + a dynamic orbiting occluder that invalidates VSM pages!
vec2 mapVSMScene(vec3 p, vec3 moverPos) {
float dFloor = p.y + 0.52;
vec2 res = vec2(dFloor, 1.0);
// Static architectural fence/railing slats (demonstrates crisp 1:1 virtual shadow resolution!)
for (int i = 0; i < 5; i++) {
float x = -0.72 + float(i) * 0.22;
float dPost = sdBox(p - vec3(x, -0.18, -0.35), vec3(0.032, 0.34, 0.032));
if (dPost < res.x) res = vec2(dPost, 2.0);
}
float dRail = sdBox(p - vec3(-0.28, 0.08, -0.35), vec3(0.50, 0.03, 0.04));
if (dRail < res.x) res = vec2(dRail, 2.0);
// Dynamic moving sphere occluder (causes VSM dirty-page invalidation on tiles its shadow touches!)
float dMov = length(p - moverPos) - 0.22;
if (dMov < res.x) res = vec2(dMov, 3.0);
return res;
}
vec3 calcNormal(vec3 p, vec3 moverPos) {
vec2 e = vec2(0.0022, 0.0);
return normalize(vec3(
mapVSMScene(p + e.xyy, moverPos).x - mapVSMScene(p - e.xyy, moverPos).x,
mapVSMScene(p + e.yxy, moverPos).x - mapVSMScene(p - e.yxy, moverPos).x,
mapVSMScene(p + e.yyx, moverPos).x - mapVSMScene(p - e.yyx, moverPos).x
));
}
float traceVSMShadow(vec3 p, vec3 sunDir, vec3 moverPos) {
float sh = 1.0;
float t = 0.025;
for (int i = 0; i < 24; i++) {
float h = mapVSMScene(p + sunDir * t, moverPos).x;
if (h < 0.002) return 0.0;
sh = min(sh, 18.0 * h / t);
t += max(h, 0.02);
if (t > 4.0) break;
}
return clamp(sh, 0.0, 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;
float screenX = fragCoord.x / max(iResolution.x, 1.0);
float split = clamp(P_SPLIT, 0.0, 1.0);
float pageGrid = clamp(floor(P_PAGE_GRID + 0.5), 4.0, 18.0);
float vis = clamp(P_CLIPMAP_VIS, 0.05, 1.0);
float t = iTime * max(P_MOVER_SPEED, 0.0);
vec3 moverPos = vec3(0.38 + 0.28 * cos(t * 0.95), -0.14 + 0.12 * sin(t * 1.4), 0.08 + 0.26 * sin(t * 0.95));
vec3 ro = vec3(0.0, 0.55, 2.25);
vec3 rd = normalize(vec3(uv.x, uv.y - 0.22, -1.45));
vec3 sunDir = normalize(vec3(0.42, 0.78, 0.46));
vec3 sky = mix(vec3(0.70, 0.80, 0.92), vec3(0.18, 0.42, 0.78), smoothstep(-0.1, 0.5, rd.y));
vec3 col = sky;
float dist = 0.05;
vec2 hit = vec2(12.0, 0.0);
for (int i = 0; i < 64; i++) {
vec2 h = mapVSMScene(ro + rd * dist, moverPos);
if (h.x < 0.0025) { hit = vec2(dist, h.y); break; }
dist += h.x;
if (dist > 10.0) break;
}
if (hit.y > 0.5) {
vec3 p = ro + rd * hit.x;
vec3 n = calcNormal(p, moverPos);
float sh = traceVSMShadow(p + n * 0.008, sunDir, moverPos);
vec3 alb = vec3(0.76, 0.74, 0.70);
if (hit.y > 1.5 && hit.y < 2.5) alb = vec3(0.32, 0.36, 0.44);
else if (hit.y > 2.5) alb = vec3(0.94, 0.52, 0.20);
float ndl = max(dot(n, sunDir), 0.0);
vec3 lit = alb * (vec3(0.20, 0.28, 0.42) + vec3(1.32, 1.20, 1.00) * ndl * sh);
if (screenX < split) {
// Left: Sparse Virtual Shadow Map clipmap page-table overlay!
// Light-space virtual coordinates projected onto physical pages:
vec3 lRight = normalize(cross(vec3(0.0, 1.0, 0.0), sunDir));
vec3 lUp = cross(sunDir, lRight);
// Clipmap LOD level halves page frequency with camera distance
float clipScale = (hit.x > 3.2) ? (pageGrid * 0.5) : pageGrid;
vec2 vCoord = vec2(dot(p, lRight), dot(p, lUp)) * clipScale * 0.35;
vec2 pageId = floor(vCoord);
vec2 pf = fract(vCoord);
float tileEdge = smoothstep(0.07, 0.015, min(min(pf.x, 1.0 - pf.x), min(pf.y, 1.0 - pf.y)));
// Check if this virtual page overlaps the moving caster's shadow footprint -> INVALIDATED (amber/red) vs CACHED (cyan/emerald)!
vec2 moverShadowCoord = vec2(dot(moverPos, lRight), dot(moverPos, lUp)) * clipScale * 0.35;
bool dirtyPage = length(pageId + 0.5 - moverShadowCoord) < 1.35;
vec3 pageTint = dirtyPage ? vec3(1.0, 0.42, 0.16)
: ((hit.x > 3.2) ? vec3(0.22, 0.62, 0.98) : vec3(0.16, 0.90, 0.68));
col = mix(lit, lit * 0.55 + pageTint * 0.65, vis * 0.55);
col = mix(col, pageTint * 1.4, tileEdge * vis * 0.72);
} else {
col = lit;
}
if (hit.y < 1.5) col = mix(sky, col, exp(-hit.x * 0.08));
}
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 |
|---|---|---|---|
| virtual-shadow-maps-live | Tesla T4 1920x1080 | 40.4× baseline (heavy) · 1.33 ms / 1.42 ms | opengl-timer-query · 32 frames · GPU Weight Atlas · Colab T4 sweep |
| virtual-shadow-maps-live | NVIDIA L4 1920x1080 | 42.9× baseline (heavy) · 0.682 ms / 0.695 ms · 1.9× faster on L4 | opengl-timer-query · Cross-architecture validation |
| virtual-shadow-maps-live | NVIDIA A100-SXM4-40GB 1920x1080 | 25.3× baseline (heavy) · 0.728 ms / 0.736 ms · 1.8× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
Sources
- primaryEpic Games. Virtual Shadow Maps in Unreal Engine. dev.epicgames.com.Verified via live page · 2026-11-29