Skip to content

Commit

Permalink
NRD v3.4.0:
Browse files Browse the repository at this point in the history
HIGHLIGHTS:

- NRD: anisotropic curvature estimation
- REBLUR/RELAX: improved specular reprojection on curved surfaces
- REBLUR: added fast history
- REBLUR: introduced denoisers working in spherical harmonic (SH) space
- REBLUR: reduced memory usage
- REBLUR: temporal stabilization pass can be turned off eliminating associated overhead
- REBLUR: specular tracking improvements
- REBLUR: better history reconstruction in disoccluded regions
- RELAX: improved performance
- RELAX: improved anti-firefly filtering
- RELAX: improved history confidence usage

DETAILS:

- NRD: anisotropic curvature estimation
- NRD: exposed helper "GetMethodString"
- NRD: gDebug is now available in Common.hlsli
- NRD: updated README and UPDATE

- REBLUR: added SH denoisers
- REBLUR: switched to YCoCg
- REBLUR: added fast history
- REBLUR: rewritten HistoryFix (no mips anymore)
- REBLUR: reduced memory usage
- REBLUR: improved error compensation and reduced bias
- REBLUR: fix for checkerboard resolve in advanced prepass mode
- REBLUR: removed virtual history amount correction which is not needed anymore
- REBLUR: reduced bias in pre-pass
- REBLUR: fixed laggy specular reprojection on bumpy surfaces
- REBLUR: specular confidence doesn't affect hit distance weight
- REBLUR: specular prepass setting should not affect diffuse only denoiser (and vice versa)
- REBLUR: improved reprojection on curved surfaces
- REBLUR: simplified temporal stabilization params
- REBLUR: fixed wrong output in DIFFUSE_DIRECTIONAL_OCCLUSION
- REBLUR: simplified roughness weight in temporal accumulation pass
- REBLUR: removed gFramerateScale based acceleration
- REBLUR: tuned "GetSpecAccumSpeed" (consistent parallax usage)
- REBLUR: tuned prepass parameters
- REBLUR: fixed & optimized hitT for specular tracking
- REBLUR: fixed (corrected) curvature if its sign is oscillating
- REBLUR: fixed (returned) virtual motion based normal weight in temporal accumulation
- REBLUR: added prev-prev test for roughness
- REBLUR: improved firefly suppression
- REBLUR: removed clamping to noisy input for specular
- REBLUR: dropped unnecessary output for sky pixels
- REBLUR: tweaked surface based motion accumulation
- REBLUR: hitT check for virtual motion in temporal accumulation replaced with parallax check
- REBLUR: improved prev-prev test
- REBLUR: prev-prev test checks surface similarity
- REBLUR: performance optimizations
- REBLUR: tweaked hit distance weight
- REBLUR: fixed regressions
- REBLUR: improved virtual motion roughness confidence in temporal accumulation
- REBLUR: maximized code reuse
- REBLUR: refactoring

- RELAX: removed geometry weights in firefly filter
- RELAX: switched from disocclusion threshold to spatial filtering threshold in disocclusion fix
- RELAX: added prev-prev test for roughness
- RELAX: improved confidence buffers handling
- RELAX: performance optimizations

- NRD integration: now computes memory usage
  • Loading branch information
