---
id: "light-bvh-many-lights"
title: "Light BVH and Adaptive Tree Splitting"
aliases: [light tree, many-light importance sampling]
domain: "gi"
stage: "lighting"
realtime: "offline"
platforms: [cpu, cuda]
year_introduced: 2018
inputs: [mesh, material-params]
outputs: [radiance]
style: "photoreal"
dynamic: "both"
cost: "offline"
authority: "Estevez & Kulla, 2018"
url: "https://texelatlas.vercel.app/t/light-bvh-many-lights/"
sources_verified_at: "2026-11-29"
---
# Light BVH and Adaptive Tree Splitting (Estevez & Kulla, 2018)

> Organizes emitters into a bounding-volume hierarchy with per-node energy and orientation bounds, then samples a light by descending the tree with probabilities proportional to estimated contribution at the shading point.

## Reach for it when

- path tracer is slow with thousands of emissive triangles
- scene with many lights is noisy
- which light to sample when there are too many
- emissive meshes make rendering cost explode
- choose lights by their likely contribution

## How it works

Choosing a light uniformly is hopeless with tens of thousands of emitters, and power-based choice ignores distance. A **light BVH** is built over the emitters. Each node stores total power, a spatial bound and an orientation cone bound for one-sided emitters.

To sample a light for a shading point `x`, you walk from the root. At each node you compute an **importance** for each child using conservative bounds: power times the geometric term from the minimum distance to the bound and the cone angle factors relative to the surface normal. You choose a child with probability proportional to its importance and continue down to a leaf, accumulating the pdf along the way. The pdf for MIS is computed from the same walk.

**Adaptive tree splitting** (Conty and Kulla) takes several samples per shading point and, when a node has similar importance in all children and the samples-per-node budget allows, splits the samples among both children instead of picking one. Near the tree top this stratifies samples and noticeably lowers variance.

## When to use it

Choose it for offline or interactive path tracers with many emissive triangles, light-emitting meshes, or large sets of point lights, as the sampling backbone with next-event estimation.

Prefer [lightcuts](lightcuts) when you want error-bounded deterministic clustering instead of stochastic sampling. Prefer [restir-di](restir-di) for real-time budgets with dynamic lights. Prefer plain power sampling with [multiple-importance-sampling](multiple-importance-sampling) when you have a few lights.

## Cost

offline — Tree traversal costs a few dozen node evaluations per light sample; build cost is small and rebuilds are fast for animation.
Measured GPU Weight: 87.27× baseline (extreme) — 2.8712 ms median / 3.0247 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 93.33× baseline (extreme) — 1.484 ms median (1.93× faster on L4).
Ampere A100 scaling: 59.73× baseline (heavy) — 1.7203 ms median (1.67× faster on A100).

## Failure modes

- Bounds are conservative, so importance for nearby shading points inside a cluster is poor and noise remains
- Needs special handling for lights on both sides of the surface plane or very large emitters
- Importance ignores visibility, so heavily occluded lights are over-sampled
- Orientation cones are weak for omnidirectional and spherical lights

## Engine support

- blender: builtin — `Properties > Render > Sampling > Lights > Light Tree` (evidence: https://docs.blender.org/manual/en/5.2/render/cycles/render_settings/sampling.html, checked 2026-12-01)
- unreal: builtin — `Project Settings > Rendering > MegaLights (stochastic direct-lighting importance sampling across many dynamic area lights)` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/megalights-in-unreal-engine, checked 2026-12-01)

## Dataflow

- Inputs: mesh, material-params
- Outputs: radiance
- Platforms: cpu, cuda

## Presets

### Light BVH Many-Light Sampling — noisy uniform light picking (left) vs energy-cone BVH importance sampling (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_LIGHT_COUNT": 24,
  "P_CONE_SHARP": 1.1,
  "P_ANIM_SPEED": 0.45,
  "P_SPLIT": 0.48
}
```

```glsl
const float P_LIGHT_COUNT = 24.0; // P Emitter Count [8.0, 32.0, 4.0]
const float P_CONE_SHARP = 1.10; // P Orientation Bound [0.2, 2.0, 0.1]
const float P_ANIM_SPEED = 0.45; // P Cluster Drift [0.0, 1.5, 0.05]
const float P_SPLIT = 0.48; // P Uniform / BVH Split [0.0, 1.0, 0.02]

