Skip to content

Commit

Permalink
Updated RTXDI to version 1.1.0, replaced the packaged dependencies on…
Browse files Browse the repository at this point in the history
… NRD and Donut with submodules.
  • Loading branch information
apanteleev committed Jul 19, 2021
1 parent 43ba012 commit 41d118d
Show file tree
Hide file tree
Showing 59 changed files with 1,456 additions and 1,322 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
media/
media*/
bin/
dxc/
donut-*/
build*/
NRD/
.vs
.vscode
*.sublime-project
*.sublime-workspace
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "donut"]
path = donut
url = https://gitlab-master.nvidia.com/nvrhi/donut.git
url = https://github.com/NVIDIAGameWorks/donut.git
[submodule "NRD"]
path = NRD
url = https://github.com/NVIDIAGameWorks/RayTracingDenoiser.git
27 changes: 17 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.10)

project(RTXDI)

Expand All @@ -20,23 +20,28 @@ if (MSVC)
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MT")
endif()

option(DONUT_WITH_ASSIMP "" OFF)
option(DONUT_USE_DXIL_ON_DX12 "" ON)
option(DONUT_WITH_DX11 "" OFF)
option(DONUT_WITH_VULKAN "" ON)
option(DONUT_WITH_SQLITE "" OFF)
option(DONUT_WITH_LZ4 "" OFF)
option(NVRHI_WITH_DXR "" ON)
option(DONUT_WITH_MINIZ "" OFF)

if (WIN32)
# Point to the DXC provided through packman
set(DXC_DXIL_EXECUTABLE "${CMAKE_CURRENT_LIST_DIR}/dxc/dxc.exe" CACHE STRING
"Path to DirectX Shader Compiler for DXIL output")
set(DXC_SPIRV_EXECUTABLE "${CMAKE_CURRENT_LIST_DIR}/dxc/dxc.exe" CACHE STRING
"Path to DirectX Shader Compiler for SPIR-V output")
set(EXE_SUFFIX ".exe")
else()
set(EXE_SUFFIX "")
endif()

include(NRD.cmake)
# Point to the DXC provided through packman
set(PACKMAN_DXC "${CMAKE_CURRENT_LIST_DIR}/dxc/bin/dxc${EXE_SUFFIX}")
if (EXISTS "${PACKMAN_DXC}")
if (WIN32 AND NOT DXC_DXIL_EXECUTABLE)
set(DXC_DXIL_EXECUTABLE "${PACKMAN_DXC}" CACHE STRING "Path to DirectX Shader Compiler for DXIL output")
endif()
if (NOT DXC_SPIRV_EXECUTABLE)
set(DXC_SPIRV_EXECUTABLE "${PACKMAN_DXC}" CACHE STRING "Path to DirectX Shader Compiler for SPIR-V output")
endif()
endif()

set(DONUT_SHADERS_OUTPUT_DIR "${CMAKE_SOURCE_DIR}/bin/shaders/framework")

Expand All @@ -48,6 +53,8 @@ else()
set(DONUT_PATH "${CMAKE_CURRENT_LIST_DIR}/donut-snapshot")
endif()

include(NRD.cmake)

add_subdirectory(rtxdi-sdk)
add_subdirectory(shaders)
add_subdirectory(src)
32 changes: 32 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# RTXDI SDK Change Log

## 1.1.0


**API changes:**

- Added the `RAB_GetTemporalConservativeVisibility` bridge function.
- Removed the `usePreviousFrameScene` parameter from the `RAB_GetConservativeVisibility` bridge function.

**Major code changes:**

