ArticleslgStudy

computer science

Spatiotemporal reservoir resampling

Spatiotemporal reservoir resampling is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Spatiotemporal reservoir resampling rather than just read about it. In short: Spatiotemporal reservoir resampling, commonly known as ReSTIR (from "Reservoir-based SpatioTemporal Importance Resampling"), is a collection of computer graphics techniques for reusing samples during rendering. It was developed primarily to allow more realistic lighting in real-time rendering, because relatively few rays can be traced per pixel while maintaining an acceptable frame rate.

Spatiotemporal reservoir resampling — main illustration
Spatiotemporal reservoir resampling — illustration

Key takeaways

  • Spatiotemporal reservoir resampling belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Spatiotemporal reservoir resampling to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Spatiotemporal reservoir resampling from memory before moving on to harder problems.

Reference excerpt

Spatiotemporal reservoir resampling, commonly known as ReSTIR (from "Reservoir-based SpatioTemporal Importance Resampling"), is a collection of computer graphics techniques for reusing samples during rendering. It was developed primarily to allow more realistic lighting in real-time rendering, because relatively few rays can be traced per pixel while maintaining an acceptable frame rate. It can also be used to speed up off-line path tracing. The first ReSTIR paper, published in 2020, provided algorithms for direct lighting, allowing scenes containing thousands of lights to be rendered in real time on a high-end GPU. Researchers later proposed versions for rendering indirect lighting (and more recently, motion blur and depth of field) and built up a framework of mathematical concepts and notation conventions that help analyze such algorithms. A major focus of this work is removing or reducing the bias that could be introduced when samples from other pixels or frames are reused—or selectively allowing some bias in order to speed up rendering and reduce variance (visible as "noise" in the image). Versions for path tracing apply transformations called shift mappings to samples, typically reusing parts of paths closer to the light and modifying the portion closer to the camera. ReSTIR-related papers and talks have been presented every year at the SIGGRAPH conference since 2020. One of the first games to incorporate ReSTIR into its rendering was Cyberpunk 2077.

Overview and motivation According to Chris Wyman, one of the co-authors of the original paper, although developers commonly thought that bias was acceptable for real-time rendering, end users (e.g. gamers) are well-aware of the artifacts caused by bias and many have a negative opinion of common sample-reuse techniques such as temporal anti-aliasing (TAA), which may cause "ghosting" when the camera moves, and denoising, which causes blurring and other artifacts. ReSTIR techniques can reduce or avoid these types of bias by reusing samples of the set of possible paths taken by light to reach the camera, instead of reusing rendered pixel color values (which are typically the average of multiple samples, discarding information such as the direction of the light). While other techniques reuse samples in a generic post-processing step, ReSTIR passes can test for shadowing, and reused samples are converted into pixel color values by rendering code that takes the characteristics of different materials into account (e.g. by implementing BRDFs). However the output of ReSTIR is noisy, and a denoising pass is typically still used. Stochastic ray tracing techniques such as path tracing need to average multiple samples (produced by tracing individual rays) in order to render a visually acceptable image. When using a simple unbiased renderer based on Monte Carlo integration, halving the deviation of the result (apparent as "noise" in the image) requires multiplying the number of samples by four, meaning that a rapidly increasingly number of samples is needed to improve quality, Standard ways to mitigate this problem include importance sampling (which requires finding improved sampling distributions for specific situations), and quasi-Monte Carlo integration (which usually still requires tracing a large number of rays). ReSTIR offers a solution that multiplies the effective number of samples while tracing a fixed number of additional rays per frame. Temporal reuse multiplies the effective sample count by the number of frames rendered. Spatial reuse multiplies the effective count by the number of neighboring pixels examined. These two types of reuse can be combined, allowing spatial reuse to be applied recursively, which appears to offer an exponentially increasing effective sample count, however this is quickly limited by the size of the neighborhood used for spatial reuse. Spatial reuse is also potentially less effective near shadow and object edges, especially for objects with fine geometric detail, and temporal reuse is limited by movement of the camera and scene elements.

Variations Many variations of ReSTIR have been proposed that generalize or improve the original technique (which builds on an earlier method called RIS), specialize it for particular types of illumination or other visual effects, or allow incorporation into rendering algorithms other than standard path tracing. Some published versions are listed below.

Algorithms

Basic algorithm ReSTIR uses a combination of resampled importance sampling (RIS) and weighted reservoir sampling (WRS) which the authors call streaming RIS. RIS processes samples from an initial probability distribution (e.g. a probability distribution for which a cheap sampling method exists) and generates samples in a new probability distribution (e.g. a sampling distribution that is optimal for rendering but is impractical to draw samples from directly). WRS allows this to be done while storing only a small number of samples in memory, which is especially helpful on a GPU. Information about the samples is stored in a data structure called a reservoir. WRS also allows samples from multiple reservoirs to be combined ("merged") into a single reservoir; this is crucial for sample reuse. Each pixel has a reservoir, typically containing only a single sample when ReSTIR is used for real-time rendering (some implementations use a larger number, e.g. four samples). The reservoir is typically initialized to a sample drawn using a simple method and is then updated by RIS steps and by reservoir merging, so that the pixel value produced by shading using the sample(s) currently in the reservoir, times the weight for the sample, is always an unbiased estimate of the correct pixel value. If appropriate resampling steps are used, the variance of this estimate (or some function of it, typically the luminance of the RGB color value) decreases with each step. A possible sequence of steps performed for each frame, suitable for computing unbiased direct illumination (DI) is:

