Skip to content

Commit

Permalink
NRD updated to v4.3.0:
Browse files Browse the repository at this point in the history
- PT: hair shading
- PT: optimized instance data
- PT: fixed / improved previous frame reuse
- PT: updated ray offsetting constants
- PT: ignored rays pointing inside the surface
- PT: primary and indirect ray tracing merged into a single pass
- PT: added depth of field
- UI: exposed or changed antilag settings
- added USE_PUDDLES for puddles emulation
- added visualization of "Material ID"
- fixed VK validation errors
- resolution 5120x1440 added to .args
- various convenience changes and bug fixes
- updated tests
- updated dependencies
  • Loading branch information
dzhdanNV committed Sep 22, 2023
1 parent 291ac00 commit 114039d
Show file tree
Hide file tree
Showing 27 changed files with 2,095 additions and 1,174 deletions.
23 changes: 20 additions & 3 deletions .args
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
{
"Command": "--width=3440 --height=1440"
},
{
"Command": "--width=5120 --height=1440"
},
{
"Command": "--width=3840 --height=2160"
}
Expand All @@ -46,6 +49,20 @@
}
]
},
{
"Command": "DPI",
"Items": [
{
"Command": "--dpiMode=0"
},
{
"Command": "--dpiMode=1"
},
{
"Command": "--dpiMode=2"
}
]
},
{
"Command": "OTHER",
"Items": [
Expand All @@ -58,9 +75,6 @@
{
"Command": "--debugNRD"
},
{
"Command": "--ignoreDPI"
},
{
"Command": "--frameNum=9999999"
}
Expand All @@ -78,6 +92,9 @@
{
"Command": "--scene=Bistro/BistroExterior.gltf"
},
{
"Command": "--scene=Hair/Hair.gltf"
},
{
"Command": "--scene=Kitchen/Kitchen.gltf"
}
Expand Down
1 change: 0 additions & 1 deletion 1-Deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
git submodule update --init --recursive

chmod +x "External/Packman/packman.sh"
chmod +x "External/NRIFramework/External/Packman/packman.sh"
chmod +x "External/NRIFramework/External/NRI/External/Packman/packman.sh"
chmod +x "2-Build.sh"
chmod +x "3-Prepare NRD SDK.sh"
Expand Down
12 changes: 6 additions & 6 deletions 3-Run NRD sample.bat
Original file line number Diff line number Diff line change
Expand Up @@ -116,28 +116,28 @@ echo 5 - quality
goto CHOOSE_DLSS

:SCENE
set SCENE=Bistro/BistroInterior.fbx
set SCENE=Bistro\BistroInterior.gltf
echo.
echo 1 - Bistro (interior)
echo 2 - Bistro (exterior)
echo 3 - Shader balls
echo 4 - Zero day
echo 4 - Kitchen
:CHOOSE_SCENE
set /P M=Choose scene [1-4]:
if %M%==1 (
set SCENE=Bistro\BistroInterior.fbx
set SCENE=Bistro\BistroInterior.gltf
goto RUN
)
if %M%==2 (
set SCENE=Bistro\BistroExterior.fbx
set SCENE=Bistro\BistroExterior.gltf
goto RUN
)
if %M%==3 (
set SCENE=ShaderBalls\ShaderBalls.obj
set SCENE=ShaderBalls\ShaderBalls.gltf
goto RUN
)
if %M%==4 (
set SCENE=ZeroDay\MEASURE_SEVEN/MEASURE_SEVEN.fbx
set SCENE=Kitchen\Kitchen.gltf
goto RUN
)
goto CHOOSE_SCENE
Expand Down
2 changes: 1 addition & 1 deletion External/NRD
Submodule NRD updated 65 files
+8 −2 CMakeLists.txt
+1 −1 External/MathLib
+1 −1 External/ShaderMake
+3 −3 Include/NRD.h
+28 −21 Include/NRDDescs.h
+48 −48 Include/NRDSettings.h
+44 −41 README.md
+2 −2 Resources/Version.h
+6 −0 Shaders.cfg
+51 −34 Shaders/Include/Common.hlsli
+26 −41 Shaders/Include/NRD.hlsli
+26 −104 Shaders/Include/REBLUR/REBLUR_Common.hlsli
+19 −13 Shaders/Include/REBLUR/REBLUR_Common_DiffuseSpatialFilter.hlsli
+55 −47 Shaders/Include/REBLUR/REBLUR_Common_SpecularSpatialFilter.hlsli
+61 −44 Shaders/Include/REBLUR/REBLUR_Config.hlsli
+25 −13 Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_HistoryFix.hlsli
+2 −2 Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli
+256 −197 Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli
+7 −17 Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_TemporalStabilization.hlsli
+1 −20 Shaders/Include/RELAX/RELAX_Common.hlsli
+3 −3 Shaders/Include/RELAX/RELAX_Config.hlsli
+21 −0 Shaders/Include/RELAX/RELAX_DiffuseSpecular_Copy.hlsli
+207 −66 Shaders/Include/RELAX/RELAX_DiffuseSpecular_HistoryClamping.hlsli
+3 −3 Shaders/Include/RELAX/RELAX_DiffuseSpecular_HitDistReconstruction.hlsli
+10 −12 Shaders/Include/RELAX/RELAX_DiffuseSpecular_PrePass.hlsli
+52 −74 Shaders/Include/RELAX/RELAX_DiffuseSpecular_TemporalAccumulation.hlsli
+5 −4 Shaders/Include/SIGMA/SIGMA_Shadow_Blur.hlsli
+4 −0 Shaders/Resources/Clear_f.resources.hlsli
+4 −0 Shaders/Resources/Clear_ui.resources.hlsli
+1 −0 Shaders/Resources/REBLUR_DiffuseSpecular_CopyStabilizedHistory.resources.hlsli
+8 −4 Shaders/Resources/REBLUR_DiffuseSpecular_HistoryFix.resources.hlsli
+24 −20 Shaders/Resources/REBLUR_DiffuseSpecular_TemporalAccumulation.resources.hlsli
+3 −4 Shaders/Resources/REBLUR_DiffuseSpecular_TemporalStabilization.resources.hlsli
+4 −0 Shaders/Resources/REFERENCE_SplitScreen.resources.hlsli
+54 −0 Shaders/Resources/RELAX_DiffuseSpecular_Copy.resources.hlsli
+28 −19 Shaders/Resources/RELAX_DiffuseSpecular_HistoryClamping.resources.hlsli
+9 −3 Shaders/Source/REBLUR_Validation.cs.hlsl
+21 −0 Shaders/Source/RELAX_DiffuseSh_Copy.cs.hlsl
+19 −0 Shaders/Source/RELAX_DiffuseSpecularSh_Copy.cs.hlsl
+19 −0 Shaders/Source/RELAX_DiffuseSpecular_Copy.cs.hlsl
+21 −0 Shaders/Source/RELAX_Diffuse_Copy.cs.hlsl
+21 −0 Shaders/Source/RELAX_SpecularSh_Copy.cs.hlsl
+21 −0 Shaders/Source/RELAX_Specular_Copy.cs.hlsl
+3 −0 Shaders/Source/RELAX_Validation.cs.hlsl
+53 −77 Shaders/Source/SpecularReflectionMv_Compute.cs.hlsl
+8 −7 Source/Denoisers/Reblur_Diffuse.hpp
+7 −6 Source/Denoisers/Reblur_DiffuseDirectionalOcclusion.hpp
+8 −7 Source/Denoisers/Reblur_DiffuseOcclusion.hpp
+8 −7 Source/Denoisers/Reblur_DiffuseSh.hpp
+25 −17 Source/Denoisers/Reblur_DiffuseSpecular.hpp
+23 −15 Source/Denoisers/Reblur_DiffuseSpecularOcclusion.hpp
+25 −17 Source/Denoisers/Reblur_DiffuseSpecularSh.hpp
+17 −10 Source/Denoisers/Reblur_Specular.hpp
+14 −7 Source/Denoisers/Reblur_SpecularOcclusion.hpp
+17 −10 Source/Denoisers/Reblur_SpecularSh.hpp
+26 −31 Source/Denoisers/Relax_Diffuse.hpp
+26 −36 Source/Denoisers/Relax_DiffuseSh.hpp
+30 −38 Source/Denoisers/Relax_DiffuseSpecular.hpp
+31 −46 Source/Denoisers/Relax_DiffuseSpecularSh.hpp
+26 −31 Source/Denoisers/Relax_Specular.hpp
+26 −35 Source/Denoisers/Relax_SpecularSh.hpp
+1 −1 Source/InstanceImpl.cpp
+17 −37 Source/Reblur.cpp
+18 −0 Source/Relax.cpp
+9 −0 UPDATE.md
2 changes: 1 addition & 1 deletion External/NRIFramework
Submodule NRIFramework updated 58 files
+0 −5 .gitignore
+10 −0 .gitmodules
+0 −1 1-Deploy.sh
+0 −3 4-Clean.bat
+0 −3 4-Clean.sh
+19 −69 CMakeLists.txt
+0 −13 Dependencies.xml
+55 −0 External/Detex/_LICENSES.txt
+45 −0 External/Detex/bits.c
+68 −0 External/Detex/bits.h
+203 −0 External/Detex/bptc-tables.c
+29 −0 External/Detex/bptc-tables.h
+74 −0 External/Detex/clamp.c
+1,172 −0 External/Detex/convert.c
+299 −0 External/Detex/dds.c
+241 −0 External/Detex/decompress-bc.c
+676 −0 External/Detex/decompress-bptc-float.c
+627 −0 External/Detex/decompress-bptc.c
+232 −0 External/Detex/decompress-eac.c
+752 −0 External/Detex/decompress-etc.c
+148 −0 External/Detex/decompress-rgtc.c
+1,247 −0 External/Detex/detex.h
+512 −0 External/Detex/division-tables.c
+334 −0 External/Detex/file-info.c
+45 −0 External/Detex/file-info.h
+318 −0 External/Detex/half-float.c
+34 −0 External/Detex/half-float.h
+214 −0 External/Detex/hdr.c
+22 −0 External/Detex/hdr.h
+337 −0 External/Detex/ktx.c
+200 −0 External/Detex/misc.c
+21 −0 External/Detex/misc.h
+81 −0 External/Detex/stb.c
+7,987 −0 External/Detex/stb_image.h
+1,724 −0 External/Detex/stb_image_write.h
+146 −0 External/Detex/texture.c
+1 −0 External/Glfw
+1 −0 External/Imgui
+1 −1 External/MathLib
+1 −1 External/NRI
+0 −164 External/Packman/bootstrap/configure.bat
+0 −53 External/Packman/bootstrap/download_file_from_url.ps1
+0 −35 External/Packman/bootstrap/fetch_file_from_packman_bootstrap.cmd
+0 −161 External/Packman/bootstrap/generate_temp_file_name.ps1
+0 −167 External/Packman/bootstrap/generate_temp_folder.ps1
+0 −154 External/Packman/bootstrap/install_package.py
+0 −3 External/Packman/config.packman.xml
+0 −60 External/Packman/packman.cmd
+0 −190 External/Packman/packman.sh
+0 −21 External/Packman/python.bat
+0 −32 External/Packman/python.sh
+1 −1 External/ShaderMake
+1 −0 Include/Camera.h
+5 −4 Include/NRIFramework.h
+62 −2 Include/Utils.h
+7 −0 Source/Camera.cpp
+32 −21 Source/SampleBase.cpp
+478 −44 Source/Utils.cpp
10 changes: 5 additions & 5 deletions Shaders.cfg
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
AfterDlss.cs.hlsl -T cs
Composition.cs.hlsl -T cs
DirectLighting.cs.hlsl -T cs
MorphMeshUpdatePrimitives.cs.hlsl -T cs
MorphMeshUpdateVertices.cs.hlsl -T cs
PreDlss.cs.hlsl -T cs
Temporal.cs.hlsl -T cs
TraceAmbient.cs.hlsl -T cs
TraceOpaque.cs.hlsl -T cs
TraceTransparent.cs.hlsl -T cs
Upsample.cs.hlsl -T cs
UpsampleNis.cs.hlsl -T cs
AmbientRays.cs.hlsl -T cs
PrimaryRays.cs.hlsl -T cs
IndirectRays.cs.hlsl -T cs
DeltaRays.cs.hlsl -T cs
58 changes: 36 additions & 22 deletions Shaders/Composition.cs.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ NRI_RESOURCE( Texture2D<float>, gIn_ViewZ, t, 0, 1 );
NRI_RESOURCE( Texture2D<float4>, gIn_Normal_Roughness, t, 1, 1 );
NRI_RESOURCE( Texture2D<float4>, gIn_BaseColor_Metalness, t, 2, 1 );
NRI_RESOURCE( Texture2D<float3>, gIn_DirectLighting, t, 3, 1 );
NRI_RESOURCE( Texture2D<float3>, gIn_PsrThroughput, t, 4, 1 );
NRI_RESOURCE( Texture2D<float4>, gIn_Diff, t, 5, 1 );
NRI_RESOURCE( Texture2D<float4>, gIn_Spec, t, 6, 1 );
NRI_RESOURCE( Texture2D<float3>, gIn_Ambient, t, 7, 1 );
NRI_RESOURCE( Texture2D<float3>, gIn_DirectEmission, t, 4, 1 );
NRI_RESOURCE( Texture2D<float3>, gIn_PsrThroughput, t, 5, 1 );
NRI_RESOURCE( Texture2D<float3>, gIn_Ambient, t, 6, 1 );
NRI_RESOURCE( Texture2D<float4>, gIn_Shadow, t, 7, 1 );
NRI_RESOURCE( Texture2D<float4>, gIn_Diff, t, 8, 1 );
NRI_RESOURCE( Texture2D<float4>, gIn_Spec, t, 9, 1 );
#if( NRD_MODE == SH )
NRI_RESOURCE( Texture2D<float4>, gIn_DiffSh, t, 8, 1 );
NRI_RESOURCE( Texture2D<float4>, gIn_SpecSh, t, 9, 1 );
NRI_RESOURCE( Texture2D<float4>, gIn_DiffSh, t, 10, 1 );
NRI_RESOURCE( Texture2D<float4>, gIn_SpecSh, t, 11, 1 );
#endif

// Outputs
Expand All @@ -40,36 +42,44 @@ void main( int2 pixelPos : SV_DispatchThreadId )

// ViewZ
float viewZ = gIn_ViewZ[ pixelPos ];
float3 Lemi = gIn_DirectEmission[ pixelPos ];

// Direct lighting with emission
float3 Ldirect = gIn_DirectLighting[ pixelPos ];

// Normal and roughness
float4 normalAndRoughness = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pixelPos ] );
// Normal, roughness and material ID
float normMaterialID;
float4 normalAndRoughness = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pixelPos ], normMaterialID );
float3 N = normalAndRoughness.xyz;
float roughness = normalAndRoughness.w;

