Restir_DI_CPP
A C++ implementation of Restir inside Falcor 8.0
git clone https://github.com/Trylz/Restir_DI_CPP.gitTrylz/Restir_DI_CPPRestir DI implementation using Nvidia Falcor
This repository host a C++ implementation of the Restir algorithm inside Falcor 8.0.


Video showcase: https://www.youtube.com/watch?v=pyQrblYP_VY
Source code: https://github.com/Trylz/Restir_CPP/tree/main/Source/Samples/Restir
Here the original paper: https://research.nvidia.com/sites/default/files/pubs/2020-07_Spatiotemporal-reservoir-resampling/ReSTIR.pdf
How to test
Grab necessary assets
The dragon buddha model used is huge. Git doesnt allow me to push files that are greater than 100 MB. That model need to be installed has explained here: https://github.com/Trylz/Restir_CPP/blob/main/TestScenes/DragonBuddha/README.txt
Controls
W, A, S, D, Q, E
Z, Q, S, D, A, E for Azerty keyboard
Mouse left click for rotation.
Building prerequisites
-
Windows 10 version 20H2 (October 2020 Update) or newer, OS build revision .789 or newer
-
Visual Studio 2022: https://aka.ms/vs/17/release/vs_community.exe
-
Cmake
-
Cuda toolkit installed. Right now 12.6(https://developer.nvidia.com/cuda-12-6-0-download-archive) is hardcoded set(CMAKE_CUDA_COMPILER "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.6/bin") in root CMakeLists.txt
You may want to change this to your current cuda installation but note that only 12.6 was tested.
This mean your CUDA_PATH environment variable should look something like this C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.6 -
An Nvidia GPU since Cuda is used
-
A GPU which supports DirectX Raytracing, such as the NVIDIA Titan V or GeForce RTX
-
NVIDIA driver 466.11 or newer
Building Restir Falcor
- Run the setup_vs2022.bat script after cloning this repository. The solution files are written to build/windows-vs2022.
- Open the Falcor.sln solution
- Set Samples/Restir as your startup project
- Set your configuration to Release(Unless you are debbuging)
- Build and run
Test scenes
Three test scenes are provided. The Arcade scene that ships with Falcor, the Sponza scene and the DragonBuddha scene.
To switch scene simply change the SCENE_NAME define inside RestirApp.cpp file
0: Arcade scene
1: Dragon buddha scene.
2: Sponza scene.
Code overview
Restir specific source code is located here
https://github.com/Trylz/Restir_DI_CPP/tree/main/Source/Samples/Restir
Application entry point
The application entry point is located in the RestirApp.cpp file
Reservoirs
Reservoirs are managed by the reservoir manager. See ReservoirManager.cpp.
Lights
Lights are managed by the light manager. See LightManager.cpp.
This is where lights are created for each scene.
Right now only spherical(so area) lights are supported.
Settings
Scenes specific tweaks are stored in the SceneSettings struct.
Render passes
GBuffer
GBuffer rendering is the first pass. It is generated by raytracing. See GBuffer.cpp.
Should ideally be done by rasterization to save time. This is WIP see: #2
RIS
Resampled Importance Sampling is performed as described in paper. See RISPass.cpp
Visibility test
For each reservoir its weight is set to zero if occluded. So raytracing is performed here. See VisibilityPass.cpp
Temporal filtering
#define USE_TEMPORAL_FILTERING 1
We combine the current frame reservoirs with thoses of the previous frame. See TemporalFilteringPass.cpp
Here the dragon buddha scene with temporal filtering ON and OFF
ON: https://youtu.be/8Q-eVLcEUPY
OFF: https://youtu.be/iBL5fuxIujA
Spatial filtering
#define USE_SPATIAL_FILTERING 0
Combine each pixel reservoirs with thoses of its neighbors. This is disabled by default since i dont see any gain using it.
See SpatialFilteringPass.cpp
Shading
Shading is performed using the reservoirs from the previous passes. See ShadingPass.cpp.
Denoising
#define USE_DENOISING 1
Denoising can be done using NRD or Optix denoiser
#define DENOISING_NRD 0
Note that NRD is currently performed on the final image(same for Optix). It is not recommended when i read the doc. So we may want to denoise the reservoirs instead? This is being investigated here: https://github.com/Trylz/Restir_DI_CPP/tree/NRD-before-shading
CURRENT ISSUES
This is work in progress and some artefacts are still visible.
1) Temporal acnee
Acnee with denoising OFF in Sponza scene
CONCLUSION
There is still work to be done to have a production ready implementation. Performance wise a i am getting decent results for a raytracer.
more like this