{
 "id": "restir-pt",
 "title": "ReSTIR PT and Generalized Resampled Importance Sampling",
 "aliases": [
  "GRIS",
  "ReSTIR path tracing"
 ],
 "domain": "gi",
 "subdomain": "Resampling-based sampling",
 "stage": "lighting",
 "realtime": "realtime",
 "platforms": [
  "desktop-gpu"
 ],
 "year_introduced": 2022,
 "inputs": [
  "gbuffer",
  "mesh",
  "material-params"
 ],
 "outputs": [
  "radiance"
 ],
 "style": "photoreal",
 "dynamic": "dynamic",
 "summary": "Extends reservoir resampling to whole light paths with shift mappings between pixels, so reuse works for multi-bounce, glossy and caustic transport. GRIS is the theory; ReSTIR PT is the path-tracing algorithm.",
 "how_it_works": "Earlier ReSTIR variants reuse samples that are single points. **Generalized resampled importance sampling** (GRIS) puts the reuse on a firm footing for samples that live in arbitrary domains, including full paths. When a sample from a neighbour is reused at the current pixel, a **shift mapping** turns the neighbour's path into a path for the current pixel, and the change in density is accounted for by a Jacobian and by resampling MIS weights that stay unbiased even when the mapping is not invertible everywhere.\n\nFor path tracing the useful shift mappings are *random replay* (reuse the random numbers), *reconnection* (connect the current pixel's first vertex to a later vertex of the neighbour's path) and a **hybrid** that reconnects after the first rough vertex and replays through near-specular ones. This lets reuse keep specular chains intact while still sharing diffuse bounces.\n\nThe pipeline traces one path per pixel, resamples it into a reservoir, then does temporal and spatial reuse with the hybrid shift, adding extra rays to confirm visibility of reused paths, followed by a denoiser.",
 "when_to_use": "Choose it as the highest-quality real-time (or interactive) path-traced GI: multi-bounce diffuse, glossy reflections and caustic-like paths all benefit, and it is also useful as a convergence accelerator offline.\n\nPrefer [restir-gi](restir-gi) when one-bounce diffuse indirect is enough and you want a smaller, simpler implementation. Prefer [restir-di](restir-di) when only direct light is the issue. Prefer [neural-radiance-caching](neural-radiance-caching) when you need predictable cost and can tolerate cache bias. Prefer [path-guiding](path-guiding) when you want an unbiased improvement without any inter-pixel reuse.",
 "cost": {
  "class": "heavy",
  "notes": "Research implementations run at tens of milliseconds per frame on high-end 2022 GPUs at 1080p; the cost depends heavily on path length and reuse radius."
 },
 "failure_modes": [
  "Correlated artifacts: reuse smears one bright path into splotches that persist for many frames",
  "Shift-mapping failures at occlusion and surface discontinuities show as dark or bright halos",
  "Memory for storing path state per pixel for both current and previous frames is large",
  "Complex unbiased MIS weights are easy to get subtly wrong, resulting in energy shifts that are hard to debug"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1145/3528223.3530158",
   "type": "paper",
   "title": "Generalized resampled importance sampling",
   "authors": [
    "Daqi Lin",
    "Markus Kettunen",
    "Benedikt Bitterli",
    "Jacopo Pantaleoni",
    "Cem Yuksel",
    "Chris Wyman"
   ],
   "year": 2022,
   "venue": "ACM Transactions on Graphics",
   "url": "https://doi.org/10.1145/3528223.3530158",
   "ids": {
    "doi": "10.1145/3528223.3530158"
   },
   "license": null,
   "extra": {
    "csl_type": "journal-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3528223.3530158",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3528223.3530158",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3528223.3530158",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3528223.3530158",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3528223.3530158",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "lin2022generalized"
  },
  {
   "role": "implementation",
   "key": "gh:dqlin/restir_pt",
   "type": "code",
   "title": "DQLin/ReSTIR_PT",
   "description": "Source Code for SIGGRAPH 2022 Paper \"Generalized Resampled Importance Sampling: Foundations of ReSTIR\"",
   "authors": [
    "DQLin"
   ],
   "year": 2022,
   "venue": "GitHub",
   "url": "https://github.com/DQLin/ReSTIR_PT",
   "ids": {
    "repo": "DQLin/ReSTIR_PT"
   },
   "license": "BSD-3-Clause",
   "extra": {
    "stars": 535,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2025-07-20T06:44:43Z",
    "language": "C++",
    "homepage": null,
    "license_name": "BSD 3-Clause \"New\" or \"Revised\" License"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/DQLin/ReSTIR_PT",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/DQLin/ReSTIR_PT",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/DQLin/ReSTIR_PT",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/DQLin/ReSTIR_PT",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/DQLin/ReSTIR_PT",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/DQLin/ReSTIR_PT",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "dqlin2022dqlin"
  }
 ],
 "presets": [
  {
   "id": "restir-pt-live",
   "title": "ReSTIR PT — noisy 1-spp multi-bounce path tracing (left) vs hybrid-shift path resampling (right)",
   "runtime": "glsl-fragment",
   "params": {
    "P_ROUGHNESS": 0.24,
    "P_REUSE_STR": 0.88,
    "P_EMIT_GAIN": 1.35,
    "P_SPLIT": 0.48
   },
   "basis": "original",
   "license_note": "MIT — written for this index.",
   "code": "const float P_ROUGHNESS = 0.24; // P Glossy Roughness [0.08, 0.65, 0.02]\nconst float P_REUSE_STR = 0.88; // P Path Reuse [0.0, 1.0, 0.02]\nconst float P_EMIT_GAIN = 1.35; // P Multi-Bounce [0.3, 2.4, 0.05]\nconst float P_SPLIT = 0.48; // P 1-spp / ReSTIR PT [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// Multi-bounce glossy + diffuse showcase: chrome-gold sphere, glossy floor, diffuse walls & moving neon rings\nvec2 mapScene(vec3 p) {\n  vec2 res = vec2(p.y + 0.82, 1.0); // glossy slate floor\n  float dC = 1.05 - p.y; if (dC < res.x) res = vec2(dC, 2.0);\n  float dB = p.z + 1.45; if (dB < res.x) res = vec2(dB, 2.0);\n  float dL = p.x + 1.35; if (dL < res.x) res = vec2(dL, 2.0);\n  float dR = 1.35 - p.x; if (dR < res.x) res = vec2(dR, 2.0);\n\n  // Glossy metallic sphere + brushed copper cylinder (hard for diffuse-only ReSTIR GI, solved by ReSTIR PT!)\n  float dSph = length(p - vec3(-0.36, -0.40, -0.22)) - 0.42;\n  if (dSph < res.x) res = vec2(dSph, 3.0);\n  float dCyl = max(length(p.xz - vec2(0.54, -0.35)) - 0.28, abs(p.y + 0.34) - 0.48);\n  if (dCyl < res.x) res = vec2(dCyl, 4.0);\n\n  // Emissive accent bars\n  float dE1 = sdBox(p - vec3(-1.30, 0.32, -0.20), vec3(0.04, 0.42, 0.08));\n  if (dE1 < res.x) res = vec2(dE1, 5.0);\n  float dE2 = sdBox(p - vec3(1.30, 0.25, -0.30), vec3(0.04, 0.42, 0.08));\n  if (dE2 < res.x) res = vec2(dE2, 6.0);\n  return res;\n}\n\nvec3 calcNormal(vec3 p) {\n  vec2 e = vec2(0.0022, 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// Evaluate glossy + diffuse multi-bounce target radiance (simulating ReSTIR PT hybrid shift mapping)\nvec3 evalFullPath(vec3 p, vec3 n, vec3 v, float rough, float t) {\n  vec3 e1 = vec3(-1.26, 0.32 + 0.14 * sin(t * 0.9), -0.20);\n  vec3 e2 = vec3(1.26, 0.25 + 0.14 * cos(t * 0.8), -0.30);\n  vec3 e3 = vec3(0.0, 0.96, -0.65);\n\n  vec3 c1 = vec3(0.18, 1.35, 1.95);\n  vec3 c2 = vec3(1.95, 0.35, 0.95);\n  vec3 c3 = vec3(1.75, 1.25, 0.45);\n\n  float specExp = mix(72.0, 6.0, clamp(rough, 0.05, 0.85));\n  vec3 rad = vec3(0.0);\n\n  vec3 d1 = e1 - p; float r1 = length(d1); vec3 l1 = d1 / max(r1, 1e-4);\n  float s1 = pow(max(dot(n, normalize(l1 + v)), 0.0), specExp) * (0.25 + 1.25 * (1.0 - rough));\n  rad += c1 * (max(dot(n, l1), 0.0) * 0.42 + s1) / (0.35 + r1 * r1 * 0.65);\n\n  vec3 d2 = e2 - p; float r2 = length(d2); vec3 l2 = d2 / max(r2, 1e-4);\n  float s2 = pow(max(dot(n, normalize(l2 + v)), 0.0), specExp) * (0.25 + 1.25 * (1.0 - rough));\n  rad += c2 * (max(dot(n, l2), 0.0) * 0.42 + s2) / (0.35 + r2 * r2 * 0.65);\n\n  vec3 d3 = e3 - p; float r3 = length(d3); vec3 l3 = d3 / max(r3, 1e-4);\n  float s3 = pow(max(dot(n, normalize(l3 + v)), 0.0), specExp * 0.7) * (0.2 + 0.9 * (1.0 - rough));\n  rad += c3 * (max(dot(n, l3), 0.0) * 0.36 + s3) / (0.45 + r3 * r3 * 0.65);\n\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  bool isPT = screenX >= split;\n  float rough = clamp(P_ROUGHNESS, 0.06, 0.75);\n  float reuse = clamp(P_REUSE_STR, 0.0, 1.0);\n  float gain = clamp(P_EMIT_GAIN, 0.2, 2.5);\n\n  vec3 ro = vec3(0.0, 0.05, 2.38);\n  vec3 rd = normalize(vec3(uv, -1.52));\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 > 9.0) break;\n  }\n\n  if (hit) {\n    vec3 p = ro + rd * t;\n    vec3 n = calcNormal(p);\n    vec3 v = -rd;\n\n    if (matId > 4.5) {\n      col = (matId < 5.5) ? vec3(0.32, 2.5, 3.6) : vec3(3.6, 0.55, 1.9);\n    } else {\n      vec3 alb = vec3(0.62, 0.65, 0.70);\n      float matRough = rough;\n      if (matId < 1.5) { alb = vec3(0.32, 0.35, 0.42); matRough = rough * 0.75; }\n      else if (matId > 2.5 && matId < 3.5) { alb = vec3(0.95, 0.78, 0.42); matRough = rough * 0.55; }\n      else if (matId > 3.5) { alb = vec3(0.86, 0.48, 0.36); matRough = rough * 0.65; }\n      else { matRough = 0.78; }\n\n      float ao = clamp(0.42 + 0.58 * mapScene(p + n * 0.24).x / 0.24, 0.2, 1.0);\n      vec3 cleanPath = evalFullPath(p, n, v, matRough, iTime) * ao * gain;\n\n      // Secondary glossy inter-reflection between metallic sphere & glossy floor\n      vec3 rDir = reflect(rd, n);\n      float specBounce = pow(max(rDir.y * 0.5 + 0.5, 0.0), 2.5) * (1.0 - matRough) * 0.35;\n      cleanPath += mix(vec3(0.18, 0.85, 1.15), vec3(1.15, 0.32, 0.75), smoothstep(-0.6, 0.6, rDir.x)) * specBounce * gain;\n\n      if (!isPT) {\n        // Left: 1-spp path tracing struggles heavily on glossy multi-bounce paths (intense fireflies!)\n        vec2 rnd = hash22(floor(fragCoord * 0.75) + fract(iTime * 7.1) * 29.3);\n        float hitP = smoothstep(0.48, 0.92, rnd.x);\n        float firefly = pow(rnd.y, 5.5) * 6.5 * (1.15 - matRough * 0.6);\n        vec3 sparkCol = (rnd.x < 0.5) ? vec3(0.25, 1.35, 1.95) : vec3(1.95, 0.42, 0.98);\n        col = alb * (cleanPath * (0.22 + 1.55 * hitP) + sparkCol * firefly * 0.45);\n      } else {\n        // Right: ReSTIR PT Generalized Resampled Importance Sampling (GRIS) with hybrid shift mapping\n        float resNoise = (hash21(floor(fragCoord) + fract(iTime * 4.3) * 19.0) - 0.5) * 0.22 * (1.0 - reuse * 0.90);\n        col = alb * cleanPath * (1.0 + resNoise);\n      }\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-pt",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T19:53:35.000Z",
     "renderer": "Headless EGL Tesla T4/PCIe/SSE2, OpenGL 3.30 Core, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.5886,
      "std": 0.2688,
      "min": 0,
      "max": 0.9919
     },
     "image": "/specimens/restir-pt-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "restir-gi",
  "restir-di",
  "path-tracing",
  "path-guiding"
 ],
 "extends": [
  "restir-gi"
 ],
 "supersedes": [],
 "combines_with": [
  {
   "id": "path-guiding",
   "why": "Better initial candidate paths from a learned guiding distribution raise the quality of every reservoir."
  }
 ],
 "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-pt.json"
 },
 "solves": [
  "path tracing with many lights is too noisy at low spp",
  "real-time path tracing needs better sample reuse",
  "indirect lighting noise in complex scenes",
  "reuse full light paths between pixels and frames"
 ],
 "authority": "Lin et al., 2022",
 "url": "https://texelatlas.vercel.app/t/restir-pt/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 26.41,
  "tier": "heavy",
  "p50_ms": 0.8186,
  "p95_ms": 0.8325,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 36,
  "preset_id": "restir-pt-live",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 27.34,
   "tier": "heavy",
   "p50_ms": 0.4347,
   "p95_ms": 0.4383,
   "speedup_x": 1.88,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 17.21,
   "tier": "moderate",
   "p50_ms": 0.4957,
   "p95_ms": 0.4976,
   "speedup_x": 1.65,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}