… excerpt ends here. Continue reading the full article.

Illustrations

Spatiotemporal reservoir resampling: A 3D model (figurine of a dancer) rendered using simple Monte Carlo integration, resampled importance sampling (RIS), ReSTIR spatial reuse, and denoised ReSTIR. Only direct light was rendered, using an environment map to simulate a scene with many lights. All images except the denoised image are unbiased. At most 5 rays were traced per pixel in each image.Top left: (Monte Carlo integration) 5 light samples per pixel, up to 5 rays traced to test shadowingTop right: (RIS) 32 light samples, 1 ray traced to test shadowing; faster if light samples are cheap and tracing rays is expensiveBottom left: Two ReSTIR spatial reuse passes (after initial light sampling using RIS), 4 additional rays per pixelBottom right: ReSTIR output processed using Intel Open Image Denoise
A 3D model (figurine of a dancer) rendered using simple Monte Carlo integration, resampled importance sampling (RIS), ReSTIR spatial reuse, and denoised ReSTIR. Only direct light was rendered, using an environment map to simulate a scene with many lights. All images except the denoised image are unbiased. At most 5 rays were traced per pixel in each image.Top left: (Monte Carlo integration) 5 light samples per pixel, up to 5 rays traced to test shadowingTop right: (RIS) 32 light samples, 1 ray traced to test shadowing; faster if light samples are cheap and tracing rays is expensiveBottom left: Two ReSTIR spatial reuse passes (after initial light sampling using RIS), 4 additional rays per pixelBottom right: ReSTIR output processed using Intel Open Image Denoise
Spatiotemporal reservoir resampling: A zoomed out version of the above image
A zoomed out version of the above image
Spatiotemporal reservoir resampling: An extreme example of color noise in a scene with three colors of light. In the top image one thousand samples were averaged. In the bottom image a single, weighted sample was used for rendering (selected using streaming RIS from one thousand samples); each pixel uses the color of a single light source, which produces very visible noise even though the pixels have approximately the correct brightness. (Some pixels look too dark due to clipping of the blue channel during conversion to 8-bit sRGB color.)
An extreme example of color noise in a scene with three colors of light. In the top image one thousand samples were averaged. In the bottom image a single, weighted sample was used for rendering (selected using streaming RIS from one thousand samples); each pixel uses the color of a single light source, which produces very visible noise even though the pixels have approximately the correct brightness. (Some pixels look too dark due to clipping of the blue channel during conversion to 8-bit sRGB color.)
Spatiotemporal reservoir resampling: The output of the Open Image Denoise NN-based denoiser, applied to the image at the beginning of the article. Top shows denoising of 5 sample Monte Carlo integration. Middle shows denoising of ReSTIR (RIS + spatial reuse) output. The bottom is a reference image using 4096 samples of Monte Carlo integration. The improved samples produced by ReSTIR allow the denoiser to reconstruct an image that appears more detailed and more similar to the reference image.
The output of the Open Image Denoise NN-based denoiser, applied to the image at the beginning of the article. Top shows denoising of 5 sample Monte Carlo integration. Middle shows denoising of ReSTIR (RIS + spatial reuse) output. The bottom is a reference image using 4096 samples of Monte Carlo integration. The improved samples produced by ReSTIR allow the denoiser to reconstruct an image that appears more detailed and more similar to the reference image.

Worked examples

Example 1 — a first encounter with Spatiotemporal reservoir resampling

Start with the simplest possible case. Write down what Spatiotemporal reservoir resampling claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Spatiotemporal reservoir resampling before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Spatiotemporal reservoir resampling ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Spatiotemporal reservoir resampling

In research
Spatiotemporal reservoir resampling appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Spatiotemporal reservoir resampling in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Spatiotemporal reservoir resampling is common in secondary-school and first-year university syllabi. It links to neighbouring topics 3D rendering, Computer graphics, Global illumination algorithms, so understanding it makes those chapters shorter.
In everyday life
Look for Spatiotemporal reservoir resampling outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Spatiotemporal reservoir resampling” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Spatiotemporal reservoir resampling in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Spatiotemporal reservoir resampling means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Spatiotemporal reservoir resampling out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Spatiotemporal reservoir resampling in simple terms?

Spatiotemporal reservoir resampling, commonly known as ReSTIR (from "Reservoir-based SpatioTemporal Importance Resampling"), is a collection of computer graphics techniques for reusing samples during rendering. It was developed primarily to allow more realistic lighting in real-time rendering, beca…

Why does Spatiotemporal reservoir resampling matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Spatiotemporal reservoir resampling?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Spatiotemporal reservoir resampling.

Tags

  • 3D rendering
  • Computer graphics
  • Global illumination algorithms
  • Monte Carlo methods
  • Ray tracing (graphics)

Keep exploring