Irradiance Caching
Computes expensive diffuse indirect irradiance only at sparse surface points and interpolates between them, placing samples more densely near geometry where lighting changes quickly.
Also known as Ward irradiance cache, irradiance gradients
In the family Light transport & global illumination, sparse interpolation
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 | Uses Adaptive Probe Volumes and progressive lightmapping rather than Ward-style sparse irradiance caching. |
| Unreal 5.7 | Built in | World Settings > Lightmass > Volumetric Lightmaps cache precomputed indirect irradiance probes in a 3D brick hierarchy docs |
| Blender 5.2 | Built in | EEVEE Light Probe > Volume bakes and caches indirect diffuse irradiance in eevee_lightprobe_volume.cc docs |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
Diffuse indirect light varies slowly over open surfaces and quickly near corners and occluders. Irradiance caching exploits this by computing the hemispherical integral (with hundreds of rays) only at selected points and reusing it for neighbours.
When a shading point x needs indirect light, the renderer searches an octree of earlier cache records. A record at p with normal n_p and validity radius R_p (tied to the harmonic mean distance to surfaces seen from p) contributes a weight w = 1 / (|x - p| / R_p + sqrt(1 - n . n_p)). If the summed weights exceed a threshold, the result is the weighted average of the contributing records. Otherwise a new record is computed and inserted.
Because the validity radius is proportional to the distance of nearby geometry, cache records are dense in corners and sparse on flat walls. Irradiance gradients (translational and rotational) extrapolate each record's value linearly, which allows larger spacing and smoother results.
When to choose it
Reach for it when
- path tracing diffuse bounce is slow and noisy
- indirect lighting computed too often in smooth areas
- speed up offline gi for diffuse interiors
- reuse indirect light between nearby surface points
Choose it for offline diffuse GI where final gathering at every pixel is too expensive, such as in a classic ray-tracing renderer or baker with photon maps.
Prefer Unidirectional Path Tracing when you want unbiased, simpler code and cost is acceptable. Prefer Lightmap Baking when the output should live in texture space for real-time use. Prefer Surfel-Based Global Illumination (GIBS) when you want the same idea (sparse cached surface irradiance) at runtime and dynamically.
Field marks
- Splotchy low-frequency artifacts where record spacing is coarse and interpolation is visible
- Light leaks at thin geometry because records near a wall can be applied to the other side
- Not view-independent in practice: sampling order shows as temporal inconsistency in animation, so caches must be shared across frames
- Diffuse only; poor for glossy indirect lighting
Presets
Irradiance Caching — sparse Ward cache records & validity radii (left) vs smooth gradient GI (right)
{
"P_ERROR_TOL": 0.55,
"P_CACHE_VIS": 1,
"P_GI_GAIN": 1.25,
"P_SPLIT": 0.48
}Show GLSL (159 lines)
const float P_ERROR_TOL = 0.55; // P Error Tolerance a [0.2, 1.2, 0.03]
const float P_CACHE_VIS = 1.0; // P Cache Overlay [0.0, 1.5, 0.05]
const float P_GI_GAIN = 1.25; // P Indirect Gain [0.3, 2.2, 0.05]
const float P_SPLIT = 0.48; // P Records / Smooth Split [0.0, 1.0, 0.02]
float hash31(vec3 p) {
p = fract(p * 0.1031);
p += dot(p, p.yzx + 33.33);
return fract((p.x + p.y) * p.z);
}
vec3 hash33(vec3 p) {
p = fract(p * vec3(0.1031, 0.1030, 0.0973));
p += dot(p, p.yxz + 33.33);
return fract((p.xxy + p.yxx) * p.zyx);
}
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);
}
vec2 mapScene(vec3 p) {
vec2 res = vec2(p.y + 0.85, 1.0);
float dC = 1.05 - p.y; if (dC < res.x) res = vec2(dC, 1.0);
float dB = p.z + 1.38; if (dB < res.x) res = vec2(dB, 1.0);
float dL = p.x + 1.28; if (dL < res.x) res = vec2(dL, 2.0);
float dR = 1.28 - p.x; if (dR < res.x) res = vec2(dR, 3.0);
float dArch = sdBox(p - vec3(-0.35, -0.35, -0.35), vec3(0.28, 0.50, 0.28)) - 0.02;
if (dArch < res.x) res = vec2(dArch, 4.0);
float dSph = length(p - vec3(0.42, -0.49, -0.10)) - 0.36;
if (dSph < res.x) res = vec2(dSph, 4.0);
return res;
}
vec3 calcNormal(vec3 p) {
vec2 e = vec2(0.0022, 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
));
}
// Harmonic-mean distance R_i proxy: shrinks tightly in creases/corners, grows wide on open walls
float harmonicRadius(vec3 p, vec3 n) {
float h1 = max(mapScene(p + n * 0.16).x, 0.02);
float h2 = max(mapScene(p + n * 0.42).x, 0.04);
float crease = clamp((h1 / 0.16) * 0.55 + (h2 / 0.42) * 0.45, 0.18, 1.0);
return 0.10 + 0.26 * crease;
}
vec3 evalIndirect(vec3 p, vec3 n) {
float wL = clamp(1.0 - (p.x + 1.28) * 0.52, 0.0, 1.0);
float wR = clamp(1.0 - (1.28 - p.x) * 0.52, 0.0, 1.0);
vec3 warm = vec3(0.95, 0.36, 0.14) * wL * (0.45 + 0.55 * max(dot(n, vec3(1.0, 0.0, 0.0)), 0.0));
vec3 cool = vec3(0.16, 0.74, 0.88) * wR * (0.45 + 0.55 * max(dot(n, vec3(-1.0, 0.0, 0.0)), 0.0));
vec3 sky = vec3(0.32, 0.34, 0.38) * (0.45 + 0.55 * max(n.y, 0.0));
float ao = clamp(0.38 + 0.62 * mapScene(p + n * 0.25).x / 0.25, 0.18, 1.0);
return (warm * 0.58 + cool * 0.58 + sky * 0.48) * ao;
}
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);
bool isSmooth = screenX >= split;
float errTol = clamp(P_ERROR_TOL, 0.18, 1.25);
float cacheVis = clamp(P_CACHE_VIS, 0.0, 1.5);
float giGain = clamp(P_GI_GAIN, 0.2, 2.4);
vec3 ro = vec3(0.0, 0.02, 2.34);
vec3 rd = normalize(vec3(uv, -1.50));
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 > 9.0) break;
}
if (hit) {
vec3 p = ro + rd * t;
vec3 n = calcNormal(p);
vec3 alb = vec3(0.78, 0.78, 0.80);
if (matId > 1.5 && matId < 2.5) alb = vec3(0.92, 0.34, 0.16);
if (matId > 2.5 && matId < 3.5) alb = vec3(0.14, 0.72, 0.84);
vec3 lPos = vec3(0.18 * sin(iTime * 0.65), 0.94, -0.25);
vec3 lDir = normalize(lPos - p);
float direct = max(dot(n, lDir), 0.0) * 0.58;
vec3 smoothGI = evalIndirect(p, n) * giGain;
// Adaptive spatial hash placing Ward irradiance cache samples denser near creases (small R_i)
float rHarm = harmonicRadius(p, n) * (0.55 + 0.85 * errTol);
float cellSz = max(rHarm * 0.92, 0.08);
vec3 cid = floor(p / cellSz);
float minDist = 1e5;
float ringVis = 0.0;
vec3 nearestIrr = smoothGI;
float nearestRad = rHarm;
// Search 3x3x3 neighborhood of 3D cache cells to find nearest surface records & Ward weights
vec3 wIrr = vec3(0.0);
float wSum = 0.0;
for (int dz = -1; dz <= 1; dz++) {
for (int dy = -1; dy <= 1; dy++) {
for (int dx = -1; dx <= 1; dx++) {
vec3 nb = cid + vec3(float(dx), float(dy), float(dz));
vec3 rnd = hash33(nb);
vec3 cPos = (nb + 0.15 + 0.70 * rnd) * cellSz;
// Project record onto tangent plane of p so it sits on the surface
vec3 cSurf = cPos - n * dot(cPos - p, n);
float d = length(p - cSurf);
float rValid = cellSz * 0.72;
if (d < minDist) {
minDist = d;
nearestIrr = evalIndirect(cSurf, n) * giGain;
nearestRad = rValid;
}
// Ward weighting function w_i(p) = 1 / (d / R_i + sqrt(1 - n.n_i)) - 1/a
float w = max(1.0 / (d / max(rValid, 0.04) + 0.15) - 1.0 / (1.0 + errTol * 2.2), 0.0);
wIrr += evalIndirect(cSurf, n) * giGain * w;
wSum += w;
ringVis = max(ringVis, smoothstep(0.012, 0.003, abs(d - rValid * 0.65)));
}
}
}
vec3 interpGI = (wSum > 1e-4) ? (wIrr / wSum) : smoothGI;
vec3 finalGI = mix(nearestIrr, interpGI, isSmooth ? 0.92 : 0.35);
col = alb * (direct + finalGI);
if (!isSmooth) {
// Left: visualize cache sample centers (bright gold dots) & validity circles (cyan)
float dotMask = smoothstep(0.024, 0.011, minDist);
col = mix(col, vec3(0.22, 0.92, 1.0), ringVis * 0.42 * min(cacheVis, 1.2));
col = mix(col, vec3(1.0, 0.88, 0.32), dotMask * 0.92 * min(cacheVis, 1.2));
}
}
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: MIT — written for this index.
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| irradiance-caching-live | Tesla T4 1920x1080 | 89.1× baseline (extreme) · 2.76 ms / 2.90 ms | opengl-timer-query · 36 frames · GPU Weight Atlas · Colab T4 sweep |
| irradiance-caching-live | NVIDIA L4 1920x1080 | 80.7× baseline (extreme) · 1.28 ms / 1.29 ms · 2.1× faster on L4 | opengl-timer-query · Cross-architecture validation |
| irradiance-caching-live | NVIDIA A100-SXM4-40GB 1920x1080 | 61.3× baseline (extreme) · 1.77 ms / 1.77 ms · 1.6× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): its primary source cites Cook-Torrance microfacet BRDF; cited by Neural Radiance Caching, Precomputed Radiance Transfer.
Crosses
- Owen-scrambled Sobol hemisphere sampling for blotch-free irradiance caches: Replacing stratified jittered hemisphere grids in Ward-style irradiance caching with hash-based Owen-scrambled Sobol sequences cuts per-cache-point ray counts by 2-4x while eliminating correlated low-frequency GI blotches.
- Photon Mapping: Final gathering at cache points uses photon-map irradiance rather than tracing every ray.
Sources
- primaryGregory J. Ward, Francis M. Rubinstein, Robert D. Clear (1988). A ray tracing solution for diffuse interreflection. Proceedings of the 15th annual conference on Computer graphics and interactive techniques.Verified via crossref · 2026-11-29doi:10.1145/54852.378490