dzhdanNV committed Aug 15, 2022
1 parent 956e6af commit 168655c
Show file tree
Hide file tree
Showing 238 changed files with 8,123 additions and 4,558 deletions.
2 changes: 1 addition & 1 deletion External/MathLib
Submodule MathLib updated 4 files
+1 −1 External/sse2neon
+1 −4 MathLib_d.h
+1 −4 MathLib_f.h
+83 −67 STL.hlsli
26 changes: 13 additions & 13 deletions Include/NRD.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,15 @@ license agreement from NVIDIA CORPORATION is strictly prohibited.
/*
CREDITS:
Developed by:
Library, REBLUR and SIGMA denoisers:
Dmitry Zhdan (dzhdan@nvidia.com)
ReLAX denoiser:
Tim Cheblokov (ttcheblokov@nvidia.com)
Pawel Kozlowski (pkozlowski@nvidia.com)
Dmitry Zhdan (dzhdan@nvidia.com)
Tim Cheblokov (ttcheblokov@nvidia.com)
Special thanks:
Evgeny Makarov (NVIDIA) - denoising ideas
Ivan Fedorov (NVIDIA) - interface
Ivan Povarov (NVIDIA) - QA, integrations and feedback
Oles Shyshkovtsov (4A GAMES) - initial idea of recurrent blurring
Pawel Kozlowski (NVIDIA)
Evgeny Makarov (NVIDIA)
Ivan Fedorov (NVIDIA)
Ivan Povarov (NVIDIA)
Oles Shyshkovtsov (4A GAMES) for initial idea of recurrent blurring
*/

#pragma once
Expand All @@ -31,9 +28,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited.
#include <cstddef>

#define NRD_VERSION_MAJOR 3
#define NRD_VERSION_MINOR 3
#define NRD_VERSION_BUILD 1
#define NRD_VERSION_DATE "16 June 2022"
#define NRD_VERSION_MINOR 4
#define NRD_VERSION_BUILD 0
#define NRD_VERSION_DATE "14 July 2022"

#if defined(_MSC_VER)
#define NRD_CALL __fastcall
Expand Down Expand Up @@ -62,5 +59,8 @@ namespace nrd
NRD_API Result NRD_CALL SetMethodSettings(Denoiser& denoiser, Method method, const void* methodSettings);
NRD_API Result NRD_CALL GetComputeDispatches(Denoiser& denoiser, const CommonSettings& commonSettings, const DispatchDesc*& dispatchDescs, uint32_t& dispatchDescNum);
NRD_API void NRD_CALL DestroyDenoiser(Denoiser& denoiser);

// Helpers
NRD_API const char* GetResourceTypeString(ResourceType resourceType);
NRD_API const char* GetMethodString(Method method);
}
97 changes: 62 additions & 35 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 3
#define NRD_DESCS_VERSION_MINOR 3
#define NRD_DESCS_VERSION_MINOR 4

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 @@ -44,6 +44,11 @@ namespace nrd
// OUTPUTS - OUT_DIFF_HITDIST
REBLUR_DIFFUSE_OCCLUSION,

// INPUTS - IN_MV, IN_NORMAL_ROUGHNESS, IN_VIEWZ, IN_DIFF_SH0, IN_DIFF_SH1
// OPTIONAL INPUTS - IN_DIFF_CONFIDENCE
// OUTPUTS - OUT_DIFF_SH0, OUT_DIFF_SH1
REBLUR_DIFFUSE_SH,

// INPUTS - IN_MV, IN_NORMAL_ROUGHNESS, IN_VIEWZ, IN_SPEC_RADIANCE_HITDIST,
// OPTIONAL INPUTS - IN_SPEC_DIRECTION_PDF, IN_SPEC_CONFIDENCE
// OUTPUTS - OUT_SPEC_RADIANCE_HITDIST
Expand All @@ -53,6 +58,11 @@ namespace nrd
// OUTPUTS - OUT_SPEC_HITDIST
REBLUR_SPECULAR_OCCLUSION,

// INPUTS - IN_MV, IN_NORMAL_ROUGHNESS, IN_VIEWZ, IN_SPEC_SH0, IN_SPEC_SH1
// OPTIONAL INPUTS - IN_SPEC_CONFIDENCE
// OUTPUTS - OUT_SPEC_SH0, OUT_SPEC_SH1
REBLUR_SPECULAR_SH,

