Reflective Shadow Maps
Extends a shadow map with per-texel world position, normal and reflected flux, treating each lit texel as a tiny light. One-bounce indirect light is gathered by sampling nearby texels around each shaded point.
Also known as RSM
In the family Light transport & global illumination, image-space GI
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | None found | |
| Babylon.js 9.38.0 | Built in | BABYLON.GIRSM / GIRSMManager with ReflectiveShadowMap docs Experimental one-bounce GI. |
| Godot 4.7 | None found | |
| Unity | None found | |
| Unreal 5.7 | None found | |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
A shadow map already holds every surface point that a light directly illuminates. A reflective shadow map stores, for each texel of that map, the depth (or world position), the normal and the reflected radiant flux (albedo times incoming light). Each texel is therefore a small secondary source that emits diffusely.
To compute indirect light at a shaded point, project it into the RSM and take a set of samples in a disc around the projection, with a larger sampling density near the centre. Each sample contributes flux * max(0, n_pixel . (x_pixel - x_sample)) * max(0, n_sample . (x_sample - x_pixel)) / |dist|^4. Because that gather is expensive, implementations run it at lower resolution and upsample with an edge-aware filter, or precompute a rotating sampling pattern per pixel.
The method has no visibility test for the secondary light, so indirect shadows are missing, but it needs no pre-computation and works for animated lights and geometry.
When to choose it
Reach for it when
- first bounce indirect light for dynamic scenes
- color bleeding from a spot or sun light
- cheap gi using light's view of the scene
- indirect illumination without baking or ray tracing
Choose it for a cheap one-bounce indirect term from a single shadow-casting light (a flashlight or sun) in an engine that already renders shadow maps.
Prefer Light Propagation Volumes when you want to inject the RSM into a grid and get multi-bounce, no per-pixel gather. Prefer Instant Radiosity (Virtual Point Lights) when you need indirect shadows. Prefer Dynamic Diffuse Global Illumination (DDGI) or SDF-Based Software Ray Tracing GI (Lumen-style) for modern dynamic GI.
Field marks
- No occlusion for indirect light: light leaks through walls and floors between the RSM and the shaded point
- Only one bounce, and only light that is visible to the light's shadow camera
- Undersampling gives noise or flickering unless the pattern is rotated and filtered
- Wide-angle spot or sun light needs large, high-resolution RSMs to cover the visible area
Presets
Reflective Shadow Maps — direct spotlight flux VPL taps & single-bounce indirect gather
{
"P_RSM_GAIN": 1.4,
"P_SPOT_SWEEP": 1,
"P_VPL_DOTS": 1,
"P_SPLIT": 0.38
}Show GLSL (147 lines)
const float P_RSM_GAIN = 1.4; // P RSM Indirect Gain [0.0, 2.8, 0.05]
const float P_SPOT_SWEEP = 1.0; // P Spot Motion [0.0, 2.5, 0.05]
const float P_VPL_DOTS = 1.0; // P RSM VPL Taps [0.0, 1.5, 0.05]
const float P_SPLIT = 0.38; // P Direct / RSM Split [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);
}
// Gallery room with painted floor strips (crimson, gold, emerald) so moving spotlight spawns colored RSM bounce!
vec2 mapScene(vec3 p) {
vec2 res = vec2(1.0 + p.y, 1.0); // floor
float cD = 1.0 - p.y; if (cD < res.x) res = vec2(cD, 2.0);
float bD = 1.45 + p.z; if (bD < res.x) res = vec2(bD, 2.0);
float lD = 1.45 + p.x; if (lD < res.x) res = vec2(lD, 2.0);
float rD = 1.45 - p.x; if (rD < res.x) res = vec2(rD, 2.0);
// Two matte white sculptural columns & floating orb to catch indirect RSM bounce light
float dCol1 = sdBox(p - vec3(-0.72, -0.35, -0.55), vec3(0.22, 0.65, 0.22)) - 0.02;
if (dCol1 < res.x) res = vec2(dCol1, 3.0);
float dCol2 = sdBox(p - vec3(0.72, -0.35, -0.55), vec3(0.22, 0.65, 0.22)) - 0.02;
if (dCol2 < res.x) res = vec2(dCol2, 3.0);
float dOrb = length(p - vec3(0.0, 0.12, -0.45)) - 0.34;
if (dOrb < res.x) res = vec2(dOrb, 3.0);
return res;
}
vec3 calcNormal(vec3 p) {
vec2 e = vec2(0.0025, 0.0);
return normalize(vec3(
mapScene(p + e.xyy).x - mapScene(p - e.xyy).x,
mapScene(p + e.yxy).x - mapScene(p - e.yxy).x,
mapScene(p + e.yyx).x - mapScene(p - e.yyx).x
));
}
// Vivid painted floor mosaic so the RSM bounce color changes dramatically as the spotlight sweeps across it
vec3 floorMosaic(vec2 xz) {
if (xz.x < -0.38) return vec3(0.92, 0.18, 0.16);
if (xz.x > 0.38) return vec3(0.12, 0.72, 0.94);
return vec3(0.96, 0.68, 0.14);
}
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 rsmGain = max(P_RSM_GAIN, 0.0);
float tAnim = iTime * max(P_SPOT_SWEEP, 0.0);
float vplVis = clamp(P_VPL_DOTS, 0.0, 1.6);
vec3 ro = vec3(0.0, 0.12, 2.38);
vec3 rd = normalize(vec3(uv, -1.48));
// Sweeping overhead spotlight hitting the painted floor mosaic
vec3 spotOrig = vec3(0.0, 0.94, 0.30);
vec3 spotTarget = vec3(0.82 * sin(tAnim * 0.62), -1.0, -0.22 + 0.32 * cos(tAnim * 0.48));
vec3 spotAxis = normalize(spotTarget - spotOrig);
vec3 col = vec3(0.02);
float t = 0.0;
float matId = 0.0;
bool hit = false;
for (int i = 0; i < 64; i++) {
vec2 h = mapScene(ro + rd * t);
if (h.x < 0.002) { hit = true; matId = h.y; break; }
t += h.x;
if (t > 10.0) break;
}
if (hit) {
vec3 p = ro + rd * t;
vec3 n = calcNormal(p);
vec3 alb = vec3(0.76, 0.77, 0.78);
if (matId < 1.5) alb = floorMosaic(p.xz);
else if (matId > 2.5) alb = vec3(0.86, 0.86, 0.84);
// Direct spotlight illumination with shadow ray
vec3 toL = spotOrig - p;
float dL = length(toL);
vec3 lDir = toL / max(dL, 1e-4);
float spotCone = smoothstep(0.86, 0.96, dot(-lDir, spotAxis));
float sh = 1.0;
float ts = 0.03;
for (int i = 0; i < 24; i++) {
float dh = mapScene(p + lDir * ts).x;
if (dh < 0.004) { sh = 0.0; break; }
ts += dh;
if (ts > dL - 0.08) break;
}
vec3 direct = alb * vec3(3.2, 2.95, 2.6) * max(dot(n, lDir), 0.0) * spotCone * sh / (1.0 + 0.22 * dL * dL);
// Reflective Shadow Map (RSM) Gather: 12 importance-sampled pixel light VPLs inside the spotlight patch!
vec3 rsmIndirect = vec3(0.0);
float vplDotGlow = 0.0;
vec3 vplDotCol = vec3(0.0);
for (int k = 0; k < 12; k++) {
float fk = float(k);
// Golden-angle concentric disk sampling of the RSM texel footprint
float rDisk = sqrt((fk + 0.5) / 12.0) * 0.42;
float ang = fk * 2.399963 + 0.3;
vec3 vplPos = vec3(
clamp(spotTarget.x + cos(ang) * rDisk, -1.38, 1.38),
-0.995,
clamp(spotTarget.z + sin(ang) * rDisk, -1.38, 0.85)
);
vec3 vplN = vec3(0.0, 1.0, 0.0);
vec3 vplFlux = floorMosaic(vplPos.xz) * (1.0 - rDisk * 1.4);
vec3 toVpl = vplPos - p;
float dist2 = dot(toVpl, toVpl);
float dist = sqrt(max(dist2, 1e-5));
vec3 dirV = toVpl / dist;
// RSM form factor: max(0, dot(n_p, dir)) * max(0, dot(n_vpl, -dir)) / (d^2 + clamp)^2
float cosP = max(dot(n, dirV), 0.0);
float cosV = max(dot(vplN, -dirV), 0.0);
float geom = (cosP * cosV) / pow(max(dist2 + 0.16, 0.16), 1.35);
rsmIndirect += vplFlux * geom;
// Visible VPL sample indicator dot on the lit floor patch
if (matId < 1.5 && vplVis > 0.01) {
float dotM = smoothstep(0.042, 0.016, length(p.xz - vplPos.xz));
vplDotGlow = max(vplDotGlow, dotM);
if (dotM > 0.05) vplDotCol = vplFlux * 1.8 + vec3(0.4);
}
}
rsmIndirect = alb * (rsmIndirect / 12.0) * 4.8 * rsmGain;
vec3 leftCol = direct + alb * vec3(0.025, 0.03, 0.04);
vec3 rightCol = direct + rsmIndirect + alb * vec3(0.025, 0.03, 0.04);
rightCol = mix(rightCol, vplDotCol, vplDotGlow * 0.85 * min(vplVis, 1.2));
col = (screenX < split) ? leftCol : rightCol;
}
float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));
col = mix(col, vec3(0.95, 0.97, 1.0), sep);
fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Attribution: Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| reflective-shadow-maps-live | Tesla T4 1920x1080 | 40.7× baseline (heavy) · 1.28 ms / 1.35 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| reflective-shadow-maps-live | NVIDIA L4 1920x1080 | 41.8× baseline (heavy) · 0.660 ms / 0.662 ms · 1.9× faster on L4 | opengl-timer-query · Cross-architecture validation |
| reflective-shadow-maps-live | NVIDIA A100-SXM4-40GB 1920x1080 | 24.9× baseline (heavy) · 0.718 ms / 0.720 ms · 1.8× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): its primary source cites Instant Radiosity (Virtual Point Lights), Precomputed Radiance Transfer; cited by Light Propagation Volumes, Neural Radiance Caching, Screen-Space Global Illumination, Visibility Bitmask Ambient Occlusion, Voxel Cone Tracing.
Crosses
- Light Propagation Volumes: The RSM's flux, normals and positions are injected as virtual point lights into the volume.
Sources
- primaryCarsten Dachsbacher, Marc Stamminger (2005). Reflective shadow maps. Proceedings of the 2005 symposium on Interactive 3D graphics and games.Verified via crossref · 2026-11-29doi:10.1145/1053427.1053460