---
id: "restir-pt"
title: "ReSTIR PT and Generalized Resampled Importance Sampling"
aliases: [GRIS, ReSTIR path tracing]
domain: "gi"
stage: "lighting"
realtime: "realtime"
platforms: [desktop-gpu]
year_introduced: 2022
inputs: [gbuffer, mesh, material-params]
outputs: [radiance]
style: "photoreal"
dynamic: "dynamic"
cost: "heavy"
authority: "Lin et al., 2022"
url: "https://texelatlas.vercel.app/t/restir-pt/"
sources_verified_at: "2026-11-29"
---
# ReSTIR PT and Generalized Resampled Importance Sampling (Lin et al., 2022)

> 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.

## Reach for it when

- 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

## 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.

For 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.

The 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 it

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.

Prefer [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

heavy — 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.
Measured GPU Weight: 26.41× baseline (heavy) — 0.8186 ms median / 0.8325 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 27.34× baseline (heavy) — 0.4347 ms median (1.88× faster on L4).
Ampere A100 scaling: 17.21× baseline (moderate) — 0.4957 ms median (1.65× faster on A100).

## 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

## Dataflow

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

## Presets

### ReSTIR PT — noisy 1-spp multi-bounce path tracing (left) vs hybrid-shift path resampling (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_ROUGHNESS": 0.24,
  "P_REUSE_STR": 0.88,
  "P_EMIT_GAIN": 1.35,
  "P_SPLIT": 0.48
}
```

```glsl
const float P_ROUGHNESS = 0.24; // P Glossy Roughness [0.08, 0.65, 0.02]
const float P_REUSE_STR = 0.88; // P Path Reuse [0.0, 1.0, 0.02]
const float P_EMIT_GAIN = 1.35; // P Multi-Bounce [0.3, 2.4, 0.05]
const float P_SPLIT = 0.48; // P 1-spp / ReSTIR PT [0.0, 1.0, 0.02]

float hash21(vec2 p) {
  p = fract(p * vec2(127.1, 311.7));
  p += dot(p, p + 34.5);
  return fract(p.x * p.y);
}

vec2 hash22(vec2 p) {
  vec3 p3 = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));
  p3 += dot(p3, p3.yzx + 33.33);
  return fract((p3.xx + p3.yz) * p3.zy);
}

float sdBox(vec3 p, vec3 b) {
  vec3 q = abs(p) - b;
  return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0);
}

// Multi-bounce glossy + diffuse showcase: chrome-gold sphere, glossy floor, diffuse walls & moving neon rings
vec2 mapScene(vec3 p) {
  vec2 res = vec2(p.y + 0.82, 1.0); // glossy slate floor
  float dC = 1.05 - p.y; if (dC < res.x) res = vec2(dC, 2.0);
  float dB = p.z + 1.45; if (dB < res.x) res = vec2(dB, 2.0);
  float dL = p.x + 1.35; if (dL < res.x) res = vec2(dL, 2.0);
  float dR = 1.35 - p.x; if (dR < res.x) res = vec2(dR, 2.0);

  // Glossy metallic sphere + brushed copper cylinder (hard for diffuse-only ReSTIR GI, solved by ReSTIR PT!)
  float dSph = length(p - vec3(-0.36, -0.40, -0.22)) - 0.42;
  if (dSph < res.x) res = vec2(dSph, 3.0);
  float dCyl = max(length(p.xz - vec2(0.54, -0.35)) - 0.28, abs(p.y + 0.34) - 0.48);
  if (dCyl < res.x) res = vec2(dCyl, 4.0);

  // Emissive accent bars
  float dE1 = sdBox(p - vec3(-1.30, 0.32, -0.20), vec3(0.04, 0.42, 0.08));
  if (dE1 < res.x) res = vec2(dE1, 5.0);
  float dE2 = sdBox(p - vec3(1.30, 0.25, -0.30), vec3(0.04, 0.42, 0.08));
  if (dE2 < res.x) res = vec2(dE2, 6.0);
  return res;
}

vec3 calcNormal(vec3 p) {
  vec2 e = vec2(0.0022, 0.0);
  return normalize(vec3(
    mapScene(p + e.xyy).x - mapScene(p - e.xyy).x,
    mapScene(p + e.yxy).x - mapScene(p - e.yxy).x,
    mapScene(p + e.yyx).x - mapScene(p - e.yyx).x
  ));
}

// Evaluate glossy + diffuse multi-bounce target radiance (simulating ReSTIR PT hybrid shift mapping)
vec3 evalFullPath(vec3 p, vec3 n, vec3 v, float rough, float t) {
  vec3 e1 = vec3(-1.26, 0.32 + 0.14 * sin(t * 0.9), -0.20);
  vec3 e2 = vec3(1.26, 0.25 + 0.14 * cos(t * 0.8), -0.30);
  vec3 e3 = vec3(0.0, 0.96, -0.65);

  vec3 c1 = vec3(0.18, 1.35, 1.95);
  vec3 c2 = vec3(1.95, 0.35, 0.95);
  vec3 c3 = vec3(1.75, 1.25, 0.45);

  float specExp = mix(72.0, 6.0, clamp(rough, 0.05, 0.85));
  vec3 rad = vec3(0.0);

  vec3 d1 = e1 - p; float r1 = length(d1); vec3 l1 = d1 / max(r1, 1e-4);
  float s1 = pow(max(dot(n, normalize(l1 + v)), 0.0), specExp) * (0.25 + 1.25 * (1.0 - rough));
  rad += c1 * (max(dot(n, l1), 0.0) * 0.42 + s1) / (0.35 + r1 * r1 * 0.65);

  vec3 d2 = e2 - p; float r2 = length(d2); vec3 l2 = d2 / max(r2, 1e-4);
  float s2 = pow(max(dot(n, normalize(l2 + v)), 0.0), specExp) * (0.25 + 1.25 * (1.0 - rough));
  rad += c2 * (max(dot(n, l2), 0.0) * 0.42 + s2) / (0.35 + r2 * r2 * 0.65);

  vec3 d3 = e3 - p; float r3 = length(d3); vec3 l3 = d3 / max(r3, 1e-4);
  float s3 = pow(max(dot(n, normalize(l3 + v)), 0.0), specExp * 0.7) * (0.2 + 0.9 * (1.0 - rough));
  rad += c3 * (max(dot(n, l3), 0.0) * 0.36 + s3) / (0.45 + r3 * r3 * 0.65);

  return rad;
}