float hash21(vec2 p) {
  p = fract(p * vec2(127.1, 311.7));
  p += dot(p, p + 34.5);
  return fract(p.x * p.y);
}

// 32 procedural point emitters organized in 4 spatial BVH clusters (amber, cyan, magenta, emerald)
void getLight(int idx, float t, out vec3 pos, out vec3 col) {
  int cl = idx / 8;
  float fi = float(idx - cl * 8);
  float ang = fi * 0.785398 + t * (0.4 + 0.15 * float(cl));
  vec3 cPos;
  if (cl == 0) { cPos = vec3(-1.15, 0.25, -0.35); col = vec3(2.4, 1.15, 0.35); }
  else if (cl == 1) { cPos = vec3(-0.32, 0.42, -0.95); col = vec3(0.28, 1.85, 2.35); }
  else if (cl == 2) { cPos = vec3(0.58, 0.22, -0.25); col = vec3(2.25, 0.38, 1.45); }
  else { cPos = vec3(1.18, 0.48, -0.95); col = vec3(0.45, 2.15, 0.85); }
  pos = cPos + vec3(cos(ang) * 0.36, 0.16 * sin(ang * 2.0), sin(ang) * 0.36);
}

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 mapHall(vec3 p) {
  float dFloor = p.y + 0.58;
  float dBack = p.z + 1.85;
  vec2 res = vec2(dFloor, 1.0);
  if (dBack < res.x) res = vec2(dBack, 2.0);
  float dB1 = sdBox(p - vec3(-0.68, -0.22, -0.62), vec3(0.22, 0.36, 0.22));
  if (dB1 < res.x) res = vec2(dB1, 3.0);
  float dB2 = length(p - vec3(0.16, -0.28, -0.45)) - 0.30;
  if (dB2 < res.x) res = vec2(dB2, 3.0);
  float dB3 = sdBox(p - vec3(0.88, -0.18, -0.78), vec3(0.20, 0.40, 0.20));
  if (dB3 < res.x) res = vec2(dB3, 3.0);
  return res;
}

vec3 calcNormal(vec3 p) {
  vec2 e = vec2(0.0025, 0.0);
  return normalize(vec3(
    mapHall(p + e.xyy).x - mapHall(p - e.xyy).x,
    mapHall(p + e.yxy).x - mapHall(p - e.yxy).x,
    mapHall(p + e.yyx).x - mapHall(p - e.yyx).x
  ));
}

