ReSTIR GI Implementation on Falcor 5.1 based on the source code provided by Daqi Lin for his ReSTIR PT paper
Original Source Code from ReSTIR PT
- Add the
Rendering/ReSTIRGI
folder intoFalcor/Source/Falcor/...
directory so that you have aFalcor/Source/Falcor/Rendering/ReSTIRGI
directory. - Add the passes(
ReSTIR
andReSTIRGIBuffer
folders) inRenderPasses
intoFalcor/Source/RenderPasses
directory so that you have aFalcor/Source/RenderPasses/ReSTIRGI
andFalcor/Source/RenderPasses/ReSTIRGIGBuffer
directories - Add the script
ReSTIRGIPassWithGBuffer
intoFalcor\Source\Mogwai\Data
directory.
Build the Falcor solution, run Mogwai and load the ReSTIRGIPassWithGBuffer
script.
Global illumination research focuses on methods for computing light transport along some of the paths photons draw. Algorithms that solve the full rendering equation can generate stunning photorealistic images. Those methods, however, are too computationally expensive for real-time applications.
So, why Ray-Traced Global Illumination(RTGI)?
RTGI resembles feature-film image quality. Ray tracing using path tracing with Rendering equation generates correct solution with global illumination.
Recent trends focuses on hybrid rendering
- G-buffer is rendered using rasterization
- Direct lighting and post-processing is done using compute shaders
- GI, reflections, and transparency & translucency are done using pure ray tracing
- 2021.06.24. CGF HPG
- Effective path sampling algorithm for indirect lighting that is suitable to highly parallel GPU architectures Screen-space spatio-temporal resampling
- Resamples multi-bounce indirect lighting paths obtained by path tracing
- Uses NVIDIA Falcor 5.1
Initial sampling is implemented with Ray-Traced GBuffer ReSTIRGIPassWithGBuffer
. GBuffer samples the position, normal, radiance of the visible point, and the sample point scattered from the visible point and its PDF.
Initial Sampling:
- for each pixel q do
- Retrieve visible point xv and normal nv from GBuffer (
ReSTIRGIPassWithGBuffer.rt.slang
) - Sample random ray direction ωi from source PDF p1 (
ReSTIRGIPassWithGBuffer.rt.slang
) - Trace ray to find sample point xs and normal ns (
ReSTIRGIPassWithGBuffer.rt.slang
) - Estimate outgoing radiance Lo at xs (
ReSTIRGIPassWithGBuffer.rt.slang
) - InitialSampleBuffer[q] ← SAMPLE(xv, nv, xs, ns, Lo) (
InitialSampling.cs.slang
)
Spatiotemporal resampling is implemented GIResampling
compute shader.
Spatial resampling (GIResampling.cs.slang
):
- for each pixel q do
- S ← InitialSampleBuffer[q]
- R ← TemporalReservoirBuffer[q]
- w ← p^q(S) / pq(S)
- R.UPDATE(S, w)
- R.W ← R.w / (R.M · p^(R.z))
- TemporalReservoirBuffer[q] ← R
Temporal resampling (GIResampling.cs.slang
):
- for each pixel q do
- Rs ← SpatialReservoirBuffer[q]
- Q ← q
- for s = 1 to maxIterations do
1. Randomly choose a neighbor pixel qn
2. Calculate geometric similarity betwen q and qn
3. if similarity is lower than the given threshold then
- continue 4. Rn ← SpatialReservoirBuffer[qn] 5. Calculate |Jqn → q| 6. p^'q ← p^q(Rn.z) / |Jqn → q| 7. if Rn's sample point is not visible to xv at q then
- p^'q ← 0 8. Rs.MERGE(Rn, p^'q) 9. Q ← Q ∩ qn
- Z ← 0
- for each qn in Q do
1. if p^qn(R.z) > 0 then
- Z ← Z + Rn.M
- Rs.W ← Rs.w / (Z · p^q(Rs.z))
- SpatialReservoirBuffer[q] ← Rs
Final shading (FinalShading.cs.slang
)
- for each pixel q do
- radiance, weight ← Reservoir[q]
- pixel radiance ← radiance × weight
Hardware:
- CPU: 11th Gen Intel(R) Core(TM) i5-11300H @ 3.10GHz (8 CPUs), ~3.1GHz
- Memory: 16384 MB RAM
- DirectX Version: DirectX 12
- Display:
- Device: NVIDIA GeForce RTX 3060 Laptop GPU
- Approx. Total Memory: 14053 MB
MinimalPathTracer without direct illumination took approximately 3536 ms per frame (28 FPS)
ReSTIR GI took approximately 4451 ms per frame (22 FPS)
Comparing the results, ReSTIR GI provides better image quality with just a tiny bit of fps drop.
Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of NVIDIA CORPORATION nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.