ReSTIR DI: Spatiotemporal Reservoir Resampling for Direct Lighting
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.
Also known as ReSTIR, RIS with reservoirs
In the family Light transport & global illumination, Resampling-based sampling
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 | Built in | Project Settings > Rendering > MegaLights (stochastic reservoir-resampled many-light direct illumination and shadows) docs |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
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 choose it
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
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 and Adaptive Tree Splitting or Lightcuts when you want a deterministic, offline-grade many-light solution. Prefer ReSTIR GI: Path Resampling for Real-Time Path Tracing or ReSTIR PT and Generalized Resampled Importance Sampling when the missing energy is indirect rather than direct. Prefer plain Unidirectional Path Tracing with Multiple Importance Sampling when you have only a handful of lights.
Field marks
- 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
Presets
Toy ReSTIR-DI core: uniform pick vs RIS reservoir vs reference (48 lights, 1 spp, no reuse)
{
"NL": 48,
"M": 12
}Show GLSL (48 lines)
// 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
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| restir-di-specimen | Tesla T4 1920x1080 | 19.3× baseline (moderate) · 0.636 ms / 0.665 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| restir-di-specimen | NVIDIA L4 1920x1080 | 16.3× baseline (moderate) · 0.259 ms / 0.266 ms · 2.5× faster on L4 | opengl-timer-query · Cross-architecture validation |
| restir-di-specimen | NVIDIA A100-SXM4-40GB 1920x1080 | 11.0× baseline (moderate) · 0.318 ms / 0.320 ms · 2.0× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): its primary source cites Light BVH and Adaptive Tree Splitting, Tiled deferred shading, Joint Non-Local Means (JNLM) Path-Tracing Denoiser, Lightcuts; cited by ReSTIR GI: Path Resampling for Real-Time Path Tracing, ReSTIR PT and Generalized Resampled Importance Sampling.
Crosses
- Light BVH and Adaptive Tree Splitting: 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: Direct reservoirs and indirect-path reservoirs share the same motion vectors and reuse machinery.
Sources
- primaryBenedikt 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.Verified via crossref · 2026-11-29doi:10.1145/3386569.3392481
- implementationNVIDIAGameWorks (2017). NVIDIAGameWorks/Falcor. Real-Time Rendering FrameworkGitHub API · license NOASSERTION · 2026-11-29