Precomputed Radiance Transfer
Precomputes, per vertex or texel, how incoming low-frequency light maps to outgoing radiance including self-shadowing and interreflection, so relighting a rigid object under a changing environment is a dot product.
Also known as PRT, SH PRT
In the family Light transport & global illumination, low-frequency lighting
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 | |
| Unreal 5.7 | None found | |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
For a rigid object, how light at a point depends on the environment is linear. If the lighting is expressed in a basis (spherical harmonics), then outgoing radiance is a transfer vector dotted with the lighting coefficient vector. The transfer vector captures everything that depends only on geometry and material: visibility (self-shadowing), cosine falloff, and with extra bounces, interreflection.
In the offline stage, for each vertex or texel, you cast many rays and project the visibility times cosine onto SH, producing n^2 coefficients (25 for order 4). For glossy materials the transfer is a matrix that maps lighting coefficients to coefficients of the exiting radiance, which is then evaluated for the view direction.
At runtime you project the current environment to SH (cheaply, even per frame, using Spherical-Harmonic Lighting (Irradiance Environment Maps)) and then compute a dot product per vertex (or per pixel with the coefficients in textures). Rotation of the light is a coefficient rotation, so it supports dynamic environments, but not moving geometry, which would invalidate the precomputed transfer.
When to choose it
Reach for it when
- rigid object must relight under changing sky
- want soft self-shadowed diffuse lighting cheaply
- time-of-day lighting on a static model
- need baked self-shadowing that responds to environment
Choose it for hero rigid objects or static scenes lit by changing low-frequency lighting (sky, time of day), where self-shadowed soft diffuse lighting is wanted.
Prefer Irradiance Volumes and Light Probes when the object deforms or moves around a baked scene, since PRT is per-object. Prefer All-Frequency Shadows via Wavelet Lighting when sharp shadows from high-frequency environments are needed. Prefer Lightmap Baking when the lighting is fixed and you want per-texel detail.
Field marks
- Low-order SH cannot represent sharp shadows or glossy highlights, so shadows look soft and generic
- Rigid geometry only: skinned meshes or moving occluders require recomputation
- Large storage for glossy transfer matrices (n^2 by n^2 per sample point)
- Ringing and negative values in the reconstructed radiance for strongly directional environments
Presets
Precomputed Radiance Transfer — 9-band SH environment lighting with self-shadowed bounce
{
"P_ENV_ROTATION": 1,
"P_SH_ORDER": 2,
"P_SELF_SHADOW": 0.88,
"P_BOUNCE_GAIN": 0.68
}Show GLSL (147 lines)
const float P_ENV_ROTATION = 1.0; // P Env Spin [0.0, 2.5, 0.05]
const float P_SH_ORDER = 2.0; // P SH Band Order [0.0, 2.0, 1.0]
const float P_SELF_SHADOW = 0.88; // P Self-Shadow [0.0, 1.4, 0.04]
const float P_BOUNCE_GAIN = 0.68; // P Interreflection [0.0, 1.5, 0.04]
mat2 rot2(float a) { float c = cos(a), s = sin(a); return mat2(c, -s, s, c); }
// Sculpted concave/grooved architectural orb to showcase PRT self-shadowing & interreflection
float mapSculpt(vec3 p) {
float dSphere = length(p) - 0.82;
// Carve three orthogonal concave bowl cavities and equatorial flute grooves
float c1 = length(p - vec3(0.68, 0.22, 0.52)) - 0.42;
float c2 = length(p - vec3(-0.62, 0.32, 0.48)) - 0.38;
float c3 = length(p - vec3(0.05, -0.58, 0.58)) - 0.38;
float d = max(dSphere, -c1);
d = max(d, -c2);
d = max(d, -c3);
// Subtle sculpted relief rings
float ring = 0.028 * sin(p.y * 18.0 + atan(p.z, p.x) * 4.0);
d += ring * smoothstep(0.2, 0.75, length(p.xz));
return d * 0.78;
}
vec3 calcNormal(vec3 p) {
vec2 e = vec2(0.0025, 0.0);
return normalize(vec3(
mapSculpt(p + e.xyy) - mapSculpt(p - e.xyy),
mapSculpt(p + e.yxy) - mapSculpt(p - e.yxy),
mapSculpt(p + e.yyx) - mapSculpt(p - e.yyx)
));
}
// Analytical rotating 3-band (L=0,1,2) Spherical Harmonics environment radiance
vec3 evalSHEnv(vec3 d, float rotAng, float order) {
vec3 dir = d;
dir.xz = rot2(rotAng) * dir.xz;
// Band 0 (DC ambient)
vec3 L00 = vec3(0.42, 0.45, 0.54);
vec3 irr = L00 * 0.8862;
if (order >= 0.5) {
// Band 1 (directional warm sun-sky dipole + cool cyan fill)
vec3 L1m1 = vec3(0.24, 0.30, 0.46); // y
vec3 L10 = vec3(0.45, 0.36, 0.24); // z
vec3 L1p1 = vec3(0.88, 0.48, 0.18); // x
irr += 1.0233 * (L1m1 * dir.y + L10 * dir.z + L1p1 * dir.x);
}
if (order >= 1.5) {
// Band 2 (quadrupole crisp golden key lobe + indigo-magenta rim)
vec3 L2m2 = vec3(0.32, 0.16, 0.28);
vec3 L2m1 = vec3(0.28, 0.34, 0.48);
vec3 L20 = vec3(0.38, 0.24, 0.14);
vec3 L2p1 = vec3(0.68, 0.42, 0.16);
vec3 L2p2 = vec3(0.46, 0.26, 0.34);
irr += 0.4954 * (
L2m2 * (dir.x * dir.y) +
L2m1 * (dir.y * dir.z) +
L20 * (3.0 * dir.z * dir.z - 1.0) * 0.33 +
L2p1 * (dir.x * dir.z) +
L2p2 * (dir.x * dir.x - dir.y * dir.y) * 0.5
);
}
return max(irr, vec3(0.02));
}
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 rotAng = iTime * 0.75 * max(P_ENV_ROTATION, 0.0);
float shOrder = clamp(P_SH_ORDER, 0.0, 2.0);
float ssWeight = clamp(P_SELF_SHADOW, 0.0, 1.5);
float bounceW = clamp(P_BOUNCE_GAIN, 0.0, 1.6);
vec3 ro = vec3(0.0, 0.08, 2.55);
vec3 rd = normalize(vec3(uv, -1.55));
// Background shows the rotated low-frequency SH environment directly
vec3 col = evalSHEnv(rd, rotAng, shOrder) * 0.55;
float t = 0.0;
bool hit = false;
for (int i = 0; i < 64; i++) {
float d = mapSculpt(ro + rd * t);
if (d < 0.002) { hit = true; break; }
t += d;
if (t > 8.0) break;
}
if (hit) {
vec3 p = ro + rd * t;
vec3 n = calcNormal(p);
// Estimate precomputed hemispherical visibility + bent normal (PRT transfer vector T_i)
vec3 bentDir = n * 0.35;
float visSum = 0.0;
vec3 tangent = normalize(abs(n.y) < 0.9 ? cross(n, vec3(0.0, 1.0, 0.0)) : cross(n, vec3(1.0, 0.0, 0.0)));
vec3 bitan = cross(n, tangent);
for (int k = 0; k < 6; k++) {
float fk = float(k);
float phi = fk * 1.0472 + 0.4;
vec3 sDir = normalize(n * 0.62 + (cos(phi) * tangent + sin(phi) * bitan) * 0.78);
float d1 = mapSculpt(p + sDir * 0.14);
float d2 = mapSculpt(p + sDir * 0.34);
float vSample = clamp(min(d1 / 0.14, d2 / 0.34), 0.0, 1.0);
visSum += vSample;
bentDir += sDir * vSample;
}
float visibility = mix(1.0, clamp(visSum / 6.0, 0.05, 1.0), ssWeight);
vec3 bentN = normalize(mix(n, normalize(bentDir + 1e-4), 0.65 * ssWeight));
// Diffuse PRT transfer dot product: irradiance along visibility-weighted bent normal
vec3 directSH = evalSHEnv(bentN, rotAng, shOrder) * visibility;
// Second-bounce interreflection inside cavities (warm terracotta-ochre bounce)
vec3 albedo = mix(vec3(0.84, 0.78, 0.72), vec3(0.86, 0.52, 0.34), smoothstep(0.75, 0.42, length(p)));
vec3 bounceSH = evalSHEnv(-n, rotAng, shOrder) * (1.0 - visibility) * albedo * albedo * bounceW * 1.35;
// Subtle specular SH sheen
vec3 rDir = reflect(rd, n);
float fres = 0.04 + 0.96 * pow(1.0 - max(dot(n, -rd), 0.0), 5.0);
vec3 specSH = evalSHEnv(rDir, rotAng, shOrder) * fres * visibility * 0.55;
col = albedo * directSH + bounceSH + specSH;
}
// Bottom-right SH light-probe inset sphere showing the active SH basis radiance
vec2 probeC = vec2(0.35, -0.34);
vec2 pd = uv - probeC;
float pr = 0.11;
float r2 = dot(pd, pd);
if (r2 < pr * pr) {
vec3 pn = normalize(vec3(pd, sqrt(max(pr * pr - r2, 0.0))));
col = evalSHEnv(pn, rotAng, shOrder);
} else if (abs(length(pd) - pr) < 0.004) {
col = vec3(0.92, 0.94, 0.98);
}
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 |
|---|---|---|---|
| precomputed-radiance-transfer-live | Tesla T4 1920x1080 | 38.5× baseline (heavy) · 1.27 ms / 1.33 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| precomputed-radiance-transfer-live | NVIDIA L4 1920x1080 | 33.0× baseline (heavy) · 0.525 ms / 0.531 ms · 2.4× faster on L4 | opengl-timer-query · Cross-architecture validation |
| precomputed-radiance-transfer-live | NVIDIA A100-SXM4-40GB 1920x1080 | 24.3× baseline (heavy) · 0.700 ms / 0.703 ms · 1.8× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): its primary source cites Light Stage Reflectance Capture, Environment mapping, cubemaps and skyboxes, Unidirectional Path Tracing, Instant Radiosity (Virtual Point Lights), Deep shadow maps, Spherical-Harmonic Lighting (Irradiance Environment Maps), Irradiance Caching, Shadow Mapping; cited by Least-Squares Vertex Light Baking, Light Propagation Volumes, Reflective Shadow Maps.
Crosses
- Day-cycle relighting for a dot product: Static buildings and props relit through a full day with soft self-shadowing and interreflection, without rebakes. An analytic sky gives a fresh environment whenever the sun moves; it is projected to spherical harmonics and dotted with baked transfer.
- Spherical-Harmonic Lighting (Irradiance Environment Maps): The environment is projected to SH each frame and dotted with per-vertex transfer coefficients.
Sources
- primaryPeter-Pike Sloan, Jan Kautz, John Snyder (2002). Precomputed radiance transfer for real-time rendering in dynamic, low-frequency lighting environments. ACM Transactions on Graphics.Verified via crossref · 2026-11-29doi:10.1145/566654.566612