Skip to content

Commit

Permalink
v4.14.0 (WIP):
Browse files Browse the repository at this point in the history
HIGHLIGHTS:
- REBLUR: improved performance (+6% in non-SH mode, +10% in SH mode)
- REBLUR: reduced memory usage (-10% in all modes)
- REBLUR: outputs are not used as history buffers anymore! (removed inter-frame dependencies)
- REBLUR: improved IQ by regaining more contact shadows
- RELAX/REBLUR: more flexible "materialID" support

DETAILS:
- REBLUR: removed "hitDistance" related antilag settings (AO/SO is not temporally stabilized anymore)
- REBLUR: removed history length "smoothing" from HistoryFix pass (not needed anymore)
- REBLUR: relaxed disocclusion checks if parallax is very small (~0 motion)
- REBLUR: temporal stabilization pass now operates only on luminance
- REBLUR: lots of C++ code changes to reflect changes in texture layouts
- RELAX/REBLUR: "enableMaterialTestFor..." replaced with "minMaterialFor..." to make "materialID" test more flexible
- updated ShaderMake
- cleanup
  • Loading branch information
dzhdanNV committed Feb 19, 2025
1 parent 3edea46 commit a4cbf7c
Show file tree
Hide file tree
Showing 64 changed files with 534 additions and 986 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ else()
set(NRD_SHADER_BINARIES "--binary")
endif()

message("NRD shaders output path: '${NRD_SHADERS_PATH}'")
message("NRD shaders path: '${NRD_SHADERS_PATH}'")

target_link_libraries(${PROJECT_NAME} PRIVATE MathLib)
target_include_directories(${PROJECT_NAME} PUBLIC "Include")
Expand Down Expand Up @@ -223,7 +223,8 @@ if(NOT NRD_DISABLE_SHADER_COMPILATION)
--allResourcesBound
--vulkanVersion 1.2
--sourceDir "Shaders/Source"
-c Shaders.cfg
--ignoreConfigDir
-c "Shaders/Shaders.cfg"
-o "${NRD_SHADERS_PATH}"
-I "${ML_SOURCE_DIR}"
-I "Shaders/Include"
Expand Down
4 changes: 2 additions & 2 deletions Include/NRD.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited.
#include <cstddef>

#define NRD_VERSION_MAJOR 4
#define NRD_VERSION_MINOR 13
#define NRD_VERSION_MINOR 14
#define NRD_VERSION_BUILD 0
#define NRD_VERSION_DATE "7 February 2025"
#define NRD_VERSION_DATE "19 February 2025"

#if defined(_WIN32)
#define NRD_CALL __stdcall
Expand Down
20 changes: 8 additions & 12 deletions Include/NRDDescs.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license agreement from NVIDIA CORPORATION is strictly prohibited.
#pragma once

#define NRD_DESCS_VERSION_MAJOR 4
#define NRD_DESCS_VERSION_MINOR 13
#define NRD_DESCS_VERSION_MINOR 14

static_assert(NRD_VERSION_MAJOR == NRD_DESCS_VERSION_MAJOR && NRD_VERSION_MINOR == NRD_DESCS_VERSION_MINOR, "Please, update all NRD SDK files");

Expand Down Expand Up @@ -101,10 +101,6 @@ namespace nrd
// Some signal (R8+)
IN_SIGNAL,

// Primary and secondary world-space positions (RGBA16f+)
IN_DELTA_PRIMARY_POS,
IN_DELTA_SECONDARY_POS,

//=============================================================================================================================
// OUTPUTS
//=============================================================================================================================
Expand All @@ -114,24 +110,24 @@ namespace nrd
// Radiance and hit distance
// REBLUR: use "REBLUR_BackEnd_UnpackRadianceAndNormHitDist" for decoding (RGBA16f+)
// RELAX: use "RELAX_BackEnd_UnpackRadiance" for decoding (R11G11B10f+)
OUT_DIFF_RADIANCE_HITDIST, // IMPORTANT: used as history if "stabilizationStrength != 0"
OUT_SPEC_RADIANCE_HITDIST, // IMPORTANT: used as history if "stabilizationStrength != 0"
OUT_DIFF_RADIANCE_HITDIST,
OUT_SPEC_RADIANCE_HITDIST,

