Improvements to
GPU performance and
ray tracing acceleration have enabled the widespread use of ray tracing in
video games, but in order to render realistic lighting in scenes lit by large numbers of lights, and diffuse global illumination with many bounces, many rays must be cast. This is challenging to do in
real time at an acceptable frame rate, especially when rendering large, detailed environments (in particular, unbiased path tracing, with arbitrary path lengths, is usually not practical in real time). One approach to address this is to share data between pixels in the image, or between consecutive frames, so fewer ray casts need to be performed per pixel. This is commonly done by denoisers and
temporal anti-aliasing (which both enable using fewer samples per pixel), however they can cause blurring of the image, "ghosting" artifacts across frames, light leakage around corners, and other types of bias. Reuse algorithms based on precomputation and caching may not respond quickly enough to lighting changes during real-time rendering, and may cause significant bias. A family of techniques called
spatiotemporal reservoir resampling, or
ReSTIR, allows sharing of samples between nearby pixels, and carrying samples forward to the next frame even when objects or the camera have moved. It can do this without introducing bias, or it can be used in biased modes that have better performance and less noise. ReSTIR consists of steps to generate new direct light or global illumination samples for a particular pixel,
spatial reuse steps that try to reuse samples from nearby pixels, and
temporal reuse steps that try to reuse samples from the previous frame (using
optical flow, also known as
temporal reprojection or
backprojection, to choose a corresponding pixel, accounting for movement of the camera and scene objects). ReSTIR uses a form of weighted
reservoir sampling, maintaining a data structure called a
reservoir for each pixel. The reservoir stores a single sample along with a
weight similar to the weights used in
importance sampling. (Reservoirs storing more than one sample can also be used: the original ReSTIR implementation used 4 samples per reservoir for its biased version but only 1 sample for the more expensive unbiased version). The earliest form of ReSTIR, now called ReSTIR DI, is designed for direct lighting in scenes with many lights. To generate initial samples, it uses an older technique called
resampled importance sampling (RIS). It take many samples of lights cheaply (without considering visibility) and chooses one based on how bright the samples are (this is an approximate or stochastic form of importance sampling). The chosen sample (e.g. a point on a specific light) is then tested to determine if it is visible (if not, it can be treated as a light sample with zero brightness) and is stored in the reservoir, along with a weight. During spatial reuse steps, another pixel is chosen randomly from a
neighborhood around the target pixel (e.g. all pixels with distance less than 30 pixels away). The sample in this other pixel's reservoir is then merged into the target pixel's reservoir by computing multiple importance sampling (MIS) weights for the two samples and choosing a sample using probabilities proportional to the weights (a similar procedure to RIS). The weight in the reservoir is updated whether or not the other pixel's sample was chosen. This process is expensive in unbiased versions, because computing the MIS weights requires knowing visibility and brightness for both of the light samples, at the surface points corresponding to both pixels, which usually involves tracing two rays or paths (this cost can be reduced by using a reciprocal reuse pattern). Some implementations examine multiple neighboring pixels (e.g. 4 neighbors) and choose one, which helps reduce variance but is more expensive, requiring tracing more rays. Temporal reuse, reusing samples from a corresponding pixel in the previous frame, is implemented in a similar way to spatial reuse. Because the camera and objects in the scene may have moved and lighting may have changed, visibility and brightness of both light samples at the surface point in both frames needs to be computed in order to calculate the correct weights, again usually requiring tracing two additional rays. A typical sequence of steps per frame (likely requiring multiple passes over all pixels) would be: • Generate new initial samples for pixels • Perform temporal reuse • Perform spatial reuse (one or more times) • Render the pixels for the current frame using the samples now in the reservoirs • Perform denoising of the rendered image By combining the steps in this way, samples can quickly propagate to neighboring pixels allowing a large amount of potential reuse of any "good" samples that are found. This can be helpful in difficult lighting situations (e.g. when there are many lights but most of them are shadowed) however excessive reuse of a small number of samples causes correlation artifacts that can be very visible. Path tracing can use the unbiased version of ReSTIR DI to compute direct light for the first surface point intersected by the camera ray. A more general version of ReSTIR for path tracing, called ReSTIR PT, extends the algorithm to support reusing arbitrary paths instead of just direct light samples. This involves applying a
shift mapping transformation to a sample to make it applicable to the position and surface orientation needed by a different pixel or a different frame (shift mappings were introduced as part of gradient domain rendering). For example a shift mapping called the
reconnection shift makes it possible to reuse the portion of a path after the second surface intersection, only needing to trace one ray to check visibility between the first and second intersections. The reconnection shift is very effective for diffuse global illumination, and is the basis of a simplified algorithm called ReSTIR GI (which assumes all surfaces are
Lambertian at the second intersection) that has been used in games. ReSTIR is primarily intended for real-time rendering, but it can also be used to speed up offline rendering. Although ReSTIR can be unbiased, potential drawbacks (which may make it less suitable for offline rendering) include unwanted correlation between errors in adjacent pixels (which may produce artifacts) and between frames (which may prevent convergence), and
color noise (brightness of the pixels is correct, but the color has noise that does not decrease with multiple passes). To mitigate these problems, the temporal reuse portion can be omitted, and instead initial sampling and spatial reuse are repeated multiple times and the results are averaged. Many variations of ReSTIR now exist, applying the technique to volume rendering, and to depth of field and motion blur effects, and combining it with other techniques such as path guiding. Although most forms of ReSTIR work in
screen space (with a reservoir for each pixel) there also exist
world space versions that use RIS and spatiotemporal reuse to find good light samples for regions of space in a 3D grid. ==See also==