// INPUTS - IN_MV, IN_NORMAL_ROUGHNESS, IN_VIEWZ, IN_DIFF_RADIANCE_HITDIST, IN_SPEC_RADIANCE_HITDIST,
// OPTIONAL INPUTS - IN_DIFF_DIRECTION_PDF, IN_SPEC_DIRECTION_PDF, IN_DIFF_CONFIDENCE, IN_SPEC_CONFIDENCE
// OUTPUTS - OUT_DIFF_RADIANCE_HITDIST, OUT_SPEC_RADIANCE_HITDIST
Expand All @@ -62,6 +72,11 @@ namespace nrd
// OUTPUTS - OUT_DIFF_HITDIST, OUT_SPEC_HITDIST
REBLUR_DIFFUSE_SPECULAR_OCCLUSION,

// INPUTS - IN_MV, IN_NORMAL_ROUGHNESS, IN_VIEWZ, IN_DIFF_SH0, IN_DIFF_SH1, IN_SPEC_SH0, IN_SPEC_SH1
// OPTIONAL INPUTS - IN_DIFF_CONFIDENCE, IN_SPEC_CONFIDENCE
// OUTPUTS - OUT_DIFF_SH0, OUT_DIFF_SH1, OUT_SPEC_SH0, OUT_SPEC_SH1
REBLUR_DIFFUSE_SPECULAR_SH,

