---
id: "restir-di"
title: "ReSTIR DI: Spatiotemporal Reservoir Resampling for Direct Lighting"
aliases: [ReSTIR, RIS with reservoirs]
domain: "gi"
stage: "lighting"
realtime: "realtime"
platforms: [desktop-gpu, webgpu]
year_introduced: 2020
inputs: [gbuffer, mesh, material-params]
outputs: [radiance]
style: "photoreal"
dynamic: "dynamic"
cost: "medium"
authority: "Bitterli et al., 2020"
url: "https://texelatlas.vercel.app/t/restir-di/"
sources_verified_at: "2026-11-29"
---
# ReSTIR DI: Spatiotemporal Reservoir Resampling for Direct Lighting (Bitterli et al., 2020)

> Renders direct lighting from thousands to millions of dynamic lights with a few shadow rays per pixel by streaming candidate lights into per-pixel reservoirs and sharing them across neighbouring pixels and frames.

## Reach for it when

- thousands of dynamic lights make direct lighting noisy
- scene has millions of emissive triangles
- can't find a good light with one or two samples per pixel
- need real-time many-light shading with few shadow rays

## How it works

ReSTIR builds on **resampled importance sampling**. For a pixel, you draw `M` cheap candidate lights from a simple distribution (power, uniform). You pick one of them with probability proportional to a target function such as unshadowed contribution, and keep only that winner. The streaming variant is a **reservoir**: it stores one sample plus a running weight sum, so memory is constant however many candidates you stream through.

The two reuse stages are what make it fast. **Temporal reuse** merges last frame's reservoir (reprojected through motion vectors) into the current one, and **spatial reuse** merges reservoirs from nearby pixels. Merging reservoirs is itself a resampling step, which keeps the estimator unbiased if each reservoir's contribution weight is corrected by a Jacobian or by an extra visibility-aware step. Effective candidate counts grow by orders of magnitude per frame at the cost of a few operations.

Finally, one visibility ray is traced for the surviving sample and the shaded result is output, usually followed by a denoiser. An extra unbiased mode re-traces visibility for the reused samples.

## When to use it

Choose it for scenes with huge numbers of emissive triangles or dynamic lights, where classic next-event estimation with a light tree cannot find a good light in one or two samples. It needs a G-buffer and motion vectors.

Prefer [light-bvh-many-lights](light-bvh-many-lights) or [lightcuts](lightcuts) when you want a deterministic, offline-grade many-light solution. Prefer [restir-gi](restir-gi) or [restir-pt](restir-pt) when the missing energy is indirect rather than direct. Prefer plain [path-tracing](path-tracing) with [multiple-importance-sampling](multiple-importance-sampling) when you have only a handful of lights.

## Cost

medium — Cost scales with the initial candidate count, one visibility ray per pixel per pass and the reuse passes; the original paper reports interactive frame rates for millions of lights on 2020 desktop GPUs.
Measured GPU Weight: 19.33× baseline (moderate) — 0.6359 ms median / 0.6654 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 16.27× baseline (moderate) — 0.2587 ms median (2.46× faster on L4).
Ampere A100 scaling: 11.04× baseline (moderate) — 0.318 ms median (2× faster on A100).

## Failure modes

- Temporal lag and ghosting after fast lighting or camera changes because stale reservoirs persist
- Biased darkening or brightening at disocclusions, depth discontinuities and normal changes unless reuse is carefully rejected
- Correlated noise patterns (blotches) from spatial reuse that the denoiser must remove
- Requires one shadow ray per reused sample for unbiased visibility, otherwise light leaks through thin occluders

## Engine support

- unreal: builtin — `Project Settings > Rendering > MegaLights (stochastic reservoir-resampled many-light direct illumination and shadows)` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/megalights-in-unreal-engine, checked 2026-12-01)

## Dataflow

- Inputs: gbuffer, mesh, material-params
- Outputs: radiance
- Platforms: desktop-gpu, webgpu

## Presets

### Toy ReSTIR-DI core: uniform pick vs RIS reservoir vs reference (48 lights, 1 spp, no reuse) (glsl-fragment; rendered 2026-11-29)

```json
{
  "NL": 48,
  "M": 12
}
```

