This repository contains the source code for the HPG 2024 paper:
ReSTIR Subsurface Scattering for Real-Time Path Tracing
Mirco Werner, Vincent Schüßler, and Carsten Dachsbacher
Abstract Subsurface scattering is an important visual cue and in real-time rendering it is often approximated using screen-space algorithms. Path tracing with the diffusion approximation can easily overcome the limitations of these algorithms, but increases image noise. We improve its efficiency by applying reservoir-based spatio-temporal importance resampling (ReSTIR) to subsurface light transport paths. For this, we adopt BSSRDF importance sampling for generating candidates. Further, spatiotemporal reuse requires shifting paths between domains. We observe that different image regions benefit most from either reconnecting through the translucent object (reconnection shift), or one vertex later (delayed reconnection shift). We first introduce a local subsurface scattering specific criterion for a hybrid shift that deterministically selects one of the two shifts for a path. Due to the locality, it cannot always choose the most efficient shift, e.g. near shadow boundaries. Therefore, we additionally propose a novel sequential shift to combine multiple shift mappings: We execute subsequent resampling passes, each one using a different shift, which does not require to deterministically choose a shift for a path. Instead, resampling can pick the most successful shift implicitly. Our method achieves real-time performance and significantly reduces noise and denoising artifacts in regions with visible subsurface scattering compared to standard path tracing with equal render time.
ReSTIRSSS/resources/shaders/main/
contains the GLSL shaders for ReSTIR SSS.
- ReSTIR SSS passes:
restirsss_pass_candidate_generation
,restirsss_pass_temporal_reuse
,restirsss_pass_spatial_reuse
, andrestirsss_pass_shade
- ReSTIR SSS reservoir:
restirsss_reservoir
- ReSTIR SSS target function:
restirsss_target_function
- ReSTIR SSS shifts (reconnection, delayed reconnection, hybrid, sequential) and their Jacobians:
restirsss_shift
- MIS weights (generalized balance heuristic, streaming pairwise MIS):
restirsss_mis
Our sequential shift strategy uses probabilistic inversion to draw new random numbers before applying random replay when shifting a path with delayed reconnection (see paper Sec. 4.3 for details).
We also demonstrate the possibility to use probabilistic inversion in ReSTIR in general to use both path and primary sample space shifts for a certain sample by implementing it in a surface reflection case with a path of length 3 (see supplemental document Sec. 3 for details).
This demonstration can be enabled in restirsss_defines
using the RESTIRSSS_PROBINVERSETEST_L3PATH
macro.
Also see probinversetest
.
- Vulkan 1.3
- GPU with ray tracing support
- (optional) OptiX 8.0.0 or higher and CUDA Toolkit for denoising
Other dependencies are included as submodules in VkRaven/lib/
.
Tested on Linux with GCC 14.1.1 and NVIDIA RTX 3070 GPU.
Windows is not officially supported, however, we get it to run using MinGW and disabling OptiX support in the CMake configuration.
git clone --recursive git@github.com:MircoWerner/ReSTIR-SSS.git
cd ReSTIR-SSS/ReSTIRSSS
mkdir build
cd build
cmake ..
make
See ReSTIR SSS Assets repository for more details.
cd ReSTIR-SSS/ReSTIRSSS/resources
git clone git@github.com:MircoWerner/ReSTIR-SSS-Assets.git assets
cd assets/asiandragon
tar -xf dragon.tar.xz # unpack large file
cd ReSTIR-SSS/ReSTIRSSS/build
./restirsss ajax
- The provided scenes can be found in
ReSTIRSSS/resources/scenes/
:ajax
,ajaxmanylights
,asiandragon
,lteorb
,flattest
. - Use
--preset ...
to select the initial rendering mode. This can also be changed during runtime in the UI. - Use
--evaluate ...
to start the automatic evaluation to generate renderings (to measure errors) or timings as shown in the paper. The video option generates the frames for our short video.
Usage: restirsss [--help] [--version] [--preset VAR] [--evaluate VAR] scene
Positional arguments:
scene name of the scene (in resources/scenes/<name>.xml) [required]
Optional arguments:
-h, --help shows help message and exits
-v, --version prints version information and exits
--preset pathtracing, hybrid, sequential [default: "hybrid"]
--evaluate renderings, timing, video
WASD
to move the cameraSpace
orE
to move the camera upShift
orQ
to move the camera down- Hold
Ctrl
to move faster - Hold
Right Mouse Button
to look around Esc
to close the application
We would like to thank the creators and authors of the used assets and libraries:
- Ajax Bust by Jotero, Asian Dragon by XYZ RGB Inc, and LTE Orb by Yasutoshi Mori (@MirageYM).
- argsparse, glfw, glm, imgui, pugixml, SPIRV-Reflect, stb, tinygltf, tinyobjloader, and OptiX.