// INPUTS - IN_MV, IN_NORMAL_ROUGHNESS, IN_VIEWZ, IN_DIFF_DIRECTION_HITDIST,
// OPTIONAL INPUTS - IN_DIFF_DIRECTION_PDF, IN_DIFF_CONFIDENCE
// OUTPUTS - OUT_DIFF_DIRECTION_HITDIST
Expand Down Expand Up @@ -122,53 +137,64 @@ namespace nrd
enum class ResourceType : uint32_t
{
//=============================================================================================================================
// INPUTS
// COMMON INPUTS
//=============================================================================================================================

// 3D world space motion (RGBA16f+) or 2D screen space motion (RG16f+), MVs must be non-jittered, MV = previous - current
IN_MV,

// Data must match encoding / decoding in "NRD_FrontEnd_PackNormalAndRoughness" / "NRD_FrontEnd_UnpackNormalAndRoughness" (RGBA8+ or R10G10B10A2+)
// Data must match encoding in "NRD_FrontEnd_PackNormalAndRoughness" and "NRD_FrontEnd_UnpackNormalAndRoughness" (RGBA8+)
IN_NORMAL_ROUGHNESS,

// Linear view depth for primary rays (R16f+)
IN_VIEWZ,

// RELAX: Data must be packed using "RELAX_FrontEnd_PackRadianceAndHitDist"
// REBLUR: Data must be packed using "REBLUR_FrontEnd_PackRadianceAndHitDist" (and "REBLUR_FrontEnd_GetNormHitDist" for hit distance) (RGBA16f+)
// Noisy and weighted sum of hit distances along a path (using NRD_GetCorrectedHitDist), excluding primary hit distance.
// REBLUR works with normalized hit distances. It's recommended to use REBLUR_FrontEnd_GetNormHitDist for hit distance normalization.
// Normalization parameters should be passed into NRD as HitDistanceParameters for diffuse and specular separately for internal
// hit distance denormalization.
//=============================================================================================================================
// INPUTS
//=============================================================================================================================

// Noisy radiance and hit distance (RGBA16f+)
// REBLUR: use "REBLUR_FrontEnd_PackRadianceAndNormHitDist" for encoding
// RELAX: use "RELAX_FrontEnd_PackRadianceAndHitDist" for encoding
IN_DIFF_RADIANCE_HITDIST,
IN_SPEC_RADIANCE_HITDIST,

// REBLUR: Data must be packed using "REBLUR_FrontEnd_GetNormHitDist" (R8+)
// Noisy hit distance (R8+)
// REBLUR: use "REBLUR_FrontEnd_GetNormHitDist" for encoding
IN_DIFF_HITDIST,
IN_SPEC_HITDIST,

// REBLUR: Data must be packed using "REBLUR_FrontEnd_PackDirectionAndHitDist" (RGBA8+)
// Noisy bent normal and normalized hit distance (RGBA8+)
// REBLUR: use "REBLUR_FrontEnd_PackDirectionAndNormHitDist" for encoding
IN_DIFF_DIRECTION_HITDIST,

// (Optional) Data must be packed using "NRD_FrontEnd_PackDirectionAndPdf" (RGBA8+)
// These inputs are needed only if PrePassMode::ADVANCED is used. The data can be averaged or weighted in case of many RPP. Encoding / decoding
// can be changed in "NRD_FrontEnd_PackDirectionAndPdf" and "NRD_FrontEnd_UnpackDirectionAndPdf" functions.
// Noisy SH data (2x RGBA16f+)
// REBLUR: use "REBLUR_FrontEnd_PackSh" for encoding
IN_DIFF_SH0,
IN_DIFF_SH1,
IN_SPEC_SH0,
IN_SPEC_SH1,

// (Optional) Ray direction and sample PDF (RGBA8+)
// These inputs are needed only for PrePassMode::ADVANCED
// REBLUR: use "NRD_FrontEnd_PackDirectionAndPdf" for encoding
IN_DIFF_DIRECTION_PDF,
IN_SPEC_DIRECTION_PDF,

// (Optional) User-provided history confidence in range 0-1, i.e. antilag (R8+)
// Used only if "CommonSettings::isHistoryConfidenceInputsAvailable = true".
// Used only if "CommonSettings::isHistoryConfidenceInputsAvailable = true"
IN_DIFF_CONFIDENCE,
IN_SPEC_CONFIDENCE,

// SIGMA: Data must be packed using "SIGMA_FrontEnd_PackShadow" (3/5-args) (RG16+/RGBA8+)
// Noisy shadow data and optional translucency (RG16f+ and RGBA8+ for optional translucency)
// SIGMA: use "SIGMA_FrontEnd_PackShadow" for encoding
IN_SHADOWDATA,
IN_SHADOW_TRANSLUCENCY,

// Any signal
// Noisy signal (R8+)
IN_RADIANCE,

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

Expand All @@ -178,37 +204,38 @@ namespace nrd

// IMPORTANT: These textures can potentially be used as history buffers!

// REBLUR: Data must be unpacked using "REBLUR_BackEnd_UnpackRadianceAndHitDist"
// .xyz - radiance, .w - normalized hit distance (RGBA16f+)
// RELAX: Data must be unpacked using "RELAX_BackEnd_UnpackRadianceAndHitDist"
// .xyz - radiance (R11G11B10f+)
// Denoised radiance and hit distance
// REBLUR: use "REBLUR_BackEnd_UnpackRadianceAndNormHitDist" for decoding (RGBA16f+)
// RELAX: use "RELAX_BackEnd_UnpackRadiance" for decoding (R11G11B10f+)
OUT_DIFF_RADIANCE_HITDIST,
OUT_SPEC_RADIANCE_HITDIST,

// .x - normalized hit distance (R8+)
// Denoised SH data
// REBLUR: use "REBLUR_BackEnd_UnpackSh" for decoding (2x RGBA16f+)
OUT_DIFF_SH0,
OUT_DIFF_SH1,
OUT_SPEC_SH0,
OUT_SPEC_SH1,

// Denoised normalized hit distance (R8+)
OUT_DIFF_HITDIST,
OUT_SPEC_HITDIST,

// .xyz - direction, .w - normalized hit distance (RGBA8+)
// Denoised bent normal and normalized hit distance (RGBA8+)
// REBLUR: use "REBLUR_BackEnd_UnpackDirectionAndNormHitDist" for decoding
OUT_DIFF_DIRECTION_HITDIST,

// SIGMA: Data must be unpacked using "SIGMA_BackEnd_UnpackShadow"
// .x - shadow, .yzw - translucency (RGBA8+)
// .x - shadow (R8+)
// Usage:
// shadowData = SIGMA_BackEnd_UnpackShadow( shadowData );
// float3 finalShadowCommon = lerp( shadowData.yzw, 1.0, shadowData.x ); // or
// float3 finalShadowExotic = shadowData.yzw * shadowData.x; // or
// float3 finalShadowMoreExotic = shadowData.yzw;
// Denoised shadow and optional transcluceny (R8+ or RGBA8+)
// SIGMA: use "SIGMA_BackEnd_UnpackShadow" for decoding
OUT_SHADOW_TRANSLUCENCY,

// .xyz - accumulated signal
// Denoised signal
OUT_RADIANCE,

// .xy - 2D screen space virtual motion (RG16f+), MV = previous - current
// 2D screen space specular motion (RG16f+), MV = previous - current
OUT_REFLECTION_MV,

// .xy - 2D screen space motion (RG16f+), MV = previous - current
// 2D screen space refraction motion (RG16f+), MV = previous - current
OUT_DELTA_MV,

//=============================================================================================================================
Expand Down
45 changes: 29 additions & 16 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 3
#define NRD_SETTINGS_VERSION_MINOR 3
#define NRD_SETTINGS_VERSION_MINOR 4

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 @@ -109,7 +109,7 @@ namespace nrd
// (units) > 0 - use TLAS or tracing range (max value = NRD_FP16_MAX / NRD_FP16_VIEWZ_SCALE - 1 = 524031)
float denoisingRange = 500000.0f;

// (normalized %)
// (normalized %) - if relative distance difference is greater than threshold, history gets reset (0.25-1.5% works well)
float disocclusionThreshold = 0.005f;

// [0; 1] - enables "noisy input / denoised output" comparison
Expand Down Expand Up @@ -191,7 +191,7 @@ namespace nrd
float sensitivityToDarkness = 0.0f; // IMPORTANT: 0 is a bad default

// Ideally, must be enabled, but since "sensitivityToDarkness" requires fine tuning from the app side it is disabled by default
bool enable = false;
bool enable = false; // IMPORTANT: doesn't affect "occlusion" denoisers
};

