Radiosity (Hemicube Form Factors)
Divides surfaces into patches and solves a linear system for diffuse light exchange using form factors. View-independent; the solution can be stored in vertex colors or lightmaps.
Also known as classical radiosity, finite-element GI
In the family Light transport & global illumination, finite element 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 | |
| Unity | Built in | Lighting > Realtime Lighting > Realtime Global Illumination (Enlighten partitions scenes into surface patches/clusters with precomputed visibility) docs |
| Unreal 5.7 | None found | |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
Radiosity assumes every surface is a perfect diffuser, so the light leaving a patch does not depend on the viewer. Each patch i has a radiosity B_i equal to its emission plus its reflectance times the light arriving from every other patch, sum_j F_ij B_j. F_ij are form factors: the fraction of light leaving i that lands directly on j. That is a linear system B = E + R F B.
Form factors come from geometry. The hemicube method places a half cube on patch i, renders the scene onto its five faces with each patch painted its own ID, and sums per-pixel weights (delta form factors) for each ID, using the GPU's visibility sorting. Solving the system by Gauss-Seidel, or by progressive refinement (repeatedly "shooting" the patch with the most unshot energy), gives a usable image after a few iterations.
The mesh is typically adaptively subdivided where radiosity changes quickly, such as at shadow boundaries. The result is stored per vertex or per lightmap texel, and any camera can render it with ordinary Gouraud or texture mapping.
When to choose it
Reach for it when
- diffuse interiors look flat with direct light only
- need soft color bleeding between walls
- precompute view independent lighting for architecture
- smooth light bounce in static room scenes
Choose it for a quick, conceptually simple baker of diffuse-only static lighting, and for teaching: it is the origin of lightmaps and precomputed GI.
Prefer Lightmap Baking with Unidirectional Path Tracing as the integrator for production, since it handles non-diffuse materials and complex lights. Prefer Instant Radiosity (Virtual Point Lights) when you want a GPU-friendly approximation with light-path sampling. Prefer Photon Mapping when glossy and caustic transport matter.
Field marks
- Diffuse-only: no specular, glossy or caustic transport
- Visible mesh artifacts (blocky shading, light leaks at patch edges) when the patch mesh is too coarse relative to lighting detail
- Hemicube aliasing and missed small patches because of pixel resolution
- Memory and time grow quickly with patch count, motivating hierarchical radiosity
Presets
Radiosity (Hemicube Form Factors) — 0-bounce direct (left) vs patch-to-patch diffuse radiosity (right)
{
"P_PATCH_RES": 7,
"P_BOUNCE_GAIN": 1.25,
"P_PATCH_GRID": 0.75,
"P_SPLIT": 0.48
}Show GLSL (143 lines)
const float P_PATCH_RES = 7.0; // P Patch Subdiv [3.0, 14.0, 1.0]
const float P_BOUNCE_GAIN = 1.25; // P Multi-Bounce [0.2, 2.2, 0.05]
const float P_PATCH_GRID = 0.75; // P Patch Outlines [0.0, 1.5, 0.05]
const float P_SPLIT = 0.48; // P Direct / Radiosity [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);
}
// Classic Cornell box scene with tall + short diffuse boxes
vec2 mapScene(vec3 p) {
vec2 res = vec2(p.y + 1.0, 1.0); // floor
float dC = 1.0 - p.y; if (dC < res.x) res = vec2(dC, 1.0);
float dB = p.z + 1.4; if (dB < res.x) res = vec2(dB, 1.0);
float dL = p.x + 1.25; if (dL < res.x) res = vec2(dL, 2.0); // red wall
float dR = 1.25 - p.x; if (dR < res.x) res = vec2(dR, 3.0); // green-cyan wall
float dTall = sdBox(p - vec3(-0.38, -0.44, -0.45), vec3(0.32, 0.56, 0.32));
if (dTall < res.x) res = vec2(dTall, 4.0);
float dShort = sdBox(p - vec3(0.42, -0.68, -0.05), vec3(0.30, 0.32, 0.30));
if (dShort < res.x) res = vec2(dShort, 4.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
));
}
// Analytical diffuse form factor F_ij = cos(theta_i)*cos(theta_j) / (pi * r^2 + A_j)
float formFactor(vec3 pi, vec3 ni, vec3 pj, vec3 nj, float areaJ) {
vec3 v = pj - pi;
float r2 = dot(v, v);
float r = sqrt(max(r2, 1e-5));
vec3 dir = v / r;
float ci = max(dot(ni, dir), 0.0);
float cj = max(dot(nj, -dir), 0.0);
return (ci * cj * areaJ) / (3.1415926 * r2 + areaJ + 0.15);
}
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 isRad = screenX >= split;
float patchN = clamp(floor(P_PATCH_RES + 0.5), 3.0, 14.0);
float bGain = clamp(P_BOUNCE_GAIN, 0.1, 2.4);
float gridVis = clamp(P_PATCH_GRID, 0.0, 1.5);
vec3 ro = vec3(0.0, 0.02, 2.35);
vec3 rd = normalize(vec3(uv, -1.52));
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);
// Quantize surface position to discrete radiosity patch centers on the right (classic piecewise-constant patches)
float patchStep = 2.0 / patchN;
vec3 pPatch = (floor(p / patchStep) + 0.5) * patchStep;
// Keep patch center on the actual surface along normal axis
vec3 evalP = isRad ? mix(p, pPatch, 0.55) : p;
vec3 alb = vec3(0.78, 0.76, 0.72);
if (matId > 1.5 && matId < 2.5) alb = vec3(0.86, 0.18, 0.15);
if (matId > 2.5 && matId < 3.5) alb = vec3(0.14, 0.72, 0.58);
// Ceiling patch emitter
vec3 emitP = vec3(0.0, 0.99, -0.35);
if (p.y > 0.98 && abs(p.x) < 0.36 && abs(p.z + 0.35) < 0.32) {
col = vec3(3.4, 3.1, 2.6);
} else {
// Direct emitter form factor F(patch -> ceiling light)
float fLight = formFactor(evalP, n, emitP, vec3(0.0, -1.0, 0.0), 0.72);
// Soft geometric visibility test toward ceiling patch
vec3 toL = normalize(emitP - p);
float vis = 1.0;
float tSh = 0.04;
for (int s = 0; s < 16; s++) {
float ds = mapScene(p + toL * tSh).x;
if (ds < 0.004) { vis = 0.08; break; }
tSh += max(ds, 0.04);
if (tSh > length(emitP - p) - 0.08) break;
}
vec3 direct = alb * vec3(2.8, 2.55, 2.15) * fLight * vis;
if (!isRad) {
// Left: direct illumination only (black shadows, zero color bleeding)
col = direct + alb * vec3(0.03);
} else {
// Right: 2-bounce patch-to-patch form-factor exchange from all 5 surrounding walls
vec3 bounce = vec3(0.0);
// Sample 3 patches on left red wall
for (int k = 0; k < 3; k++) {
float yk = -0.55 + float(k) * 0.55;
float fL = formFactor(evalP, n, vec3(-1.24, yk, -0.35), vec3(1.0, 0.0, 0.0), 0.95);
bounce += vec3(0.86, 0.18, 0.15) * fL * 1.15;
float fR = formFactor(evalP, n, vec3(1.24, yk, -0.35), vec3(-1.0, 0.0, 0.0), 0.95);
bounce += vec3(0.14, 0.72, 0.58) * fR * 1.15;
}
// Floor & back wall neutral bounce
bounce += vec3(0.76, 0.74, 0.68) * formFactor(evalP, n, vec3(0.0, -0.99, -0.35), vec3(0.0, 1.0, 0.0), 2.2) * 0.75;
bounce += vec3(0.74, 0.72, 0.68) * formFactor(evalP, n, vec3(0.0, 0.0, -1.39), vec3(0.0, 0.0, 1.0), 2.0) * 0.62;
// Ambient occlusion darkening inside corners for realistic patch shadowing
float ao = clamp(0.45 + 0.55 * mapScene(p + n * 0.24).x / 0.24, 0.22, 1.0);
col = direct + alb * (bounce * bGain * ao + vec3(0.08, 0.075, 0.07));
// Patch mesh grid overlay showing discrete radiosity elements
vec3 pf = abs(fract(p / patchStep - 0.5) - 0.5);
vec3 an = abs(n);
float dEdge = (an.x > an.y && an.x > an.z) ? min(pf.y, pf.z) : ((an.y > an.z) ? min(pf.x, pf.z) : min(pf.x, pf.y));
float wire = smoothstep(0.045, 0.010, dEdge);
col = mix(col, col * 0.42 + vec3(0.04, 0.06, 0.09), wire * 0.45 * min(gridVis, 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 |
|---|---|---|---|
| radiosity-live | Tesla T4 1920x1080 | 26.3× baseline (heavy) · 0.815 ms / 0.854 ms | opengl-timer-query · 36 frames · GPU Weight Atlas · Colab T4 sweep |
| radiosity-live | NVIDIA L4 1920x1080 | 27.2× baseline (heavy) · 0.432 ms / 0.436 ms · 1.9× faster on L4 | opengl-timer-query · Cross-architecture validation |
| radiosity-live | NVIDIA A100-SXM4-40GB 1920x1080 | 16.0× baseline (moderate) · 0.460 ms / 0.462 ms · 1.8× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): cited by Unidirectional Path Tracing.
Crosses
- Progressive radiosity relighting on PatchMatch multi-view stereo rooms: Dense depth and normal maps recovered by PatchMatch MVS are clustered into planar architectural patches whose diffuse inter-reflection is solved by progressive radiosity, turning multi-view room photos into interactively relit global-illumination spaces.
- Lightmap Baking: Radiosity solutions are written into lightmap texels that the real-time shader samples.
Sources
- primaryCindy M. Goral, Kenneth E. Torrance, Donald P. Greenberg, Bennett Battaile (1984). Modeling the interaction of light between diffuse surfaces. ACM SIGGRAPH Computer Graphics.Verified via crossref · 2026-11-29doi:10.1145/964965.808601
- primaryMichael F. Cohen, Donald P. Greenberg (1985). The hemi-cube. Proceedings of the 12th annual conference on Computer graphics and interactive techniques - SIGGRAPH '85.Verified via crossref · 2026-11-29doi:10.1145/325334.325171