{
 "id": "restir-di",
 "title": "ReSTIR DI: Spatiotemporal Reservoir Resampling for Direct Lighting",
 "aliases": [
  "ReSTIR",
  "RIS with reservoirs"
 ],
 "domain": "gi",
 "subdomain": "Resampling-based sampling",
 "stage": "lighting",
 "realtime": "realtime",
 "platforms": [
  "desktop-gpu",
  "webgpu"
 ],
 "year_introduced": 2020,
 "inputs": [
  "gbuffer",
  "mesh",
  "material-params"
 ],
 "outputs": [
  "radiance"
 ],
 "style": "photoreal",
 "dynamic": "dynamic",
 "summary": "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.",
 "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.\n\nThe 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.\n\nFinally, 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": "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.\n\nPrefer [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": {
  "class": "medium",
  "notes": "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."
 },
 "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"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1145/3386569.3392481",
   "type": "paper",
   "title": "Spatiotemporal reservoir resampling for real-time ray tracing with dynamic direct lighting",
   "authors": [
    "Benedikt Bitterli",
    "Chris Wyman",
    "Matt Pharr",
    "Peter Shirley",
    "Aaron Lefohn",
    "Wojciech Jarosz"
   ],
   "year": 2020,
   "venue": "ACM Transactions on Graphics",
   "url": "https://doi.org/10.1145/3386569.3392481",
   "ids": {
    "doi": "10.1145/3386569.3392481"
   },
   "license": null,
   "extra": {
    "csl_type": "journal-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3386569.3392481",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3386569.3392481",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3386569.3392481",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3386569.3392481",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3386569.3392481",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "bitterli2020spatiotemporal"
  },
  {
   "role": "implementation",
   "key": "gh:nvidia-rtx/rtxdi",
   "type": "code",
   "title": "NVIDIA-RTX/RTXDI",
   "description": "",
   "authors": [
    "NVIDIA-RTX"
   ],
   "year": 2021,
   "venue": "GitHub",
   "url": "https://github.com/NVIDIA-RTX/RTXDI",
   "ids": {
    "repo": "NVIDIA-RTX/RTXDI"
   },
   "license": "NOASSERTION",
   "extra": {
    "stars": 577,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2026-11-13T14:48:32Z",
    "language": "HLSL",
    "homepage": null,
    "license_name": "Other"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/NVIDIA-RTX/RTXDI",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/NVIDIA-RTX/RTXDI",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/NVIDIA-RTX/RTXDI",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/NVIDIA-RTX/RTXDI",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/NVIDIA-RTX/RTXDI",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/NVIDIA-RTX/RTXDI",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "nvidiartx2021nvidiab"
  },
  {
   "role": "implementation",
   "key": "gh:nvidiagameworks/falcor",
   "type": "code",
   "title": "NVIDIAGameWorks/Falcor",
   "description": "Real-Time Rendering Framework",
   "authors": [
    "NVIDIAGameWorks"
   ],
   "year": 2017,
   "venue": "GitHub",
   "url": "https://github.com/NVIDIAGameWorks/Falcor",
   "ids": {
    "repo": "NVIDIAGameWorks/Falcor"
   },
   "license": "NOASSERTION",
   "extra": {
    "stars": 3285,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2026-09-21T15:12:00Z",
    "language": "C++",
    "homepage": "https://developer.nvidia.com/falcor",
    "license_name": "Other"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/NVIDIAGameWorks/Falcor",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/NVIDIAGameWorks/Falcor",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/NVIDIAGameWorks/Falcor",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/NVIDIAGameWorks/Falcor",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/NVIDIAGameWorks/Falcor",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/NVIDIAGameWorks/Falcor",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "nvidiagameworks2017nvidiagameworks"
  }
 ],
 "presets": [
  {
   "id": "restir-di-specimen",
   "title": "Toy ReSTIR-DI core: uniform pick vs RIS reservoir vs reference (48 lights, 1 spp, no reuse)",
   "runtime": "glsl-fragment",
   "params": {
    "NL": 48,
    "M": 12
   },
   "code": "// Toy ReSTIR-DI core: resampled importance sampling (RIS) with a streaming reservoir, no temporal/spatial reuse.\n// 48 coloured point lights over a plane, unshadowed, 1 shading sample per pixel.\n// Left: uniform light pick.  Middle: RIS, 12 candidates, target pdf = luminance of the unshadowed contribution.\n// Right: reference (all 48 lights).\nconst int NL = 48;\nconst int M = 12;\nconst float GAIN = 0.012;\n\nvec2 h2(float n) { return fract(sin(vec2(n * 127.1, n * 311.7 + 17.0)) * 43758.5453); }\nvec3 lightPos(int i) { vec2 r = h2(float(i) + 1.0); return vec3((r - 0.5) * 2.3, 0.25); }\nvec3 lightCol(int i) {\n  float r = h2(float(i) + 40.0).x;\n  return (0.5 + 0.5 * cos(6.2832 * (r + vec3(0.0, 0.33, 0.67)))) * (0.15 + 2.5 * r * r * r);\n}\nvec3 contrib(int i, vec3 p) {\n  vec3 l = lightPos(i) - p; float d2 = dot(l, l);\n  return lightCol(i) * (l.z / sqrt(d2)) / d2 * GAIN;\n}\nfloat lum(vec3 c) { return dot(c, vec3(0.2126, 0.7152, 0.0722)); }\nfloat rnd(inout float s) { s += 1.0; return fract(sin(s * 91.3458) * 47453.5453); }\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n  vec3 p = vec3(uv * 2.2, 0.0);\n  float seed = dot(fragCoord, vec2(12.9898, 78.233));\n  float x3 = fragCoord.x / iResolution.x * 3.0;\n  vec3 col = vec3(0.0);\n  if (x3 < 1.0) {\n    int i = int(floor(rnd(seed) * float(NL)));\n    col = contrib(min(i, NL - 1), p) * float(NL);\n  } else if (x3 < 2.0) {\n    float wsum = 0.0; int sel = 0; float selL = 0.0;\n    for (int m = 0; m < M; m++) {\n      int i = min(int(floor(rnd(seed) * float(NL))), NL - 1);\n      float pl = lum(contrib(i, p)); float w = pl * float(NL);\n      wsum += w;\n      if (rnd(seed) * wsum < w) { sel = i; selL = pl; }\n    }\n    col = selL > 0.0 ? contrib(sel, p) * (wsum / (float(M) * selL)) : vec3(0.0);\n  } else {\n    for (int i = 0; i < NL; i++) col += contrib(i, p);\n  }\n  for (int i = 0; i < NL; i++) if (length(p.xy - lightPos(i).xy) < 0.012) col = lightCol(i) * 0.5 + 0.5;\n  col = col / (1.0 + col);\n  if (fract(x3) < 0.004 || fract(x3) > 0.996) col = vec3(1.0);\n  fragColor = vec4(pow(col, vec3(1.0 / 2.2)), 1.0);\n}\n",
   "basis": "original",
   "license_note": "written for this index",
   "execution_fidelity": "conceptual-diagram",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-29",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "restir-di",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-29T15:51:50.471Z",
     "renderer": "Chromium 145.0.7632.6 headless, WebGL2 via ANGLE/SwiftShader, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.3833,
      "std": 0.1959,
      "unique_colors": 1149
     },
     "image": "/specimens/restir-di-specimen.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "restir-gi",
  "restir-pt",
  "light-bvh-many-lights",
  "multiple-importance-sampling"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "light-bvh-many-lights",
   "why": "A light tree or grid can provide better initial candidate distributions than uniform or power sampling."
  },
  {
   "id": "restir-gi",
   "why": "Direct reservoirs and indirect-path reservoirs share the same motion vectors and reuse machinery."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/gi/restir-di.json"
 },
 "solves": [
  "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"
 ],
 "authority": "Bitterli et al., 2020",
 "url": "https://texelatlas.vercel.app/t/restir-di/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 19.33,
  "tier": "moderate",
  "p50_ms": 0.6359,
  "p95_ms": 0.6654,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "restir-di-specimen",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 16.27,
   "tier": "moderate",
   "p50_ms": 0.2587,
   "p95_ms": 0.2657,
   "speedup_x": 2.46,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 11.04,
   "tier": "moderate",
   "p50_ms": 0.318,
   "p95_ms": 0.3196,
   "speedup_x": 2,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}