// ( Trick ) Needed only to avoid back facing in "ReprojectRadiance"
// ( Trick ) Needed only to avoid back facing in "ReprojectIrradiance"
float z = abs( viewZ ) * NRD_FP16_VIEWZ_SCALE;
z *= STL::Math::Sign( dot( N, gSunDirection ) );
z *= STL::Math::Sign( dot( N, gSunDirection_gExposure.xyz ) );

// Early out - sky
if( abs( viewZ ) == INF )
{
gOut_ComposedDiff[ pixelPos ] = Ldirect * float( gOnScreen == SHOW_FINAL );
gOut_ComposedDiff[ pixelPos ] = Lemi * float( gOnScreen == SHOW_FINAL );
gOut_ComposedSpec_ViewZ[ pixelPos ] = float4( 0, 0, 0, z );

return;
}

// Direct sun lighting * shadow + emission
float4 shadowData = gIn_Shadow[ pixelPos ];
shadowData = SIGMA_BackEnd_UnpackShadow( shadowData );
float3 shadow = lerp( shadowData.yzw, 1.0, shadowData.x );

float3 Ldirect = gIn_DirectLighting[ pixelPos ];
if( gOnScreen < SHOW_INSTANCE_INDEX )
Ldirect = Ldirect * shadow + Lemi;

