Screen-Space-ReSTIR-GI

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

Integration

  1. Add the Rendering/ReSTIRGI folder into Falcor/Source/Falcor/... directory so that you have a Falcor/Source/Falcor/Rendering/ReSTIRGI directory.
  2. Add the passes(ReSTIR and ReSTIRGIBuffer folders) in RenderPasses into Falcor/Source/RenderPasses directory so that you have a Falcor/Source/RenderPasses/ReSTIRGI and Falcor/Source/RenderPasses/ReSTIRGIGBuffer directories
  3. Add the script ReSTIRGIPassWithGBuffer into Falcor\Source\Mogwai\Data directory.

Build the Falcor solution, run Mogwai and load the ReSTIRGIPassWithGBuffer script.

1. Introduction

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

ReSTIR GI: Path Resampling for Real-Time Path 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

2. Implementation Details

  • 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:

  1. for each pixel q do
  2. Retrieve visible point xv and normal nv from GBuffer (ReSTIRGIPassWithGBuffer.rt.slang)
  3. Sample random ray direction ωi from source PDF p1 (ReSTIRGIPassWithGBuffer.rt.slang)
  4. Trace ray to find sample point xs and normal ns (ReSTIRGIPassWithGBuffer.rt.slang)
  5. Estimate outgoing radiance Lo at xs (ReSTIRGIPassWithGBuffer.rt.slang)
  6. InitialSampleBuffer[q] ← SAMPLE(xv, nv, xs, ns, Lo) (InitialSampling.cs.slang)

Spatiotemporal resampling is implemented GIResampling compute shader.

Spatial resampling (GIResampling.cs.slang):

  1. for each pixel q do
  2. S ← InitialSampleBuffer[q]
  3. R ← TemporalReservoirBuffer[q]
  4. w ← p^q(S) / pq(S)
  5. R.UPDATE(S, w)
  6. R.W ← R.w / (R.M · p^(R.z))
  7. TemporalReservoirBuffer[q] ← R

Temporal resampling (GIResampling.cs.slang):

  1. for each pixel q do
  2. Rs ← SpatialReservoirBuffer[q]
  3. Q ← q
  4. 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

    1. 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
    2. p^’q ← 0 8. Rs.MERGE(Rn, p^’q) 9. Q ← Q ∩ qn
  5. Z ← 0
  6. for each qn in Q do 1. if p^qn(R.z) > 0 then

    1. Z ← Z + Rn.M
  7. Rs.W ← Rs.w / (Z · p^q(Rs.z))
  8. SpatialReservoirBuffer[q] ← Rs

Final shading (FinalShading.cs.slang)

  1. for each pixel q do
  2. radiance, weight ← Reservoir[q]
  3. pixel radiance ← radiance × weight

3. Results

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.

License from the Original Source Code

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.

GitHub

View Github