struct AntilagHitDistanceSettings
Expand Down Expand Up @@ -220,7 +220,10 @@ namespace nrd
AntilagHitDistanceSettings antilagHitDistanceSettings = {};

// [0; REBLUR_MAX_HISTORY_FRAME_NUM] - maximum number of linearly accumulated frames (= FPS * "time of accumulation")
uint32_t maxAccumulatedFrameNum = 31;
uint32_t maxAccumulatedFrameNum = 30;

// [0; REBLUR_MAX_HISTORY_FRAME_NUM] - maximum number of linearly accumulated frames in fast history
uint32_t maxFastAccumulatedFrameNum = 6;

// (pixels) - pre-accumulation spatial reuse pass blur radius (0 = disabled, must be used in case of probabilistic sampling)
float diffusePrepassBlurRadius = 30.0f;
Expand Down Expand Up @@ -253,9 +256,6 @@ namespace nrd
// (normalized %) - represents maximum allowed deviation from local tangent plane
float planeDistanceSensitivity = 0.005f;

// (normalized %) - adds a portion of input to the output of spatial passes
float inputMix = 0.0f;

// If not OFF and used for DIFFUSE_SPECULAR, defines diffuse orientation, specular orientation is the opposite
CheckerboardMode checkerboardMode = CheckerboardMode::OFF;

Expand Down Expand Up @@ -301,12 +301,12 @@ namespace nrd
float specularPrepassBlurRadius = 50.0f;

// [0; RELAX_MAX_HISTORY_FRAME_NUM] - maximum number of linearly accumulated frames ( = FPS * "time of accumulation")
uint32_t diffuseMaxAccumulatedFrameNum = 31;
uint32_t specularMaxAccumulatedFrameNum = 31;
uint32_t diffuseMaxAccumulatedFrameNum = 30;
uint32_t specularMaxAccumulatedFrameNum = 30;