// G-buffer
float3 albedo, Rf0;
float4 baseColorMetalness = gIn_BaseColor_Metalness[ pixelPos ];
STL::BRDF::ConvertBaseColorMetalnessToAlbedoRf0( baseColorMetalness.xyz, baseColorMetalness.w, albedo, Rf0 );

float3 Xv = STL::Geometry::ReconstructViewPosition( sampleUv, gCameraFrustum, viewZ, gOrthoMode );
float3 Xv = STL::Geometry::ReconstructViewPosition( sampleUv, gCameraFrustum, viewZ, gViewDirection_gOrthoMode.w );
float3 X = STL::Geometry::AffineTransform( gViewToWorld, Xv );
float3 V = gOrthoMode == 0 ? normalize( gCameraOrigin - X ) : gViewDirection;
float3 V = gViewDirection_gOrthoMode.w == 0 ? normalize( gCameraOrigin_gMipBias.xyz - X ) : gViewDirection_gOrthoMode.xyz;

// Sample NRD outputs
float4 diff = gIn_Diff[ pixelPos ];
Expand All @@ -85,7 +95,7 @@ void main( int2 pixelPos : SV_DispatchThreadId )
NRD_SG diffSg = REBLUR_BackEnd_UnpackSh( diff, diff1 );
NRD_SG specSg = REBLUR_BackEnd_UnpackSh( spec, spec1 );

