Time-gated ReSTIR (TimeGatedReSTIRInline)¶
This render pass renders the same time-gated image as the time-gated path tracer, the radiance of the paths whose optical length falls inside the gate, but with ReSTIR: every pixel samples candidate paths, keeps one in a reservoir, and then resamples the reservoirs of neighboring pixels (spatial reuse) and of the previous frame (temporal reuse). A reused path is moved to the new pixel and gate with a path-length-aware shift mapping, which keeps its length inside the gate. This finds many more paths that fit a narrow gate than path tracing does in the same time.
Parameters¶
The time gate is set as for the path tracer:
Parameter |
Type |
Description |
|---|---|---|
|
string |
Gate kernel: |
|
float |
Gate width \(\Delta\), in path-length units. (Default: |
|
float |
Range of gate centers. Equal values give a single fixed gate. (Default: |
|
float |
Shortcut for a single fixed gate: sets |
|
integer |
Number of gate centers from |
|
boolean |
Move the gate to the next center after every frame, wrapping from |
Initial sampling, the candidate paths each pixel starts from in every frame:
Parameter |
Type |
Description |
|---|---|---|
|
integer |
Camera paths traced per pixel in each frame; every connection to the laser spot along them is
a candidate. (Default: |
|
integer |
Maximum number of surface vertices on a candidate path, counting the primary hit and any
vertex inserted by an ellipsoidal connection. The primary hit itself is not connected to the
laser spot. |
|
string |
How a candidate path’s vertices are connected to the laser spot: |
|
float |
With |
|
string |
How an ellipsoidal connection picks the scene triangle to place its vertex on: |
|
float |
Triangles larger than this (world-space area) never hold an ellipsoidal vertex, e.g. an NLOS
relay wall that would take most samples; paths through them come from BSDF sampling. Unused with
|
|
boolean |
Importance-sample the BSDF when extending a candidate path. (Default: |
|
boolean |
Shrink mapping: trace candidate paths with a wide gate and shrink them into the gate. See
Shrink mapping. (Default: |
|
float |
Width of the wide gate. 0 uses 10 x |
|
float |
Fraction of the camera paths traced with the wide gate, clamped to [0, 1]; the others use the
gate itself. (Default: |
Reuse:
Parameter |
Type |
Description |
|---|---|---|
|
integer |
Rounds of spatial reuse per frame. 0 turns spatial reuse off. (Default: |
|
integer |
Neighbor pixels resampled in each round. (Default: |
|
float |
Radius, in pixels, within which the neighbors are chosen. (Default: |
|
boolean |
Run each spatial round as two passes (every candidate’s shifts in its own thread, then the
resampling), which is faster with a length-aware shift. |
|
boolean |
Resample the previous frame’s reservoir, reprojected with motion vectors when the |
|
float |
Cap on the history’s sample count, in frames of |
|
boolean |
Keep the temporal history when the laser moves or changes, re-evaluating the lighting of
reused paths. Otherwise any laser change discards the history. (Default: |
|
integer |
Seed of the random numbers in spatial reuse; it advances with every round. (Default: |
Shift mapping:
Parameter |
Type |
Description |
|---|---|---|
|
string |
The chart on which the reconnection vertex is moved: |
|
float |
A path can reconnect at a segment only if both of its vertices are rougher than this.
(Default: |
|
float |
A path can reconnect at a segment only if it is longer than this, in scene units. Very short
segments make the shift nearly singular. (Default: |
|
string |
Fixes the direction the path-length constraint leaves free. |
|
float pair |
Chart-space axis for |
|
integer |
Maximum Newton iterations per shift. A solve cut off by the cap can fail in one direction of a pair only, which
biases reuse (with temporal reuse and ray charts most: |
|
float |
Tolerance of the shift solve on the path length, relative to the path-length change of the shift, and at least
the float32 resolution of the path lengths involved. Looser solves leave the forward and reverse shifts slightly
inconsistent, which biases reuse. (Default: |
|
float |
|
|
boolean |
Keep a shift only if the reverse shift maps it back to its start, at the cost of a second shift. Newton’s method
is local, so a rare shift reaches another solution than its reverse, mostly with a ray chart; the check removes
most of the bias this leaves. |
|
boolean |
|
Other:
Parameter |
Type |
Description |
|---|---|---|
|
boolean |
Include the shortest path, camera -> primary hit -> laser spot. It is evaluated at the primary
hit without reuse and added to the output after reuse; see Every frame.
(Default: |
|
boolean |
Keep one channel of the image, chosen by |
|
string |
The channel kept by |
|
boolean |
Honor alpha-tested materials when tracing rays. (Default: |
|
boolean |
Add the |
The reservoirs resample by the luminance of the path contribution, or by the channel kept with
useSingleChannel.
Every frame¶
Initial sampling. Every pixel traces
samplesPerPixelpaths from its primary hit, connects their vertices to the laser spot as the path tracer does, and keeps one of these candidates in its reservoir, chosen in proportion to its contribution through the gate.Temporal reuse (with
useTemporalReuse). The pixel resamples its reservoir from the previous frame, shifted to the current gate.Spatial reuse,
spatialReuseIterationrounds. The pixel resamples the reservoirs ofspatialReuseNeighborCountrandom pixels withinspatialReuseGatherRadius, each shifted to this pixel. Neighbors without a primary hit, or whose primary hit differs too much in normal or depth, are skipped.Output. The pixel’s reservoir gives its estimate of the time-gated image.
Primary-hit direct (with
computeDirect). The path camera -> primary hit -> laser spot is evaluated in step 1 on its own, kept out of the reservoirs, and added to the output after the last reuse step. Its length is fixed for each pixel, so reuse would not help it.
Reuse gives a lower-variance image per frame, but not an independent one: neighboring pixels and
consecutive frames share paths. Averaging frames with AccumulatePass reduces the remaining
noise.
Shift mapping¶
Reusing a path at another pixel changes its first segments (a different primary hit, and possibly
a different gate), so its length changes too. The shift keeps the rest of the path and moves the
reconnection vertex, the first vertex where the path may reconnect (a segment whose two
vertices are both rougher than reconnectionRoughnessThreshold and that is longer than
reconnectionMinDistance), so that the shifted path has the length it needs. The move is a Newton
solve on a 2D chart around that vertex, chosen by shiftMappingMethod; the path-length constraint
fixes only one direction, and gaugeMode fixes the other. radial instead moves the vertex along
the ray, in the vertex’s plane, from the point where the path length is shortest (a 1D search), so
it needs no gauge. With no, the vertex is not moved, so the shifted path often no longer fits
the gate.
Reuse is unbiased only if the shift from a pixel to its neighbor and the shift back are inverse. The two equations
(the path length and the gauge) have more than one solution, and Newton’s method is local: it finds the solution its
start leads to, from the vertex for the forward shift and from the moved vertex for the reverse. The solve therefore
converges both equations and keeps a solution only on its start’s branch: the path lengths at both ends change the
same way along the move, the move keeps the orientation, and with a ray chart the vertex stays on its object. With
avg_grad and shiftReachCheck, it also keeps a solution only within the reach of Newton’s method from both ends:
the first Newton step from each end must land within half the move of the other end. Both pixels of a pair evaluate
the same tests, so they accept the same shifts.
avg_grad moves the vertex along the path-length gradient, where the length changes fastest on the surface, so the
move is as short as the length change allows and both solves start close to their solutions. constant moves the
vertex along a fixed chart axis, which needs a long move wherever the gradient is nearly orthogonal to that axis.
local_tangent with avg_grad is a good starting point, and the tutorials use it.
Because Newton’s method is local, a rare shift can still reach another solution than its reverse. This happens near
the minimum of the path length, where avg_grad’s two solutions come close (in a transient histogram: the bins at
the onset of a bounce), and with a ray chart, whose coordinates do not follow the surface. In our tests with temporal
reuse, against the exact radial shift: local_tangent with avg_grad within 0.1 % (a transient histogram: -0.08 %
with shiftReachCheck, -0.5 % without); ray_trace_chart +0.4 % with avg_grad on a finely tessellated model
(+1.9 % without the reach check) and +0.5 % with constant in the Cornell box. shiftRoundTripCheck removes most of
the rest, at the cost of a second shift. Both checks are off by default: without temporal reuse the bias is small,
and both cost more than they save there (Cornell box scenes, spatial reuse, equal time: 8-20 % more error with the
reach check, which rejects valid shifts too, and 8-39 % with the round-trip check, which takes up to 50 % longer
with ray charts). Turn one on for temporal reuse, transient histograms or ray charts. radial is one-to-one without
either check.
Moving the gate¶
With shiftGate and timeMax above timeMin, the gate moves to the next center after every
frame. Temporal reuse keeps its history and shifts the previous frame’s paths to the new gate. The
move also flags the render graph, which restarts downstream accumulation.
From a script, set_time_gate_info(timeMin, timeMax, timeBin) sets the gate range, and
increment_time_gate_frame() advances the gate index. Both keep the temporal history, and
neither restarts downstream accumulation; reset an AccumulatePass yourself if you use one.
Changing an option in the UI or with set_properties() discards the history.
When the history is discarded¶
The temporal history is discarded, and the next frame starts from its own samples only, when:
an option changes in the UI or with
set_properties(),the scene changes in any way other than camera motion, including a camera animated by the scene (without
isSceneDynamic, a laser change counts too),the frame size changes, or
the camera uses depth of field.
Per pixel, the history is reused only if it saw the same surface: the same material, an orientation within about 45 degrees and a distance within 10 % (otherwise, e.g. where the camera’s motion uncovers a surface, the pixel starts from its own samples).
Limitations¶
Static scene geometry: the camera may move (and, with
isSceneDynamic, the laser), but objects may not move or deform; the history is discarded when geometry changes, as above.Layered materials (for example pbrt’s
coateddiffuseandcoatedconductor) are not supported.
Shrink mapping¶
With useShrinkMapping, direct sampling and a box or tent gate, a fraction
wideGateSampleRatio of the candidate paths is traced against the wide gate, of width
wideGateWindow (10 x timeGateWindow unless set), and shrunk into the gate with the
path-length shift. This finds candidates for very narrow gates that direct sampling rarely hits.
It has no effect when the wide gate is not wider than timeGateWindow, or when
wideGateSampleRatio x samplesPerPixel is below 1.
With a fraction of 1, every candidate uses the wide gate, and paths whose shift fails are lost: in a test on the Cornell box (0.01 gate), the image was about 7 % darker than the reference. A fraction below 1 keeps some candidates on the gate itself; with 0.5 and a wide gate 5 x the gate the difference was under 1 %.
Connection sampling¶
As for the path tracer: direct connects every vertex to the
laser spot, ellipsoidal inserts a vertex whose length fits the gate, and ellipsoidal_direct_mis
combines both. With isSceneDynamic, ellipsoidal sampling supports at most 3 bounces. The same surfaces
as in the path tracer can hold the ellipsoidal vertex (see its connection sampling): the
triangles are collected once per scene, so animated geometry is not followed.
Laser¶
The laser is set on the LaserLight pass, as for the path tracer.
Inputs and outputs¶
Channel |
Description |
|---|---|
|
Primary hits, from |
|
Primary ray directions, from |
|
Motion vectors, from |
|
Time-gated image, RGBA32Float. |
|
Per pixel: mapping successes, successes after visibility, attempts, and the sum of Newton iterations, RGBA32Uint. |
|
Per pixel: summed chart-space and world-space displacement of successful shifts, RG32Float. |
Example¶
testbed.load_scene("cornell-box/scene-v4-nolight.pbrt", falcor.SceneBuilderFlags.DontMergeMaterials)
graph = testbed.create_render_graph("TimeGatedReSTIR")
graph.create_pass("VBuffer", "VBufferRT", {"samplePattern": "Center", "sampleCount": 1})
graph.create_pass("Laser", "LaserLight", {
"laserPosition": [0.0, 1.7, 6.8], "laserDirection": [0.0, 0.0, -1.0], "laserPower": [170.0, 120.0, 40.0],
})
graph.create_pass("Tracer", "TimeGatedReSTIRInline", {
"samplesPerPixel": 16, "maxBounces": 6,
"timeGateMode": "box", "timeGateWindow": 0.02, "timeCenter": 17.337,
"spatialReuseIteration": 3, "spatialReuseNeighborCount": 5,
"shiftMappingMethod": "local_tangent", "gaugeMode": "avg_grad",
"reconnectionRoughnessThreshold": 0.05,
})
graph.add_edge("VBuffer.vbuffer", "Tracer.vbuffer")
graph.add_edge("VBuffer.viewW", "Tracer.viewW")
graph.add_edge("Laser", "Tracer") # run the laser pass first
graph.mark_output("Tracer.color")
testbed.render_graph = graph
See the offline and online ReSTIR tutorials for complete scripts.