vec3 aces(vec3 x) {
  x = max(x, 0.0);
  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
  float screenX = fragCoord.x / max(iResolution.x, 1.0);
  float split = clamp(P_SPLIT, 0.0, 1.0);
  bool isPT = screenX >= split;
  float rough = clamp(P_ROUGHNESS, 0.06, 0.75);
  float reuse = clamp(P_REUSE_STR, 0.0, 1.0);
  float gain = clamp(P_EMIT_GAIN, 0.2, 2.5);

  vec3 ro = vec3(0.0, 0.05, 2.38);
  vec3 rd = normalize(vec3(uv, -1.52));

  vec3 col = vec3(0.02);
  float t = 0.0;
  float matId = 0.0;
  bool hit = false;
  for (int i = 0; i < 64; i++) {
    vec2 h = mapScene(ro + rd * t);
    if (h.x < 0.002) { hit = true; matId = h.y; break; }
    t += h.x;
    if (t > 9.0) break;
  }

  if (hit) {
    vec3 p = ro + rd * t;
    vec3 n = calcNormal(p);
    vec3 v = -rd;

    if (matId > 4.5) {
      col = (matId < 5.5) ? vec3(0.32, 2.5, 3.6) : vec3(3.6, 0.55, 1.9);
    } else {
      vec3 alb = vec3(0.62, 0.65, 0.70);
      float matRough = rough;
      if (matId < 1.5) { alb = vec3(0.32, 0.35, 0.42); matRough = rough * 0.75; }
      else if (matId > 2.5 && matId < 3.5) { alb = vec3(0.95, 0.78, 0.42); matRough = rough * 0.55; }
      else if (matId > 3.5) { alb = vec3(0.86, 0.48, 0.36); matRough = rough * 0.65; }
      else { matRough = 0.78; }

      float ao = clamp(0.42 + 0.58 * mapScene(p + n * 0.24).x / 0.24, 0.2, 1.0);
      vec3 cleanPath = evalFullPath(p, n, v, matRough, iTime) * ao * gain;

      // Secondary glossy inter-reflection between metallic sphere & glossy floor
      vec3 rDir = reflect(rd, n);
      float specBounce = pow(max(rDir.y * 0.5 + 0.5, 0.0), 2.5) * (1.0 - matRough) * 0.35;
      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;

      if (!isPT) {
        // Left: 1-spp path tracing struggles heavily on glossy multi-bounce paths (intense fireflies!)
        vec2 rnd = hash22(floor(fragCoord * 0.75) + fract(iTime * 7.1) * 29.3);
        float hitP = smoothstep(0.48, 0.92, rnd.x);
        float firefly = pow(rnd.y, 5.5) * 6.5 * (1.15 - matRough * 0.6);
        vec3 sparkCol = (rnd.x < 0.5) ? vec3(0.25, 1.35, 1.95) : vec3(1.95, 0.42, 0.98);
        col = alb * (cleanPath * (0.22 + 1.55 * hitP) + sparkCol * firefly * 0.45);
      } else {
        // Right: ReSTIR PT Generalized Resampled Importance Sampling (GRIS) with hybrid shift mapping
        float resNoise = (hash21(floor(fragCoord) + fract(iTime * 4.3) * 19.0) - 0.5) * 0.22 * (1.0 - reuse * 0.90);
        col = alb * cleanPath * (1.0 + resNoise);
      }
    }
  }

  float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));
  col = mix(col, vec3(0.95, 0.97, 1.0), sep);

  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}
```

Attribution: MIT — written for this index.

## Lineage

- extends [ReSTIR GI: Path Resampling for Real-Time Path Tracing](https://texelatlas.vercel.app/t/restir-gi.md)

## Combines with

- [Practical Path Guiding](https://texelatlas.vercel.app/t/path-guiding.md): Better initial candidate paths from a learned guiding distribution raise the quality of every reservoir.

## Combination ideas

- [ReSTIR path-traced relighting on 2D Gaussian surfels](https://texelatlas.vercel.app/ideas/surfel-splats-restir-path-tracing/)

## Sources

1. [primary] Daqi Lin, Markus Kettunen, Benedikt Bitterli, Jacopo Pantaleoni, Cem Yuksel, Chris Wyman (2022) Generalized resampled importance sampling. ACM Transactions on Graphics. https://doi.org/10.1145/3528223.3530158 (verified via crossref on 2026-11-29)
2. [implementation] DQLin (2022) DQLin/ReSTIR_PT. https://github.com/DQLin/ReSTIR_PT License: BSD-3-Clause. (verified via github on 2026-11-29)

## Cite this entry

Texel. "ReSTIR PT and Generalized Resampled Importance Sampling." https://texelatlas.vercel.app/t/restir-pt/ (accessed 2026-12-01).