- Switched to use the open source version of the [Donut framework](https://github.com/NVIDIAGameWorks/donut) and [glTF](https://www.khronos.org/gltf) models.
- Updated [NRD](https://github.com/NVIDIAGameWorks/RayTracingDenoiser) to version 2.5 that is now integrated as a git submodule and works on Linux (both x64 and ARM64 architectures).

**New features:**

- Added bloom post-processing effect.
- Added compatibility with the ARM64 processor architecture (when running Linux)
- Added support for skeletal animation in the sample application.
- Enabled the `KHR_ray_tracing_pipeline` API on Vulkan.
- Enabled TLAS updates (instead of rebuilds) in the sample application.

**Misc improvements:**

- Added dependency packages and scripts to make the sample application easy to build on Linux.
- Fixed some issues with the material model and BRDF evaluation.
- Improved the BRDF ray importance sampling logic.

## 1.0.0

Initial release.
1 change: 1 addition & 0 deletions NRD
Submodule NRD added at f1b51f
24 changes: 9 additions & 15 deletions NRD.cmake
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@

find_path(NRD_INCLUDE_DIR
Nrd.h
PATHS ${CMAKE_CURRENT_LIST_DIR}/NRD/Include)
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/NRD")
set(NRD_DXC_PATH ${DXC_DXIL_EXECUTABLE})
set(NRD_DXC_SPIRV_PATH ${DXC_SPIRV_EXECUTABLE})
option(NRD_STATIC_LIBRARY "" ON)

if (WIN32)
find_path(NRD_LIB_DIR
NRD.lib
PATHS ${CMAKE_CURRENT_LIST_DIR}/NRD/Lib/Release)
else()
find_path(NRD_LIB_DIR
libNRD.so
PATHS ${CMAKE_CURRENT_LIST_DIR}/NRD/Lib/Release)
add_subdirectory(NRD)

set_target_properties(NRD PROPERTIES FOLDER NRD)
set_target_properties(Shaders PROPERTIES FOLDER NRD)
set_target_properties(CreateFolderForShaders PROPERTIES FOLDER NRD)
endif()

find_path(NRD_SHADERS_DIR
NRD.hlsl
PATHS ${CMAKE_CURRENT_LIST_DIR}/NRD/Shaders)
64 changes: 41 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@

# RTXDI SDK and Sample App

Version 1.1.

[Change Log](ChangeLog.md)

## Introduction

**RTX** **D**irect **I**llumination is a framework that facilitates the implementations of efficient direct light sampling in real-time renderers. It is based on the **ReSTIR** algorithm published in the paper called "Spatiotemporal reservoir resampling for real-time ray tracing with dynamic direct lighting" by B. Bitterli et al.
Expand All @@ -16,50 +20,64 @@ For more information, see the [NVIDIA Developer Page](https://developer.nvidia.c
- [`rtxdi-sdk/shaders`](rtxdi-sdk/shaders) has the shader files that are supposed to be compiled through whatever means the application normally uses
- [`rtxdi-sdk/src`](rtxdi-sdk/src) has the host code with various utility functions for setting up the parameters and resources for resampling

[`src`](src) contains the sample application host code
[`src`](src) contains the sample application host code.

[`shaders`](shaders) contains the sample application shaders
[`shaders`](shaders) contains the sample application shaders.

Additional contents delivered through packman:
[`donut`](donut) is a submodule structure with the ["Donut" rendering framework](https://github.com/NVIDIAGameWorks/donut) used to build the sample app.

`donut-snapshot` is a snapshot of the source code for the NVIDIA "Donut" rendering framework that the sample application is built on, and its dependencies.
[`NRD`](NRD) is a submodule with the ["NRD" denoiser library](https://github.com/NVIDIAGameWorks/RayTracingDenoiser).

Additional contents delivered through packman:

`dxc` is a recent version of DirectX Shader Compiler;

`media` contains the media files necessary for the sample app to run.

## Building and Running the Sample App

### Setting up the source code tree and dependencies
### Windows

1. Clone the repository.
2. Pull the media files and other large dependencies from packman by running `update_dependencies.bat`.
1. Clone the repository with all submodules:
- `git clone --recursive <URL>`

### Building and integrating NRD (optional)
2. Pull the media files and DXC binaries from packman:
- `update_dependencies.bat`

3. Configure the solution with CMake. The easiest option is to use [CMake GUI](https://cmake.org/download/).
4. Assuming that the RTXDI SDK tree is located in `D:\RTXDI`, set the following parameters in the GUI:
- "Where is the source code" to `D:\RTXDI`
- "Where to build the binaries" to `D:\RTXDI\build`
5. Click "Configure", set "Generator" to the Visual Studio you're using (tested with VS 2019 version 16.8.2), set "Optional platform" to x64, click "Finish".
6. Click "Generate", then "Open Project".
7. Build the solution with Visual Studio
8. Run the `rtxdi-sample` project.

To build the sample app with NRD (NVIDIA Real-Time Denoiser) integration, follow these steps to build and install NRD *before* building RTXDI SDK:
### Linux

1. Get the NRD 2.1.1 source code from the [GitHub repository](https://github.com/NVIDIAGameWorks/RayTracingDenoiser/) (accessing the repository requires approval through the [NVIDIA Developer website](https://developer.nvidia.com/nvidia-rt-denoiser)).
2. Build NRD using the following batch files in its directory: `1-Deploy.bat`, `2-Build.bat`, `4b-Prepare NRD SDK.bat`. That will put all the necessary SDK files into the `_NRD_SDK` folder.
3. Copy that `_NRD_SDK` folder into the RTXDI SDK folder, next to `src`, and rename it to `NRD`. Then CMake should find the NRD SDK paths automatically. Alternatively, specify all the paths manually using the `NRD_INCLUDE_DIR`, `NRD_LIB_DIR`, and `NRD_SHADERS_DIR` CMake variables.
1. Clone the repository with all submodules:
- `git clone --recursive <URL>`

### Configuring and building the solution with CMake
2. Pull the media files and DXC binaries from packman:
- `update_dependencies.sh`

3. Create a build folder:
- `cd RTXDI && mkdir build && cd build`

The easiest option is to use [CMake GUI](https://cmake.org/download/).
4. Configure the project with CMake:
- `cmake ..`

1. Assuming that the RTXDI SDK tree is located in `D:\RTXDI`, set the following parameters in the GUI:
- "Where is the source code" to `D:\RTXDI`
- "Where to build the binaries" to `D:\RTXDI\build`
2. Click "Configure", set "Generator" to the Visual Studio you're using (tested with VS 2019 version 16.8.2), set "Optional platform" to x64, click "Finish".
4. Click "Generate", then "Open Project".
5. Build the solution with Visual Studio
6. Run the `rtxdi-sample` project.
5. Build:
- `make -j8` (example for an 8-core CPU)

6. Run:
- `../bin/rtxdi-sample`

### Vulkan support

The RTXDI sample application can run using D3D12 or Vulkan, which is achieved through the NVRHI rendering API abstraction layer and HLSL shader compilation to SPIR-V through DXC (DirectX Shader Compiler). Unfortunately, the current version of DXC shipping with Vulkan SDK cannot compile the RTXDI SDK shaders into SPIR-V. For this reason, we deliver a compatible version of DXC through packman. If you wish to use a different (e.g. newer) version of DXC, it can be obtained from [Microsoft/DirectXShaderCompiler](https://github.com/Microsoft/DirectXShaderCompiler) on GitHub. The path to a custom version of DXC can be configured using the `DXC_DXIL_EXECUTABLE` and `DXC_SPIRV_EXECUTABLE` CMake variables.
The RTXDI sample application can run using D3D12 or Vulkan, which is achieved through the [NVRHI](https://github.com/NVIDIAGameWorks/nvrhi) rendering API abstraction layer and HLSL shader compilation to SPIR-V through DXC (DirectX Shader Compiler). We deliver a compatible version of DXC through packman. If you wish to use a different (e.g. newer) version of DXC, it can be obtained from [Microsoft/DirectXShaderCompiler](https://github.com/Microsoft/DirectXShaderCompiler) on GitHub. The path to a custom version of DXC can be configured using the `DXC_DXIL_EXECUTABLE` and `DXC_SPIRV_EXECUTABLE` CMake variables.

By default, the sample app will run using D3D12. To start it in Vulkan mode, add `-vk` to the command line. To compile the sample app without Vulkan support, set the CMake variable `DONUT_WITH_VULKAN` to `OFF` and re-generate the project.
By default, the sample app will run using D3D12 on Windows. To start it in Vulkan mode, add `-vk` to the command line. To compile the sample app without Vulkan support, set the CMake variable `DONUT_WITH_VULKAN` to `OFF` and re-generate the project.

## Integration

Expand Down
11 changes: 8 additions & 3 deletions doc/RtxdiApplicationBridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,19 @@ Samples a polymorphic light relative to the given receiver surface. For most lig

### `RAB_GetConservativeVisibility`

`bool RAB_GetConservativeVisibility(RAB_Surface surface, RAB_LightSample lightSample, bool usePreviousFrameScene)`
`bool RAB_GetConservativeVisibility(RAB_Surface surface, RAB_LightSample lightSample)`

Traces a visibility ray that returns approximate, conservative visibility between the surface and the light sample. Conservative means if unsure, assume the light is visible. For example, conservative visibility can skip alpha-tested or translucent surfaces, which may provide significant performance gains. However, significant differences between this conservative visibility and the final one will result in more noise.

When `usePreviousFrameScene` is `true`, use the previous frame TLAS to compute the visibility. If the previous frame TLAS is unavailable, the implementation can use the current frame TLAS, but doing so will bias the lighting results around moving occluders, making them darker.
This function is used in the spatial resampling functions for ray traced bias correction. The initial samples should also be kept or discarded based on visibility computed in the same way to keep the results unbiased.

This function is used in the temporal and spatial resampling functions for ray traced bias correction. The initial samples should also be kept or discarded based on visibility computed in the same way to keep the results unbiased.
### `RAB_GetTemporalConservativeVisibility`

`bool RAB_GetTemporalConservativeVisibility(RAB_Surface currentSurface, RAB_Surface previousSurface, RAB_LightSample lightSample)`

Same visibility ray tracing as [`RAB_GetConservativeVisibility`](#rab_getconservativevisibility) but for surfaces and light samples originating from the previous frame.

When the previous frame TLAS and BLAS data is available, the implementation should use that previous data and the `previousSurface` parameter. When the previous acceleration structures are not available, the implementation should use the `currentSurface` parameter, but that will make the results temporarily biased and, in some cases, more noisy. Specifically, the fused spatio-temporal resampling algorithm will produce very noisy results on animated objects.

## Misc Functions

Expand Down
1 change: 1 addition & 0 deletions donut
Submodule donut added at 594898
8 changes: 3 additions & 5 deletions packman/dependencies.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<project toolsVersion="5.0">
<dependency name="rtxdi-media" linkPath="../media" >
<package name="rtxdi-media" version="p4sw-29720145" />
<package name="rtxdi-media" version="p4sw-30199253" />
</dependency>
<dependency name="dxc" linkPath="../dxc" >
<package name="dxc" version="1.6.0.3108-3960adab4-windows-x86_64" platforms="win" />
</dependency>
<dependency name="donut" linkPath="../donut-snapshot" >
<package name="rtxdi-donut" version="0102c189" />
<package name="dxc" version="1.6.2106-${platform}" platforms="windows-x86_64 linux-x86_64" />
<package name="dxc" version="1.6.2106_glibc2.27_linux-aarch64" platforms="linux-aarch64" />
</dependency>
</project>
12 changes: 9 additions & 3 deletions rtxdi-sdk/include/rtxdi/ResamplingFunctions.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ RTXDI_Reservoir RTXDI_TemporalResampling(
#if RTXDI_ALLOWED_BIAS_CORRECTION >= RTXDI_BIAS_CORRECTION_RAY_TRACED
if (tparams.biasCorrectionMode == RTXDI_BIAS_CORRECTION_RAY_TRACED && temporalP > 0)
{
if (!RAB_GetConservativeVisibility(temporalSurface, selectedLightSample, true))
if (!RAB_GetTemporalConservativeVisibility(surface, temporalSurface, selectedLightSample))
{
temporalP = 0;
}
Expand Down Expand Up @@ -1361,7 +1361,7 @@ RTXDI_Reservoir RTXDI_SpatialResampling(
#if RTXDI_ALLOWED_BIAS_CORRECTION >= RTXDI_BIAS_CORRECTION_RAY_TRACED
if (sparams.biasCorrectionMode == RTXDI_BIAS_CORRECTION_RAY_TRACED && ps > 0)
{
if (!RAB_GetConservativeVisibility(neighborSurface, selectedLightSample, false))
if (!RAB_GetConservativeVisibility(neighborSurface, selectedLightSample))
{
ps = 0;
}
Expand Down Expand Up @@ -1662,7 +1662,13 @@ RTXDI_Reservoir RTXDI_SpatioTemporalResampling(
#if RTXDI_ALLOWED_BIAS_CORRECTION >= RTXDI_BIAS_CORRECTION_RAY_TRACED
if (stparams.biasCorrectionMode == RTXDI_BIAS_CORRECTION_RAY_TRACED && ps > 0)
{
if (!RAB_GetConservativeVisibility(neighborSurface, selectedLightSample, true))
RAB_Surface fallbackSurface;
if (i == 0 && foundTemporalSurface)
fallbackSurface = surface;
else
fallbackSurface = neighborSurface;

if (!RAB_GetTemporalConservativeVisibility(fallbackSurface, neighborSurface, selectedLightSample))
{
ps = 0;
}
Expand Down
7 changes: 6 additions & 1 deletion rtxdi-sdk/shaders/ResamplingCompileTest.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ struct RAB_LightInfo

};

bool RAB_GetConservativeVisibility(RAB_Surface surface, RAB_LightSample lightSample, bool usePreviousFrameScene)
bool RAB_GetConservativeVisibility(RAB_Surface surface, RAB_LightSample lightSample)
{
return true;
}

bool RAB_GetTemporalConservativeVisibility(RAB_Surface currentSurface, RAB_Surface previousSurface, RAB_LightSample lightSample)
{
return true;
}
Expand Down
Loading

0 comments on commit 41d118d

Please sign in to comment.