if( gDenoiserType == RELAX )
if( gDenoiserType == DENOISER_RELAX )
{
diffSg = RELAX_BackEnd_UnpackSh( diff, diff1 );
specSg = RELAX_BackEnd_UnpackSh( spec, spec1 );
Expand Down Expand Up @@ -157,7 +167,7 @@ void main( int2 pixelPos : SV_DispatchThreadId )
diff.w = NRD_SG_ExtractColor( sg ).x;
// Decode NORMAL mode outputs
#else
if( gDenoiserType == RELAX )
if( gDenoiserType == DENOISER_RELAX )
{
diff = RELAX_BackEnd_UnpackRadiance( diff );
spec = RELAX_BackEnd_UnpackRadiance( spec );
Expand All @@ -170,7 +180,7 @@ void main( int2 pixelPos : SV_DispatchThreadId )
#endif

// ( Optional ) RELAX doesn't support AO / SO
if( gDenoiserType == RELAX )
if( gDenoiserType == DENOISER_RELAX )
{
diff.w = 1.0 / STL::Math::Pi( 1.0 );
spec.w = 1.0 / STL::Math::Pi( 1.0 );
Expand All @@ -195,7 +205,7 @@ void main( int2 pixelPos : SV_DispatchThreadId )
ambient *= exp2( AMBIENT_FADE * STL::Math::LengthSquared( Xv ) );
ambient *= gAmbient;

float specAmbientAmount = gDenoiserType == RELAX ? roughness : GetSpecMagicCurve( roughness );
float specAmbientAmount = gDenoiserType == DENOISER_RELAX ? roughness : GetSpecMagicCurve( roughness );

Ldiff += ambient * diff.w * ( 1.0 - Fenv ) * albedo;
Lspec += ambient * spec.w * Fenv * specAmbientAmount;
Expand All @@ -222,6 +232,8 @@ void main( int2 pixelPos : SV_DispatchThreadId )
Ldiff = diff.w;
else if( gOnScreen == SHOW_SPECULAR_OCCLUSION )
Ldiff = spec.w;
else if( gOnScreen == SHOW_SHADOW )
Ldiff = shadow;
else if( gOnScreen == SHOW_BASE_COLOR )
Ldiff = baseColorMetalness.xyz;
else if( gOnScreen == SHOW_NORMAL )
Expand All @@ -230,10 +242,12 @@ void main( int2 pixelPos : SV_DispatchThreadId )
Ldiff = roughness;
else if( gOnScreen == SHOW_METALNESS )
Ldiff = baseColorMetalness.w;
else if( gOnScreen == SHOW_WORLD_UNITS )
Ldiff = frac( X * gUnitToMetersMultiplier );
else if( gOnScreen == SHOW_MATERIAL_ID )
Ldiff = normMaterialID;
else if( gOnScreen == SHOW_PSR_THROUGHPUT )
Ldiff = psrThroughput;
else if( gOnScreen == SHOW_WORLD_UNITS )
Ldiff = frac( X * gUnitToMetersMultiplier );
else if( gOnScreen != SHOW_FINAL )
Ldiff = gOnScreen == SHOW_MIP_SPECULAR ? spec.xyz : Ldirect.xyz;

Expand Down
44 changes: 0 additions & 44 deletions Shaders/DirectLighting.cs.hlsl

This file was deleted.

12 changes: 5 additions & 7 deletions Shaders/Include/BindingBridge.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,25 @@ distribution of this software and related documentation without an express
license agreement from NVIDIA CORPORATION is strictly prohibited.
*/

#if( defined( COMPILER_DXC ) )
#if( defined( VULKAN ) )

#if( defined( __cplusplus ) )
#define NRI_RESOURCE( resourceType, resourceName, regName, bindingIndex, setIndex ) \
struct resourceName
#elif( defined( COMPILER_DXC ) )
#if( defined( VULKAN ) )
#define NRI_RESOURCE( resourceType, resourceName, regName, bindingIndex, setIndex ) \
resourceType resourceName : register( regName ## bindingIndex, space ## setIndex )

#define NRI_PUSH_CONSTANTS( structName, constantBufferName, bindingIndex ) \
[[vk::push_constant]] structName constantBufferName

#else

#define NRI_RESOURCE( resourceType, resourceName, regName, bindingIndex, setIndex ) \
resourceType resourceName : register( regName ## bindingIndex, space ## setIndex )

#define NRI_PUSH_CONSTANTS( structName, constantBufferName, bindingIndex ) \
ConstantBuffer<structName> constantBufferName : register( b ## bindingIndex, space0 )

#endif
#else

#define NRI_RESOURCE( resourceType, resourceName, regName, bindingIndex, setIndex ) \
resourceType resourceName : register( regName ## bindingIndex )

Expand All @@ -36,5 +35,4 @@ license agreement from NVIDIA CORPORATION is strictly prohibited.
{ \
structName constantBufferName; \
}

#endif

0 comments on commit 114039d

Please sign in to comment.