// [0; RELAX_MAX_HISTORY_FRAME_NUM] - maximum number of linearly accumulated frames in fast history
uint32_t diffuseMaxFastAccumulatedFrameNum = 8;
uint32_t specularMaxFastAccumulatedFrameNum = 8;
uint32_t diffuseMaxFastAccumulatedFrameNum = 6;
uint32_t specularMaxFastAccumulatedFrameNum = 6;

// A-trous edge stopping Luminance sensitivity
float diffusePhiLuminance = 2.0f;
Expand Down Expand Up @@ -350,6 +350,11 @@ namespace nrd
// (normalized %) - A-trous edge stopping depth threshold
float depthThreshold = 0.01f;

// Confidence inputs can affect spatial blurs, relaxing some weights in areas with low confidence
float confidenceDrivenRelaxationMultiplier = 0.0f;
float confidenceDrivenLuminanceEdgeStoppingRelaxation = 0.0f;
float confidenceDrivenNormalEdgeStoppingRelaxation = 0.0f;

// How much we relax roughness based rejection in areas where specular reprojection is low
float luminanceEdgeStoppingRelaxation = 0.5f;
float normalEdgeStoppingRelaxation = 0.3f;
Expand Down Expand Up @@ -384,8 +389,8 @@ namespace nrd
{
float prepassBlurRadius = 0.0f;

uint32_t diffuseMaxAccumulatedFrameNum = 31;
uint32_t diffuseMaxFastAccumulatedFrameNum = 8;
uint32_t diffuseMaxAccumulatedFrameNum = 30;
uint32_t diffuseMaxFastAccumulatedFrameNum = 6;

float diffusePhiLuminance = 2.0f;
float diffuseLobeAngleFraction = 0.5f;
Expand All @@ -401,6 +406,10 @@ namespace nrd
float minLuminanceWeight = 0.0f;
float depthThreshold = 0.01f;

float confidenceDrivenRelaxationMultiplier = 0.0f;
float confidenceDrivenLuminanceEdgeStoppingRelaxation = 0.0f;
float confidenceDrivenNormalEdgeStoppingRelaxation = 0.0f;

CheckerboardMode checkerboardMode = CheckerboardMode::OFF;
HitDistanceReconstructionMode hitDistanceReconstructionMode = HitDistanceReconstructionMode::OFF;

Expand All @@ -415,8 +424,8 @@ namespace nrd
{
float prepassBlurRadius = 50.0f;

uint32_t specularMaxAccumulatedFrameNum = 31;
uint32_t specularMaxFastAccumulatedFrameNum = 8;
uint32_t specularMaxAccumulatedFrameNum = 30;
uint32_t specularMaxFastAccumulatedFrameNum = 6;

float specularPhiLuminance = 1.0f;
float diffuseLobeAngleFraction = 0.5f;
Expand All @@ -437,6 +446,10 @@ namespace nrd
float minLuminanceWeight = 0.0f;
float depthThreshold = 0.01f;

float confidenceDrivenRelaxationMultiplier = 0.0f;
float confidenceDrivenLuminanceEdgeStoppingRelaxation = 0.0f;
float confidenceDrivenNormalEdgeStoppingRelaxation = 0.0f;

float luminanceEdgeStoppingRelaxation = 0.5f;
float normalEdgeStoppingRelaxation = 0.3f;
float roughnessEdgeStoppingRelaxation = 0.3f;
Expand All @@ -456,7 +469,7 @@ namespace nrd
struct ReferenceSettings
{
// (>= 0) - maximum number of linearly accumulated frames ( = FPS * "time of accumulation")
uint32_t maxAccumulatedFrameNum = 3600;
uint32_t maxAccumulatedFrameNum = 1024;
};

// SPECULAR_REFLECTION_MV
Expand Down
Loading

0 comments on commit 168655c

Please sign in to comment.