Skip to content

Commit

Permalink
NRD v3.6.0:
Browse files Browse the repository at this point in the history
HIGHLIGHTS:
- NRD: removed "SpecularLobeTrimmingParameters"
- NRD: improved NRD SDK generation script
- REBLUR: regression and bug fixes (sorry, it's an expected side effect of doing steps forward)
- REBLUR: improved IQ and performance

DETAILS:
- NRD: removed "SpecularLobeTrimmingParameters"
- NRD: improved NRD SDK generation script
- NRD: Fooplot graphs replaced with Desmos graphs
- NRD: improved compatibility with HLSL 2021 (WIP)
- NRD: clarified in comments where NRD_USE_OCT_NORMAL_ENCODING and NRD_USE_MATERIAL_ID come from
- NRD: getting rid of point-mirror samplers in the shader code
- REBLUR: changed estimation of optimal hitT for tracking
- REBLUR: added random rotation to HistoryFix pass
- REBLUR: hitT for very low roughness is not modified by HistoryFix pass (already clean)
- REBLUR: made another attempt to properly tune virtual parallax based history rejection
- REBLUR: fixed SH related bug in pre-pass (regression)
- REBLUR: improved SH denoising (pre-pass now behaves as "advanced" since direction and PDF are available)
- REBLUR: unified hitT weight between radiance and hitT
- REBLUR: unified hit distance factor
- REBLUR: improved performance
- REBLUR: fixed a rare case of out-of-bounds access, when unused half of a resource is filled with NaNs
- REBLUR: improved calculation of virtual motion based accumulation speed for specular
- REBLUR: blur radius refactoring (all relevant code gathered in one place for clarity)
- REBLUR: fixed a minor issue in debug visualization
- REBLUR: tuned blur radius "addon"
- REBLUR: code refactoring and simplification
- SIGMA: changed shader names to match overall REBLUR style (no functional changes)
- updated README & UPDATE
  • Loading branch information
dzhdanNV committed Sep 5, 2022
1 parent 39b7ae9 commit 247382b
Show file tree
Hide file tree
Showing 54 changed files with 622 additions and 600 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
-
name: Prepare NRD SDK
run: |
&'.\3-Prepare NRD SDK.bat' --no-pause --copy-shaders
&'.\3-Prepare NRD SDK.bat' --no-pause --shaders
-
name: Upload NRD SDK as artefact
uses: actions/upload-artifact@v3
Expand Down
54 changes: 40 additions & 14 deletions 3-Prepare NRD SDK.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@ set NRD_DIR=.
set "use_pause=y"
set "copy_shaders="
set "no_copy_shaders="
set "copy_integration="
set "no_copy_integration="

:PARSE
if "%~1"=="" goto :MAIN

if /i "%~1"=="-h" goto :HELP
if /i "%~1"=="--help" goto :HELP
if /i "%~1"=="-h" goto :HELP
if /i "%~1"=="--help" goto :HELP

if /i "%~1"=="--no-pause" set "use_pause="
if /i "%~1"=="--no-pause" set "use_pause="

if /i "%~1"=="--copy-shaders" set "copy_shaders=y"
if /i "%~1"=="--no-copy-shaders" set "no_copy_shaders=y"
if /i "%~1"=="--shaders" set "copy_shaders=y"
if /i "%~1"=="--no-shaders" set "no_copy_shaders=y"

if /i "%~1"=="--integration" set "copy_integration=y"
if /i "%~1"=="--no-integration" set "no_copy_integration=y"

shift
goto :PARSE
Expand All @@ -24,43 +29,64 @@ goto :PARSE
rd /q /s "_NRD_SDK"

mkdir "_NRD_SDK\Include"
mkdir "_NRD_SDK\Integration"
mkdir "_NRD_SDK\Lib\Debug"
mkdir "_NRD_SDK\Lib\Release"
mkdir "_NRD_SDK\Shaders"
mkdir "_NRD_SDK\Shaders\Include"

cd "_NRD_SDK"

copy "..\%NRD_DIR%\Integration\*" "Integration"
copy "..\%NRD_DIR%\Include\*" "Include"
copy "..\_Build\Debug\NRD.dll" "Lib\Debug"
copy "..\_Build\Debug\NRD.lib" "Lib\Debug"
copy "..\_Build\Debug\NRD.pdb" "Lib\Debug"
copy "..\_Build\Release\NRD.dll" "Lib\Release"
copy "..\_Build\Release\NRD.lib" "Lib\Release"
copy "..\%NRD_DIR%\Shaders\Include\NRD.hlsli" "Shaders\Include"
copy "..\%NRD_DIR%\LICENSE.txt" "."
copy "..\%NRD_DIR%\README.md" "."

echo.
if defined copy_shaders goto :SHADERS
if defined no_copy_shaders goto :END
if defined no_copy_shaders goto :PRE_INTEGRATION
set /P M=Do you need the shader source code for a white-box integration? [y/n]
if /I "%M%" neq "y" goto END
if /I "%M%" neq "y" goto :PRE_INTEGRATION

:SHADERS

mkdir "Shaders"

xcopy "..\%NRD_DIR%\Shaders\" "Shaders" /s
xcopy "..\%NRD_DIR%\Shaders\" "Shaders" /s /y
copy "..\%NRD_DIR%\External\MathLib\*.hlsli" "Shaders\Source"

:PRE_INTEGRATION

echo.
if defined copy_integration goto :INTEGRATION
if defined no_copy_integration goto :END
set /P M=Do you need NRD integration layer? [y/n]
if /I "%M%" neq "y" goto :END

:INTEGRATION

mkdir "Integration"
copy "..\%NRD_DIR%\Integration\*" "Integration"

cd ..

:END

cd ..
if defined use_pause pause
exit
exit /b %errorlevel%

:HELP

echo. -h, --help show help message
echo. --no-pause skip pause in the end of script
echo. --copy-shaders copy shadres for a white-box integration
echo. --no-copy-shaders don't copy shadres for a white-box integration
echo. --no-pause skip pause at the end of the script
echo. --shaders copy shaders for a white-box integration
echo. --no-shaders do not copy shaders for a white-box integration
echo. --integration copy NRD integration layer
echo. --no-integration do not copy NRD integration layer

exit
14 changes: 12 additions & 2 deletions 3-Prepare NRD SDK.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ NRD_DIR=.
rm -rf "_NRD_SDK"

mkdir -p "_NRD_SDK/Include"
mkdir -p "_NRD_SDK/Integration"
mkdir -p "_NRD_SDK/Lib/Debug"
mkdir -p "_NRD_SDK/Lib/Release"
mkdir -p "_NRD_SDK/Shaders"
mkdir -p "_NRD_SDK/Shaders/Include"

cd "_NRD_SDK"

cp -r ../$NRD_DIR/Integration/ "Integration"
cp -r ../$NRD_DIR/Include/ "Include"
cp -H ../_Build/Debug/libNRD.so "Lib/Debug"
cp -H ../_Build/Release/libNRD.so "Lib/Release"
cp ../$NRD_DIR/Shaders/Include/NRD.hlsli "Shaders/Include"
cp ../$NRD_DIR/LICENSE.txt "."
cp ../$NRD_DIR/README.md "."

Expand All @@ -28,4 +29,13 @@ then
cp ../$NRD_DIR/External/MathLib/*.hlsli "Shaders\Source"
fi

read -p "Do you need NRD integration layer? [y/n]" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
mkdir -p "Integration"

cp -r ../$NRD_DIR/Integration/ "Integration"
fi

cd ..
2 changes: 1 addition & 1 deletion External/MathLib
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 3
#define NRD_VERSION_MINOR 5
#define NRD_VERSION_MINOR 6
#define NRD_VERSION_BUILD 0
#define NRD_VERSION_DATE "1 September 2022"
#define NRD_VERSION_DATE "6 September 2022"

#if defined(_MSC_VER)
#define NRD_CALL __fastcall
Expand Down
6 changes: 3 additions & 3 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 5
#define NRD_DESCS_VERSION_MINOR 6

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 @@ -353,8 +353,8 @@ namespace nrd
uint8_t versionMajor;
uint8_t versionMinor;
uint8_t versionBuild;
uint8_t maxSupportedMaterialBitNum;
bool isCompiledWithOctPackNormalEncoding : 1;
uint8_t maxSupportedMaterialBitNum; // if 0, compiled with NRD_USE_MATERIAL_ID = 0
bool isCompiledWithOctPackNormalEncoding : 1; // if 0, compield with NRD_USE_OCT_NORMAL_ENCODING = 0
};

struct MethodDesc
Expand Down
17 changes: 1 addition & 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 5
#define NRD_SETTINGS_VERSION_MINOR 6

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 @@ -157,20 +157,6 @@ namespace nrd
float D = -25.0f;
};

// Optional specular lobe trimming = A * smoothstep( B, C, roughness )
// Recommended settings if lobe trimming is needed = { 0.85f, 0.04f, 0.11f }
struct SpecularLobeTrimmingParameters
{
// [0; 1] - main level (0 - GGX dominant direction, 1 - full lobe)
float A = 1.0f;

// [0; 1] - max trimming if roughness is less than this threshold
float B = 0.0f;

// [0; 1] - main level if roughness is greater than this threshold
float C = 0.0001f;
};

// Antilag logic:
// delta = ( abs( old - new ) - localVariance * sigmaScale ) / ( max( old, new ) + localVariance * sigmaScale + sensitivityToDarkness )
// delta = LinearStep( thresholdMax, thresholdMin, delta )
Expand Down Expand Up @@ -214,7 +200,6 @@ namespace nrd

struct ReblurSettings
{
SpecularLobeTrimmingParameters specularLobeTrimmingParameters = {};
HitDistanceParameters hitDistanceParameters = {};
AntilagIntensitySettings antilagIntensitySettings = {};
AntilagHitDistanceSettings antilagHitDistanceSettings = {};
Expand Down
4 changes: 2 additions & 2 deletions Integration/NRDIntegration.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ license agreement from NVIDIA CORPORATION is strictly prohibited.

#define NRD_INTEGRATION 1
#define NRD_INTEGRATION_MAJOR 3
#define NRD_INTEGRATION_MINOR 0
#define NRD_INTEGRATION_DATE "14 July 2022"
#define NRD_INTEGRATION_MINOR 2
#define NRD_INTEGRATION_DATE "6 September 2022"

// Settings
#ifndef NRD_INTEGRATION_ASSERT
Expand Down
4 changes: 2 additions & 2 deletions Integration/NRDIntegration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ license agreement from NVIDIA CORPORATION is strictly prohibited.

#include "NRDIntegration.h"

static_assert(NRD_VERSION_MAJOR >= 3 && NRD_VERSION_MINOR >= 4, "Unsupported NRD version!");
static_assert(NRD_VERSION_MAJOR >= 3 && NRD_VERSION_MINOR >= 6, "Unsupported NRD version!");

#if _WIN32
#define NRD_INTEGRATION_ALLOCA _alloca
Expand Down Expand Up @@ -449,7 +449,7 @@ void NrdIntegration::Dispatch(nri::CommandBuffer& commandBuffer, nri::Descriptor
{
nrdTexture = (NrdIntegrationTexture*)&userPool[(uint32_t)nrdResource.type];

NRD_INTEGRATION_ASSERT( nrdTexture && nrdTexture->subresourceStates && nrdTexture->subresourceStates->texture, "IN_XXX can't be NULL if it's in use!");
NRD_INTEGRATION_ASSERT( nrdTexture && nrdTexture->subresourceStates && nrdTexture->subresourceStates->texture, "'userPool' entry can't be NULL if it's in use!");
NRD_INTEGRATION_ASSERT( nrdTexture->format != nri::Format::UNKNOWN, "Format must be a valid format!");
}

Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NVIDIA Real-time Denoisers v3.5.0 (NRD)
# NVIDIA Real-time Denoisers v3.6.0 (NRD)

## SAMPLE APP

Expand Down Expand Up @@ -169,7 +169,7 @@ commandBufferDesc.d3d12CommandAllocator = (ID3D12CommandAllocator*)d3d12CommandA
nri::CommandBuffer* nriCommandBuffer = nullptr;
NRI.CreateCommandBufferD3D12(*nriDevice, commandBufferDesc, nriCommandBuffer);

// Wrap required textures
// Wrap required textures (better do it only once on initialization)
nri::TextureTransitionBarrierDesc entryDescs[N] = {};
nri::Format entryFormat[N] = {};

Expand Down Expand Up @@ -217,14 +217,18 @@ NrdUserPool userPool = {};
NrdIntegration_SetResource(userPool, ...);
};

NRD.Denoise(*nriCommandBuffer, commonSettings, userPool);
// Better use "true" if NRI texture wrappers are non-volatile between frames
bool enableDescriptorCaching = true;

NRD.Denoise(frameIndex, *nriCommandBuffer, commonSettings, userPool, enableDescriptorCaching);

// IMPORTANT: NRD integration binds own descriptor pool, don't forget to re-bind back your descriptor pool (heap)

//====================================================================================================================
// SHUTDOWN or RENDER - CLEANUP
//====================================================================================================================

// Better do it only once on shutdown
for (uint32_t i = 0; i < N; i++)
NRI.DestroyTexture(entryDescs[i].texture);

Expand Down Expand Up @@ -308,6 +312,8 @@ Commons inputs:
- project on screen using matrices passed to NRD
- `.w` component is positive view Z (or just transform world space position to main view space and take `.z` component)
**IMPORTANT**: All textures should be *NaN* free at each pixel, even at pixels outside of denoising range.
See `NRDDescs.h` for more details and descriptions of other inputs and outputs.
## NOISY DATA REQUIREMENTS
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 3
#define VERSION_MINOR 5
#define VERSION_MINOR 6
#define VERSION_BUILD 0
#define VERSION_REVISION 0

Expand Down
21 changes: 9 additions & 12 deletions Shaders/Include/Common.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ float PixelRadiusToWorld( float unproject, float orthoMode, float pixelRadius, f
return pixelRadius * unproject * lerp( viewZ, 1.0, abs( orthoMode ) );
}

float GetHitDistFactor( float hitDist, float frustumHeight, float scale = 1.0 )
float GetHitDistFactor( float hitDist, float frustumHeight )
{
return saturate( hitDist / ( hitDist * scale + frustumHeight ) );
return saturate( hitDist / frustumHeight );
}

float4 GetBlurKernelRotation( compiletime const uint mode, uint2 pixelPos, float4 baseRotator, uint frameIndex )
Expand Down Expand Up @@ -152,10 +152,10 @@ float2 ApplyCheckerboardShift( float2 uv, uint mode, uint counter, float2 screen
return ( float2( uvi ) + 0.5 ) * invScreenSize;
}

// Comparison of two methods:
// https://www.desmos.com/calculator/xwq1nrawho
float GetSpecMagicCurve( float roughness, float power = 0.25 )
{
// http://fooplot.com/#W3sidHlwZSI6MCwiZXEiOiIoMS0yXigtMjAwKngqeCkpKih4XjAuMDEpIiwiY29sb3IiOiIjMDAwMDAwIn0seyJ0eXBlIjowLCJlcSI6IigxLTJeKC0yMDAqeCp4KSkqKHheMC4xKSIsImNvbG9yIjoiIzAwMDAwMCJ9LHsidHlwZSI6MCwiZXEiOiIoMS0yXigtMjAwKngqeCkpKih4XjAuMjUpIiwiY29sb3IiOiIjMDBGRjA5In0seyJ0eXBlIjowLCJlcSI6IigxLTJeKC0yMDAqeCp4KSkqKHheMC4zKSIsImNvbG9yIjoiIzAwMDAwMCJ9LHsidHlwZSI6MCwiZXEiOiIoMS0yXigtMjAwKngqeCkpKih4XjAuNSkiLCJjb2xvciI6IiNENjIwMDAifSx7InR5cGUiOjAsImVxIjoiKDEtMl4oLTIwMCp4KngpKSooeF4wLjcpIiwiY29sb3IiOiIjMDAwMDAwIn0seyJ0eXBlIjowLCJlcSI6IigxLTJeKC0yMDAqeCp4KSkqKHheMC45KSIsImNvbG9yIjoiIzAwMDAwMCJ9LHsidHlwZSI6MCwiZXEiOiIoMS0yXigtMjAwKngqeCkpKih4XjAuOTkpIiwiY29sb3IiOiIjMDAwMDAwIn0seyJ0eXBlIjoxMDAwLCJ3aW5kb3ciOlsiMCIsIjEiLCIwIiwiMS4xIl0sInNpemUiOlsxMDAwLDUwMF19XQ--

float f = 1.0 - exp2( -200.0 * roughness * roughness );
f *= STL::Math::Pow01( roughness, power );

Expand All @@ -164,9 +164,6 @@ float GetSpecMagicCurve( float roughness, float power = 0.25 )

float GetSpecMagicCurve2( float roughness, float percentOfVolume = 0.987 )
{
// http://fooplot.com/#W3sidHlwZSI6MCwiZXEiOiJhdGFuKDAuOTkqeCp4LygxLTAuOTkpKS8oYXRhbigwLjk5LygxLTAuOTkpKSkiLCJjb2xvciI6IiMwMDAwMDAifSx7InR5cGUiOjAsImVxIjoiYXRhbigwLjk4Nyp4KngvKDEtMC45ODcpKS8oYXRhbigwLjk4Ny8oMS0wLjk4NykpKSIsImNvbG9yIjoiIzE5QkEwMCJ9LHsidHlwZSI6MCwiZXEiOiJhdGFuKDAuOTcqeCp4LygxLTAuOTcpKS8oYXRhbigwLjk3LygxLTAuOTcpKSkiLCJjb2xvciI6IiMwMDAwMDAifSx7InR5cGUiOjAsImVxIjoiYXRhbigwLjk1KngqeC8oMS0wLjk1KSkvKGF0YW4oMC45NS8oMS0wLjk1KSkpIiwiY29sb3IiOiIjMDAwMDAwIn0seyJ0eXBlIjowLCJlcSI6ImF0YW4oMC45KngqeC8oMS0wLjkpKS8oYXRhbigwLjkvKDEtMC45KSkpIiwiY29sb3IiOiIjMDAwMDAwIn0seyJ0eXBlIjowLCJlcSI6ImF0YW4oMC44NSp4KngvKDEtMC44NSkpLyhhdGFuKDAuODUvKDEtMC44NSkpKSIsImNvbG9yIjoiIzAwMDAwMCJ9LHsidHlwZSI6MCwiZXEiOiJhdGFuKDAuOCp4KngvKDEtMC44KSkvKGF0YW4oMC44LygxLTAuOCkpKSIsImNvbG9yIjoiIzAwMDAwMCJ9LHsidHlwZSI6MCwiZXEiOiJhdGFuKDAuNzUqeCp4LygxLTAuNzUpKS8oYXRhbigwLjc1LygxLTAuNzUpKSkiLCJjb2xvciI6IiMwMDAwMDAifSx7InR5cGUiOjAsImVxIjoiYXRhbigwLjcqeCp4LygxLTAuNykpLyhhdGFuKDAuNy8oMS0wLjcpKSkiLCJjb2xvciI6IiMwMDAwMDAifSx7InR5cGUiOjEwMDAsIndpbmRvdyI6WyIwIiwiMSIsIjAiLCIxLjEiXSwic2l6ZSI6WzEwMDAsNTAwXX1d
// http://fooplot.com/#W3sidHlwZSI6MCwiZXEiOiIoMS0yXigtMjAwKngqeCkpKih4XjAuMjUpIiwiY29sb3IiOiIjMDAwMDAwIn0seyJ0eXBlIjowLCJlcSI6ImF0YW4oMC45ODcqeCp4LygxLTAuOTg3KSkvKGF0YW4oMC45ODcvKDEtMC45ODcpKSkiLCJjb2xvciI6IiMxREQ2MDAifSx7InR5cGUiOjAsImVxIjoiYXRhbigwLjk3KngqeC8oMS0wLjk3KSkvKGF0YW4oMC45Ny8oMS0wLjk3KSkpIiwiY29sb3IiOiIjQ0MzMDAwIn0seyJ0eXBlIjoxMDAwLCJ3aW5kb3ciOlsiMCIsIjEiLCIwIiwiMS4xIl0sInNpemUiOlsxMDAwLDUwMF19XQ--

float angle = STL::ImportanceSampling::GetSpecularLobeHalfAngle( roughness, percentOfVolume );
float almostHalfPi = STL::ImportanceSampling::GetSpecularLobeHalfAngle( 1.0, percentOfVolume );

Expand Down Expand Up @@ -204,8 +201,6 @@ float GetColorCompressionExposureForSpatialPasses( float roughness )
// - the compression function must be monotonic for full roughness range
// - returned exposure must be used with colors in the HDR range used in tonemapping, i.e. "color * exposure"

// http://fooplot.com/#W3sidHlwZSI6MCwiZXEiOiIwLjUvKDErNTAqeCkiLCJjb2xvciI6IiNGNzBBMEEifSx7InR5cGUiOjAsImVxIjoiMC41KigxLXgpLygxKzYwKngpIiwiY29sb3IiOiIjMkJGRjAwIn0seyJ0eXBlIjowLCJlcSI6IjAuNSooMS14KS8oMSsxMDAwKngqeCkrKDEteF4wLjUpKjAuMDMiLCJjb2xvciI6IiMwMDU1RkYifSx7InR5cGUiOjAsImVxIjoiMC42KigxLXgqeCkvKDErNDAwKngqeCkiLCJjb2xvciI6IiMwMDAwMDAifSx7InR5cGUiOjEwMDAsIndpbmRvdyI6WyIwIiwiMSIsIjAiLCIxIl0sInNpemUiOlsyOTUwLDk1MF19XQ--

// Moderate compression
#if( NRD_RADIANCE_COMPRESSION_MODE == 1 )
return 0.5 / ( 1.0 + 50.0 * roughness );
Expand Down Expand Up @@ -338,8 +333,10 @@ float2 GetGeometryWeightParams( float planeDistSensitivity, float frustumHeight,

float2 GetHitDistanceWeightParams( float hitDist, float nonLinearAccumSpeed, float roughness = 1.0 )
{
// IMPORTANT: since this weight is exponential, 3% can lead to leaks from bright objects in reflections.
// Eeven 1% is not enough in some cases, but using a lower value makes things even more fragile
float smc = GetSpecMagicCurve2( roughness );
float norm = lerp( 0.03, 1.0, min( nonLinearAccumSpeed, smc ) );
float norm = lerp( 0.01, 1.0, min( nonLinearAccumSpeed, smc ) );
float a = 1.0 / norm;
float b = hitDist * a;

Expand All @@ -351,12 +348,12 @@ float2 GetHitDistanceWeightParams( float hitDist, float nonLinearAccumSpeed, flo
// IMPORTANT:
// - works for "negative x" only
// - huge error for x < -2, but still applicable for "weight" calculations
// http://fooplot.com/#W3sidHlwZSI6MCwiZXEiOiJleHAoeCkiLCJjb2xvciI6IiMwMDAwMDAifSx7InR5cGUiOjAsImVxIjoiMS8oeCp4LXgrMSkiLCJjb2xvciI6IiMwRkIwMDAifSx7InR5cGUiOjEwMDAsIndpbmRvdyI6WyItMTAiLCIwIiwiMCIsIjEiXX1d
// https://www.desmos.com/calculator/cd3mvg1gfo
#define ExpApprox( x ) \
rcp( ( x ) * ( x ) - ( x ) + 1.0 )

// Must be used for noisy data
// http://fooplot.com/#W3sidHlwZSI6MCwiZXEiOiIxLWFicygoeC0wLjUpLzAuMikiLCJjb2xvciI6IiMwMDAwMDAifSx7InR5cGUiOjAsImVxIjoiZXhwKC0yKmFicygoeC0wLjUpLzAuMikpIiwiY29sb3IiOiIjRkYwMDE1In0seyJ0eXBlIjowLCJlcSI6IjEvKCgtMyphYnMoKHgtMC41KS8wLjIpKV4yLSgtMyphYnMoKHgtMC41KS8wLjIpKSsxKSIsImNvbG9yIjoiIzAwQTgyNyJ9LHsidHlwZSI6MTAwMCwid2luZG93IjpbIjAiLCIxIiwiMCIsIjEiXX1d
// https://www.desmos.com/calculator/9yoyc3is2g
// scale = 3-5 is needed to match energy in "_ComputeNonExponentialWeight" ( especially when used in a recurrent loop )
#define _ComputeExponentialWeight( x, px, py ) \
ExpApprox( -NRD_EXP_WEIGHT_DEFAULT_SCALE * abs( ( x ) * ( px ) + ( py ) ) )
Expand Down
Loading

0 comments on commit 247382b

Please sign in to comment.