Part 3 of the Metal PathTracer Architecture series, based on the renderer documentation snapshot created on May 14, 2026.

ReSTIR is one of those names that can compress a lot of different ideas into a single word. In my Metal renderer, the implementation is better understood as several related experiments: reservoir-based direct-light sampling, screen-space temporal and spatial reuse, ReGIR-style world-reuse plumbing, and bounded prototypes for indirect path reuse. They share concepts, but they are not one finished system. Being precise about that distinction is part of making the experiments useful.

The common thread is reservoir sampling. Rather than keeping every candidate light sample, a reservoir keeps a selected payload together with the information needed to interpret that selection. In the direct-light path, the stored state includes the chosen light payload, the sum of weights, a represented sample count, the final weight, and a validity flag. The reservoir is compact, but its meaning depends on how candidates were generated, weighted, and reused.

The small core

Candidate selection uses weighted reservoir sampling. When a candidate arrives, its probability of replacing the current selection is based on its weight divided by the accumulated weight sum:

accept probability = candidate_weight / accumulated_weight_sum

This gives me a way to process a stream of candidates without storing the whole stream. It does not, by itself, solve direct lighting. The candidate weight still has to represent a useful estimate of the candidate’s contribution, and a reused reservoir still has to be compatible with the surface and sampling context where it is applied.

The current target-weight proxy is luminance-based:

p_hat = luminance(Le) * luminance(BSDF) * cos(surface) * cos(light) / distance^2

This is a practical experiment, not a universal statement about the correct target function for every material and light. The implementation rejects candidates with invalid PDFs, invalid BSDF evaluation, delta-only behavior, BSSRDF events, or non-finite values. Those rejection rules are important because a reservoir can otherwise retain a mathematically tidy record of an unusable sample.

Direct-light reuse in passes

The explicit ReSTIR DI path has separate state for current, previous, temporal, and spatial reservoirs, along with visibility state and optional debug AOVs. The screen-space sequence is also explicit: initialize, generate initial candidates, perform temporal reuse, perform spatial reuse, evaluate visibility, apply lighting, and optionally write debug output.

That sequence gives me useful handles for investigation. If a reused sample is wrong, I can ask whether the problem entered with the initial candidates, during temporal history, during spatial neighbors, or at visibility evaluation. If a result changes when debug output is enabled, I have a concrete pass boundary to inspect rather than a single opaque kernel.

The available direct-light modes include legacy rectangle-light sampling, baseline emissive sampling, RIS, spatial and temporal RIS reuse, world reuse, a RIS/ReGIR-style cache, ReSTIR DI, and a ReSTIR DI plus ReGIR-style hybrid. These names describe selectable paths in the renderer, not a claim that each is equally complete.

The provider boundary is especially worth stating. Candidate plumbing can include emissive primitives, analytic rectangle lights, an environment provider, and ReGIR provider slots. In the inspected helper path, the environment and ReGIR functions are present as provider slots but return no sample directly there. The hybrid mode is represented by feature gates, state, and debug views, but that should not be described as a production world-reuse implementation.

A bounded indirect experiment

The indirect work is intentionally narrower. ReSTIR GI is currently a diffuse-first prototype. In the inspected path it is eligible only for a conservative first diffuse bounce, in a non-specular-only mode, on a guideable and ReSTIR-eligible material. The reused event must be non-delta, non-BSSRDF, non-transmission, and have finite direction, PDF, and weight.

When those conditions hold, the prototype can store and reload a direction from reservoir-style state, check compatibility through normal agreement and sample luminance, and replace the current BSDF sample with a reweighted reused direction. That is enough to study the mechanics and failure modes of indirect reuse. It is not enough to claim broad global-illumination coverage across every lobe and transport configuration.

The path-tracing variant is even more explicitly bounded. The ReSTIR PT work is a research scaffold plus an experimental path-reuse mode. The scaffold records eligible deeper diffuse samples into path reservoirs and exposes counters. The experimental mode can blend the current sample direction toward a compatible stored reservoir direction, controlled by reuse strength and confidence.

Its exclusions are part of the result: specular, glass and transmission, delta, BSSRDF, unsupported lobe, invalid-PDF, and non-finite states are left out. Those rules may make the prototype less dramatic in a demo, but they make its behavior legible. A reuse mask can then mean “a compatible experiment was applied,” rather than “the renderer reused arbitrary transport history.”

Debug views are evidence, not decoration

The renderer includes views for candidate source ID, reservoir confidence, ReGIR or world-cell ID, path-guiding usage, ReSTIR PT reuse, a SVGF-style variance proxy, NaN/Inf detection, and radiance-cache state. I use these as audit views. They help reveal where a candidate came from, whether confidence is collapsing, and whether a numerical failure is being hidden by reconstruction.

A debug view is not a beauty-quality improvement by itself. It is a way of checking an assertion about the algorithm. A bright frame with lower apparent noise is not sufficient evidence that reuse is correct. I want to know which candidates were selected, which reservoirs survived validation, where visibility was evaluated, and whether the reused direction satisfied the eligibility rules.

What I can claim today

The accurate description is that the renderer contains ReSTIR-style direct-light and world-reuse experiments, with explicit reservoir state and screen-space passes. It also contains bounded diffuse-first GI and path-reservoir prototypes. Several advanced modes are gated and disabled by default so they cannot silently alter baseline renders.

That wording may sound cautious, but it is also more informative. It tells a reader where the implementation is concrete—the reservoir core, the direct-light passes, the state and debug views—and where it remains exploratory—the provider coverage, indirect reuse breadth, and production-level guarantees. It keeps a research scaffold from being mistaken for a finished ReSTIR PT system.

The next useful work is not to add a stronger label. It is to measure each path against the baseline, retain the exclusions and counters, and expand eligibility only when the estimator and compatibility rules are understood. Reservoir sampling gives the renderer a compact way to reason about many candidates. The engineering challenge is making sure that compact state still carries an honest account of what was sampled, reused, rejected, and finally applied.

Continue the series

Previous: From Megakernel to Wavefront on Apple GPUs.

Next: Guiding and Caching Diffuse Indirect Light.