SDF-Based Software Ray Tracing GI (Lumen-style)
Traces rays through per-mesh and global signed distance fields, and shades hits from a cached, low-resolution lit representation of surfaces, with screen-space probes gathering the result. Fully dynamic GI without hardware RT.
Also known as Lumen, SDF GI, Surface cache GI
In the family Light transport & global illumination, hybrid tracing GI
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 | Godot SDFGI (Environment.sdfgi_enabled) is cascaded SDF probe GI, not Lumen-style surface-cache tracing. |
| Unity | None found | HDRP RT GI uses hardware ray tracing, not SDF software tracing. |
| Unreal 5.7 | Built in | Project Settings > Rendering > Global Illumination > Dynamic Global Illumination Method = Lumen (also per Post Process Volume) docs |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
The system splits the problem into what do I hit and what light is there. Hit finding uses signed distance fields: each mesh has a precomputed SDF, and a coarse global SDF (a camera-centred clipmap) is built on the fly. Rays sphere-trace the global SDF for far hits and the per-mesh SDFs near the camera; hardware ray tracing can replace them where available.
Shading hits is expensive, so Lumen keeps a surface cache: each mesh has a set of low-resolution cards (axis-aligned captures with albedo, normals and emissive) that are lit with direct lighting and prior-frame indirect light on a time-sliced schedule. A ray that hits a surface just looks up the cached radiance at the corresponding card texel.
Final gather uses screen-space probes placed on a coarse tile grid in the G-buffer. Each probe traces a few dozen rays with importance sampling toward the BRDF and previous radiance, the results are projected to spherical harmonics or octahedral maps, then interpolated to pixels with filtering and temporal accumulation. A world-space radiance cache covers far-field and reflections.
When to choose it
Reach for it when
- need fully dynamic global illumination without baking
- no hardware ray tracing but want dynamic bounce light
- large scenes need scalable indirect lighting and reflections
- lighting must update when geometry or sun moves
Choose the approach (not necessarily the engine) when you need fully dynamic, large-scale GI and reflections across scalable hardware, and your content is mesh-based so SDFs can be generated.
Prefer Dynamic Diffuse Global Illumination (DDGI) when you control scene scale, want simpler code and have hardware ray tracing. Prefer Surfel-Based Global Illumination (GIBS) when you want a surface-cache design based on surfels with hardware RT. Prefer Voxel Cone Tracing for simpler engines without per-mesh SDFs. Prefer ReSTIR GI: Path Resampling for Real-Time Path Tracing when you want pixel-accurate indirect with a high-end GPU budget.
Field marks
- Thin walls and small details missing from coarse SDFs cause light leaks and missing occlusion
- Surface cache cards give inaccurate lighting on complex or concave meshes and when UVs/cards cover surfaces poorly
- Slow temporal accumulation shows lag when lights or doors move quickly
- Small-scale indirect detail and glossy reflections are noisy or blurry because the screen probes are sparse
Presets
SDF-Based Software Ray Tracing GI (Lumen-style) — real-time SDF hemisphere tracing & surface cache cards
{
"P_GI_INTENSITY": 1.4,
"P_TRACE_DIST": 2.2,
"P_SUN_ANGLE": 0.6,
"P_SPLIT": 0.4
}Show GLSL (149 lines)
const float P_GI_INTENSITY = 1.4; // P SDF GI Bounce [0.0, 2.8, 0.05]
const float P_TRACE_DIST = 2.2; // P SDF Trace Range [0.6, 3.6, 0.1]
const float P_SUN_ANGLE = 0.6; // P Sun Elevation [0.15, 1.25, 0.03]
const float P_SPLIT = 0.40; // P Direct / Lumen GI [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);
}
// Sunlit architectural atrium SDF (open roof skylight + terracotta bounce wall + columns)
vec2 mapAtrium(vec3 p) {
vec2 res = vec2(1.0 + p.y, 1.0); // limestone floor
// Roof slab with central sunlit skylight opening
float roof = max(1.0 - p.y, -(sdBox(p - vec3(0.0, 1.0, -0.35), vec3(0.62, 0.4, 0.58))));
if (roof < res.x) res = vec2(roof, 1.0);
float backW = 1.55 + p.z; if (backW < res.x) res = vec2(backW, 1.0);
float leftW = 1.50 + p.x; if (leftW < res.x) res = vec2(leftW, 2.0); // sunlit terracotta bounce card
float rightW = 1.50 - p.x; if (rightW < res.x) res = vec2(rightW, 3.0); // sage-emerald bounce card
// Twin colonnade piers & sculpted pedestal orb
float dP1 = sdBox(p - vec3(-0.68, 0.0, -0.78), vec3(0.18, 1.0, 0.18)) - 0.02;
if (dP1 < res.x) res = vec2(dP1, 4.0);
float dP2 = sdBox(p - vec3(0.68, 0.0, -0.78), vec3(0.18, 1.0, 0.18)) - 0.02;
if (dP2 < res.x) res = vec2(dP2, 4.0);
float dSph = length(p - vec3(0.0, -0.58, -0.30)) - 0.40;
if (dSph < res.x) res = vec2(dSph, 4.0);
return res;
}
vec3 calcNormal(vec3 p) {
vec2 e = vec2(0.0025, 0.0);
return normalize(vec3(
mapAtrium(p + e.xyy).x - mapAtrium(p - e.xyy).x,
mapAtrium(p + e.yxy).x - mapAtrium(p - e.yxy).x,
mapAtrium(p + e.yyx).x - mapAtrium(p - e.yyx).x
));
}
vec3 surfaceAlbedo(float id) {
if (id < 1.5) return vec3(0.76, 0.74, 0.70);
if (id < 2.5) return vec3(0.92, 0.34, 0.14); // terracotta
if (id < 3.5) return vec3(0.14, 0.68, 0.56); // turquoise-sage
return vec3(0.86, 0.85, 0.82);
}
// Fast SDF sun visibility shadow test
float sunVis(vec3 p, vec3 sunDir) {
float t = 0.04;
for (int i = 0; i < 20; i++) {
float d = mapAtrium(p + sunDir * t).x;
if (d < 0.004) return 0.0;
t += max(d, 0.02);
if (t > 4.2) return 1.0;
}
return 1.0;
}
// Evaluate Lumen-style Surface Cache radiance at an SDF secondary ray hit
vec3 sampleSurfaceCache(vec3 hitP, float hitId, vec3 sunDir) {
vec3 n = calcNormal(hitP);
vec3 alb = surfaceAlbedo(hitId);
float vis = sunVis(hitP + n * 0.02, sunDir);
float ndl = max(dot(n, sunDir), 0.0);
return alb * (vec3(3.1, 2.65, 2.0) * ndl * vis + vec3(0.18, 0.24, 0.34));
}
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 giGain = max(P_GI_INTENSITY, 0.0);
float maxTrace = clamp(P_TRACE_DIST, 0.5, 4.0);
float sunElev = clamp(P_SUN_ANGLE, 0.15, 1.35);
vec3 ro = vec3(0.0, 0.05, 2.32);
vec3 rd = normalize(vec3(uv, -1.48));
float sunAz = sin(iTime * 0.45) * 0.85;
vec3 sunDir = normalize(vec3(sin(sunAz), sunElev + 0.45, cos(sunAz) * 0.35));
vec3 skyCol = vec3(0.45, 0.72, 1.15) * 1.4;
vec3 col = skyCol;
float t = 0.0;
float matId = 0.0;
bool hit = false;
for (int i = 0; i < 64; i++) {
vec2 h = mapAtrium(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 = surfaceAlbedo(matId);
// Direct sun illumination through skylight
float vis = sunVis(p + n * 0.02, sunDir);
vec3 direct = alb * vec3(2.8, 2.45, 1.95) * max(dot(n, sunDir), 0.0) * vis;
// Lumen-style Software SDF Hemisphere Ray Tracing (6 deterministic Fibonacci hemisphere rays)
vec3 upVec = (abs(n.y) < 0.9) ? vec3(0.0, 1.0, 0.0) : vec3(1.0, 0.0, 0.0);
vec3 tang = normalize(cross(upVec, n));
vec3 bitang = cross(n, tang);
float jitter = fract(sin(dot(fragCoord, vec2(12.9898, 78.233))) * 43758.5453);
vec3 giAccum = vec3(0.0);
for (int r = 0; r < 6; r++) {
float fr = float(r);
float phi = (fr + jitter * 0.5) * 2.399963 + 0.4;
float cosTheta = clamp((fr + 0.5) / 6.0, 0.15, 0.96);
float sinTheta = sqrt(max(1.0 - cosTheta * cosTheta, 0.0));
vec3 rDir = normalize(tang * (cos(phi) * sinTheta) + bitang * (sin(phi) * sinTheta) + n * cosTheta);
// Sphere-trace global distance field
float tr = 0.05;
bool rHit = false;
float rMat = 0.0;
for (int s = 0; s < 14; s++) {
vec2 rh = mapAtrium(p + n * 0.03 + rDir * tr);
if (rh.x < 0.015) { rHit = true; rMat = rh.y; break; }
tr += max(rh.x, 0.04);
if (tr > maxTrace) break;
}
if (rHit) {
giAccum += sampleSurfaceCache(p + n * 0.03 + rDir * tr, rMat, sunDir);
} else {
// Ray escaped through skylight -> sample procedural sky radiance
giAccum += skyCol * smoothstep(-0.1, 0.65, rDir.y) * 0.85;
}
}
vec3 indirect = alb * (giAccum / 6.0) * giGain;
vec3 directOnly = direct + alb * vec3(0.03, 0.04, 0.055);
col = (screenX < split) ? directOnly : (direct + indirect);
}
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 |
|---|---|---|---|
| lumen-gi-live | Tesla T4 1920x1080 | 201× baseline (extreme) · 6.32 ms / 6.40 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| lumen-gi-live | NVIDIA L4 1920x1080 | 220× baseline (extreme) · 3.48 ms / 3.58 ms · 1.8× faster on L4 | opengl-timer-query · Cross-architecture validation |
| lumen-gi-live | NVIDIA A100-SXM4-40GB 1920x1080 | 134× baseline (extreme) · 3.86 ms / 3.87 ms · 1.6× faster on A100 | opengl-timer-query · Cross-architecture validation |
Crosses
- Screen-Space Global Illumination: Screen-space traces supply exact near-field hits before falling back to the SDF.
Sources
- primaryDaniel Wright et al.. Lumen: Real-time Global Illumination in Unreal Engine 5. SIGGRAPH 2022 Advances in Real-Time Rendering.Verified via live page · 2026-11-29