// SH data
// REBLUR: use "REBLUR_BackEnd_UnpackSh" for decoding (2x RGBA16f+)
// RELAX: use "RELAX_BackEnd_UnpackSh" for decoding (2x RGBA16f+)
OUT_DIFF_SH0, // IMPORTANT: used as history if "stabilizationStrength != 0"
OUT_DIFF_SH1, // IMPORTANT: used as history if "stabilizationStrength != 0"
OUT_SPEC_SH0, // IMPORTANT: used as history if "stabilizationStrength != 0"
OUT_SPEC_SH1, // IMPORTANT: used as history if "stabilizationStrength != 0"
OUT_DIFF_SH0,
OUT_DIFF_SH1,
OUT_SPEC_SH0,
OUT_SPEC_SH1,

// Normalized hit distance (R8+)
OUT_DIFF_HITDIST,
OUT_SPEC_HITDIST,

// Bent normal and normalized hit distance (RGBA8+)
// REBLUR: use "REBLUR_BackEnd_UnpackDirectionalOcclusion" for decoding
OUT_DIFF_DIRECTION_HITDIST, // IMPORTANT: used as history if "stabilizationStrength != 0"
OUT_DIFF_DIRECTION_HITDIST,

// Shadow and optional transcluceny (R8+ or RGBA8+)
// SIGMA: use "SIGMA_BackEnd_UnpackShadow" for decoding
Expand Down
18 changes: 8 additions & 10 deletions Include/NRDSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license agreement from NVIDIA CORPORATION is strictly prohibited.
#pragma once

#define NRD_SETTINGS_VERSION_MAJOR 4
#define NRD_SETTINGS_VERSION_MINOR 13
#define NRD_SETTINGS_VERSION_MINOR 14

static_assert(NRD_VERSION_MAJOR == NRD_SETTINGS_VERSION_MAJOR && NRD_VERSION_MINOR == NRD_SETTINGS_VERSION_MINOR, "Please, update all NRD SDK files");

Expand Down Expand Up @@ -178,7 +178,7 @@ namespace nrd
AccumulationMode accumulationMode = AccumulationMode::CONTINUE;

// If "true" IN_MV is 3D motion in world-space (0 should be everywhere if the scene is static, camera motion must not be included),
// otherwise it's 2D (+ optional Z delta) screen-space motion (0 should be everywhere if the camera doesn't move) (recommended value = true)
// otherwise it's 2D (+ optional Z delta) screen-space motion (0 should be everywhere if the camera doesn't move)
bool isMotionVectorInWorldSpace = false;

// If "true" IN_DIFF_CONFIDENCE and IN_SPEC_CONFIDENCE are available
Expand Down Expand Up @@ -222,11 +222,9 @@ namespace nrd
{
// [1; 5] - delta is reduced by local variance multiplied by this value
float luminanceSigmaScale = 4.0f; // can be 3.0 or even less if signal is good
float hitDistanceSigmaScale = 3.0f;

// [1; 5] - antilag sensitivity (smaller values increase sensitivity)
float luminanceSensitivity = 3.0f; // can be 2.0 or even less if signal is good
float hitDistanceSensitivity = 2.0f;
};

struct ReblurSettings
Expand Down Expand Up @@ -300,9 +298,9 @@ namespace nrd
// Boosts performance by sacrificing IQ
bool enablePerformanceMode = false;

// (Optional) material ID comparison: enableMaterialTest ? materialID[x] == materialID[y] : 1 (requires "NormalEncoding::R10_G10_B10_A2_UNORM")
bool enableMaterialTestForDiffuse = false;
bool enableMaterialTestForSpecular = false;
// (Optional) material ID comparison: max(m0, minMaterial) == max(m1, minMaterial) (requires "NormalEncoding::R10_G10_B10_A2_UNORM")
float minMaterialForDiffuse = 4.0f;
float minMaterialForSpecular = 4.0f;

// In rare cases, when bright samples are so sparse that any other bright neighbor can't
// be reached, pre-pass transforms a standalone bright pixel into a standalone bright blob,
Expand Down Expand Up @@ -423,9 +421,9 @@ namespace nrd
// Roughness based rejection
bool enableRoughnessEdgeStopping = true;

// (Optional) material ID comparison: enableMaterialTest ? materialID[x] == materialID[y] : 1 (requires "NormalEncoding::R10_G10_B10_A2_UNORM")
bool enableMaterialTestForDiffuse = false;
bool enableMaterialTestForSpecular = false;
// (Optional) material ID comparison: max(m0, minMaterial) == max(m1, minMaterial) (requires "NormalEncoding::R10_G10_B10_A2_UNORM")
float minMaterialForDiffuse = 4.0f;
float minMaterialForSpecular = 4.0f;
};

//====================================================================================================================================================
Expand Down
72 changes: 36 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NVIDIA REAL-TIME DENOISERS v4.13.0 (NRD)
# NVIDIA REAL-TIME DENOISERS v4.14.0 (NRD)

