Sample Distribution Shadow Maps (SDSM)
Analyses the depth buffer each frame to fit cascade split positions and light-space bounds tightly around the pixels that will actually sample the shadow map.
Also known as SDSM
In the family Visibility, shadows & ambient occlusion, shadow map fitting
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 | DirectionalLight3D uses fixed PSSM splits (directional_shadow_split_*), no SDSM depth analysis. |
| Unity | None found | |
| Unreal 5.7 | None found | Cascaded and Virtual Shadow Maps are used instead. |
| Blender 5.2 | None found | EEVEE uses virtual shadow maps. |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
Classic cascaded shadow maps place split planes with a fixed scheme and fit each cascade to the whole sub-frustum, wasting texels on empty space. SDSM first renders the scene depth and runs a GPU reduction to find the minimum and maximum visible view depth. It can then (a) set split planes from a logarithmic partition of that real range, or from a depth histogram, so cascades follow where pixels exist, and (b) for each cascade compute the tight light-space bounding box of just the visible samples, using min/max reductions of the projected positions. The resulting orthographic projections are read back or consumed by indirect dispatch, then used to render the maps. Snapping extents to texel increments keeps shadows stable under camera motion, and conservative expansion handles reduction latency.
When to choose it
Reach for it when
- cascaded shadows waste resolution when looking at a wall
- shadow quality changes a lot depending on view direction
- cascade splits do not match the visible depth range
- want tighter shadow map fitting around visible pixels
- distant sun shadows blurry although camera sees little depth
Choose it when Cascaded Shadow Maps waste resolution because the visible depth range varies a lot, as in outdoor scenes that alternate between looking at a wall and looking at the horizon. Prefer Virtual Shadow Maps when geometry density and uniform quality matter more than fitting, and keep plain stabilised CSM for mobile where an extra depth reduction is too costly. Pair with normal-offset bias from Shadow map depth bias (constant, slope-scale, normal offset) per cascade.
Field marks
- Shadow shimmering when cascade bounds change every frame without stabilisation or hysteresis
- One-frame latency in bounds when reductions are read back, causing pop at fast camera turns
- Tight fit excludes off-screen casters unless the near plane is extended toward the light
- Depth outliers (sky, tiny particles) must be masked or the reduction loosens again
Presets
Sample Distribution Shadow Maps (SDSM) — fixed CSM wasted cascades & aliasing (left) vs depth-fitted tight SDSM cascades (right)
{
"P_CASCADES": 4,
"P_BAND_VIS": 0.55,
"P_SUN_SWEEP": 0.5,
"P_SPLIT": 0.48
}Show GLSL (131 lines)
const float P_CASCADES = 4.00; // P Cascade Count [2.0, 5.0, 1.0]
const float P_BAND_VIS = 0.55; // P Cascade Tint [0.0, 1.0, 0.05]
const float P_SUN_SWEEP = 0.50; // P Sun Sweep [0.0, 1.5, 0.05]
const float P_SPLIT = 0.48; // P Fixed CSM / SDSM [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);
}
// Long architectural vista with foreground + mid-ground + distant monoliths and empty depth gap in between
vec2 mapVista(vec3 p) {
float dFloor = p.y + 0.55;
vec2 res = vec2(dFloor, 1.0);
// Repeating rows of tall monoliths along -Z
for (int i = 0; i < 4; i++) {
float z = -0.35 - float(i) * 1.35;
float dL = sdBox(p - vec3(-0.62, 0.05, z), vec3(0.16, 0.60, 0.16));
float dR = sdBox(p - vec3(0.62, 0.05, z), vec3(0.16, 0.60, 0.16));
float dTop = sdBox(p - vec3(0.0, 0.58, z), vec3(0.80, 0.09, 0.16));
float dArch = min(min(dL, dR), dTop);
if (dArch < res.x) res = vec2(dArch, 2.0);
}
return res;
}
vec3 calcNormal(vec3 p) {
vec2 e = vec2(0.003, 0.0);
return normalize(vec3(
mapVista(p + e.xyy).x - mapVista(p - e.xyy).x,
mapVista(p + e.yxy).x - mapVista(p - e.yxy).x,
mapVista(p + e.yyx).x - mapVista(p - e.yyx).x
));
}
// Trace shadow ray from quantized shadow-map texel position to visualize real texel-resolution difference!
float traceShadowAt(vec3 p, vec3 sunDir, float texelSize) {
// Snap point onto light-space shadow-map texel grid of size texelSize
vec3 lUp = vec3(0.0, 1.0, 0.0);
vec3 lRight = normalize(cross(lUp, sunDir));
vec3 lOrtho = cross(sunDir, lRight);
float u = floor(dot(p, lRight) / texelSize + 0.5) * texelSize;
float v = floor(dot(p, lOrtho) / texelSize + 0.5) * texelSize;
float w = dot(p, sunDir);
vec3 pSnap = lRight * u + lOrtho * v + sunDir * w;
float t = 0.05;
for (int i = 0; i < 20; i++) {
float h = mapVista(pSnap + sunDir * t).x;
if (h < 0.005) return 0.0;
t += max(h, 0.04);
if (t > 4.0) break;
}
return 1.0;
}
vec3 cascadeColor(float idx) {
if (idx < 0.5) return vec3(0.18, 0.92, 0.56);
if (idx < 1.5) return vec3(0.20, 0.72, 1.0);
if (idx < 2.5) return vec3(0.98, 0.78, 0.22);
if (idx < 3.5) return vec3(0.98, 0.36, 0.32);
return vec3(0.84, 0.38, 0.98);
}
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 numCasc = clamp(floor(P_CASCADES + 0.5), 2.0, 5.0);
float bandVis = clamp(P_BAND_VIS, 0.0, 1.0);
float t = iTime * max(P_SUN_SWEEP, 0.0);
vec3 ro = vec3(0.16 * sin(t * 0.4), 0.36, 2.20);
vec3 rd = normalize(vec3(uv.x, uv.y - 0.10, -1.45));
vec3 sunDir = normalize(vec3(0.68 * cos(t * 0.35 + 0.4), 0.62, 0.38));
vec3 sky = mix(vec3(0.72, 0.80, 0.90), vec3(0.18, 0.42, 0.76), smoothstep(-0.08, 0.55, 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 = mapVista(ro + rd * dist);
if (h.x < 0.003) { hit = vec2(dist, h.y); break; }
dist += h.x;
if (dist > 11.0) break;
}
if (hit.y > 0.5) {
vec3 p = ro + rd * hit.x;
vec3 n = calcNormal(p);
float viewZ = hit.x;
float cascIdx = 0.0;
float texelSz = 0.02;
if (screenX < split) {
// Left: Fixed naive CSM splits spanning [0.1 .. 24.0] -> wastes cascade 0 in empty air near camera,
// forcing visible geometry into coarse cascades with blocky aliased shadows!
float zFrac = clamp(log(max(viewZ, 0.1) / 0.1) / log(24.0 / 0.1), 0.0, 0.999);
cascIdx = floor(zFrac * numCasc);
texelSz = 0.032 * pow(1.75, cascIdx);
} else {
// Right: SDSM reduces actual visible depth bounds [zMin=1.6 .. zMax=8.2] each frame ->
// tightly fits all cascades around real scene samples for 3-4x crisper shadow texels!
float zMin = 1.55;
float zMax = 8.40;
float zFrac = clamp(log(max(viewZ, zMin) / zMin) / log(zMax / zMin), 0.0, 0.999);
cascIdx = floor(zFrac * numCasc);
texelSz = 0.008 * pow(1.42, cascIdx);
}
float sh = traceShadowAt(p + n * 0.01, sunDir, texelSz);
vec3 alb = (hit.y < 1.5) ? vec3(0.74, 0.72, 0.68) : vec3(0.86, 0.82, 0.76);
float ndl = max(dot(n, sunDir), 0.0);
vec3 lit = alb * (vec3(0.20, 0.28, 0.42) + vec3(1.32, 1.18, 0.96) * ndl * sh);
// Subtle cascade split band tint & boundary line
vec3 cTint = cascadeColor(cascIdx);
col = mix(lit, lit * (0.55 + 0.75 * cTint), bandVis * 0.48);
col = mix(sky, col, exp(-viewZ * 0.06));
}
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 |
|---|---|---|---|
| sample-distribution-shadow-maps-live | Tesla T4 1920x1080 | 49.0× baseline (heavy) · 1.61 ms / 1.68 ms | opengl-timer-query · 32 frames · GPU Weight Atlas · Colab T4 sweep |
| sample-distribution-shadow-maps-live | NVIDIA L4 1920x1080 | 55.7× baseline (heavy) · 0.885 ms / 0.894 ms · 1.8× faster on L4 | opengl-timer-query · Cross-architecture validation |
| sample-distribution-shadow-maps-live | NVIDIA A100-SXM4-40GB 1920x1080 | 32.8× baseline (heavy) · 0.944 ms / 0.962 ms · 1.7× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): its primary source cites Voronoi Diagrams and Lloyd Relaxation; cited by Moment Shadow Maps.
Crosses
- Hierarchical-Z occlusion culling: The depth pyramid built for culling can provide the min/max depth the SDSM reduction needs.
Sources
- primaryAndrew Lauritzen, Marco Salvi, Aaron Lefohn (2011). Sample distribution shadow maps. Symposium on Interactive 3D Graphics and Games.Verified via crossref · 2026-11-29doi:10.1145/1944745.1944761
- implementationTheRealMJP (2016). TheRealMJP/Shadows. A sample app that demonstrates several techniques for rendering real-time shadow mapsGitHub API · license MIT · 2026-11-29