```glsl
// Toy ReSTIR-DI core: resampled importance sampling (RIS) with a streaming reservoir, no temporal/spatial reuse.
// 48 coloured point lights over a plane, unshadowed, 1 shading sample per pixel.
// Left: uniform light pick.  Middle: RIS, 12 candidates, target pdf = luminance of the unshadowed contribution.
// Right: reference (all 48 lights).
const int NL = 48;
const int M = 12;
const float GAIN = 0.012;

vec2 h2(float n) { return fract(sin(vec2(n * 127.1, n * 311.7 + 17.0)) * 43758.5453); }
vec3 lightPos(int i) { vec2 r = h2(float(i) + 1.0); return vec3((r - 0.5) * 2.3, 0.25); }
vec3 lightCol(int i) {
  float r = h2(float(i) + 40.0).x;
  return (0.5 + 0.5 * cos(6.2832 * (r + vec3(0.0, 0.33, 0.67)))) * (0.15 + 2.5 * r * r * r);
}
vec3 contrib(int i, vec3 p) {
  vec3 l = lightPos(i) - p; float d2 = dot(l, l);
  return lightCol(i) * (l.z / sqrt(d2)) / d2 * GAIN;
}
float lum(vec3 c) { return dot(c, vec3(0.2126, 0.7152, 0.0722)); }
float rnd(inout float s) { s += 1.0; return fract(sin(s * 91.3458) * 47453.5453); }

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
  vec3 p = vec3(uv * 2.2, 0.0);
  float seed = dot(fragCoord, vec2(12.9898, 78.233));
  float x3 = fragCoord.x / iResolution.x * 3.0;
  vec3 col = vec3(0.0);
  if (x3 < 1.0) {
    int i = int(floor(rnd(seed) * float(NL)));
    col = contrib(min(i, NL - 1), p) * float(NL);
  } else if (x3 < 2.0) {
    float wsum = 0.0; int sel = 0; float selL = 0.0;
    for (int m = 0; m < M; m++) {
      int i = min(int(floor(rnd(seed) * float(NL))), NL - 1);
      float pl = lum(contrib(i, p)); float w = pl * float(NL);
      wsum += w;
      if (rnd(seed) * wsum < w) { sel = i; selL = pl; }
    }
    col = selL > 0.0 ? contrib(sel, p) * (wsum / (float(M) * selL)) : vec3(0.0);
  } else {
    for (int i = 0; i < NL; i++) col += contrib(i, p);
  }
  for (int i = 0; i < NL; i++) if (length(p.xy - lightPos(i).xy) < 0.012) col = lightCol(i) * 0.5 + 0.5;
  col = col / (1.0 + col);
  if (fract(x3) < 0.004 || fract(x3) > 0.996) col = vec3(1.0);
  fragColor = vec4(pow(col, vec3(1.0 / 2.2)), 1.0);
}

```

Attribution: written for this index

## Combines with

- [Light BVH and Adaptive Tree Splitting](https://texelatlas.vercel.app/t/light-bvh-many-lights.md): A light tree or grid can provide better initial candidate distributions than uniform or power sampling.
- [ReSTIR GI: Path Resampling for Real-Time Path Tracing](https://texelatlas.vercel.app/t/restir-gi.md): Direct reservoirs and indirect-path reservoirs share the same motion vectors and reuse machinery.

## Sources

1. [primary] Benedikt Bitterli, Chris Wyman, Matt Pharr, Peter Shirley, Aaron Lefohn, Wojciech Jarosz (2020) Spatiotemporal reservoir resampling for real-time ray tracing with dynamic direct lighting. ACM Transactions on Graphics. https://doi.org/10.1145/3386569.3392481 (verified via crossref on 2026-11-29)
2. [implementation] NVIDIA-RTX (2021) NVIDIA-RTX/RTXDI. https://github.com/NVIDIA-RTX/RTXDI License: NOASSERTION. (verified via github on 2026-11-29)
3. [implementation] NVIDIAGameWorks (2017) NVIDIAGameWorks/Falcor. https://github.com/NVIDIAGameWorks/Falcor License: NOASSERTION. (verified via github on 2026-11-29)

## Cite this entry

Texel. "ReSTIR DI: Spatiotemporal Reservoir Resampling for Direct Lighting." https://texelatlas.vercel.app/t/restir-di/ (accessed 2026-12-01).
