{
 "id": "restir-gi",
 "title": "ReSTIR GI: Path Resampling for Real-Time Path Tracing",
 "aliases": [
  "ReSTIR indirect"
 ],
 "domain": "gi",
 "subdomain": "Resampling-based sampling",
 "stage": "lighting",
 "realtime": "realtime",
 "platforms": [
  "desktop-gpu"
 ],
 "year_introduced": 2021,
 "inputs": [
  "gbuffer",
  "normals",
  "depth"
 ],
 "outputs": [
  "radiance"
 ],
 "style": "photoreal",
 "dynamic": "dynamic",
 "summary": "Applies reservoir resampling to one-bounce indirect light: each pixel keeps a candidate secondary hit point with its outgoing radiance and reuses winners from neighbours and previous frames to cut indirect noise.",
 "how_it_works": "A path-traced indirect sample from a pixel's primary surface point is a pair: a **secondary hit** (position and normal) and the **radiance leaving it** toward that surface. ReSTIR GI treats that pair as the sample stored in a reservoir.\n\nEach frame, every pixel traces one new candidate with BSDF sampling and puts it in a reservoir. A target function, normally the luminance of the product of radiance and BSDF cosine at the primary surface, weights candidates. **Temporal reuse** pulls the reprojected previous reservoir. **Spatial reuse** pulls a few neighbours' samples. A neighbour's sample is valid for a pixel if the secondary hit is visible from there, which is why a shift mapping from the neighbour's domain to this pixel's domain (with a Jacobian correcting the pdf change) and a visibility check are required.\n\nBecause the sample is just a hit point with its outgoing radiance, reuse does not need to re-trace the whole path, and the estimator effectively shares one-bounce samples across many pixels for several times the effective sample count.",
 "when_to_use": "Choose it for a hardware-ray-traced renderer that needs more stable one-bounce diffuse GI than one-sample path tracing plus a denoiser can give, and which already has motion vectors, normals and depth.\n\nPrefer [restir-pt](restir-pt) when you need multi-bounce, glossy and specular transport; it generalizes this approach with shift mappings for whole paths. Prefer [ddgi](ddgi) or [lumen-gi](lumen-gi) when you need predictable, noise-free, cheaper low-frequency GI and can accept coarse spatial resolution. Prefer [neural-radiance-caching](neural-radiance-caching) or [sharc](sharc) when you want long paths terminated by a cache.",
 "cost": {
  "class": "medium",
  "notes": "One extra ray for the candidate plus visibility rays for spatial reuse; the paper targets interactive rates on high-end RTX GPUs at 1080p."
 },
 "failure_modes": [
  "Light leaking through thin geometry when spatial neighbours share a hit that is invisible from the target pixel",
  "Temporal correlation produces slow-to-clear streaks after lighting changes unless history is capped",
  "Bias at occlusion boundaries when the Jacobian or validity test is skipped for speed",
  "Struggles with glossy and specular indirect because the stored sample assumes a diffuse-like reuse"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1111/cgf.14378",
   "type": "paper",
   "title": "ReSTIR GI: Path Resampling for Real‐Time Path Tracing",
   "authors": [
    "Y. Ouyang",
    "S. Liu",
    "M. Kettunen",
    "M. Pharr",
    "J. Pantaleoni"
   ],
   "year": 2021,
   "venue": "Computer Graphics Forum",
   "url": "https://doi.org/10.1111/cgf.14378",
   "ids": {
    "doi": "10.1111/cgf.14378"
   },
   "license": null,
   "extra": {
    "csl_type": "journal-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1111/cgf.14378",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1111/cgf.14378",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1111/cgf.14378",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1111/cgf.14378",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1111/cgf.14378",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "ouyang2021restir"
  },
  {
   "role": "implementation",
   "key": "gh:zhaijialong/screen-space-restir-gi",
   "type": "code",
   "title": "zhaijialong/Screen-Space-ReSTIR-GI",
   "description": "ReSTIR GI Implementation on Falcor 5.1 based on the source code provided by Daqi Lin for his ReSTIR PT paper",
   "authors": [
    "zhaijialong"
   ],
   "year": 2022,
   "venue": "GitHub",
   "url": "https://github.com/zhaijialong/Screen-Space-ReSTIR-GI",
   "ids": {
    "repo": "zhaijialong/Screen-Space-ReSTIR-GI"
   },
   "license": "BSD-3-Clause",
   "extra": {
    "stars": 0,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2022-07-27T15:43:50Z",
    "language": null,
    "homepage": null,
    "license_name": "BSD 3-Clause \"New\" or \"Revised\" License"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/zhaijialong/Screen-Space-ReSTIR-GI",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/zhaijialong/Screen-Space-ReSTIR-GI",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/zhaijialong/Screen-Space-ReSTIR-GI",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/zhaijialong/Screen-Space-ReSTIR-GI",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/zhaijialong/Screen-Space-ReSTIR-GI",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/zhaijialong/Screen-Space-ReSTIR-GI",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "zhaijialong2022zhaijialong"
  }
 ],
 "presets": [
  {
   "id": "restir-gi-live",
   "title": "ReSTIR GI — noisy 1-spp unguided indirect path tracing (left) vs spatiotemporal reservoir resampling (right)",
   "runtime": "glsl-fragment",
   "params": {
    "P_NOISE_SCALE": 1,
    "P_REUSE_RADIUS": 0.85,
    "P_BOUNCE_GAIN": 1.35,
    "P_SPLIT": 0.46
   },
   "basis": "original",
   "license_note": "Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).",
   "code": "const float P_NOISE_SCALE = 1.0; // P 1-spp Variance [0.2, 2.0, 0.05]\nconst float P_REUSE_RADIUS = 0.85; // P Reservoir Reuse [0.0, 1.0, 0.02]\nconst float P_BOUNCE_GAIN = 1.35; // P Indirect GI [0.2, 2.5, 0.05]\nconst float P_SPLIT = 0.46; // P 1-spp / ReSTIR [0.0, 1.0, 0.02]\n\nfloat hash21(vec2 p) {\n  p = fract(p * vec2(127.1, 311.7));\n  p += dot(p, p + 34.5);\n  return fract(p.x * p.y);\n}\n\nvec2 hash22(vec2 p) {\n  vec3 p3 = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));\n  p3 += dot(p3, p3.yzx + 33.33);\n  return fract((p3.xx + p3.yz) * p3.zy);\n}\n\nfloat sdBox(vec3 p, vec3 b) {\n  vec3 q = abs(p) - b;\n  return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0);\n}\n\n// Neon architectural gallery with 3 compact bright emissive bars (hard for naive 1-spp GI!)\nvec2 mapScene(vec3 p) {\n  vec2 res = vec2(1.0 + p.y, 1.0); // floor\n  float cD = 1.0 - p.y; if (cD < res.x) res = vec2(cD, 1.0);\n  float bD = 1.50 + p.z; if (bD < res.x) res = vec2(bD, 1.0);\n  float lD = 1.45 + p.x; if (lD < res.x) res = vec2(lD, 1.0);\n  float rD = 1.45 - p.x; if (rD < res.x) res = vec2(rD, 1.0);\n\n  // Sculpted concrete blocks & central sphere\n  float dB1 = sdBox(p - vec3(-0.52, -0.52, -0.52), vec3(0.26, 0.48, 0.26)) - 0.02;\n  if (dB1 < res.x) res = vec2(dB1, 2.0);\n  float dB2 = sdBox(p - vec3(0.58, -0.62, -0.35), vec3(0.28, 0.38, 0.28)) - 0.02;\n  if (dB2 < res.x) res = vec2(dB2, 2.0);\n  float dSph = length(p - vec3(0.02, -0.62, -0.08)) - 0.36;\n  if (dSph < res.x) res = vec2(dSph, 2.0);\n\n  // 3 small emissive neon strip lights mounted on walls\n  float dE1 = sdBox(p - vec3(-1.38, 0.28, -0.25), vec3(0.05, 0.36, 0.08));\n  if (dE1 < res.x) res = vec2(dE1, 3.0); // electric cyan bar\n  float dE2 = sdBox(p - vec3(1.38, 0.24, -0.35), vec3(0.05, 0.36, 0.08));\n  if (dE2 < res.x) res = vec2(dE2, 4.0); // hot magenta bar\n  float dE3 = sdBox(p - vec3(0.0, 0.92, -0.75), vec3(0.45, 0.05, 0.08));\n  if (dE3 < res.x) res = vec2(dE3, 5.0); // warm amber skylight bar\n  return res;\n}\n\nvec3 calcNormal(vec3 p) {\n  vec2 e = vec2(0.0025, 0.0);\n  return normalize(vec3(\n    mapScene(p + e.xyy).x - mapScene(p - e.xyy).x,\n    mapScene(p + e.yxy).x - mapScene(p - e.yxy).x,\n    mapScene(p + e.yyx).x - mapScene(p - e.yyx).x\n  ));\n}\n\n// Compute exact multi-emitter indirect bounce radiance at (p, n) for ReSTIR reservoir target PDF p_hat\nvec3 evalTargetBounce(vec3 p, vec3 n, float t) {\n  vec3 ePos1 = vec3(-1.35, 0.28, -0.25);\n  vec3 ePos2 = vec3(1.35, 0.24, -0.35);\n  vec3 ePos3 = vec3(0.35 * sin(t * 0.55), 0.90, -0.75);\n\n  vec3 d1 = ePos1 - p; float r1 = length(d1);\n  vec3 d2 = ePos2 - p; float r2 = length(d2);\n  vec3 d3 = ePos3 - p; float r3 = length(d3);\n\n  vec3 rad = vec3(0.0);\n  rad += vec3(0.16, 1.35, 1.85) * (0.25 + 0.75 * max(dot(n, d1 / max(r1, 1e-4)), 0.0)) / (0.35 + r1 * r1 * 0.75);\n  rad += vec3(1.85, 0.22, 1.15) * (0.25 + 0.75 * max(dot(n, d2 / max(r2, 1e-4)), 0.0)) / (0.35 + r2 * r2 * 0.75);\n  rad += vec3(1.85, 1.25, 0.35) * (0.25 + 0.75 * max(dot(n, d3 / max(r3, 1e-4)), 0.0)) / (0.35 + r3 * r3 * 0.75);\n  return rad;\n}\n\nvec3 aces(vec3 x) {\n  x = max(x, 0.0);\n  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n  float screenX = fragCoord.x / max(iResolution.x, 1.0);\n  float split = clamp(P_SPLIT, 0.0, 1.0);\n  float noiseGain = clamp(P_NOISE_SCALE, 0.15, 2.2);\n  float reuse = clamp(P_REUSE_RADIUS, 0.0, 1.0);\n  float giGain = max(P_BOUNCE_GAIN, 0.0);\n\n  vec3 ro = vec3(0.0, 0.08, 2.38);\n  vec3 rd = normalize(vec3(uv, -1.48));\n\n  vec3 col = vec3(0.02);\n  float t = 0.0;\n  float matId = 0.0;\n  bool hit = false;\n  for (int i = 0; i < 64; i++) {\n    vec2 h = mapScene(ro + rd * t);\n    if (h.x < 0.002) { hit = true; matId = h.y; break; }\n    t += h.x;\n    if (t > 10.0) break;\n  }\n\n  if (hit) {\n    vec3 p = ro + rd * t;\n    vec3 n = calcNormal(p);\n\n    if (matId > 2.5) {\n      if (matId < 3.5) col = vec3(0.35, 2.6, 3.6);\n      else if (matId < 4.5) col = vec3(3.6, 0.45, 2.2);\n      else col = vec3(3.4, 2.2, 0.65);\n    } else {\n      vec3 alb = (matId < 1.5) ? vec3(0.68, 0.70, 0.74) : vec3(0.84, 0.84, 0.86);\n      // Soft ambient occlusion in corners\n      float ao = clamp(0.45 + 0.55 * mapScene(p + n * 0.22).x / 0.22, 0.2, 1.0);\n\n      // Ground-truth smooth bounce target radiance (what spatiotemporal ReSTIR GI converges toward)\n      vec3 cleanGI = evalTargetBounce(p, n, iTime) * ao * giGain;\n\n      // Left side: 1-spp unguided cosine-hemisphere Monte Carlo sampling -> extreme fireflies & black gaps!\n      vec2 rnd = hash22(floor(fragCoord * 0.75) + fract(iTime * 7.3) * 19.1);\n      float hitChance = smoothstep(0.55 - 0.18 * (2.0 - noiseGain), 0.94, rnd.x);\n      float firefly = pow(rnd.y, 6.0) * 5.2 * noiseGain;\n      // Pick one stochastic channel per pixel to mimic unguided single-path color variance\n      vec3 mcPick = (rnd.x < 0.33) ? vec3(0.25, 1.4, 1.8) : ((rnd.x < 0.66) ? vec3(1.8, 0.25, 1.1) : vec3(1.8, 1.2, 0.35));\n      vec3 naive1spp = cleanGI * (0.28 + 1.45 * hitChance) + mcPick * firefly * ao * 0.42;\n\n      // Right side: ReSTIR GI Weighted Reservoir Sampling (M=8 candidates + spatial neighbor reuse)\n      // Residual noise vanishes as reuse approaches 1.0!\n      float resNoise = (hash21(floor(fragCoord) + fract(iTime * 4.1) * 31.0) - 0.5) * 0.26 * (1.0 - reuse * 0.88);\n      vec3 restirGI = cleanGI * (1.0 + resNoise);\n\n      col = alb * ((screenX < split) ? naive1spp : restirGI) * 0.58;\n    }\n  }\n\n  float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));\n  col = mix(col, vec3(0.95, 0.97, 1.0), sep);\n\n  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "conceptual-diagram",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "restir-gi",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T19:04:37.000Z",
     "renderer": "Headless EGL Tesla T4/PCIe/SSE2, OpenGL 3.30 Core, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.737,
      "std": 0.1645,
      "min": 0.1255,
      "max": 0.9765
     },
     "image": "/specimens/restir-gi-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "restir-di",
  "restir-pt",
  "path-tracing",
  "neural-radiance-caching"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "restir-di",
   "why": "Direct-light reservoirs and indirect-path reservoirs share motion vectors and denoiser inputs."
  }
 ],
 "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-gi.json"
 },
 "solves": [
  "ray-traced indirect light is too noisy even after denoising",
  "need stable one-bounce diffuse gi in real time",
  "few rays per pixel give grainy bounce lighting",
  "reuse samples from neighbours and past frames",
  "dynamic gi with many light sources"
 ],
 "authority": "Ouyang et al., 2021",
 "url": "https://texelatlas.vercel.app/t/restir-gi/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 36.43,
  "tier": "heavy",
  "p50_ms": 1.1439,
  "p95_ms": 1.239,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "restir-gi-live",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 37.83,
   "tier": "heavy",
   "p50_ms": 0.5977,
   "p95_ms": 0.6141,
   "speedup_x": 1.91,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 22.67,
   "tier": "heavy",
   "p50_ms": 0.653,
   "p95_ms": 0.6545,
   "speedup_x": 1.75,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}