Skip to content

karel-tomanec/Falcor-ReSTIR

 
 

Repository files navigation

ReSTIR DI in Falcor

This repository contains an implementation of ReSTIR DI (Reservoir-based Spatio-Temporal Importance Resampling for Direct Illumination) within the Falcor rendering framework. The code forms the practical component of my master's thesis titled Efficient Sampling for Computing Complex Illumination in Real-Time

Introduction

This project focuses on implementing the ReSTIR DI algorithm in Falcor, aiming to achieve efficient real-time sampling and rendering of complex illumination. ReSTIR offers a highly promising approach to efficiently computing direct illumination by leveraging spatio-temporal resampling techniques, making it suitable for real-time applications. The results demonstrate that ReSTIR is a highly effective approach for achieving high-quality real-time rendering while maintaining interactive performance.

Installation

Please refer to the About Falcor section below for details on installing the Falcor framework and other dependencies required to run this implementation.

Implementation and Usage

The implementation is encapsulated as a separate render pass located in Source\RenderPasses\ReSTIRPass. This pass can be integrated into the render graph for executing the ReSTIR DI algorithm.

Running the Example Render Graph

An example render graph script that utilizes the ReSTIR pass is available in Source\Mogwai\Data\ReSTIR.py. To run this script:

  1. Open Mogwai: Launch the Mogwai project from the Falcor framework.

  2. Load the Render Graph:

    • Navigate to File -> Load Script.
    • Select the ReSTIR.py script from Source\Mogwai\Data\ReSTIR.py.
  3. Load a Scene:

    • You can download scenes from resources such as ORCA Rendering Resources (see the About Falcor section below).
    • Alternatively, use one of the test scenes available in media\TestScenes.
  4. Experiment with Settings:

    • After loading the scene, the rendered output should be visible, along with the settings for individual render passes.
    • The settings for the ReSTIR pass are designed to be intuitive for those familiar with the algorithm. For further understanding, please refer to my thesis or consult related academic papers.

Documentation

See thesis.

Examples

video

About Falcor

Falcor is a real-time rendering framework supporting DirectX 12. It aims to improve productivity of research and prototype projects.

Prerequisites

Optional:

  • Windows 10 Graphics Tools. To run DirectX 12 applications with the debug layer enabled, you must install this. There are two ways to install it:
    • Click the Windows button and type Optional Features, in the window that opens click Add a feature and select Graphics Tools.
    • Download an offline package from here. Choose a ZIP file that matches the OS version you are using (not the SDK version used for building Falcor). The ZIP includes a document which explains how to install the graphics tools.
  • NVAPI, CUDA, OptiX (see below)

Building Falcor

Falcor uses the CMake build system. Additional information on how to use Falcor with CMake is available in the CMake development documetation page.

Visual Studio

If you are working with Visual Studio, you can setup a native Visual Studio solution by running setup_vs2019.bat (or setup_vs2022.bat, same process) after cloning this repository. The solution files are written to build/windows-vs2019-d3d12 and the binary output is located in build/windows-vs2019-d3d12/bin.

By default, the solution is configured to use the native D3D12 rendering backend. Alternatively, you can setup additional solutions for the GFX backends by running setup_vs2019.bat gfx-d3d12 or setup_vs2019.bat gfx-vk. Note that each configuration is setting up a separate build tree, so it's easy to switch between different backends during development.

Visual Studio Code

If you are working with Visual Studio Code, run setup.bat after cloning this repository. This will setup a VS Code workspace in the .vscode folder with sensible defaults (only if .vscode does not exist yet). When opening the project folder in VS Code, it will prompt to install recommended extensions. We recommend you do, but at least make sure that CMake Tools is installed. To build Falcor, you can select the configure preset by executing the CMake: Select Configure Preset action (Ctrl+Shift+P). Choose the Windows Ninja/MSVC D3D12 preset (or one for a different rendering backend). Then simply hit Build (or press F7) to build the project. The binary output is located in build/windows-ninja-msvc-d3d12/bin.

Warning: Do not start VS Code from Git Bash, it will modify the PATH environment variable to an incompatible format, leading to issues with CMake.

Configure Presets

Falcor uses CMake Presets store in CMakePresets.json to provide a set of commonly used build configurations. You can get the full list of available configure presets running cmake --list-presets:

$ cmake --list-presets
Available configure presets:

  "windows-vs2019-d3d12"         - Windows VS2019 D3D12
  "windows-vs2019-gfx-d3d12"     - Windows VS2019 GFX-D3D12
  "windows-vs2019-gfx-vk"        - Windows VS2019 GFX-VK
  "windows-vs2022-d3d12"         - Windows VS2022 D3D12
  "windows-vs2022-gfx-d3d12"     - Windows VS2022 GFX-D3D12
  "windows-vs2022-gfx-vk"        - Windows VS2022 GFX-VK
  "windows-ninja-msvc-d3d12"     - Windows Ninja/MSVC D3D12
  "windows-ninja-msvc-gfx-d3d12" - Windows Ninja/MSVC GFX-D3D12
  "windows-ninja-msvc-gfx-vk"    - Windows Ninja/MSVC GFX-VK

Use cmake --preset <preset name> to generate the build tree for a given preset. The build tree is written to the build/<preset name> folder and the binary output files are in build/<preset name>/bin.

An existing build tree can be compiled using cmake --build build/<preset name>.

Note: Some render passes (RTXGI, RTXDI, DLSS in particular) are not fully working with the new Slang GFX backend.

Microsoft DirectX 12 Agility SDK

Falcor uses the Microsoft DirectX 12 Agility SDK to get access to the latest DirectX 12 features. Applications can enable the Agility SDK by putting FALCOR_EXPORT_D3D12_AGILITY_SDK in the main .cpp file. Mogwai, FalcorTest and RenderGraphEditor have the Agility SDK enabled by default.

NVAPI

To enable NVAPI support, head over to https://developer.nvidia.com/nvapi and download the latest version of NVAPI (this build is tested against version R470). Extract the content of the zip file into external/packman/ and rename R470-developer to nvapi.

CUDA

To enable CUDA support, download and install CUDA 11.6.2 or later and reconfigure the build.

See the CudaInterop sample application located in Source/Samples/CudaInterop for an example of how to use CUDA.

OptiX

If you want to use Falcor's OptiX functionality (specifically the OptixDenoiser render pass) download the OptiX SDK (Falcor is currently tested against OptiX version 7.3) After running the installer, link or copy the OptiX SDK folder into external/packman/optix (i.e., file external/packman/optix/include/optix.h should exist).

Note: You also need CUDA installed to compile the OptixDenoiser render pass, see above for details.

NVIDIA RTX SDKs

Falcor ships with the following NVIDIA RTX SDKs:

Note that these SDKs are not under the same license as Falcor, see LICENSE.md for details.

Falcor Configuration

FalcorConfig.h contains some flags which control Falcor's behavior.

  • FALCOR_ENABLE_LOGGER - Enable/disable the logger. By default, it is set to 1.
  • FALCOR_ENABLE_PROFILER - Enable/disable the internal CPU/GPU profiler. By default, it is set to 1.

Resources

Releases

No releases published

Packages

No packages published

Languages

  • C++ 92.0%
  • Python 5.4%
  • CMake 1.0%
  • HLSL 0.4%
  • C 0.4%
  • PowerShell 0.3%
  • Other 0.5%