float evalShadow(vec3 p, vec3 lPos) {
  vec3 d = lPos - p;
  float dist = length(d);
  vec3 dir = d / max(dist, 1e-4);
  float t = 0.04;
  for (int i = 0; i < 14; i++) {
    float h = mapHall(p + dir * t).x;
    if (h < 0.004) return 0.0;
    t += max(h, 0.04);
    if (t >= dist - 0.05) break;
  }
  return 1.0;
}

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 sx = fragCoord.x / max(iResolution.x, 1.0);
  float split = clamp(P_SPLIT, 0.0, 1.0);
  bool useBVH = sx >= split;

  int nLights = int(clamp(floor(P_LIGHT_COUNT + 0.5), 8.0, 32.0));
  float coneK = clamp(P_CONE_SHARP, 0.2, 2.5);
  float anim = iTime * max(P_ANIM_SPEED, 0.0);

  vec3 ro = vec3(0.0, 0.42, 2.08);
  vec3 rd = normalize(vec3(uv.x, uv.y - 0.16, -1.35));
  vec3 col = vec3(0.025, 0.03, 0.045);

  float t = 0.05;
  float hitId = 0.0;
  for (int i = 0; i < 64; i++) {
    vec2 h = mapHall(ro + rd * t);
    if (h.x < 0.002) { hitId = h.y; break; }
    t += h.x;
    if (t > 9.0) break;
  }

  if (hitId > 0.5) {
    vec3 p = ro + rd * t;
    vec3 n = calcNormal(p);
    vec3 alb = (hitId < 1.5) ? vec3(0.56, 0.57, 0.60) : ((hitId < 2.5) ? vec3(0.45, 0.48, 0.52) : vec3(0.76, 0.76, 0.78));

    // Cluster bounding centers for 2-level Light BVH importance traversal
    vec3 clCent[4];
    clCent[0] = vec3(-1.15, 0.25, -0.35);
    clCent[1] = vec3(-0.32, 0.42, -0.95);
    clCent[2] = vec3(0.58, 0.22, -0.25);
    clCent[3] = vec3(1.18, 0.48, -0.95);

    int activeClusters = max(nLights / 8, 1);
    float cw[4];
    float sumW = 0.0;
    for (int c = 0; c < 4; c++) {
      if (c >= activeClusters) { cw[c] = 0.0; continue; }
      vec3 toC = clCent[c] - p;
      float d2 = max(dot(toC, toC), 0.18);
      float cosBound = pow(max(dot(n, normalize(toC)) + 0.35, 0.05), coneK);
      cw[c] = cosBound / d2;
      sumW += cw[c];
    }

    vec3 acc = vec3(0.0);
    float frameJit = floor(iTime * 10.0) * 0.13;
    const int SAMPLES = 4;

    for (int s = 0; s < SAMPLES; s++) {
      float u1 = hash21(fragCoord + vec2(float(s) * 19.3, frameJit * 13.7));
      float u2 = hash21(fragCoord * 1.19 + vec2(frameJit * 7.1, float(s) * 31.1));
      int chosenIdx = 0;
      float pdf = 1.0 / float(nLights);

      if (!useBVH) {
        // Left: Uniform random selection across all N lights -> massive variance & missed nearby emitters
        chosenIdx = int(min(floor(u1 * float(nLights)), float(nLights - 1)));
      } else {
        // Right: Light BVH descent: pick cluster with probability cw[c]/sumW, then pick child in cluster
        float target = u1 * max(sumW, 1e-5);
        int pickedCl = 0;
        float run = 0.0;
        for (int c = 0; c < 4; c++) {
          run += cw[c];
          if (target <= run) { pickedCl = c; break; }
        }
        int subIdx = int(min(floor(u2 * 8.0), 7.0));
        chosenIdx = min(pickedCl * 8 + subIdx, nLights - 1);
        pdf = (cw[pickedCl] / max(sumW, 1e-5)) * (1.0 / 8.0);
      }

      vec3 lPos, lCol;
      getLight(chosenIdx, anim, lPos, lCol);
      vec3 toL = lPos - p;
      float d2 = max(dot(toL, toL), 0.08);
      vec3 L = toL / sqrt(d2);
      float ndl = max(dot(n, L), 0.0);
      if (ndl > 0.002) {
        float vis = evalShadow(p + n * 0.015, lPos);
        vec3 contrib = alb * lCol * (ndl * vis / d2) * 0.055;
        acc += contrib / max(pdf, 1e-4);
      }
    }
    col = acc / float(SAMPLES) + alb * vec3(0.03, 0.035, 0.048);
  }

  // Render glowing emitter bulbs in 3D space so clusters are immediately legible
  for (int i = 0; i < 32; i++) {
    if (i >= nLights) break;
    vec3 lPos, lCol;
    getLight(i, anim, lPos, lCol);
    vec3 toL = lPos - ro;
    float proj = dot(toL, rd);
    if (proj > 0.1 && proj < t) {
      float perp = length(toL - rd * proj);
      col += lCol * exp(-perp * perp * 850.0) * 0.72;
    }
  }

  float sep = smoothstep(0.0035, 0.0008, abs(sx - 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.

## Combines with

- [ReSTIR DI: Spatiotemporal Reservoir Resampling for Direct Lighting](https://texelatlas.vercel.app/t/restir-di.md): The tree supplies better initial candidates that reservoirs then resample and reuse.

## Sources

1. [primary] Alejandro Conty Estevez, Christopher Kulla (2018) Importance Sampling of Many Lights with Adaptive Tree Splitting. Proceedings of the ACM on Computer Graphics and Interactive Techniques. https://doi.org/10.1145/3233305 (verified via crossref on 2026-11-29)
2. [implementation] mmp (2017) mmp/pbrt-v4. https://github.com/mmp/pbrt-v4 License: Apache-2.0. (verified via github on 2026-11-29)

## Cite this entry

Texel. "Light BVH and Adaptive Tree Splitting." https://texelatlas.vercel.app/t/light-bvh-many-lights/ (accessed 2026-12-01).
