---
id: "precomputed-radiance-transfer"
title: "Precomputed Radiance Transfer"
aliases: [PRT, SH PRT]
domain: "gi"
stage: "lighting"
realtime: "realtime"
platforms: [desktop-gpu, webgl2, mobile-gpu]
year_introduced: 2002
inputs: [mesh, hdr-image]
outputs: [radiance]
style: "photoreal"
dynamic: "both"
cost: "cheap"
authority: "Sloan et al., 2002"
url: "https://texelatlas.vercel.app/t/precomputed-radiance-transfer/"
sources_verified_at: "2026-11-29"
---
# Precomputed Radiance Transfer (Sloan et al., 2002)

> 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.

## 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

## 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-harmonics-lighting](spherical-harmonics-lighting)) 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 use it

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](irradiance-volumes) when the object deforms or moves around a baked scene, since PRT is per-object. Prefer [wavelet-all-frequency-relighting](wavelet-all-frequency-relighting) when sharp shadows from high-frequency environments are needed. Prefer [lightmap-baking](lightmap-baking) when the lighting is fixed and you want per-texel detail.

## Cost

cheap — Runtime is a dot product of 9 to 25 coefficients per vertex; offline precomputation is heavy.
Measured GPU Weight: 38.47× baseline (heavy) — 1.2655 ms median / 1.3318 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 33.05× baseline (heavy) — 0.5255 ms median (2.41× faster on L4).
Ampere A100 scaling: 24.31× baseline (heavy) — 0.7001 ms median (1.81× faster on A100).

## Failure modes

- 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

## Dataflow

- Inputs: mesh, hdr-image
- Outputs: radiance
- Platforms: desktop-gpu, webgl2, mobile-gpu

## Presets

### Precomputed Radiance Transfer — 9-band SH environment lighting with self-shadowed bounce (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_ENV_ROTATION": 1,
  "P_SH_ORDER": 2,
  "P_SELF_SHADOW": 0.88,
  "P_BOUNCE_GAIN": 0.68
}
```

```glsl
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).

## Lineage

- extended by [All-Frequency Shadows via Wavelet Lighting](https://texelatlas.vercel.app/t/wavelet-all-frequency-relighting.md)

## Combines with

- [Spherical-Harmonic Lighting (Irradiance Environment Maps)](https://texelatlas.vercel.app/t/spherical-harmonics-lighting.md): The environment is projected to SH each frame and dotted with per-vertex transfer coefficients.

## Combination ideas

- [Day-cycle relighting for a dot product](https://texelatlas.vercel.app/ideas/time-of-day-prt/)

## Sources

1. [primary] Peter-Pike Sloan, Jan Kautz, John Snyder (2002) Precomputed radiance transfer for real-time rendering in dynamic, low-frequency lighting environments. ACM Transactions on Graphics. https://doi.org/10.1145/566654.566612 (verified via crossref on 2026-11-29)

## Cite this entry

Texel. "Precomputed Radiance Transfer." https://texelatlas.vercel.app/t/precomputed-radiance-transfer/ (accessed 2026-12-01).