[![Build NRD SDK](https://github.com/NVIDIA-RTX/NRD/actions/workflows/build.yml/badge.svg)](https://github.com/NVIDIA-RTX/NRD/actions/workflows/build.yml)

Expand All @@ -16,8 +16,8 @@ For quick starting see *[NRD sample](https://github.com/NVIDIA-RTX/NRD-Sample)*
- *SIGMA* - shadow-only denoiser

Performance on RTX 4080 @ 1440p (native resolution, default denoiser settings, `NormalEncoding::R10_G10_B10_A2_UNORM`):
- `REBLUR_DIFFUSE_SPECULAR` - 2.40 ms (2.15 in performance mode)
- `RELAX_DIFFUSE_SPECULAR` - 2.95 ms
- `REBLUR_DIFFUSE_SPECULAR` - 2.30 ms (2.00 ms in performance mode, 3.15 ms in `SH` mode)
- `RELAX_DIFFUSE_SPECULAR` - 3.00 ms (4.85 ms in `SH` mode)
- `SIGMA_SHADOW` - 0.40 ms
- `SIGMA_SHADOW_TRANSLUCENCY` - 0.50 ms

Expand Down Expand Up @@ -207,11 +207,11 @@ See `NRDDescs.h` and `NRD.hlsli` for more details and descriptions of other inpu
# NOISY & NON-NOISY DATA REQUIREMENTS

Noisy inputs:
- garbage values are allowed outside of active viewport, i.e. `>= CommonSettings::rectSize`
- garbage values are allowed outside of denoising range, i.e. `>= CommonSettings::denoisingRange`
- garbage values are allowed outside of active viewport, i.e. `pixelPos >= CommonSettings::rectSize`
- garbage values are allowed outside of denoising range, i.e. `abs( viewZ ) >= CommonSettings::denoisingRange`

Non-noisy inputs (guides):
- must not contain garbage
- must not contain `NAN/INF` values

Where "garbage" is `NAN/INF` or undesired value.

Expand Down Expand Up @@ -319,16 +319,16 @@ The *Persistent* column (matches *NRD Permanent pool*) indicates how much of the

| Resolution | Denoiser | Working set (Mb) | Persistent (Mb) | Aliasable (Mb) |
|------------|--------------------------------------|------------------|------------------|------------------|
| 1080p | REBLUR_DIFFUSE | 84.56 | 42.25 | 42.31 |
| | REBLUR_DIFFUSE_OCCLUSION | 40.31 | 25.38 | 14.94 |
| | REBLUR_DIFFUSE_SH | 135.19 | 59.12 | 76.06 |
| | REBLUR_SPECULAR | 103.62 | 50.75 | 52.88 |
| | REBLUR_SPECULAR_OCCLUSION | 48.81 | 33.88 | 14.94 |
| | REBLUR_SPECULAR_SH | 154.25 | 67.62 | 86.62 |
| | REBLUR_DIFFUSE_SPECULAR | 164.88 | 71.88 | 93.00 |
| | REBLUR_DIFFUSE_SPECULAR_OCCLUSION | 67.94 | 38.12 | 29.81 |
| | REBLUR_DIFFUSE_SPECULAR_SH | 266.12 | 105.62 | 160.50 |
| | REBLUR_DIFFUSE_DIRECTIONAL_OCCLUSION | 84.56 | 42.25 | 42.31 |
| 1080p | REBLUR_DIFFUSE | 76.19 | 50.75 | 25.44 |
| | REBLUR_DIFFUSE_OCCLUSION | 36.06 | 25.38 | 10.69 |
| | REBLUR_DIFFUSE_SH | 109.94 | 67.62 | 42.31 |
| | REBLUR_SPECULAR | 95.25 | 59.25 | 36.00 |
| | REBLUR_SPECULAR_OCCLUSION | 44.56 | 33.88 | 10.69 |
| | REBLUR_SPECULAR_SH | 129.00 | 76.12 | 52.88 |
| | REBLUR_DIFFUSE_SPECULAR | 148.12 | 88.88 | 59.25 |
| | REBLUR_DIFFUSE_SPECULAR_OCCLUSION | 59.44 | 38.12 | 21.31 |
| | REBLUR_DIFFUSE_SPECULAR_SH | 232.50 | 122.62 | 109.88 |
| | REBLUR_DIFFUSE_DIRECTIONAL_OCCLUSION | 76.19 | 50.75 | 25.44 |
| | RELAX_DIFFUSE | 90.81 | 54.88 | 35.94 |
| | RELAX_DIFFUSE_SH | 158.31 | 88.62 | 69.69 |
| | RELAX_SPECULAR | 101.44 | 63.38 | 38.06 |
Expand All @@ -339,16 +339,16 @@ The *Persistent* column (matches *NRD Permanent pool*) indicates how much of the
| | SIGMA_SHADOW_TRANSLUCENCY | 50.81 | 8.44 | 42.38 |
| | REFERENCE | 33.75 | 33.75 | 0.00 |
| | | | | |
| 1440p | REBLUR_DIFFUSE | 150.06 | 75.00 | 75.06 |
| | REBLUR_DIFFUSE_OCCLUSION | 71.31 | 45.00 | 26.31 |
| | REBLUR_DIFFUSE_SH | 240.06 | 105.00 | 135.06 |
| | REBLUR_SPECULAR | 183.81 | 90.00 | 93.81 |
| | REBLUR_SPECULAR_OCCLUSION | 86.31 | 60.00 | 26.31 |
| | REBLUR_SPECULAR_SH | 273.81 | 120.00 | 153.81 |
| | REBLUR_DIFFUSE_SPECULAR | 292.56 | 127.50 | 165.06 |
| | REBLUR_DIFFUSE_SPECULAR_OCCLUSION | 120.06 | 67.50 | 52.56 |
| | REBLUR_DIFFUSE_SPECULAR_SH | 472.56 | 187.50 | 285.06 |
| | REBLUR_DIFFUSE_DIRECTIONAL_OCCLUSION | 150.06 | 75.00 | 75.06 |
| 1440p | REBLUR_DIFFUSE | 135.06 | 90.00 | 45.06 |
| | REBLUR_DIFFUSE_OCCLUSION | 63.81 | 45.00 | 18.81 |
| | REBLUR_DIFFUSE_SH | 195.06 | 120.00 | 75.06 |
| | REBLUR_SPECULAR | 168.81 | 105.00 | 63.81 |
| | REBLUR_SPECULAR_OCCLUSION | 78.81 | 60.00 | 18.81 |
| | REBLUR_SPECULAR_SH | 228.81 | 135.00 | 93.81 |
| | REBLUR_DIFFUSE_SPECULAR | 262.56 | 157.50 | 105.06 |
| | REBLUR_DIFFUSE_SPECULAR_OCCLUSION | 105.06 | 67.50 | 37.56 |
| | REBLUR_DIFFUSE_SPECULAR_SH | 412.56 | 217.50 | 195.06 |
| | REBLUR_DIFFUSE_DIRECTIONAL_OCCLUSION | 135.06 | 90.00 | 45.06 |
| | RELAX_DIFFUSE | 161.31 | 97.50 | 63.81 |
| | RELAX_DIFFUSE_SH | 281.31 | 157.50 | 123.81 |
| | RELAX_SPECULAR | 180.06 | 112.50 | 67.56 |
Expand All @@ -359,16 +359,16 @@ The *Persistent* column (matches *NRD Permanent pool*) indicates how much of the
| | SIGMA_SHADOW_TRANSLUCENCY | 90.12 | 15.00 | 75.12 |
| | REFERENCE | 60.00 | 60.00 | 0.00 |
| | | | | |
| 2160p | REBLUR_DIFFUSE | 318.88 | 159.38 | 159.50 |
| | REBLUR_DIFFUSE_OCCLUSION | 151.50 | 95.62 | 55.88 |
| | REBLUR_DIFFUSE_SH | 510.12 | 223.12 | 287.00 |
| | REBLUR_SPECULAR | 390.56 | 191.25 | 199.31 |
| | REBLUR_SPECULAR_OCCLUSION | 183.38 | 127.50 | 55.88 |
| | REBLUR_SPECULAR_SH | 581.81 | 255.00 | 326.81 |
| | REBLUR_DIFFUSE_SPECULAR | 621.62 | 270.94 | 350.69 |
| | REBLUR_DIFFUSE_SPECULAR_OCCLUSION | 255.06 | 143.44 | 111.62 |
| | REBLUR_DIFFUSE_SPECULAR_SH | 1004.12 | 398.44 | 605.69 |
| | REBLUR_DIFFUSE_DIRECTIONAL_OCCLUSION | 318.88 | 159.38 | 159.50 |
| 2160p | REBLUR_DIFFUSE | 287.00 | 191.25 | 95.75 |
| | REBLUR_DIFFUSE_OCCLUSION | 135.56 | 95.62 | 39.94 |
| | REBLUR_DIFFUSE_SH | 414.50 | 255.00 | 159.50 |
| | REBLUR_SPECULAR | 358.69 | 223.12 | 135.56 |
| | REBLUR_SPECULAR_OCCLUSION | 167.44 | 127.50 | 39.94 |
| | REBLUR_SPECULAR_SH | 486.19 | 286.88 | 199.31 |
| | REBLUR_DIFFUSE_SPECULAR | 557.88 | 334.69 | 223.19 |
| | REBLUR_DIFFUSE_SPECULAR_OCCLUSION | 223.19 | 143.44 | 79.75 |
| | REBLUR_DIFFUSE_SPECULAR_SH | 876.62 | 462.19 | 414.44 |
| | REBLUR_DIFFUSE_DIRECTIONAL_OCCLUSION | 287.00 | 191.25 | 95.75 |
| | RELAX_DIFFUSE | 342.81 | 207.25 | 135.56 |
| | RELAX_DIFFUSE_SH | 597.81 | 334.75 | 263.06 |
| | RELAX_SPECULAR | 382.69 | 239.12 | 143.56 |
Expand Down
2 changes: 1 addition & 1 deletion Resources/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Versioning rules:
*/

#define VERSION_MAJOR 4
#define VERSION_MINOR 13
#define VERSION_MINOR 14
#define VERSION_BUILD 0

#define VERSION_STRING STR(VERSION_MAJOR.VERSION_MINOR.VERSION_BUILD encoding=NRD_NORMAL_ENCODING.NRD_ROUGHNESS_ENCODING)
6 changes: 3 additions & 3 deletions Shaders/Include/Common.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ license agreement from NVIDIA CORPORATION is strictly prohibited.

// FP16

#ifdef NRD_COMPILER_DXC
#ifdef __hlsl_dx_compiler
#define half_float float16_t
#define half_float2 float16_t2
#define half_float3 float16_t3
Expand Down Expand Up @@ -226,9 +226,9 @@ static const float3 g_Special8[ 8 ] =
#define GetStdDev( m1, m2 ) sqrt( abs( ( m2 ) - ( m1 ) * ( m1 ) ) ) // sqrt( max( m2 - m1 * m1, 0.0 ) )

#if( NRD_NORMAL_ENCODING == NRD_NORMAL_ENCODING_R10G10B10A2_UNORM )
#define CompareMaterials( m0, m, mask ) ( ( mask ) == 0 ? 1.0 : ( ( m0 ) == ( m ) ) )
#define CompareMaterials( m0, m, minm ) ( max( m0, minm ) == max( m, minm ) )
#else
#define CompareMaterials( m0, m, mask ) 1.0
#define CompareMaterials( m0, m, minm ) true
#endif

#define UnpackViewZ( z ) abs( z * gViewZScale )
Expand Down
10 changes: 9 additions & 1 deletion Shaders/Include/NRD.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ distribution of this software and related documentation without an express
license agreement from NVIDIA CORPORATION is strictly prohibited.
*/

// NRD v4.13
// NRD v4.14

// IMPORTANT: DO NOT MODIFY THIS FILE WITHOUT FULL RECOMPILATION OF NRD LIBRARY!

Expand Down Expand Up @@ -134,6 +134,10 @@ NOISY INPUTS:

#define NRD_EXPORT

#ifndef NRD_COMPILER_DXC
#define NRD_COMPILER_DXC
#endif

// PlayStation // TODO: register spaces?
#elif( defined( NRD_COMPILER_PSSLC ) || defined( __PSSL__ ) )

Expand Down Expand Up @@ -187,6 +191,10 @@ NOISY INPUTS:
#define NRD_EXPORT
#endif

#ifndef NRD_COMPILER_PSSLC
#define NRD_COMPILER_PSSLC
#endif

// Unreal Engine
#elif( defined( NRD_COMPILER_UNREAL_ENGINE ) ) // TODO: is there a predefined macro in UE?

Expand Down
2 changes: 1 addition & 1 deletion Shaders/Include/REBLUR_Blur.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ NRD_EXPORT void NRD_CS_MAIN( NRD_CS_MAIN_ARGS )
NRD_CTA_ORDER_DEFAULT;

// Tile-based early out
float isSky = gIn_Tiles[ pixelPos >> 4 ];
float isSky = gIn_Tiles[ pixelPos >> 4 ].x;
if( isSky != 0.0 || any( pixelPos > gRectSizeMinusOne ) )
return;

Expand Down
Loading

0 comments on commit a4cbf7c

Please sign in to comment.