From a6d20d98713ddb2f863b80eef07dc85e5cf108e2 Mon Sep 17 00:00:00 2001 From: dzhdan Date: Wed, 27 Dec 2023 11:58:25 +0800 Subject: [PATCH] v4.4.0: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit HIGHLIGHTS: - NRD: improved API & robustness - NRD: flexible DRS support (improved compatibility with engines using resource suballocation for DRS) - NRD: IQ improvements - NRD: added GLSL support for NRD.hlsli - NRD: added "NRD_FrontEnd_SpecHitDistAveraging_X" functions, needed to properly average specular hit distance for correct specular tracking in case of many RPP DETAILS: - NRD: denoisers made less sensitive to NAN/INF values outside of denoising range and DRS rectangle - NRD: added "NRD_FrontEnd_SpecHitDistAveraging_X" functions, needed to properly average specular hit distance for correct specular tracking in case of many RPP - NRD: fixed regression: "motionVectorScale[] = 0 and isMotionVectorInWorldSpace = true" case was broken - NRD: more flexible CTA definition - NRD: improved performance by adjusting CTA sizes - NRD: simplified constant data storage related code, ring buffer is not needed (2 Mb => 128 Kb) - NRD: added GLSL support for NRD.hlsli - NRD: refactored resource macros - NRD: added "identifier" to "DispatchDesc" to distinguish which denoiser "ResourceType" is coming from - NRD: greatly simplified C++ code by utilizing shared headers - NRD: flexible DRS support - NRD: minor DRS related fixes - NRD: removed unused samplers - NRD: clarified "gRectOffset" usage - NRD: "gRectOffset" usage moved under NRD_USE_VIEWPORT_OFFSET macro (disabled by default) - SIGMA: reduced bias, improved stability - RELAX: greatly simplified C++ side code (181 Kb => 99 Kb) - RELAX: fixed bugs preventing usage of non-square CTA sizes - RELAX: minor fixes in HistoryFix pass - RELAX: removed standalone "diffuse" and "specular" settings (was a shortened copy of "RelaxSettings") - RELAX: reduced code entropy - REBLUR / RELAX: out of bounds fixes - REBLUR / RELAX: removed "historyFixStrideBetweenSamples" - REBLUR / SIGMA: added snapping to pixel center in spatial passes - REBLUR: replaced "table-flip" unicode emoji ¯\_(ツ)_/¯ - REBLUR: improved behavior on thin objects - REBLUR: improved HistoryFix - REBLUR: material IDs properly applied to all CatRom footprint (fixed outlining on material boundaries) - REBLUR: fixed potential color bleeding caused by virtual motion disocclusion - REBLUR: optional MV modification made stochastic based - REBLUR: fixed suboptimal "vmb" reprojection behavior in disocclusions - REFERENCE: renamed REFERENCE inputs - NRD INTEGRATION: updated to reflect NRD API changes - NRD INTEGRATION: NRI updated to v1.110 - Cmake: fixed unconditional use of CMAKE_MSVC_RUNTIME_LIBRARY - updated docs and comments - updated dependencies - refactoring --- CMakeLists.txt | 20 +- External/MathLib | 2 +- External/ShaderMake | 2 +- Include/NRD.h | 6 +- Include/NRDDescs.h | 307 ++++---- Include/NRDSettings.h | 125 +--- Integration/NRDIntegration.h | 18 +- Integration/NRDIntegration.hpp | 128 ++-- README.md | 53 +- Resources/Version.h | 4 +- Shaders.cfg | 16 +- Shaders/Include/Common.hlsli | 117 +-- Shaders/Include/NRD.hlsli | 238 ++++-- ...eSpecular_Blur.hlsli => REBLUR_Blur.hlsli} | 16 +- .../Include/{REBLUR => }/REBLUR_Common.hlsli | 35 +- .../REBLUR_Common_DiffuseSpatialFilter.hlsli | 91 +-- .../REBLUR_Common_SpecularSpatialFilter.hlsli | 127 ++-- .../Include/{REBLUR => }/REBLUR_Config.hlsli | 94 +-- ...bilizedHistory.hlsli => REBLUR_Copy.hlsli} | 0 ...storyFix.hlsli => REBLUR_HistoryFix.hlsli} | 164 ++-- ...sli => REBLUR_HitDistReconstruction.hlsli} | 31 +- ...r_PostBlur.hlsli => REBLUR_PostBlur.hlsli} | 16 +- ...lar_PrePass.hlsli => REBLUR_PrePass.hlsli} | 62 +- ...tScreen.hlsli => REBLUR_SplitScreen.hlsli} | 16 +- ...lsli => REBLUR_TemporalAccumulation.hlsli} | 491 ++++++------ ...sli => REBLUR_TemporalStabilization.hlsli} | 52 +- Shaders/Include/RELAX/RELAX_Config.hlsli | 58 -- ...iFirefly.hlsli => RELAX_AntiFirefly.hlsli} | 12 +- ...ecular_Atrous.hlsli => RELAX_Atrous.hlsli} | 68 +- ...trousSmem.hlsli => RELAX_AtrousSmem.hlsli} | 51 +- .../Include/{RELAX => }/RELAX_Common.hlsli | 8 +- Shaders/Include/RELAX_Config.hlsli | 97 +++ ...seSpecular_Copy.hlsli => RELAX_Copy.hlsli} | 6 +- ...ping.hlsli => RELAX_HistoryClamping.hlsli} | 36 +- ...istoryFix.hlsli => RELAX_HistoryFix.hlsli} | 34 +- ...lsli => RELAX_HitDistReconstruction.hlsli} | 36 +- ...ular_PrePass.hlsli => RELAX_PrePass.hlsli} | 243 +++--- ...itScreen.hlsli => RELAX_SplitScreen.hlsli} | 11 +- ...hlsli => RELAX_TemporalAccumulation.hlsli} | 175 ++--- ...GMA_Shadow_Blur.hlsli => SIGMA_Blur.hlsli} | 66 +- ...yTiles.hlsli => SIGMA_ClassifyTiles.hlsli} | 0 .../Include/{SIGMA => }/SIGMA_Common.hlsli | 8 +- .../Include/{SIGMA => }/SIGMA_Config.hlsli | 34 +- ...itScreen.hlsli => SIGMA_SplitScreen.hlsli} | 12 +- ...lsli => SIGMA_TemporalStabilization.hlsli} | 38 +- ...rces.hlsli => Clear_Float.resources.hlsli} | 20 +- ...urces.hlsli => Clear_Uint.resources.hlsli} | 20 +- Shaders/Resources/REBLUR_Blur.resources.hlsli | 98 +++ .../REBLUR_ClassifyTiles.resources.hlsli | 26 +- Shaders/Resources/REBLUR_Copy.resources.hlsli | 80 ++ ...EBLUR_DiffuseSpecular_Blur.resources.hlsli | 94 --- ...ular_CopyStabilizedHistory.resources.hlsli | 71 -- ...DiffuseSpecular_HistoryFix.resources.hlsli | 98 --- ...ular_HitDistReconstruction.resources.hlsli | 71 -- ...R_DiffuseSpecular_PostBlur.resources.hlsli | 116 --- ...UR_DiffuseSpecular_PrePass.resources.hlsli | 88 --- ...iffuseSpecular_SplitScreen.resources.hlsli | 80 -- ...cular_TemporalAccumulation.resources.hlsli | 158 ---- ...ular_TemporalStabilization.resources.hlsli | 120 --- .../REBLUR_HistoryFix.resources.hlsli | 104 +++ ...BLUR_HitDistReconstruction.resources.hlsli | 75 ++ .../Resources/REBLUR_PostBlur.resources.hlsli | 120 +++ .../Resources/REBLUR_PrePass.resources.hlsli | 94 +++ .../REBLUR_SplitScreen.resources.hlsli | 85 +++ ...EBLUR_TemporalAccumulation.resources.hlsli | 148 ++++ ...BLUR_TemporalStabilization.resources.hlsli | 115 +++ .../REBLUR_Validation.resources.hlsli | 54 +- .../REFERENCE_SplitScreen.resources.hlsli | 33 +- ...RENCE_TemporalAccumulation.resources.hlsli | 33 +- .../RELAX_AntiFirefly.resources.hlsli | 71 ++ .../Resources/RELAX_Atrous.resources.hlsli | 102 +++ .../RELAX_AtrousSmem.resources.hlsli | 114 +++ .../RELAX_ClassifyTiles.resources.hlsli | 26 +- Shaders/Resources/RELAX_Copy.resources.hlsli | 62 ++ ...iffuseSpecular_AntiFirefly.resources.hlsli | 63 -- ...LAX_DiffuseSpecular_Atrous.resources.hlsli | 152 ---- ...DiffuseSpecular_AtrousSmem.resources.hlsli | 164 ---- ...RELAX_DiffuseSpecular_Copy.resources.hlsli | 54 -- ...seSpecular_HistoryClamping.resources.hlsli | 121 --- ...DiffuseSpecular_HistoryFix.resources.hlsli | 100 --- ...ular_HitDistReconstruction.resources.hlsli | 72 -- ...AX_DiffuseSpecular_PrePass.resources.hlsli | 116 --- ...iffuseSpecular_SplitScreen.resources.hlsli | 72 -- ...cular_TemporalAccumulation.resources.hlsli | 182 ----- .../RELAX_HistoryClamping.resources.hlsli | 114 +++ .../RELAX_HistoryFix.resources.hlsli | 94 +++ ...ELAX_HitDistReconstruction.resources.hlsli | 74 ++ .../Resources/RELAX_PrePass.resources.hlsli | 92 +++ .../RELAX_SplitScreen.resources.hlsli | 65 ++ ...RELAX_TemporalAccumulation.resources.hlsli | 146 ++++ .../RELAX_Validation.resources.hlsli | 45 +- Shaders/Resources/SIGMA_Blur.resources.hlsli | 55 ++ .../SIGMA_ClassifyTiles.resources.hlsli | 39 + .../SIGMA_Shadow_Blur.resources.hlsli | 48 -- ...SIGMA_Shadow_ClassifyTiles.resources.hlsli | 31 - .../SIGMA_Shadow_SmoothTiles.resources.hlsli | 29 - .../SIGMA_Shadow_SplitScreen.resources.hlsli | 32 - ...adow_TemporalStabilization.resources.hlsli | 39 - .../SIGMA_SmoothTiles.resources.hlsli | 36 + .../SIGMA_SplitScreen.resources.hlsli | 39 + ...IGMA_TemporalStabilization.resources.hlsli | 44 ++ .../SpecularDeltaMv_Compute.resources.hlsli | 53 +- ...ecularReflectionMv_Compute.resources.hlsli | 57 +- .../{Clear_f.cs.hlsl => Clear_Float.cs.hlsl} | 2 +- .../{Clear_ui.cs.hlsl => Clear_Uint.cs.hlsl} | 2 +- Shaders/Source/REBLUR_ClassifyTiles.cs.hlsl | 1 + ...R_DiffuseDirectionalOcclusion_Blur.cs.hlsl | 8 +- ...useDirectionalOcclusion_HistoryFix.cs.hlsl | 8 +- ...ffuseDirectionalOcclusion_PostBlur.cs.hlsl | 8 +- ...n_PostBlur_NoTemporalStabilization.cs.hlsl | 8 +- ...iffuseDirectionalOcclusion_PrePass.cs.hlsl | 8 +- ...onalOcclusion_TemporalAccumulation.cs.hlsl | 8 +- ...nalOcclusion_TemporalStabilization.cs.hlsl | 8 +- .../REBLUR_DiffuseOcclusion_Blur.cs.hlsl | 8 +- ...REBLUR_DiffuseOcclusion_HistoryFix.cs.hlsl | 8 +- ...useOcclusion_HitDistReconstruction.cs.hlsl | 8 +- ...cclusion_HitDistReconstruction_5x5.cs.hlsl | 8 +- ...n_PostBlur_NoTemporalStabilization.cs.hlsl | 8 +- .../REBLUR_DiffuseOcclusion_PrePass.cs.hlsl | 8 +- ...fuseOcclusion_TemporalAccumulation.cs.hlsl | 8 +- Shaders/Source/REBLUR_DiffuseSh_Blur.cs.hlsl | 8 +- ....cs.hlsl => REBLUR_DiffuseSh_Copy.cs.hlsl} | 6 +- .../REBLUR_DiffuseSh_HistoryFix.cs.hlsl | 8 +- .../Source/REBLUR_DiffuseSh_PostBlur.cs.hlsl | 8 +- ...h_PostBlur_NoTemporalStabilization.cs.hlsl | 8 +- .../Source/REBLUR_DiffuseSh_PrePass.cs.hlsl | 8 +- .../REBLUR_DiffuseSh_SplitScreen.cs.hlsl | 8 +- ...LUR_DiffuseSh_TemporalAccumulation.cs.hlsl | 8 +- ...UR_DiffuseSh_TemporalStabilization.cs.hlsl | 8 +- ...BLUR_DiffuseSpecularOcclusion_Blur.cs.hlsl | 8 +- ...iffuseSpecularOcclusion_HistoryFix.cs.hlsl | 8 +- ...larOcclusion_HitDistReconstruction.cs.hlsl | 8 +- ...cclusion_HitDistReconstruction_5x5.cs.hlsl | 8 +- ...n_PostBlur_NoTemporalStabilization.cs.hlsl | 8 +- ...R_DiffuseSpecularOcclusion_PrePass.cs.hlsl | 8 +- ...ularOcclusion_TemporalAccumulation.cs.hlsl | 8 +- .../REBLUR_DiffuseSpecularSh_Blur.cs.hlsl | 8 +- ... => REBLUR_DiffuseSpecularSh_Copy.cs.hlsl} | 6 +- ...EBLUR_DiffuseSpecularSh_HistoryFix.cs.hlsl | 8 +- .../REBLUR_DiffuseSpecularSh_PostBlur.cs.hlsl | 8 +- ...h_PostBlur_NoTemporalStabilization.cs.hlsl | 8 +- .../REBLUR_DiffuseSpecularSh_PrePass.cs.hlsl | 8 +- ...BLUR_DiffuseSpecularSh_SplitScreen.cs.hlsl | 8 +- ...useSpecularSh_TemporalAccumulation.cs.hlsl | 8 +- ...seSpecularSh_TemporalStabilization.cs.hlsl | 8 +- .../REBLUR_DiffuseSpecular_Blur.cs.hlsl | 8 +- ...sl => REBLUR_DiffuseSpecular_Copy.cs.hlsl} | 6 +- .../REBLUR_DiffuseSpecular_HistoryFix.cs.hlsl | 8 +- ...fuseSpecular_HitDistReconstruction.cs.hlsl | 8 +- ...Specular_HitDistReconstruction_5x5.cs.hlsl | 8 +- .../REBLUR_DiffuseSpecular_PostBlur.cs.hlsl | 8 +- ...r_PostBlur_NoTemporalStabilization.cs.hlsl | 8 +- .../REBLUR_DiffuseSpecular_PrePass.cs.hlsl | 8 +- ...REBLUR_DiffuseSpecular_SplitScreen.cs.hlsl | 8 +- ...ffuseSpecular_TemporalAccumulation.cs.hlsl | 8 +- ...fuseSpecular_TemporalStabilization.cs.hlsl | 8 +- Shaders/Source/REBLUR_Diffuse_Blur.cs.hlsl | 8 +- ...ry.cs.hlsl => REBLUR_Diffuse_Copy.cs.hlsl} | 6 +- .../Source/REBLUR_Diffuse_HistoryFix.cs.hlsl | 8 +- ...BLUR_Diffuse_HitDistReconstruction.cs.hlsl | 8 +- ..._Diffuse_HitDistReconstruction_5x5.cs.hlsl | 8 +- .../Source/REBLUR_Diffuse_PostBlur.cs.hlsl | 8 +- ...e_PostBlur_NoTemporalStabilization.cs.hlsl | 8 +- Shaders/Source/REBLUR_Diffuse_PrePass.cs.hlsl | 8 +- .../Source/REBLUR_Diffuse_SplitScreen.cs.hlsl | 8 +- ...EBLUR_Diffuse_TemporalAccumulation.cs.hlsl | 8 +- ...BLUR_Diffuse_TemporalStabilization.cs.hlsl | 8 +- ...f_DiffuseDirectionalOcclusion_Blur.cs.hlsl | 8 +- ...useDirectionalOcclusion_HistoryFix.cs.hlsl | 8 +- ...ffuseDirectionalOcclusion_PostBlur.cs.hlsl | 8 +- ...n_PostBlur_NoTemporalStabilization.cs.hlsl | 8 +- ...iffuseDirectionalOcclusion_PrePass.cs.hlsl | 8 +- ...onalOcclusion_TemporalAccumulation.cs.hlsl | 8 +- ...nalOcclusion_TemporalStabilization.cs.hlsl | 8 +- .../REBLUR_Perf_DiffuseOcclusion_Blur.cs.hlsl | 8 +- ...R_Perf_DiffuseOcclusion_HistoryFix.cs.hlsl | 8 +- ...useOcclusion_HitDistReconstruction.cs.hlsl | 8 +- ...cclusion_HitDistReconstruction_5x5.cs.hlsl | 8 +- ...n_PostBlur_NoTemporalStabilization.cs.hlsl | 8 +- ...BLUR_Perf_DiffuseOcclusion_PrePass.cs.hlsl | 8 +- ...fuseOcclusion_TemporalAccumulation.cs.hlsl | 8 +- .../Source/REBLUR_Perf_DiffuseSh_Blur.cs.hlsl | 8 +- .../REBLUR_Perf_DiffuseSh_HistoryFix.cs.hlsl | 8 +- .../REBLUR_Perf_DiffuseSh_PostBlur.cs.hlsl | 8 +- ...h_PostBlur_NoTemporalStabilization.cs.hlsl | 8 +- .../REBLUR_Perf_DiffuseSh_PrePass.cs.hlsl | 8 +- ...erf_DiffuseSh_TemporalAccumulation.cs.hlsl | 8 +- ...rf_DiffuseSh_TemporalStabilization.cs.hlsl | 8 +- ...Perf_DiffuseSpecularOcclusion_Blur.cs.hlsl | 8 +- ...iffuseSpecularOcclusion_HistoryFix.cs.hlsl | 8 +- ...larOcclusion_HitDistReconstruction.cs.hlsl | 8 +- ...cclusion_HitDistReconstruction_5x5.cs.hlsl | 8 +- ...n_PostBlur_NoTemporalStabilization.cs.hlsl | 8 +- ...f_DiffuseSpecularOcclusion_PrePass.cs.hlsl | 8 +- ...ularOcclusion_TemporalAccumulation.cs.hlsl | 8 +- ...REBLUR_Perf_DiffuseSpecularSh_Blur.cs.hlsl | 8 +- ..._Perf_DiffuseSpecularSh_HistoryFix.cs.hlsl | 8 +- ...UR_Perf_DiffuseSpecularSh_PostBlur.cs.hlsl | 8 +- ...h_PostBlur_NoTemporalStabilization.cs.hlsl | 8 +- ...LUR_Perf_DiffuseSpecularSh_PrePass.cs.hlsl | 8 +- ...useSpecularSh_TemporalAccumulation.cs.hlsl | 8 +- ...seSpecularSh_TemporalStabilization.cs.hlsl | 8 +- .../REBLUR_Perf_DiffuseSpecular_Blur.cs.hlsl | 8 +- ...UR_Perf_DiffuseSpecular_HistoryFix.cs.hlsl | 8 +- ...fuseSpecular_HitDistReconstruction.cs.hlsl | 8 +- ...Specular_HitDistReconstruction_5x5.cs.hlsl | 8 +- ...BLUR_Perf_DiffuseSpecular_PostBlur.cs.hlsl | 8 +- ...r_PostBlur_NoTemporalStabilization.cs.hlsl | 8 +- ...EBLUR_Perf_DiffuseSpecular_PrePass.cs.hlsl | 8 +- ...ffuseSpecular_TemporalAccumulation.cs.hlsl | 8 +- ...fuseSpecular_TemporalStabilization.cs.hlsl | 8 +- .../Source/REBLUR_Perf_Diffuse_Blur.cs.hlsl | 8 +- .../REBLUR_Perf_Diffuse_HistoryFix.cs.hlsl | 8 +- ...Perf_Diffuse_HitDistReconstruction.cs.hlsl | 8 +- ..._Diffuse_HitDistReconstruction_5x5.cs.hlsl | 8 +- .../REBLUR_Perf_Diffuse_PostBlur.cs.hlsl | 8 +- ...e_PostBlur_NoTemporalStabilization.cs.hlsl | 8 +- .../REBLUR_Perf_Diffuse_PrePass.cs.hlsl | 8 +- ..._Perf_Diffuse_TemporalAccumulation.cs.hlsl | 8 +- ...Perf_Diffuse_TemporalStabilization.cs.hlsl | 8 +- ...REBLUR_Perf_SpecularOcclusion_Blur.cs.hlsl | 8 +- ..._Perf_SpecularOcclusion_HistoryFix.cs.hlsl | 8 +- ...larOcclusion_HitDistReconstruction.cs.hlsl | 8 +- ...cclusion_HitDistReconstruction_5x5.cs.hlsl | 8 +- ...n_PostBlur_NoTemporalStabilization.cs.hlsl | 8 +- ...LUR_Perf_SpecularOcclusion_PrePass.cs.hlsl | 8 +- ...ularOcclusion_TemporalAccumulation.cs.hlsl | 8 +- .../REBLUR_Perf_SpecularSh_Blur.cs.hlsl | 8 +- .../REBLUR_Perf_SpecularSh_HistoryFix.cs.hlsl | 8 +- .../REBLUR_Perf_SpecularSh_PostBlur.cs.hlsl | 8 +- ...h_PostBlur_NoTemporalStabilization.cs.hlsl | 8 +- .../REBLUR_Perf_SpecularSh_PrePass.cs.hlsl | 8 +- ...rf_SpecularSh_TemporalAccumulation.cs.hlsl | 8 +- ...f_SpecularSh_TemporalStabilization.cs.hlsl | 8 +- .../Source/REBLUR_Perf_Specular_Blur.cs.hlsl | 8 +- .../REBLUR_Perf_Specular_HistoryFix.cs.hlsl | 8 +- ...erf_Specular_HitDistReconstruction.cs.hlsl | 8 +- ...Specular_HitDistReconstruction_5x5.cs.hlsl | 8 +- .../REBLUR_Perf_Specular_PostBlur.cs.hlsl | 8 +- ...r_PostBlur_NoTemporalStabilization.cs.hlsl | 8 +- .../REBLUR_Perf_Specular_PrePass.cs.hlsl | 8 +- ...Perf_Specular_TemporalAccumulation.cs.hlsl | 8 +- ...erf_Specular_TemporalStabilization.cs.hlsl | 8 +- .../REBLUR_SpecularOcclusion_Blur.cs.hlsl | 8 +- ...EBLUR_SpecularOcclusion_HistoryFix.cs.hlsl | 8 +- ...larOcclusion_HitDistReconstruction.cs.hlsl | 8 +- ...cclusion_HitDistReconstruction_5x5.cs.hlsl | 8 +- ...n_PostBlur_NoTemporalStabilization.cs.hlsl | 8 +- .../REBLUR_SpecularOcclusion_PrePass.cs.hlsl | 8 +- ...ularOcclusion_TemporalAccumulation.cs.hlsl | 8 +- Shaders/Source/REBLUR_SpecularSh_Blur.cs.hlsl | 8 +- ...cs.hlsl => REBLUR_SpecularSh_Copy.cs.hlsl} | 6 +- .../REBLUR_SpecularSh_HistoryFix.cs.hlsl | 8 +- .../Source/REBLUR_SpecularSh_PostBlur.cs.hlsl | 8 +- ...h_PostBlur_NoTemporalStabilization.cs.hlsl | 8 +- .../Source/REBLUR_SpecularSh_PrePass.cs.hlsl | 8 +- .../REBLUR_SpecularSh_SplitScreen.cs.hlsl | 8 +- ...UR_SpecularSh_TemporalAccumulation.cs.hlsl | 8 +- ...R_SpecularSh_TemporalStabilization.cs.hlsl | 8 +- Shaders/Source/REBLUR_Specular_Blur.cs.hlsl | 8 +- ...y.cs.hlsl => REBLUR_Specular_Copy.cs.hlsl} | 6 +- .../Source/REBLUR_Specular_HistoryFix.cs.hlsl | 8 +- ...LUR_Specular_HitDistReconstruction.cs.hlsl | 8 +- ...Specular_HitDistReconstruction_5x5.cs.hlsl | 8 +- .../Source/REBLUR_Specular_PostBlur.cs.hlsl | 8 +- ...r_PostBlur_NoTemporalStabilization.cs.hlsl | 8 +- .../Source/REBLUR_Specular_PrePass.cs.hlsl | 8 +- .../REBLUR_Specular_SplitScreen.cs.hlsl | 8 +- ...BLUR_Specular_TemporalAccumulation.cs.hlsl | 8 +- ...LUR_Specular_TemporalStabilization.cs.hlsl | 8 +- Shaders/Source/REBLUR_Validation.cs.hlsl | 20 +- .../REFERENCE_TemporalAccumulation.cs.hlsl | 4 +- Shaders/Source/RELAX_ClassifyTiles.cs.hlsl | 1 + .../RELAX_DiffuseSh_AntiFirefly.cs.hlsl | 8 +- Shaders/Source/RELAX_DiffuseSh_Atrous.cs.hlsl | 8 +- .../Source/RELAX_DiffuseSh_AtrousSmem.cs.hlsl | 8 +- Shaders/Source/RELAX_DiffuseSh_Copy.cs.hlsl | 8 +- .../RELAX_DiffuseSh_HistoryClamping.cs.hlsl | 8 +- .../Source/RELAX_DiffuseSh_HistoryFix.cs.hlsl | 8 +- ...AX_DiffuseSh_HitDistReconstruction.cs.hlsl | 8 +- .../Source/RELAX_DiffuseSh_PrePass.cs.hlsl | 8 +- .../RELAX_DiffuseSh_SplitScreen.cs.hlsl | 8 +- ...LAX_DiffuseSh_TemporalAccumulation.cs.hlsl | 8 +- ...ELAX_DiffuseSpecularSh_AntiFirefly.cs.hlsl | 8 +- .../RELAX_DiffuseSpecularSh_Atrous.cs.hlsl | 8 +- ...RELAX_DiffuseSpecularSh_AtrousSmem.cs.hlsl | 8 +- .../RELAX_DiffuseSpecularSh_Copy.cs.hlsl | 8 +- ..._DiffuseSpecularSh_HistoryClamping.cs.hlsl | 8 +- ...RELAX_DiffuseSpecularSh_HistoryFix.cs.hlsl | 8 +- .../RELAX_DiffuseSpecularSh_PrePass.cs.hlsl | 8 +- ...ELAX_DiffuseSpecularSh_SplitScreen.cs.hlsl | 8 +- ...useSpecularSh_TemporalAccumulation.cs.hlsl | 8 +- .../RELAX_DiffuseSpecular_AntiFirefly.cs.hlsl | 8 +- .../RELAX_DiffuseSpecular_Atrous.cs.hlsl | 8 +- .../RELAX_DiffuseSpecular_AtrousSmem.cs.hlsl | 8 +- .../Source/RELAX_DiffuseSpecular_Copy.cs.hlsl | 8 +- ...AX_DiffuseSpecular_HistoryClamping.cs.hlsl | 8 +- .../RELAX_DiffuseSpecular_HistoryFix.cs.hlsl | 8 +- ...fuseSpecular_HitDistReconstruction.cs.hlsl | 8 +- ...Specular_HitDistReconstruction_5x5.cs.hlsl | 8 +- .../RELAX_DiffuseSpecular_PrePass.cs.hlsl | 8 +- .../RELAX_DiffuseSpecular_SplitScreen.cs.hlsl | 8 +- ...ffuseSpecular_TemporalAccumulation.cs.hlsl | 8 +- .../Source/RELAX_Diffuse_AntiFirefly.cs.hlsl | 8 +- Shaders/Source/RELAX_Diffuse_Atrous.cs.hlsl | 8 +- .../Source/RELAX_Diffuse_AtrousSmem.cs.hlsl | 8 +- Shaders/Source/RELAX_Diffuse_Copy.cs.hlsl | 8 +- .../RELAX_Diffuse_HistoryClamping.cs.hlsl | 8 +- .../Source/RELAX_Diffuse_HistoryFix.cs.hlsl | 8 +- ...ELAX_Diffuse_HitDistReconstruction.cs.hlsl | 8 +- ..._Diffuse_HitDistReconstruction_5x5.cs.hlsl | 8 +- Shaders/Source/RELAX_Diffuse_PrePass.cs.hlsl | 8 +- .../Source/RELAX_Diffuse_SplitScreen.cs.hlsl | 8 +- ...RELAX_Diffuse_TemporalAccumulation.cs.hlsl | 8 +- .../RELAX_SpecularSh_AntiFirefly.cs.hlsl | 8 +- .../Source/RELAX_SpecularSh_Atrous.cs.hlsl | 8 +- .../RELAX_SpecularSh_AtrousSmem.cs.hlsl | 8 +- Shaders/Source/RELAX_SpecularSh_Copy.cs.hlsl | 8 +- .../RELAX_SpecularSh_HistoryClamping.cs.hlsl | 8 +- .../RELAX_SpecularSh_HistoryFix.cs.hlsl | 8 +- .../Source/RELAX_SpecularSh_PrePass.cs.hlsl | 8 +- .../RELAX_SpecularSh_SplitScreen.cs.hlsl | 8 +- ...AX_SpecularSh_TemporalAccumulation.cs.hlsl | 8 +- .../Source/RELAX_Specular_AntiFirefly.cs.hlsl | 8 +- Shaders/Source/RELAX_Specular_Atrous.cs.hlsl | 8 +- .../Source/RELAX_Specular_AtrousSmem.cs.hlsl | 8 +- Shaders/Source/RELAX_Specular_Copy.cs.hlsl | 8 +- .../RELAX_Specular_HistoryClamping.cs.hlsl | 8 +- .../Source/RELAX_Specular_HistoryFix.cs.hlsl | 8 +- ...LAX_Specular_HitDistReconstruction.cs.hlsl | 8 +- ...Specular_HitDistReconstruction_5x5.cs.hlsl | 8 +- Shaders/Source/RELAX_Specular_PrePass.cs.hlsl | 8 +- .../Source/RELAX_Specular_SplitScreen.cs.hlsl | 8 +- ...ELAX_Specular_TemporalAccumulation.cs.hlsl | 8 +- Shaders/Source/RELAX_Validation.cs.hlsl | 17 +- .../SIGMA_ShadowTranslucency_Blur.cs.hlsl | 8 +- ...A_ShadowTranslucency_ClassifyTiles.cs.hlsl | 8 +- .../SIGMA_ShadowTranslucency_PostBlur.cs.hlsl | 8 +- ...GMA_ShadowTranslucency_SplitScreen.cs.hlsl | 8 +- ...Translucency_TemporalStabilization.cs.hlsl | 8 +- Shaders/Source/SIGMA_Shadow_Blur.cs.hlsl | 8 +- .../Source/SIGMA_Shadow_ClassifyTiles.cs.hlsl | 8 +- Shaders/Source/SIGMA_Shadow_PostBlur.cs.hlsl | 8 +- .../Source/SIGMA_Shadow_SmoothTiles.cs.hlsl | 6 +- .../Source/SIGMA_Shadow_SplitScreen.cs.hlsl | 8 +- ...SIGMA_Shadow_TemporalStabilization.cs.hlsl | 8 +- .../Source/SpecularDeltaMv_Compute.cs.hlsl | 26 +- .../SpecularReflectionMv_Compute.cs.hlsl | 47 +- Source/Denoisers/Reblur_Diffuse.hpp | 180 ++--- .../Reblur_DiffuseDirectionalOcclusion.hpp | 180 ++--- Source/Denoisers/Reblur_DiffuseOcclusion.hpp | 176 ++--- Source/Denoisers/Reblur_DiffuseSh.hpp | 202 +++-- Source/Denoisers/Reblur_DiffuseSpecular.hpp | 224 +++--- .../Reblur_DiffuseSpecularOcclusion.hpp | 212 +++--- Source/Denoisers/Reblur_DiffuseSpecularSh.hpp | 276 ++++--- Source/Denoisers/Reblur_Specular.hpp | 190 +++-- Source/Denoisers/Reblur_SpecularOcclusion.hpp | 184 ++--- Source/Denoisers/Reblur_SpecularSh.hpp | 214 +++--- Source/Denoisers/Reference.hpp | 46 +- Source/Denoisers/Relax_Diffuse.hpp | 533 +++---------- Source/Denoisers/Relax_DiffuseSh.hpp | 568 ++++---------- Source/Denoisers/Relax_DiffuseSpecular.hpp | 631 ++++------------ Source/Denoisers/Relax_DiffuseSpecularSh.hpp | 706 +++++------------- Source/Denoisers/Relax_Specular.hpp | 559 ++++---------- Source/Denoisers/Relax_SpecularSh.hpp | 598 ++++----------- Source/Denoisers/Sigma_Shadow.hpp | 33 +- Source/Denoisers/Sigma_ShadowTranslucency.hpp | 33 +- Source/Denoisers/SpecularDeltaMv.hpp | 35 +- Source/Denoisers/SpecularReflectionMv.hpp | 47 +- Source/InstanceImpl.cpp | 275 ++++--- Source/InstanceImpl.h | 235 +++--- Source/Reblur.cpp | 550 ++++++-------- Source/Relax.cpp | 334 ++++++--- Source/Sigma.cpp | 159 ++-- Source/Wrapper.cpp | 4 +- UPDATE.md | 30 + 376 files changed, 7571 insertions(+), 9665 deletions(-) rename Shaders/Include/{REBLUR/REBLUR_DiffuseSpecular_Blur.hlsli => REBLUR_Blur.hlsli} (85%) rename Shaders/Include/{REBLUR => }/REBLUR_Common.hlsli (90%) rename Shaders/Include/{REBLUR => }/REBLUR_Common_DiffuseSpatialFilter.hlsli (71%) rename Shaders/Include/{REBLUR => }/REBLUR_Common_SpecularSpatialFilter.hlsli (79%) rename Shaders/Include/{REBLUR => }/REBLUR_Config.hlsli (81%) rename Shaders/Include/{REBLUR/REBLUR_DiffuseSpecular_CopyStabilizedHistory.hlsli => REBLUR_Copy.hlsli} (100%) rename Shaders/Include/{REBLUR/REBLUR_DiffuseSpecular_HistoryFix.hlsli => REBLUR_HistoryFix.hlsli} (72%) rename Shaders/Include/{REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli => REBLUR_HitDistReconstruction.hlsli} (87%) rename Shaders/Include/{REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli => REBLUR_PostBlur.hlsli} (89%) rename Shaders/Include/{REBLUR/REBLUR_DiffuseSpecular_PrePass.hlsli => REBLUR_PrePass.hlsli} (63%) rename Shaders/Include/{REBLUR/REBLUR_DiffuseSpecular_SplitScreen.hlsli => REBLUR_SplitScreen.hlsli} (69%) rename Shaders/Include/{REBLUR/REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli => REBLUR_TemporalAccumulation.hlsli} (81%) rename Shaders/Include/{REBLUR/REBLUR_DiffuseSpecular_TemporalStabilization.hlsli => REBLUR_TemporalStabilization.hlsli} (91%) delete mode 100644 Shaders/Include/RELAX/RELAX_Config.hlsli rename Shaders/Include/{RELAX/RELAX_DiffuseSpecular_AntiFirefly.hlsli => RELAX_AntiFirefly.hlsli} (94%) rename Shaders/Include/{RELAX/RELAX_DiffuseSpecular_Atrous.hlsli => RELAX_Atrous.hlsli} (84%) rename Shaders/Include/{RELAX/RELAX_DiffuseSpecular_AtrousSmem.hlsli => RELAX_AtrousSmem.hlsli} (92%) rename Shaders/Include/{RELAX => }/RELAX_Common.hlsli (97%) create mode 100644 Shaders/Include/RELAX_Config.hlsli rename Shaders/Include/{RELAX/RELAX_DiffuseSpecular_Copy.hlsli => RELAX_Copy.hlsli} (71%) rename Shaders/Include/{RELAX/RELAX_DiffuseSpecular_HistoryClamping.hlsli => RELAX_HistoryClamping.hlsli} (93%) rename Shaders/Include/{RELAX/RELAX_DiffuseSpecular_HistoryFix.hlsli => RELAX_HistoryFix.hlsli} (86%) rename Shaders/Include/{RELAX/RELAX_DiffuseSpecular_HitDistReconstruction.hlsli => RELAX_HitDistReconstruction.hlsli} (84%) rename Shaders/Include/{RELAX/RELAX_DiffuseSpecular_PrePass.hlsli => RELAX_PrePass.hlsli} (56%) rename Shaders/Include/{RELAX/RELAX_DiffuseSpecular_SplitScreen.hlsli => RELAX_SplitScreen.hlsli} (74%) rename Shaders/Include/{RELAX/RELAX_DiffuseSpecular_TemporalAccumulation.hlsli => RELAX_TemporalAccumulation.hlsli} (86%) rename Shaders/Include/{SIGMA/SIGMA_Shadow_Blur.hlsli => SIGMA_Blur.hlsli} (85%) rename Shaders/Include/{SIGMA/SIGMA_Shadow_ClassifyTiles.hlsli => SIGMA_ClassifyTiles.hlsli} (100%) rename Shaders/Include/{SIGMA => }/SIGMA_Common.hlsli (92%) rename Shaders/Include/{SIGMA => }/SIGMA_Config.hlsli (73%) rename Shaders/Include/{SIGMA/SIGMA_Shadow_SplitScreen.hlsli => SIGMA_SplitScreen.hlsli} (69%) rename Shaders/Include/{SIGMA/SIGMA_Shadow_TemporalStabilization.hlsli => SIGMA_TemporalStabilization.hlsli} (80%) rename Shaders/Resources/{Clear_f.resources.hlsli => Clear_Float.resources.hlsli} (52%) rename Shaders/Resources/{Clear_ui.resources.hlsli => Clear_Uint.resources.hlsli} (53%) create mode 100644 Shaders/Resources/REBLUR_Blur.resources.hlsli create mode 100644 Shaders/Resources/REBLUR_Copy.resources.hlsli delete mode 100644 Shaders/Resources/REBLUR_DiffuseSpecular_Blur.resources.hlsli delete mode 100644 Shaders/Resources/REBLUR_DiffuseSpecular_CopyStabilizedHistory.resources.hlsli delete mode 100644 Shaders/Resources/REBLUR_DiffuseSpecular_HistoryFix.resources.hlsli delete mode 100644 Shaders/Resources/REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli delete mode 100644 Shaders/Resources/REBLUR_DiffuseSpecular_PostBlur.resources.hlsli delete mode 100644 Shaders/Resources/REBLUR_DiffuseSpecular_PrePass.resources.hlsli delete mode 100644 Shaders/Resources/REBLUR_DiffuseSpecular_SplitScreen.resources.hlsli delete mode 100644 Shaders/Resources/REBLUR_DiffuseSpecular_TemporalAccumulation.resources.hlsli delete mode 100644 Shaders/Resources/REBLUR_DiffuseSpecular_TemporalStabilization.resources.hlsli create mode 100644 Shaders/Resources/REBLUR_HistoryFix.resources.hlsli create mode 100644 Shaders/Resources/REBLUR_HitDistReconstruction.resources.hlsli create mode 100644 Shaders/Resources/REBLUR_PostBlur.resources.hlsli create mode 100644 Shaders/Resources/REBLUR_PrePass.resources.hlsli create mode 100644 Shaders/Resources/REBLUR_SplitScreen.resources.hlsli create mode 100644 Shaders/Resources/REBLUR_TemporalAccumulation.resources.hlsli create mode 100644 Shaders/Resources/REBLUR_TemporalStabilization.resources.hlsli create mode 100644 Shaders/Resources/RELAX_AntiFirefly.resources.hlsli create mode 100644 Shaders/Resources/RELAX_Atrous.resources.hlsli create mode 100644 Shaders/Resources/RELAX_AtrousSmem.resources.hlsli create mode 100644 Shaders/Resources/RELAX_Copy.resources.hlsli delete mode 100644 Shaders/Resources/RELAX_DiffuseSpecular_AntiFirefly.resources.hlsli delete mode 100644 Shaders/Resources/RELAX_DiffuseSpecular_Atrous.resources.hlsli delete mode 100644 Shaders/Resources/RELAX_DiffuseSpecular_AtrousSmem.resources.hlsli delete mode 100644 Shaders/Resources/RELAX_DiffuseSpecular_Copy.resources.hlsli delete mode 100644 Shaders/Resources/RELAX_DiffuseSpecular_HistoryClamping.resources.hlsli delete mode 100644 Shaders/Resources/RELAX_DiffuseSpecular_HistoryFix.resources.hlsli delete mode 100644 Shaders/Resources/RELAX_DiffuseSpecular_HitDistReconstruction.resources.hlsli delete mode 100644 Shaders/Resources/RELAX_DiffuseSpecular_PrePass.resources.hlsli delete mode 100644 Shaders/Resources/RELAX_DiffuseSpecular_SplitScreen.resources.hlsli delete mode 100644 Shaders/Resources/RELAX_DiffuseSpecular_TemporalAccumulation.resources.hlsli create mode 100644 Shaders/Resources/RELAX_HistoryClamping.resources.hlsli create mode 100644 Shaders/Resources/RELAX_HistoryFix.resources.hlsli create mode 100644 Shaders/Resources/RELAX_HitDistReconstruction.resources.hlsli create mode 100644 Shaders/Resources/RELAX_PrePass.resources.hlsli create mode 100644 Shaders/Resources/RELAX_SplitScreen.resources.hlsli create mode 100644 Shaders/Resources/RELAX_TemporalAccumulation.resources.hlsli create mode 100644 Shaders/Resources/SIGMA_Blur.resources.hlsli create mode 100644 Shaders/Resources/SIGMA_ClassifyTiles.resources.hlsli delete mode 100644 Shaders/Resources/SIGMA_Shadow_Blur.resources.hlsli delete mode 100644 Shaders/Resources/SIGMA_Shadow_ClassifyTiles.resources.hlsli delete mode 100644 Shaders/Resources/SIGMA_Shadow_SmoothTiles.resources.hlsli delete mode 100644 Shaders/Resources/SIGMA_Shadow_SplitScreen.resources.hlsli delete mode 100644 Shaders/Resources/SIGMA_Shadow_TemporalStabilization.resources.hlsli create mode 100644 Shaders/Resources/SIGMA_SmoothTiles.resources.hlsli create mode 100644 Shaders/Resources/SIGMA_SplitScreen.resources.hlsli create mode 100644 Shaders/Resources/SIGMA_TemporalStabilization.resources.hlsli rename Shaders/Source/{Clear_f.cs.hlsl => Clear_Float.cs.hlsl} (94%) rename Shaders/Source/{Clear_ui.cs.hlsl => Clear_Uint.cs.hlsl} (94%) rename Shaders/Source/{REBLUR_DiffuseSh_CopyStabilizedHistory.cs.hlsl => REBLUR_DiffuseSh_Copy.cs.hlsl} (74%) rename Shaders/Source/{REBLUR_DiffuseSpecularSh_CopyStabilizedHistory.cs.hlsl => REBLUR_DiffuseSpecularSh_Copy.cs.hlsl} (75%) rename Shaders/Source/{REBLUR_DiffuseSpecular_CopyStabilizedHistory.cs.hlsl => REBLUR_DiffuseSpecular_Copy.cs.hlsl} (74%) rename Shaders/Source/{REBLUR_Diffuse_CopyStabilizedHistory.cs.hlsl => REBLUR_Diffuse_Copy.cs.hlsl} (74%) rename Shaders/Source/{REBLUR_SpecularSh_CopyStabilizedHistory.cs.hlsl => REBLUR_SpecularSh_Copy.cs.hlsl} (74%) rename Shaders/Source/{REBLUR_Specular_CopyStabilizedHistory.cs.hlsl => REBLUR_Specular_Copy.cs.hlsl} (74%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0029541..8a27cec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,7 +61,7 @@ set (CMAKE_CXX_STANDARD 17) set (CMAKE_CXX_STANDARD_REQUIRED ON) set (CMAKE_C_STANDARD 99) -if (MSVC) +if (MSVC AND NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif () @@ -103,14 +103,14 @@ endif () # External/MathLib file (READ "External/MathLib/MathLib.h" ver_h) -string (REGEX MATCH "MATHLIB_VERSION_MAJOR ([0-9]*)" _ ${ver_h}) -set (MATHLIB_VERSION_MAJOR ${CMAKE_MATCH_1}) -string (REGEX MATCH "MATHLIB_VERSION_MINOR ([0-9]*)" _ ${ver_h}) -set (MATHLIB_VERSION_MINOR ${CMAKE_MATCH_1}) -message ("MathLib v${MATHLIB_VERSION_MAJOR}.${MATHLIB_VERSION_MINOR}") +string (REGEX MATCH "ML_VERSION_MAJOR ([0-9]*)" _ ${ver_h}) +set (ML_VERSION_MAJOR ${CMAKE_MATCH_1}) +string (REGEX MATCH "ML_VERSION_MINOR ([0-9]*)" _ ${ver_h}) +set (ML_VERSION_MINOR ${CMAKE_MATCH_1}) +message ("MathLib v${ML_VERSION_MAJOR}.${ML_VERSION_MINOR}") -file (GLOB MATHLIB_FILES "External/MathLib/*.h" "External/MathLib/*.hpp") -source_group ("MathLib" FILES ${MATHLIB_FILES}) +file (GLOB ML_FILES "External/MathLib/*.h" "External/MathLib/*.hpp") +source_group ("MathLib" FILES ${ML_FILES}) # NRD file (GLOB GLOB_INCUDE "Include/*") @@ -123,9 +123,9 @@ file (GLOB GLOB_RESOURCES "Resources/*") source_group ("Resources" FILES ${GLOB_RESOURCES}) if (NRD_STATIC_LIBRARY) - add_library (${PROJECT_NAME} STATIC ${GLOB_SOURCE} ${GLOB_DENOISERS} ${MATHLIB_FILES} ${GLOB_RESOURCES} ${GLOB_INCUDE}) + add_library (${PROJECT_NAME} STATIC ${GLOB_SOURCE} ${GLOB_DENOISERS} ${ML_FILES} ${GLOB_RESOURCES} ${GLOB_INCUDE}) else () - add_library (${PROJECT_NAME} SHARED ${GLOB_SOURCE} ${GLOB_DENOISERS} ${MATHLIB_FILES} ${GLOB_RESOURCES} ${GLOB_INCUDE}) + add_library (${PROJECT_NAME} SHARED ${GLOB_SOURCE} ${GLOB_DENOISERS} ${ML_FILES} ${GLOB_RESOURCES} ${GLOB_INCUDE}) if (WIN32) target_compile_definitions (${PROJECT_NAME} PRIVATE "NRD_API=extern \"C\" __declspec(dllexport)") diff --git a/External/MathLib b/External/MathLib index a994536..b5fbb76 160000 --- a/External/MathLib +++ b/External/MathLib @@ -1 +1 @@ -Subproject commit a9945363972d9b653ed6b358203aa10b18c962b4 +Subproject commit b5fbb76f1e665735ada5bee35d476acbaf1842de diff --git a/External/ShaderMake b/External/ShaderMake index 2f180c9..21e54e6 160000 --- a/External/ShaderMake +++ b/External/ShaderMake @@ -1 +1 @@ -Subproject commit 2f180c9c17be811e2339c1b8cc207f3658e494fb +Subproject commit 21e54e6ee91a4330cbdd6f9e1a798d59e8d746d2 diff --git a/Include/NRD.h b/Include/NRD.h index 3d4c15e..3929bce 100644 --- a/Include/NRD.h +++ b/Include/NRD.h @@ -28,9 +28,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include #define NRD_VERSION_MAJOR 4 -#define NRD_VERSION_MINOR 3 -#define NRD_VERSION_BUILD 6 -#define NRD_VERSION_DATE "3 November 2023" +#define NRD_VERSION_MINOR 4 +#define NRD_VERSION_BUILD 0 +#define NRD_VERSION_DATE "15 November 2023" #if defined(_MSC_VER) #define NRD_CALL __fastcall diff --git a/Include/NRDDescs.h b/Include/NRDDescs.h index db6e61a..dca1004 100644 --- a/Include/NRDDescs.h +++ b/Include/NRDDescs.h @@ -11,9 +11,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #pragma once #define NRD_DESCS_VERSION_MAJOR 4 -#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"); +static_assert(NRD_VERSION_MAJOR == NRD_DESCS_VERSION_MAJOR && NRD_VERSION_MINOR == NRD_DESCS_VERSION_MINOR, "Please, update all NRD SDK files"); namespace nrd { @@ -32,6 +32,137 @@ namespace nrd MAX_NUM }; + // Only resources referenced by "Denoiser" must be provided from the application side + // See NRD.hlsli for more details + enum class ResourceType : uint32_t + { + //============================================================================================================================= + // NON-NOISY 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 in "NRD_FrontEnd_PackNormalAndRoughness" and "NRD_FrontEnd_UnpackNormalAndRoughness" (RGBA8+) + IN_NORMAL_ROUGHNESS, + + // Linear view depth for primary rays (R16f+) + IN_VIEWZ, + + // (Optional) User-provided history confidence in range 0-1, i.e. antilag (R8+) + // Used only if "CommonSettings::isHistoryConfidenceAvailable = true" + IN_DIFF_CONFIDENCE, + IN_SPEC_CONFIDENCE, + + // (Optional) User-provided disocclusion threshold selector in range 0-1 (R8+) + // Disocclusion threshold is mixed between "disocclusionThreshold" and "disocclusionThresholdAlternate" + // Used only if "CommonSettings::isDisocclusionThresholdMixAvailable = true" + IN_DISOCCLUSION_THRESHOLD_MIX, + + // (Optional) Base color (can be decoupled to diffuse and specular albedo based on metalness) and metalness (RGBA8+) + // Used only if "CommonSettings::isBaseColorMetalnessAvailable = true". Currently used only by REBLUR (if temporal + // stabilization pass is available and "stabilizationStrength != 0") to patch MV if specular (virtual) motion prevails + // on diffuse (surface) motion + IN_BASECOLOR_METALNESS, + + //============================================================================================================================= + // NOISY INPUTS + //============================================================================================================================= + + // 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, + + // Hit distance (R8+) + // REBLUR: use "REBLUR_FrontEnd_GetNormHitDist" for encoding + IN_DIFF_HITDIST, + IN_SPEC_HITDIST, + + // Sampling direction and normalized hit distance (RGBA8+) + // REBLUR: use "REBLUR_FrontEnd_PackDirectionalOcclusion" for encoding + IN_DIFF_DIRECTION_HITDIST, + + // SH data (2x RGBA16f+) + // REBLUR: use "REBLUR_FrontEnd_PackSh" for encoding + // RELAX: use "RELAX_FrontEnd_PackSh" for encoding + IN_DIFF_SH0, + IN_DIFF_SH1, + IN_SPEC_SH0, + IN_SPEC_SH1, + + // Shadow data and optional translucency (RG16f+ and RGBA8+ for translucency) + // SIGMA: use "SIGMA_FrontEnd_PackShadow" for encoding + IN_SHADOWDATA, + IN_SHADOW_TRANSLUCENCY, + + // Some signal (R8+) + IN_SIGNAL, + + // Primary and secondary world-space positions (RGBA16f+) + IN_DELTA_PRIMARY_POS, + IN_DELTA_SECONDARY_POS, + + //============================================================================================================================= + // OUTPUTS + //============================================================================================================================= + + // IMPORTANT: These textures can be potentially used as history buffers! + // IMPORTANT: Most of denoisers do not write into output pixels outside of "CommonSettings::denoisingRange"! + + // 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, + + // SH data + // REBLUR: use "REBLUR_BackEnd_UnpackSh" for decoding (2x RGBA16f+) + // RELAX: use "RELAX_BackEnd_UnpackSh" for decoding (2x RGBA16f+) + 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, + + // Shadow and optional transcluceny (R8+ or RGBA8+) + // SIGMA: use "SIGMA_BackEnd_UnpackShadow" for decoding + OUT_SHADOW_TRANSLUCENCY, + + // Denoised signal (R8+) + OUT_SIGNAL, + + // 2D screen-space specular motion (RG16f+), MV = previous - current + OUT_REFLECTION_MV, + + // 2D screen-space refraction motion (RG16f+), MV = previous - current + OUT_DELTA_MV, + + // (Optional) Debug output (RGBA8+), .w = transparency + // Used if "CommonSettings::enableValidation = true" + OUT_VALIDATION, + + //============================================================================================================================= + // POOLS + //============================================================================================================================= + + // Can be reused after denoising + TRANSIENT_POOL, + + // Dedicated to NRD, can't be reused + PERMANENT_POOL, + + MAX_NUM, + }; + enum class Denoiser : uint32_t { /* @@ -142,8 +273,8 @@ namespace nrd // REFERENCE // ============================================================================================================================= - // INPUTS - IN_RADIANCE - // OUTPUTS - OUT_RADIANCE + // INPUTS - IN_SIGNAL + // OUTPUTS - OUT_SIGNAL REFERENCE, // ============================================================================================================================= @@ -161,134 +292,6 @@ namespace nrd MAX_NUM }; - // See NRD.hlsli for more details - enum class ResourceType : uint32_t - { - //============================================================================================================================= - // 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 in "NRD_FrontEnd_PackNormalAndRoughness" and "NRD_FrontEnd_UnpackNormalAndRoughness" (RGBA8+) - IN_NORMAL_ROUGHNESS, - - // Linear view depth for primary rays (R16f+) - IN_VIEWZ, - - //============================================================================================================================= - // 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, - - // Noisy hit distance (R8+) - // REBLUR: use "REBLUR_FrontEnd_GetNormHitDist" for encoding - IN_DIFF_HITDIST, - IN_SPEC_HITDIST, - - // Noisy bent normal and normalized hit distance (RGBA8+) - // REBLUR: use "REBLUR_FrontEnd_PackDirectionalOcclusion" for encoding - IN_DIFF_DIRECTION_HITDIST, - - // Noisy SH data (2x RGBA16f+) - // REBLUR: use "REBLUR_FrontEnd_PackSh" for encoding - // RELAX: use "RELAX_FrontEnd_PackSh" for encoding - IN_DIFF_SH0, - IN_DIFF_SH1, - IN_SPEC_SH0, - IN_SPEC_SH1, - - // (Optional) User-provided history confidence in range 0-1, i.e. antilag (R8+) - // Used only if "CommonSettings::isHistoryConfidenceAvailable = true" - IN_DIFF_CONFIDENCE, - IN_SPEC_CONFIDENCE, - - // (Optional) User-provided disocclusion threshold selector in range 0-1 (R8+) - // Disocclusion threshold is mixed between "disocclusionThreshold" and "disocclusionThresholdAlternate" - // Used only if "CommonSettings::isDisocclusionThresholdMixAvailable = true" - IN_DISOCCLUSION_THRESHOLD_MIX, - - // (Optional) Base color (can be decoupled to diffuse and specular albedo based on metalness) and metalness (RGBA8+) - // Used only if "CommonSettings::isBaseColorMetalnessAvailable = true" - IN_BASECOLOR_METALNESS, - - // Noisy shadow data and optional translucency (RG16f+ and RGBA8+ for optional translucency) - // SIGMA: use "SIGMA_FrontEnd_PackShadow" for encoding - IN_SHADOWDATA, - IN_SHADOW_TRANSLUCENCY, - - // Noisy signal (R8+) - IN_RADIANCE, - - // Primary and secondary world-space positions (RGBA16f+) - IN_DELTA_PRIMARY_POS, - IN_DELTA_SECONDARY_POS, - - //============================================================================================================================= - // OUTPUTS - //============================================================================================================================= - - // IMPORTANT: These textures can be potentially used as history buffers! - // IMPORTANT: Most of denoisers do not write into output pixels outside of "CommonSettings::denoisingRange"! - - // 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, - - // Denoised SH data - // REBLUR: use "REBLUR_BackEnd_UnpackSh" for decoding (2x RGBA16f+) - // RELAX: use "RELAX_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, - - // Denoised bent normal and normalized hit distance (RGBA8+) - // REBLUR: use "REBLUR_BackEnd_UnpackDirectionalOcclusion" for decoding - OUT_DIFF_DIRECTION_HITDIST, - - // Denoised shadow and optional transcluceny (R8+ or RGBA8+) - // SIGMA: use "SIGMA_BackEnd_UnpackShadow" for decoding - OUT_SHADOW_TRANSLUCENCY, - - // Denoised signal - OUT_RADIANCE, - - // 2D screen-space specular motion (RG16f+), MV = previous - current - OUT_REFLECTION_MV, - - // 2D screen-space refraction motion (RG16f+), MV = previous - current - OUT_DELTA_MV, - - // (Optional) Debug output (RGBA8+), .w = transparency - // Used if "CommonSettings::enableValidation = true" - OUT_VALIDATION, - - //============================================================================================================================= - // POOLS - //============================================================================================================================= - - // Can be reused after denoising - TRANSIENT_POOL, - - // Dedicated to NRD, can't be reused - PERMANENT_POOL, - - MAX_NUM, - }; - enum class Format : uint32_t { R8_UNORM, @@ -363,9 +366,7 @@ namespace nrd enum class Sampler : uint32_t { NEAREST_CLAMP, - NEAREST_MIRRORED_REPEAT, LINEAR_CLAMP, - LINEAR_MIRRORED_REPEAT, MAX_NUM }; @@ -434,8 +435,6 @@ namespace nrd { Identifier identifier; Denoiser denoiser; - uint16_t renderWidth; - uint16_t renderHeight; }; struct InstanceCreationDesc @@ -448,9 +447,7 @@ namespace nrd struct TextureDesc { Format format; - uint16_t width; - uint16_t height; - uint16_t mipNum; + uint16_t downsampleFactor; }; struct ResourceDesc @@ -458,8 +455,6 @@ namespace nrd DescriptorType stateNeeded; ResourceType type; uint16_t indexInPool; - uint16_t mipOffset; - uint16_t mipNum; }; struct ResourceRangeDesc @@ -484,6 +479,8 @@ namespace nrd const char* shaderEntryPointName; const ResourceRangeDesc* resourceRanges; uint32_t resourceRangesNum; + + // Hint that pipeline has a constant buffer with shared parameters from "InstanceDesc" bool hasConstantData; }; @@ -500,21 +497,19 @@ namespace nrd { // Constant buffer (shared) uint32_t constantBufferMaxDataSize; - uint32_t constantBufferSpaceIndex; - uint32_t constantBufferRegisterIndex; + uint32_t constantBufferSpaceIndex; // = NRD_CONSTANT_BUFFER_SPACE_INDEX + uint32_t constantBufferRegisterIndex; // = NRD_CONSTANT_BUFFER_REGISTER_INDEX // Samplers (shared) const Sampler* samplers; - uint32_t samplersNum; - uint32_t samplersSpaceIndex; + uint32_t samplersNum; // = Sampler::MAX_NUM + uint32_t samplersSpaceIndex; // = NRD_SAMPLERS_SPACE_INDEX uint32_t samplersBaseRegisterIndex; // Pipelines - // - if "PipelineDesc::hasConstantData = true" a pipeline has a constant buffer with the shared description - // - if "samplers" are used as static/immutable samplers, "DescriptorPoolDesc::samplerMaxNum" is not needed (it counts samplers across all dispatches) const PipelineDesc* pipelines; uint32_t pipelinesNum; - uint32_t resourcesSpaceIndex; + uint32_t resourcesSpaceIndex; // = NRD_RESOURCES_SPACE_INDEX // Textures const TextureDesc* permanentPool; @@ -522,17 +517,29 @@ namespace nrd const TextureDesc* transientPool; uint32_t transientPoolSize; - // Limits + // ( Optional) Limits + // - "DescriptorPoolDesc::samplersMaxNum" counts samplers across all dispatches, assuming naive usage + // - "DescriptorPoolDesc::samplersMaxNum" is not needed, if "samplers" are used as static/immutable samplers + // - "DescriptorPoolDesc::samplersMaxNum" = "InstanceDesc::samplersNum", if "InstanceDesc::samplersBaseRegisterIndex" is a unique space DescriptorPoolDesc descriptorPoolDesc; }; struct DispatchDesc { + // ( Optional ) const char* name; - const ResourceDesc* resources; // concatenated resources for all "resourceRanges" descriptions in DenoiserDesc::pipelines[ pipelineIndex ] + Identifier identifier; // which denoiser this dispatch belongs to + + // Concatenated resources for all "resourceRanges" descriptions in DenoiserDesc::pipelines[ pipelineIndex ] + const ResourceDesc* resources; uint32_t resourcesNum; + + // Constants const uint8_t* constantBufferData; uint32_t constantBufferDataSize; + bool constantBufferDataMatchesPreviousDispatch; // i.e. no update needed + + // Other uint16_t pipelineIndex; uint16_t gridWidth; uint16_t gridHeight; diff --git a/Include/NRDSettings.h b/Include/NRDSettings.h index 620c990..cfaf765 100644 --- a/Include/NRDSettings.h +++ b/Include/NRDSettings.h @@ -11,9 +11,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #pragma once #define NRD_SETTINGS_VERSION_MAJOR 4 -#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"); +static_assert(NRD_VERSION_MAJOR == NRD_SETTINGS_VERSION_MAJOR && NRD_VERSION_MINOR == NRD_SETTINGS_VERSION_MINOR, "Please, update all NRD SDK files"); namespace nrd { @@ -103,9 +103,11 @@ namespace nrd float cameraJitter[2] = {}; float cameraJitterPrev[2] = {}; - // (0; 1] - dynamic resolution scaling - float resolutionScale[2] = {1.0f, 1.0f}; - float resolutionScalePrev[2] = {1.0f, 1.0f}; + // Flexible dynamic resolution scaling support + uint16_t resourceSize[2] = {}; + uint16_t resourceSizePrev[2] = {}; + uint16_t rectSize[2] = {}; + uint16_t rectSizePrev[2] = {}; // (ms) - user provided if > 0, otherwise - tracked internally float timeDeltaBetweenFrames = 0.0f; @@ -125,8 +127,10 @@ namespace nrd // For internal needs float debug = 0.0f; - // (pixels) - data rectangle origin in ALL input textures - uint32_t inputSubrectOrigin[2] = {}; + // (pixels) - viewport origin + // IMPORTANT: gets applied only to non-noisy guides (aka g-buffer), including IN_DIFF_CONFIDENCE, IN_SPEC_CONFIDENCE, IN_DISOCCLUSION_THRESHOLD_MIX and IN_BASECOLOR_METALNESS + // Must be manually enabled via NRD_USE_VIEWPORT_OFFSET macro switch + uint32_t rectOrigin[2] = {}; // A consecutive number uint32_t frameIndex = 0; @@ -147,7 +151,7 @@ namespace nrd // If "true" IN_BASECOLOR_METALNESS is available bool isBaseColorMetalnessAvailable = false; - // Enables debug overlay in OUT_VALIDATION, requires "InstanceCreationDesc::allowValidation = true" + // Enables debug overlay in OUT_VALIDATION bool enableValidation = false; }; @@ -195,7 +199,7 @@ namespace nrd // [0; REBLUR_MAX_HISTORY_FRAME_NUM] - maximum number of linearly accumulated frames in fast history (less than "maxAccumulatedFrameNum") uint32_t maxFastAccumulatedFrameNum = 6; - // [0; REBLUR_MAX_HISTORY_FRAME_NUM] - number of reconstructed frames after history reset (less than "maxFastAccumulatedFrameNum") + // [0; 3] - number of reconstructed frames after history reset (less than "maxFastAccumulatedFrameNum") uint32_t historyFixFrameNum = 3; // (pixels) - pre-accumulation spatial reuse pass blur radius (0 = disabled, recommended in case of probabilistic sampling) @@ -205,9 +209,6 @@ namespace nrd // (pixels) - base denoising radius (30 is a baseline for 1440p) float blurRadius = 15.0f; - // (pixels) - base stride between samples in history reconstruction pass - float historyFixStrideBetweenSamples = 14.0f; - // (normalized %) - base fraction of diffuse or specular lobe angle used to drive normal based rejection float lobeAngleFraction = 0.15f; @@ -262,7 +263,7 @@ namespace nrd float blurRadiusScale = 2.0f; }; - // RELAX_DIFFUSE_SPECULAR + // RELAX const uint32_t RELAX_MAX_HISTORY_FRAME_NUM = 255; @@ -284,12 +285,12 @@ namespace nrd float resetAmount = 0.5f; }; - struct RelaxDiffuseSpecularSettings + struct RelaxSettings { RelaxAntilagSettings antilagSettings = {}; // (pixels) - pre-accumulation spatial reuse pass blur radius (0 = disabled, must be used in case of probabilistic sampling) - float diffusePrepassBlurRadius = 50.0f; + float diffusePrepassBlurRadius = 30.0f; float specularPrepassBlurRadius = 50.0f; // [0; RELAX_MAX_HISTORY_FRAME_NUM] - maximum number of linearly accumulated frames ( = FPS * "time of accumulation") @@ -300,7 +301,7 @@ namespace nrd uint32_t diffuseMaxFastAccumulatedFrameNum = 6; uint32_t specularMaxFastAccumulatedFrameNum = 6; - // [0; RELAX_MAX_HISTORY_FRAME_NUM] - number of reconstructed frames after history reset (less than "maxFastAccumulatedFrameNum") + // [0; 3] - number of reconstructed frames after history reset (less than "maxFastAccumulatedFrameNum") uint32_t historyFixFrameNum = 3; // A-trous edge stopping Luminance sensitivity @@ -320,9 +321,6 @@ namespace nrd // (degrees) - slack for the specular lobe angle used in normal based rejection of specular during A-Trous passes float specularLobeAngleSlack = 0.15f; - // (pixels) - base stride between samples in history reconstruction pass - float historyFixStrideBetweenSamples = 14.0f; - // (> 0) - normal edge stopper for history reconstruction pass float historyFixEdgeStoppingNormalPower = 8.0f; @@ -363,9 +361,6 @@ namespace nrd // Firefly suppression bool enableAntiFirefly = false; - // Skip reprojection test when there is no motion, might improve quality along the edges for static camera with a jitter - bool enableReprojectionTestSkippingWithoutMotion = false; - // Roughness based rejection bool enableRoughnessEdgeStopping = true; @@ -374,92 +369,6 @@ namespace nrd bool enableMaterialTestForSpecular = false; }; - // RELAX_DIFFUSE - - struct RelaxDiffuseSettings - { - RelaxAntilagSettings antilagSettings = {}; - - float prepassBlurRadius = 30.0f; - - uint32_t diffuseMaxAccumulatedFrameNum = 30; - uint32_t diffuseMaxFastAccumulatedFrameNum = 6; - uint32_t historyFixFrameNum = 3; - - float diffusePhiLuminance = 2.0f; - float diffuseLobeAngleFraction = 0.5f; - - float historyFixEdgeStoppingNormalPower = 8.0f; - float historyFixStrideBetweenSamples = 14.0f; - - float historyClampingColorBoxSigmaScale = 2.0f; - - uint32_t spatialVarianceEstimationHistoryThreshold = 3; - - uint32_t atrousIterationNum = 5; - 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; - - bool enableAntiFirefly = false; - bool enableReprojectionTestSkippingWithoutMotion = false; - bool enableMaterialTest = false; - }; - - // RELAX_SPECULAR - - struct RelaxSpecularSettings - { - RelaxAntilagSettings antilagSettings = {}; - - float prepassBlurRadius = 50.0f; - - uint32_t specularMaxAccumulatedFrameNum = 30; - uint32_t specularMaxFastAccumulatedFrameNum = 6; - uint32_t historyFixFrameNum = 3; - - float specularPhiLuminance = 1.0f; - float diffuseLobeAngleFraction = 0.5f; - float specularLobeAngleFraction = 0.5f; - float roughnessFraction = 0.15f; - - float specularVarianceBoost = 0.0f; - float specularLobeAngleSlack = 0.15f; - - float historyFixEdgeStoppingNormalPower = 8.0f; - float historyFixStrideBetweenSamples = 14.0f; - - float historyClampingColorBoxSigmaScale = 2.0f; - - uint32_t spatialVarianceEstimationHistoryThreshold = 3; - - uint32_t atrousIterationNum = 5; - 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 = 1.0f; - - CheckerboardMode checkerboardMode = CheckerboardMode::OFF; - HitDistanceReconstructionMode hitDistanceReconstructionMode = HitDistanceReconstructionMode::OFF; - - bool enableAntiFirefly = false; - bool enableReprojectionTestSkippingWithoutMotion = false; - bool enableRoughnessEdgeStopping = true; - bool enableMaterialTest = false; - }; - // REFERENCE struct ReferenceSettings diff --git a/Integration/NRDIntegration.h b/Integration/NRDIntegration.h index 2f09117..5184800 100644 --- a/Integration/NRDIntegration.h +++ b/Integration/NRDIntegration.h @@ -23,23 +23,21 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include #define NRD_INTEGRATION_MAJOR 1 -#define NRD_INTEGRATION_MINOR 7 -#define NRD_INTEGRATION_DATE "25 October 2023" +#define NRD_INTEGRATION_MINOR 10 +#define NRD_INTEGRATION_DATE "26 December 2023" #define NRD_INTEGRATION 1 #define NRD_INTEGRATION_DEBUG_LOGGING 0 #ifndef NRD_INTEGRATION_ASSERT #include - #define NRD_INTEGRATION_ASSERT(expr, msg) assert(expr && msg) + #define NRD_INTEGRATION_ASSERT(expr, msg) assert(msg && expr) #endif -// User inputs / outputs are not mipmapped, thus only 1 entry is needed. -// "TextureTransitionBarrierDesc::texture" is used to store the resource. -// "TextureTransitionBarrierDesc::next..." are used to represent the current state of the subresource. +// "state->texture" represents the resource, the rest represents the state. struct NrdIntegrationTexture { - nri::TextureTransitionBarrierDesc* subresourceStates; + nri::TextureTransitionBarrierDesc* state; nri::Format format; }; @@ -49,7 +47,7 @@ typedef std::arraytexture != nullptr, "Invalid texture!" ); + NRD_INTEGRATION_ASSERT( texture.state->texture != nullptr, "Invalid texture!" ); NRD_INTEGRATION_ASSERT( texture.format != nri::Format::UNKNOWN, "Invalid format!" ); pool[(size_t)slot] = texture; @@ -76,7 +74,7 @@ class NrdIntegration // There is no "Resize" functionality, because NRD full recreation costs nothing. // The main cost comes from render targets resizing, which needs to be done in any case // (call Destroy beforehand) - bool Initialize(const nrd::InstanceCreationDesc& instanceCreationDesc, nri::Device& nriDevice, const nri::CoreInterface& nriCore, const nri::HelperInterface& nriHelper); + bool Initialize(uint16_t resourceWidth, uint16_t resourceHeight, const nrd::InstanceCreationDesc& instanceCreationDesc, nri::Device& nriDevice, const nri::CoreInterface& nriCore, const nri::HelperInterface& nriHelper); // Must be called once on a frame start void NewFrame(); @@ -106,7 +104,7 @@ class NrdIntegration private: NrdIntegration(const NrdIntegration&) = delete; - void CreateResources(); + void CreateResources(uint16_t resourceWidth, uint16_t resourceHeight); void AllocateAndBindMemory(); void Dispatch(nri::CommandBuffer& commandBuffer, nri::DescriptorPool& descriptorPool, const nrd::DispatchDesc& dispatchDesc, const NrdUserPool& userPool); diff --git a/Integration/NRDIntegration.hpp b/Integration/NRDIntegration.hpp index 2789ced..293c6a3 100644 --- a/Integration/NRDIntegration.hpp +++ b/Integration/NRDIntegration.hpp @@ -10,8 +10,8 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "NRDIntegration.h" -static_assert(NRD_VERSION_MAJOR >= 4 && NRD_VERSION_MINOR >= 3, "Unsupported NRD version!"); -static_assert(NRI_VERSION_MAJOR >= 1 && NRI_VERSION_MINOR >= 93, "Unsupported NRI version!"); +static_assert(NRD_VERSION_MAJOR >= 4 && NRD_VERSION_MINOR >= 4, "Unsupported NRD version!"); +static_assert(NRI_VERSION_MAJOR >= 1 && NRI_VERSION_MINOR >= 110, "Unsupported NRI version!"); #ifdef _WIN32 #define alloca _alloca @@ -65,17 +65,16 @@ constexpr std::array g_NRD_NrdToNriFo nri::Format::R9_G9_B9_E5_UFLOAT, }; +static inline uint16_t NRD_DivideUp(uint32_t x, uint16_t y) +{ return uint16_t((x + y - 1) / y); } + static inline nri::Format NRD_GetNriFormat(nrd::Format format) -{ - return g_NRD_NrdToNriFormat[(uint32_t)format]; -} +{ return g_NRD_NrdToNriFormat[(uint32_t)format]; } -static inline uint64_t NRD_CreateDescriptorKey(uint64_t texture, bool isStorage, uint8_t mipOffset, uint8_t mipNum) +static inline uint64_t NRD_CreateDescriptorKey(uint64_t texture, bool isStorage) { - uint64_t key = uint64_t(isStorage ? 1 : 0) << 49ull; - key |= uint64_t(mipOffset & 127) << 50ull; - key |= uint64_t(mipNum & 127) << 57ull; - key |= texture & ((1ull << 49ull) - 1); + uint64_t key = uint64_t(isStorage ? 1 : 0) << 63ull; + key |= texture & ((1ull << 63ull) - 1); return key; } @@ -85,8 +84,7 @@ template constexpr T NRD_GetAlignedSize(const T& size, A return T(((size + alignment - 1) / alignment) * alignment); } -bool NrdIntegration::Initialize(const nrd::InstanceCreationDesc& instanceCreationDesc, nri::Device& nriDevice, - const nri::CoreInterface& nriCore, const nri::HelperInterface& nriHelper) +bool NrdIntegration::Initialize(uint16_t resourceWidth, uint16_t resourceHeight, const nrd::InstanceCreationDesc& instanceCreationDesc, nri::Device& nriDevice, const nri::CoreInterface& nriCore, const nri::HelperInterface& nriHelper) { NRD_INTEGRATION_ASSERT(!m_Instance, "Already initialized! Did you forget to call 'Destroy'?"); @@ -112,7 +110,7 @@ bool NrdIntegration::Initialize(const nrd::InstanceCreationDesc& instanceCreatio m_NRIHelper = &nriHelper; CreatePipelines(); - CreateResources(); + CreateResources(resourceWidth, resourceHeight); return true; } @@ -268,30 +266,24 @@ void NrdIntegration::CreatePipelines() m_IsShadersReloadRequested = true; } -void NrdIntegration::CreateResources() +void NrdIntegration::CreateResources(uint16_t resourceWidth, uint16_t resourceHeight) { const nrd::InstanceDesc& instanceDesc = nrd::GetInstanceDesc(*m_Instance); const uint32_t poolSize = instanceDesc.permanentPoolSize + instanceDesc.transientPoolSize; - uint32_t resourceStateNum = 0; - for (uint32_t i = 0; i < poolSize; i++) - { - const nrd::TextureDesc& nrdTextureDesc = (i < instanceDesc.permanentPoolSize) ? instanceDesc.permanentPool[i] : instanceDesc.transientPool[i - instanceDesc.permanentPoolSize]; - resourceStateNum += nrdTextureDesc.mipNum; - } - m_ResourceState.resize(resourceStateNum); // No reallocation! - + m_ResourceState.resize(poolSize); // No reallocation! m_TexturePool.resize(poolSize); // Texture pool - resourceStateNum = 0; for (uint32_t i = 0; i < poolSize; i++) { // Create NRI texture const nrd::TextureDesc& nrdTextureDesc = (i < instanceDesc.permanentPoolSize) ? instanceDesc.permanentPool[i] : instanceDesc.transientPool[i - instanceDesc.permanentPoolSize]; const nri::Format format = NRD_GetNriFormat(nrdTextureDesc.format); - nri::TextureDesc textureDesc = nri::Texture2D(format, nrdTextureDesc.width, nrdTextureDesc.height, nrdTextureDesc.mipNum, 1, nri::TextureUsageBits::SHADER_RESOURCE | nri::TextureUsageBits::SHADER_RESOURCE_STORAGE); + uint16_t w = NRD_DivideUp(resourceWidth, nrdTextureDesc.downsampleFactor); + uint16_t h = NRD_DivideUp(resourceHeight, nrdTextureDesc.downsampleFactor); + nri::TextureDesc textureDesc = nri::Texture2D(format, w, h, 1, 1, nri::TextureUsageBits::SHADER_RESOURCE | nri::TextureUsageBits::SHADER_RESOURCE_STORAGE); nri::Texture* texture = nullptr; NRD_INTEGRATION_ABORT_ON_FAILURE(m_NRI->CreateTexture(*m_Device, textureDesc, texture)); @@ -304,14 +296,11 @@ void NrdIntegration::CreateResources() // Construct NRD texture NrdIntegrationTexture nrdTexture = {}; - nrdTexture.subresourceStates = &m_ResourceState[resourceStateNum]; + nrdTexture.state = &m_ResourceState[i]; nrdTexture.format = format; m_TexturePool[i] = nrdTexture; - for (uint16_t mip = 0; mip < nrdTextureDesc.mipNum; mip++) - nrdTexture.subresourceStates[mip] = nri::TextureTransitionFromUnknown(texture, nri::AccessBits::UNKNOWN, nri::TextureLayout::UNKNOWN, mip, 1); - - resourceStateNum += nrdTextureDesc.mipNum; + nrdTexture.state[0] = nri::TextureTransitionFromUnknown(texture, {nri::AccessBits::UNKNOWN, nri::TextureLayout::UNKNOWN}, 0, 1); // Adjust memory usage nri::MemoryDesc memoryDesc = {}; @@ -337,23 +326,9 @@ void NrdIntegration::CreateResources() nrd::Sampler nrdSampler = instanceDesc.samplers[i]; nri::SamplerDesc samplerDesc = {}; - samplerDesc.mipMax = 16.0f; - - if (nrdSampler == nrd::Sampler::NEAREST_CLAMP || nrdSampler == nrd::Sampler::LINEAR_CLAMP) - samplerDesc.addressModes = {nri::AddressMode::CLAMP_TO_EDGE, nri::AddressMode::CLAMP_TO_EDGE}; - else - samplerDesc.addressModes = {nri::AddressMode::MIRRORED_REPEAT, nri::AddressMode::MIRRORED_REPEAT}; - - if (nrdSampler == nrd::Sampler::NEAREST_CLAMP || nrdSampler == nrd::Sampler::NEAREST_MIRRORED_REPEAT) - { - samplerDesc.minification = nri::Filter::NEAREST; - samplerDesc.magnification = nri::Filter::NEAREST; - } - else - { - samplerDesc.minification = nri::Filter::LINEAR; - samplerDesc.magnification = nri::Filter::LINEAR; - } + samplerDesc.addressModes = {nri::AddressMode::CLAMP_TO_EDGE, nri::AddressMode::CLAMP_TO_EDGE}; + samplerDesc.filters.min = nrdSampler == nrd::Sampler::NEAREST_CLAMP ? nri::Filter::NEAREST : nri::Filter::LINEAR; + samplerDesc.filters.mag = nrdSampler == nrd::Sampler::NEAREST_CLAMP ? nri::Filter::NEAREST : nri::Filter::LINEAR; nri::Descriptor* descriptor = nullptr; NRD_INTEGRATION_ABORT_ON_FAILURE(m_NRI->CreateSampler(*m_Device, samplerDesc, descriptor)); @@ -391,7 +366,7 @@ void NrdIntegration::CreateResources() nri::DescriptorPool* descriptorPool = nullptr; NRD_INTEGRATION_ABORT_ON_FAILURE(m_NRI->CreateDescriptorPool(*m_Device, descriptorPoolDesc, descriptorPool)); m_DescriptorPools.push_back(descriptorPool); - + m_DescriptorSetSamplers.push_back(nullptr); m_DescriptorsInFlight.push_back({}); } @@ -401,7 +376,7 @@ void NrdIntegration::AllocateAndBindMemory() { std::vector textures(m_TexturePool.size(), nullptr); for (size_t i = 0; i < m_TexturePool.size(); i++) - textures[i] = (nri::Texture*)m_TexturePool[i].subresourceStates->texture; + textures[i] = (nri::Texture*)m_TexturePool[i].state->texture; nri::ResourceGroupDesc resourceGroupDesc = {}; resourceGroupDesc.memoryLocation = nri::MemoryLocation::DEVICE; @@ -500,18 +475,14 @@ void NrdIntegration::Dispatch(nri::CommandBuffer& commandBuffer, nri::Descriptor const nrd::InstanceDesc& instanceDesc = nrd::GetInstanceDesc(*m_Instance); const nrd::PipelineDesc& pipelineDesc = instanceDesc.pipelines[dispatchDesc.pipelineIndex]; - uint32_t transitionNum = 0; - for (uint32_t i = 0; i < dispatchDesc.resourcesNum; i++) - transitionNum += dispatchDesc.resources[i].mipNum; - nri::Descriptor** descriptors = (nri::Descriptor**)alloca(sizeof(nri::Descriptor*) * dispatchDesc.resourcesNum); memset(descriptors, 0, sizeof(nri::Descriptor*) * dispatchDesc.resourcesNum); nri::DescriptorRangeUpdateDesc* resourceRanges = (nri::DescriptorRangeUpdateDesc*)alloca(sizeof(nri::DescriptorRangeUpdateDesc) * pipelineDesc.resourceRangesNum); memset(resourceRanges, 0, sizeof(nri::DescriptorRangeUpdateDesc) * pipelineDesc.resourceRangesNum); - nri::TextureTransitionBarrierDesc* transitions = (nri::TextureTransitionBarrierDesc*)alloca(sizeof(nri::TextureTransitionBarrierDesc) * transitionNum); - memset(transitions, 0, sizeof(nri::TextureTransitionBarrierDesc) * transitionNum); + nri::TextureTransitionBarrierDesc* transitions = (nri::TextureTransitionBarrierDesc*)alloca(sizeof(nri::TextureTransitionBarrierDesc) * dispatchDesc.resourcesNum); + memset(transitions, 0, sizeof(nri::TextureTransitionBarrierDesc) * dispatchDesc.resourcesNum); nri::TransitionBarrierDesc transitionBarriers = {}; transitionBarriers.textures = transitions; @@ -538,29 +509,25 @@ void NrdIntegration::Dispatch(nri::CommandBuffer& commandBuffer, nri::Descriptor { nrdTexture = (NrdIntegrationTexture*)&userPool[(uint32_t)nrdResource.type]; - NRD_INTEGRATION_ASSERT(nrdTexture && nrdTexture->subresourceStates && nrdTexture->subresourceStates->texture, "'userPool' entry can't be NULL if it's in use!"); + NRD_INTEGRATION_ASSERT(nrdTexture && nrdTexture->state && nrdTexture->state->texture, "'userPool' entry can't be NULL if it's in use!"); NRD_INTEGRATION_ASSERT(nrdTexture->format != nri::Format::UNKNOWN, "Format must be valid!"); } const nri::AccessBits nextAccess = nrdResource.stateNeeded == nrd::DescriptorType::TEXTURE ? nri::AccessBits::SHADER_RESOURCE : nri::AccessBits::SHADER_RESOURCE_STORAGE; const nri::TextureLayout nextLayout = nrdResource.stateNeeded == nrd::DescriptorType::TEXTURE ? nri::TextureLayout::SHADER_RESOURCE : nri::TextureLayout::GENERAL; - for (uint16_t mip = 0; mip < nrdResource.mipNum; mip++) - { - nri::TextureTransitionBarrierDesc* state = nrdTexture->subresourceStates + nrdResource.mipOffset + mip; - bool isStateChanged = nextAccess != state->nextAccess || nextLayout != state->nextLayout; - bool isStorageBarrier = nextAccess == nri::AccessBits::SHADER_RESOURCE_STORAGE && state->nextAccess == nri::AccessBits::SHADER_RESOURCE_STORAGE; - if (isStateChanged || isStorageBarrier) - transitions[transitionBarriers.textureNum++] = nri::TextureTransitionFromState(*state, nextAccess, nextLayout, nrdResource.mipOffset + mip, 1); - } + bool isStateChanged = nextAccess != nrdTexture->state->nextState.acessBits || nextLayout != nrdTexture->state->nextState.layout; + bool isStorageBarrier = nextAccess == nri::AccessBits::SHADER_RESOURCE_STORAGE && nrdTexture->state->nextState.acessBits == nri::AccessBits::SHADER_RESOURCE_STORAGE; + if (isStateChanged || isStorageBarrier) + transitions[transitionBarriers.textureNum++] = nri::TextureTransitionFromState(*nrdTexture->state, {nextAccess, nextLayout}, 0, 1); - uint64_t resource = m_NRI->GetTextureNativeObject(*nrdTexture->subresourceStates->texture, 0); - uint64_t key = NRD_CreateDescriptorKey(resource, isStorage, (uint8_t)nrdResource.mipOffset, (uint8_t)nrdResource.mipNum); + uint64_t resource = m_NRI->GetTextureNativeObject(*nrdTexture->state->texture, 0); + uint64_t key = NRD_CreateDescriptorKey(resource, isStorage); const auto& entry = m_CachedDescriptors.find(key); nri::Descriptor* descriptor = nullptr; if (entry == m_CachedDescriptors.end()) { - nri::Texture2DViewDesc desc = {nrdTexture->subresourceStates->texture, isStorage ? nri::Texture2DViewType::SHADER_RESOURCE_STORAGE_2D : nri::Texture2DViewType::SHADER_RESOURCE_2D, nrdTexture->format, nrdResource.mipOffset, nrdResource.mipNum}; + nri::Texture2DViewDesc desc = {nrdTexture->state->texture, isStorage ? nri::Texture2DViewType::SHADER_RESOURCE_STORAGE_2D : nri::Texture2DViewType::SHADER_RESOURCE_2D, nrdTexture->format, 0, 1}; NRD_INTEGRATION_ABORT_ON_FAILURE(m_NRI->CreateTexture2DView(desc, descriptor)); m_CachedDescriptors.insert( std::make_pair(key, descriptor) ); m_DescriptorsInFlight[m_DescriptorPoolIndex].push_back(descriptor); @@ -584,22 +551,25 @@ void NrdIntegration::Dispatch(nri::CommandBuffer& commandBuffer, nri::Descriptor for (uint32_t i = 0; i < descriptorSetNum; i++) { if (!samplersAreInSeparateSet || i != descriptorSetSamplersIndex) - NRD_INTEGRATION_ABORT_ON_FAILURE(m_NRI->AllocateDescriptorSets(descriptorPool, *pipelineLayout, i, &descriptorSets[i], 1, nri::WHOLE_DEVICE_GROUP, 0)); + NRD_INTEGRATION_ABORT_ON_FAILURE(m_NRI->AllocateDescriptorSets(descriptorPool, *pipelineLayout, i, &descriptorSets[i], 1, nri::ALL_NODES, 0)); } // Updating constants uint32_t dynamicConstantBufferOffset = 0; if (dispatchDesc.constantBufferDataSize) { - if (m_ConstantBufferOffset + m_ConstantBufferViewSize > m_ConstantBufferSize) - m_ConstantBufferOffset = 0; + if (!dispatchDesc.constantBufferDataMatchesPreviousDispatch) + { + if (m_ConstantBufferOffset + m_ConstantBufferViewSize > m_ConstantBufferSize) + m_ConstantBufferOffset = 0; - // TODO: persistent mapping? But no D3D11 support... - void* data = m_NRI->MapBuffer(*m_ConstantBuffer, m_ConstantBufferOffset, dispatchDesc.constantBufferDataSize); - memcpy(data, dispatchDesc.constantBufferData, dispatchDesc.constantBufferDataSize); - m_NRI->UnmapBuffer(*m_ConstantBuffer); + // TODO: persistent mapping? But no D3D11 support... + void* data = m_NRI->MapBuffer(*m_ConstantBuffer, m_ConstantBufferOffset, dispatchDesc.constantBufferDataSize); + memcpy(data, dispatchDesc.constantBufferData, dispatchDesc.constantBufferDataSize); + m_NRI->UnmapBuffer(*m_ConstantBuffer); + } - m_NRI->UpdateDynamicConstantBuffers(*descriptorSets[0], nri::WHOLE_DEVICE_GROUP, 0, 1, &m_ConstantBufferView); + m_NRI->UpdateDynamicConstantBuffers(*descriptorSets[0], nri::ALL_NODES, 0, 1, &m_ConstantBufferView); dynamicConstantBufferOffset = m_ConstantBufferOffset; m_ConstantBufferOffset += m_ConstantBufferViewSize; @@ -612,17 +582,17 @@ void NrdIntegration::Dispatch(nri::CommandBuffer& commandBuffer, nri::Descriptor nri::DescriptorSet*& descriptorSetSamplers = m_DescriptorSetSamplers[m_DescriptorPoolIndex]; if (!descriptorSetSamplers) { - NRD_INTEGRATION_ABORT_ON_FAILURE(m_NRI->AllocateDescriptorSets(descriptorPool, *pipelineLayout, descriptorSetSamplersIndex, &descriptorSetSamplers, 1, nri::WHOLE_DEVICE_GROUP, 0)); - m_NRI->UpdateDescriptorRanges(*descriptorSetSamplers, nri::WHOLE_DEVICE_GROUP, 0, 1, &samplersDescriptorRange); + NRD_INTEGRATION_ABORT_ON_FAILURE(m_NRI->AllocateDescriptorSets(descriptorPool, *pipelineLayout, descriptorSetSamplersIndex, &descriptorSetSamplers, 1, nri::ALL_NODES, 0)); + m_NRI->UpdateDescriptorRanges(*descriptorSetSamplers, nri::ALL_NODES, 0, 1, &samplersDescriptorRange); } descriptorSets[descriptorSetSamplersIndex] = descriptorSetSamplers; } else - m_NRI->UpdateDescriptorRanges(*descriptorSets[descriptorSetSamplersIndex], nri::WHOLE_DEVICE_GROUP, 0, 1, &samplersDescriptorRange); + m_NRI->UpdateDescriptorRanges(*descriptorSets[descriptorSetSamplersIndex], nri::ALL_NODES, 0, 1, &samplersDescriptorRange); // Updating resources - m_NRI->UpdateDescriptorRanges(*descriptorSets[descriptorSetResourcesIndex], nri::WHOLE_DEVICE_GROUP, instanceDesc.samplersSpaceIndex == instanceDesc.resourcesSpaceIndex ? 1 : 0, pipelineDesc.resourceRangesNum, resourceRanges); + m_NRI->UpdateDescriptorRanges(*descriptorSets[descriptorSetResourcesIndex], nri::ALL_NODES, instanceDesc.samplersSpaceIndex == instanceDesc.resourcesSpaceIndex ? 1 : 0, pipelineDesc.resourceRangesNum, resourceRanges); // Rendering m_NRI->CmdPipelineBarrier(commandBuffer, &transitionBarriers, nullptr, nri::BarrierDependency::ALL_STAGES); @@ -681,7 +651,7 @@ void NrdIntegration::Destroy() m_CachedDescriptors.clear(); for (const NrdIntegrationTexture& nrdTexture : m_TexturePool) - m_NRI->DestroyTexture(*(nri::Texture*)nrdTexture.subresourceStates->texture); + m_NRI->DestroyTexture(*(nri::Texture*)nrdTexture.state->texture); m_TexturePool.clear(); for (nri::Descriptor* descriptor : m_Samplers) diff --git a/README.md b/README.md index d37eab0..7c9b55f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# NVIDIA REAL-TIME DENOISERS v4.3.6 (NRD) +# NVIDIA REAL-TIME DENOISERS v4.4.0 (NRD) [![Build NRD SDK](https://github.com/NVIDIAGameWorks/RayTracingDenoiser/actions/workflows/build.yml/badge.svg)](https://github.com/NVIDIAGameWorks/RayTracingDenoiser/actions/workflows/build.yml) @@ -12,9 +12,14 @@ For quick starting see *[NRD sample](https://github.com/NVIDIAGameWorks/NRDSampl *NRD* includes the following denoisers: - *REBLUR* - recurrent blur based denoiser -- *RELAX* - SVGF based denoiser using clamping to fast history to minimize temporal lag, has been designed for *[RTXDI (RTX Direct Illumination)](https://developer.nvidia.com/rtxdi)*. It uses 30% more memory and 20% slower than *REBLUR* +- *RELAX* - A-trous based denoiser, has been designed for *[RTXDI (RTX Direct Illumination)](https://developer.nvidia.com/rtxdi)* - *SIGMA* - shadow-only denoiser +Performance on RTX 4080 @ 1440p (native resolution, default denoiser settings): +- `REBLUR_DIFFUSE_SPECULAR` - 2.45 ms +- `RELAX_DIFFUSE_SPECULAR` - 2.90 ms +- `SIGMA_DIFFUSE_SPECULAR` - 0.30 ms + Supported signal types: - *RELAX*: - Diffuse & specular radiance @@ -26,7 +31,6 @@ Supported signal types: - *SIGMA*: - Shadows from an infinite light source (sun, moon) - Shadows from a local light source (omni, spot) - - Shadows from multiple sources (experimental). For diffuse and specular signals de-modulated irradiance (i.e. irradiance with "removed" materials) can be used instead of radiance (see "Recommendations and Best Practices" section). @@ -38,7 +42,7 @@ For diffuse and specular signals de-modulated irradiance (i.e. irradiance with " - Install [*Cmake*](https://cmake.org/download/) 3.15+ - Install on - - Windows: latest *WindowsSDK* (22000+), *VulkanSDK* (1.3.216+) + - Windows: latest *WindowsSDK* and *VulkanSDK* - Linux (x86-64): latest *VulkanSDK* - Linux (aarch64): find a precompiled binary for [*DXC*](https://github.com/microsoft/DirectXShaderCompiler) or disable shader compilation `NRD_EMBEDS_SPIRV_SHADERS=OFF` - Build (variant 1) - using *Git* and *CMake* explicitly @@ -394,7 +398,13 @@ The pseudo code below demonstrates how *NRD integration* and *NRI* can be used t #include "NRD.h" #include "NRDIntegration.hpp" -NrdIntegration NRD = NrdIntegration(maxNumberOfFramesInFlight); +// bufferedFramesNum (usually 2-3 frames): +// The application must provide number of buffered frames, it's needed to guarantee that +// constant data and descriptor sets are not overwritten while being executed on the GPU. +// enableDescriptorCaching: +// true - enables descriptor caching for the whole lifetime of an NrdIntegration instance +// false - descriptors are cached only within a single "Denoise" call +NrdIntegration NRD = NrdIntegration(bufferedFramesNum, enableDescriptorCaching, "Name"); struct NriInterface : public nri::CoreInterface @@ -410,22 +420,21 @@ NriInterface NRI; // Wrap the device nri::DeviceCreationD3D12Desc deviceDesc = {}; deviceDesc.d3d12Device = ...; -deviceDesc.d3d12PhysicalAdapter = ...; deviceDesc.d3d12GraphicsQueue = ...; deviceDesc.enableNRIValidation = false; nri::Device* nriDevice = nullptr; -nri::Result nriResult = nri::CreateDeviceFromD3D12Device(deviceDesc, nriDevice); +nri::Result nriResult = nri::nriCreateDeviceFromD3D12Device(deviceDesc, nriDevice); // Get core functionality -nriResult = nri::GetInterface(*nriDevice, +nriResult = nri::nriGetInterface(*nriDevice, NRI_INTERFACE(nri::CoreInterface), (nri::CoreInterface*)&NRI); -nriResult = nri::GetInterface(*nriDevice, +nriResult = nri::nriGetInterface(*nriDevice, NRI_INTERFACE(nri::HelperInterface), (nri::HelperInterface*)&NRI); // Get appropriate "wrapper" extension (XXX - can be D3D11, D3D12 or VULKAN) -nriResult = nri::GetInterface(*nriDevice, +nriResult = nri::nriGetInterface(*nriDevice, NRI_INTERFACE(nri::WrapperXXXInterface), (nri::WrapperXXXInterface*)&NRI); //======================================================================================================= @@ -435,15 +444,17 @@ nriResult = nri::GetInterface(*nriDevice, const nrd::DenoiserDesc denoiserDescs[] = { // Put neeeded denoisers here, like: - { identifier1, nrd::Denoiser::XXX, renderResolution.x, renderResolution.y }, - { identifier2, nrd::Denoiser::YYY, renderResolution.x, renderResolution.y }, + { identifier1, nrd::Denoiser::XXX }, + { identifier2, nrd::Denoiser::YYY }, }; nrd::InstanceCreationDesc instanceCreationDesc = {}; instanceCreationDesc.denoisers = denoiserDescs; instanceCreationDesc.denoisersNum = GetCountOf(denoiserDescs); -bool result = NRD.Initialize(*nriDevice, NRI, NRI, instanceCreationDesc); +// NRD itself is flexible and supports any kind of DRS, but NRD INTEGRATION pre-allocate resources with +// statically defines dimensions. DRS works only by adjusting the viewport: "CommonSettings::rectSize" +bool result = NRD.Initialize(resourceWidth, resourceHeight, instanceCreationDesc, *nriDevice, NRI, NRI); //======================================================================================================= // INITIALIZATION or RENDER - WRAP NATIVE POINTERS @@ -514,11 +525,8 @@ NrdUserPool userPool = {}; NrdIntegration_SetResource(userPool, ...); }; -// Better use "true" if resources are not changing between frames (i.e. are not suballocated from a heap) -bool enableDescriptorCaching = true; - const nrd::Identifier denoisers[] = {identifier1, identifier2}; -NRD.Denoise(denoisers, helper::GetCountOf(denoisers), *nriCommandBuffer, userPool, enableDescriptorCaching); +NRD.Denoise(denoisers, helper::GetCountOf(denoisers), *nriCommandBuffer, userPool); // IMPORTANT: NRD integration binds own descriptor pool, don't forget to re-bind back your pool (heap) @@ -537,7 +545,7 @@ NRI.DestroyCommandBuffer(*nriCommandBuffer); //======================================================================================================= // Release wrapped device -NRI.DestroyDevice(*nriDevice); +nri::nriDestroyDevice(*nriDevice); // Also NRD needs to be recreated on "resize" NRD.Destroy(); @@ -634,6 +642,13 @@ IN_NORMAL_ROUGHNESS = GetVirtualSpaceNormalAndRoughnessAt( B ); IN_MV = GetMotionAt( B ); ``` +## INTERACTION WITH `INFs` AND `NANs` + +- NRD doesn't touch pixels outside of viewport: `INFs / NANs` are allowed +- NRD doesn't touch pixels outside of denoising range: `INFs / NANs` are allowed +- `INFs / NANs` are not allowed for pixels inside the viewport and denoising range + - `INFs` can be used in `IN_VIEWZ`, but not recommended + ## INTERACTION WITH FRAME GENERATION TECHNIQUES Frame generation (FG) techniques boost FPS by interpolating between 2 last available frames. *NRD* works better when framerate increases, because it gets more data per second. It's not the case for FG, because all rendering pipeline underlying passes (like, denoising) continue to work on the original non-boosted framerate. @@ -696,7 +711,7 @@ Frame generation (FG) techniques boost FPS by interpolating between 2 last avail maxAccumulatedFrameNum = accumulationPeriodInSeconds * FPS ``` -**[NRD]** The number of accumulated frames in the fast history needs to be carefully tuned to avoid introducing significant bias and dirt. Initial integration should be done by setting `maxFastAccumulatedFrameNum` to `maxAccumulatedFrameNum`. Bare in mind the following recommendation: +**[NRD]** Fast history is the input signal, accumulated for a few frames. Fast history helps to minimize lags in the main history, which is accumulated for more frames. The number of accumulated frames in the fast history needs to be carefully tuned to avoid introducing significant bias and dirt. Initial integration should be done with default settings. Bear in mind the following recommendation: ``` maxAccumulatedFrameNum > maxFastAccumulatedFrameNum > historyFixFrameNum ``` diff --git a/Resources/Version.h b/Resources/Version.h index 3d51db9..78f009c 100644 --- a/Resources/Version.h +++ b/Resources/Version.h @@ -22,7 +22,7 @@ Versioning rules: */ #define VERSION_MAJOR 4 -#define VERSION_MINOR 3 -#define VERSION_BUILD 6 +#define VERSION_MINOR 4 +#define VERSION_BUILD 0 #define VERSION_STRING STR(VERSION_MAJOR.VERSION_MINOR.VERSION_BUILD encoding=NRD_NORMAL_ENCODING.NRD_ROUGHNESS_ENCODING) diff --git a/Shaders.cfg b/Shaders.cfg index ad7b2c9..1374289 100644 --- a/Shaders.cfg +++ b/Shaders.cfg @@ -1,5 +1,5 @@ -Clear_f.cs.hlsl -T cs -Clear_ui.cs.hlsl -T cs +Clear_Float.cs.hlsl -T cs +Clear_Uint.cs.hlsl -T cs REBLUR_ClassifyTiles.cs.hlsl -T cs REBLUR_DiffuseDirectionalOcclusion_Blur.cs.hlsl -T cs REBLUR_DiffuseDirectionalOcclusion_HistoryFix.cs.hlsl -T cs @@ -16,7 +16,7 @@ REBLUR_DiffuseOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl -T cs REBLUR_DiffuseOcclusion_PrePass.cs.hlsl -T cs REBLUR_DiffuseOcclusion_TemporalAccumulation.cs.hlsl -T cs REBLUR_DiffuseSh_Blur.cs.hlsl -T cs -REBLUR_DiffuseSh_CopyStabilizedHistory.cs.hlsl -T cs +REBLUR_DiffuseSh_Copy.cs.hlsl -T cs REBLUR_DiffuseSh_HistoryFix.cs.hlsl -T cs REBLUR_DiffuseSh_PostBlur.cs.hlsl -T cs REBLUR_DiffuseSh_PostBlur_NoTemporalStabilization.cs.hlsl -T cs @@ -32,7 +32,7 @@ REBLUR_DiffuseSpecularOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl -T cs REBLUR_DiffuseSpecularOcclusion_PrePass.cs.hlsl -T cs REBLUR_DiffuseSpecularOcclusion_TemporalAccumulation.cs.hlsl -T cs REBLUR_DiffuseSpecularSh_Blur.cs.hlsl -T cs -REBLUR_DiffuseSpecularSh_CopyStabilizedHistory.cs.hlsl -T cs +REBLUR_DiffuseSpecularSh_Copy.cs.hlsl -T cs REBLUR_DiffuseSpecularSh_HistoryFix.cs.hlsl -T cs REBLUR_DiffuseSpecularSh_PostBlur.cs.hlsl -T cs REBLUR_DiffuseSpecularSh_PostBlur_NoTemporalStabilization.cs.hlsl -T cs @@ -41,7 +41,7 @@ REBLUR_DiffuseSpecularSh_SplitScreen.cs.hlsl -T cs REBLUR_DiffuseSpecularSh_TemporalAccumulation.cs.hlsl -T cs REBLUR_DiffuseSpecularSh_TemporalStabilization.cs.hlsl -T cs REBLUR_DiffuseSpecular_Blur.cs.hlsl -T cs -REBLUR_DiffuseSpecular_CopyStabilizedHistory.cs.hlsl -T cs +REBLUR_DiffuseSpecular_Copy.cs.hlsl -T cs REBLUR_DiffuseSpecular_HistoryFix.cs.hlsl -T cs REBLUR_DiffuseSpecular_HitDistReconstruction.cs.hlsl -T cs REBLUR_DiffuseSpecular_HitDistReconstruction_5x5.cs.hlsl -T cs @@ -52,7 +52,7 @@ REBLUR_DiffuseSpecular_SplitScreen.cs.hlsl -T cs REBLUR_DiffuseSpecular_TemporalAccumulation.cs.hlsl -T cs REBLUR_DiffuseSpecular_TemporalStabilization.cs.hlsl -T cs REBLUR_Diffuse_Blur.cs.hlsl -T cs -REBLUR_Diffuse_CopyStabilizedHistory.cs.hlsl -T cs +REBLUR_Diffuse_Copy.cs.hlsl -T cs REBLUR_Diffuse_HistoryFix.cs.hlsl -T cs REBLUR_Diffuse_HitDistReconstruction.cs.hlsl -T cs REBLUR_Diffuse_HitDistReconstruction_5x5.cs.hlsl -T cs @@ -146,7 +146,7 @@ REBLUR_SpecularOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl -T cs REBLUR_SpecularOcclusion_PrePass.cs.hlsl -T cs REBLUR_SpecularOcclusion_TemporalAccumulation.cs.hlsl -T cs REBLUR_SpecularSh_Blur.cs.hlsl -T cs -REBLUR_SpecularSh_CopyStabilizedHistory.cs.hlsl -T cs +REBLUR_SpecularSh_Copy.cs.hlsl -T cs REBLUR_SpecularSh_HistoryFix.cs.hlsl -T cs REBLUR_SpecularSh_PostBlur.cs.hlsl -T cs REBLUR_SpecularSh_PostBlur_NoTemporalStabilization.cs.hlsl -T cs @@ -155,7 +155,7 @@ REBLUR_SpecularSh_SplitScreen.cs.hlsl -T cs REBLUR_SpecularSh_TemporalAccumulation.cs.hlsl -T cs REBLUR_SpecularSh_TemporalStabilization.cs.hlsl -T cs REBLUR_Specular_Blur.cs.hlsl -T cs -REBLUR_Specular_CopyStabilizedHistory.cs.hlsl -T cs +REBLUR_Specular_Copy.cs.hlsl -T cs REBLUR_Specular_HistoryFix.cs.hlsl -T cs REBLUR_Specular_HitDistReconstruction.cs.hlsl -T cs REBLUR_Specular_HitDistReconstruction_5x5.cs.hlsl -T cs diff --git a/Shaders/Include/Common.hlsli b/Shaders/Include/Common.hlsli index b57cd3e..3f8039c 100644 --- a/Shaders/Include/Common.hlsli +++ b/Shaders/Include/Common.hlsli @@ -17,8 +17,6 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define NRD_PIXEL 2 #define NRD_RANDOM 3 // for experiments only -#define NRD_INF 1e6 - // FP16 #ifdef NRD_COMPILER_DXC @@ -40,11 +38,13 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. // Switches ( default 1 ) #define NRD_USE_TILE_CHECK 1 #define NRD_USE_HIGH_PARALLAX_CURVATURE 1 +#define NRD_USE_DENANIFICATION 1 // needed only if inputs have NAN / INF outside of viewport or denoising range range // Switches ( default 0 ) #define NRD_USE_QUADRATIC_DISTRIBUTION 0 #define NRD_USE_EXPONENTIAL_WEIGHTS 0 #define NRD_USE_HIGH_PARALLAX_CURVATURE_SILHOUETTE_FIX 0 // it fixes silhouettes, but leads to less flattening on bumpy surfaces ( worse for bumpy surfaces ) and shorter arcs on smooth curved surfaces ( worse for low bit normals ) +#define NRD_USE_VIEWPORT_OFFSET 0 // enable if "CommonSettings::rectOrigin" is used // Settings #define NRD_BILATERAL_WEIGHT_CUTOFF 0.03 @@ -71,14 +71,6 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. // CTA & preloading //================================================================================================================== -#ifndef GROUP_X - #define GROUP_X 16 -#endif - -#ifndef GROUP_Y - #define GROUP_Y 16 -#endif - #ifdef NRD_USE_BORDER_2 #define BORDER 2 #else @@ -126,6 +118,32 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. // SHARED FUNCTIONS //================================================================================================================== +// Texture access + +#if( NRD_USE_VIEWPORT_OFFSET == 1 ) + #define WithRectOrigin( pos ) ( gRectOrigin + pos ) + #define WithRectOffset( uv ) ( gRectOffset + uv ) +#else + #define WithRectOrigin( pos ) ( pos ) + #define WithRectOffset( uv ) ( uv ) +#endif + +#if( NRD_USE_DENANIFICATION == 1 ) + // clamp( uv * gRectSize, 0.0, gRectSize - 0.5 ) * gResourceSizeInv + // = clamp( uv * gRectSize * gResourceSizeInv, 0.0, ( gRectSize - 0.5 ) * gResourceSizeInv ) + // = clamp( uv * gResolutionScale, 0.0, gResolutionScale - 0.5 * gResourceSizeInv ) + + #if( NRD_USE_VIEWPORT_OFFSET == 1 ) + #define ClampUvToViewport( uv ) clamp( uv * gResolutionScale, 0.0, gResolutionScale - 0.5 * gResourceSizeInv ) + #else + #define ClampUvToViewport( uv ) min( uv * gResolutionScale, gResolutionScale - 0.5 * gResourceSizeInv ) + #endif + #define Denanify( w, x ) ( ( w ) == 0.0 ? 0.0 : ( x ) ) +#else + #define ClampUvToViewport( uv ) ( uv * gResolutionScale ) + #define Denanify( w, x ) ( x ) +#endif + // Misc // sigma = standard deviation, variance = sigma ^ 2 @@ -180,15 +198,14 @@ float4 GetBlurKernelRotation( compiletime const uint mode, uint2 pixelPos, float return baseRotator; } -// IMPORTANT: use "IsInScreen2x2" in critical places -float IsInScreen( float2 uv ) +float IsInScreenNearest( float2 uv ) { - return float( all( saturate( uv ) == uv ) ); + return float( all( uv >= 0.0 ) && all( uv < 1.0 ) ); } // x y // z w -float4 IsInScreen2x2( float2 footprintOrigin, float2 rectSize ) +float4 IsInScreenBilinear( float2 footprintOrigin, float2 rectSize ) { float4 p = footprintOrigin.xyxy + float4( 0, 0, 1, 1 ); @@ -198,14 +215,15 @@ float4 IsInScreen2x2( float2 footprintOrigin, float2 rectSize ) return r.xzxz * r.yyww; } -float2 ApplyCheckerboardShift( float2 uv, uint mode, uint counter, float2 screenSize, float2 invScreenSize, uint frameIndex ) +float2 ApplyCheckerboardShift( float2 pos, uint mode, uint counter, uint frameIndex ) { - int2 uvi = int2( uv * screenSize ); - bool hasData = STL::Sequence::CheckerBoard( uvi, frameIndex ) == mode; - if( !hasData ) - uvi.x += ( ( counter & 0x1 ) == 0 ) ? -1 : 1; + // IMPORTANT: "pos" must be snapped to the pixel center + uint checkerboard = STL::Sequence::CheckerBoard( uint2( pos ), frameIndex ); + float shift = ( ( counter & 0x1 ) == 0 ) ? -1.0 : 1.0; - return ( float2( uvi ) + 0.5 ) * invScreenSize; + pos.x += shift * float( checkerboard != mode && mode != 2 ); + + return pos; } // Comparison of two methods: @@ -218,13 +236,12 @@ float GetSpecMagicCurve( float roughness, float power = 0.25 ) return f; } -/* -Produce same results: - ComputeParallaxInPixels( Xprev - gCameraDelta, gOrthoMode == 0.0 ? pixelUv : smbPixelUv, gWorldToClip, gRectSize ); - ComputeParallaxInPixels( Xprev + gCameraDelta, gOrthoMode == 0.0 ? smbPixelUv : pixelUv, gWorldToClipPrev, gRectSize ); -*/ float ComputeParallaxInPixels( float3 X, float2 uvForZeroParallax, float4x4 mWorldToClip, float2 rectSize ) { + // Produce same results: + // - ComputeParallaxInPixels( Xprev - gCameraDelta, gOrthoMode == 0.0 ? pixelUv : smbPixelUv, gWorldToClip, gRectSize ); + // - ComputeParallaxInPixels( Xprev + gCameraDelta, gOrthoMode == 0.0 ? smbPixelUv : pixelUv, gWorldToClipPrev, gRectSize ); + float2 uv = STL::Geometry::GetScreenUv( mWorldToClip, X ); float2 parallaxInUv = uv - uvForZeroParallax; float parallaxInPixels = length( parallaxInUv * rectSize ); @@ -435,21 +452,18 @@ float GetEncodingAwareNormalWeight( float3 Ncurr, float3 Nprev, float maxAngle, // Only for checkerboard resolve and some "lazy" comparisons #define GetBilateralWeight( z, zc ) \ - STL::Math::LinearStep( NRD_BILATERAL_WEIGHT_CUTOFF, 0.0, abs( z - zc ) * rcp( max( abs( z ), abs( zc ) ) ) ) + STL::Math::LinearStep( NRD_BILATERAL_WEIGHT_CUTOFF, 0.0, abs( z - zc ) * rcp( max( z, zc ) ) ) // Upsampling -// TODO: used only for history resampling. This is why "gRectSizePrev" is hardcoded #define _BicubicFilterNoCornersWithFallbackToBilinearFilterWithCustomWeights_Init \ /* Catmul-Rom with 12 taps ( excluding corners ) */ \ float2 centerPos = floor( samplePos - 0.5 ) + 0.5; \ float2 f = saturate( samplePos - centerPos ); \ - float2 f2 = f * f; \ - float2 f3 = f * f2; \ - float2 w0 = -NRD_CATROM_SHARPNESS * f3 + 2.0 * NRD_CATROM_SHARPNESS * f2 - NRD_CATROM_SHARPNESS * f; \ - float2 w1 = ( 2.0 - NRD_CATROM_SHARPNESS ) * f3 - ( 3.0 - NRD_CATROM_SHARPNESS ) * f2 + 1.0; \ - float2 w2 = -( 2.0 - NRD_CATROM_SHARPNESS ) * f3 + ( 3.0 - 2.0 * NRD_CATROM_SHARPNESS ) * f2 + NRD_CATROM_SHARPNESS * f; \ - float2 w3 = NRD_CATROM_SHARPNESS * f3 - NRD_CATROM_SHARPNESS * f2; \ + float2 w0 = f * ( f * ( -NRD_CATROM_SHARPNESS * f + 2.0 * NRD_CATROM_SHARPNESS ) - NRD_CATROM_SHARPNESS ); \ + float2 w1 = f * ( f * ( ( 2.0 - NRD_CATROM_SHARPNESS ) * f - ( 3.0 - NRD_CATROM_SHARPNESS ) ) ) + 1.0; \ + float2 w2 = f * ( f * ( -( 2.0 - NRD_CATROM_SHARPNESS ) * f + ( 3.0 - 2.0 * NRD_CATROM_SHARPNESS ) ) + NRD_CATROM_SHARPNESS ); \ + float2 w3 = f * ( f * ( NRD_CATROM_SHARPNESS * f - NRD_CATROM_SHARPNESS ) ); \ float2 w12 = w1 + w2; \ float2 tc = w2 / w12; \ float4 w; \ @@ -463,12 +477,13 @@ float GetEncodingAwareNormalWeight( float3 Ncurr, float3 Nprev, float maxAngle, w4 = useBicubic ? w4 : 0.0; \ float sum = dot( w, 1.0 ) + w4; \ /* Texture coordinates */ \ - float2 uv0 = min( centerPos + ( useBicubic ? float2( tc.x, -1.0 ) : float2( 0, 0 ) ), gRectSizePrev - 1.0 ); \ - float2 uv1 = min( centerPos + ( useBicubic ? float2( -1.0, tc.y ) : float2( 1, 0 ) ), gRectSizePrev - 1.0 ); \ - float2 uv2 = min( centerPos + ( useBicubic ? float2( tc.x, tc.y ) : float2( 0, 1 ) ), gRectSizePrev - 1.0 ); \ - float2 uv3 = min( centerPos + ( useBicubic ? float2( 2.0, tc.y ) : float2( 1, 1 ) ), gRectSizePrev - 1.0 ); \ - float2 uv4 = min( centerPos + ( useBicubic ? float2( tc.x, 2.0 ) : f ), gRectSizePrev - 1.0 ); \ - float4 bilinearTaps + float4 uv01 = centerPos.xyxy + ( useBicubic ? float4( tc.x, -1.0, -1.0, tc.y ) : float4( 0, 0, 1, 0 ) ); \ + float4 uv23 = centerPos.xyxy + ( useBicubic ? float4( tc.x, tc.y, 2.0, tc.y ) : float4( 0, 1, 1, 1 ) ); \ + float2 uv4 = centerPos + ( useBicubic ? float2( tc.x, 2.0 ) : f ); \ + uv01 *= invResourceSize.xyxy; \ + uv23 *= invResourceSize.xyxy; \ + uv4 *= invResourceSize; \ + int3 bilinearOrigin = int3( centerPos, 0 ); /* IMPORTANT: @@ -479,22 +494,20 @@ IMPORTANT: */ #define _BicubicFilterNoCornersWithFallbackToBilinearFilterWithCustomWeights_Color( color, tex ) \ /* Sampling */ \ - color = tex.SampleLevel( gLinearClamp, uv0 * invTextureSize, 0 ) * w.x; \ - color += tex.SampleLevel( gLinearClamp, uv1 * invTextureSize, 0 ) * w.y; \ - color += tex.SampleLevel( gLinearClamp, uv2 * invTextureSize, 0 ) * w.z; \ - color += tex.SampleLevel( gLinearClamp, uv3 * invTextureSize, 0 ) * w.w; \ - color += tex.SampleLevel( gLinearClamp, uv4 * invTextureSize, 0 ) * w4; \ + color = tex.SampleLevel( gLinearClamp, uv01.xy, 0 ) * w.x; \ + color += tex.SampleLevel( gLinearClamp, uv01.zw, 0 ) * w.y; \ + color += tex.SampleLevel( gLinearClamp, uv23.xy, 0 ) * w.z; \ + color += tex.SampleLevel( gLinearClamp, uv23.zw, 0 ) * w.w; \ + color += tex.SampleLevel( gLinearClamp, uv4, 0 ) * w4; \ /* Normalize similarly to "STL::Filtering::ApplyBilinearCustomWeights()" */ \ - color = sum < 0.0001 ? 0 : color * rcp( sum ); + color = sum < 0.0001 ? 0 : color / sum; #define _BilinearFilterWithCustomWeights_Color( color, tex ) \ /* Sampling */ \ - bilinearTaps = centerPos.xyxy + float4( 0.0, 0.0, 1.0, 1.0 ); \ - bilinearTaps.zw = min( bilinearTaps.zw, gRectSizePrev - 1.0 ); \ - color = tex.SampleLevel( gNearestClamp, bilinearTaps.xy * invTextureSize, 0 ) * bilinearCustomWeights.x; \ - color += tex.SampleLevel( gNearestClamp, bilinearTaps.zy * invTextureSize, 0 ) * bilinearCustomWeights.y; \ - color += tex.SampleLevel( gNearestClamp, bilinearTaps.xw * invTextureSize, 0 ) * bilinearCustomWeights.z; \ - color += tex.SampleLevel( gNearestClamp, bilinearTaps.zw * invTextureSize, 0 ) * bilinearCustomWeights.w; \ + color = tex.Load( bilinearOrigin ) * bilinearCustomWeights.x; \ + color += tex.Load( bilinearOrigin, int2( 1, 0 ) ) * bilinearCustomWeights.y; \ + color += tex.Load( bilinearOrigin, int2( 0, 1 ) ) * bilinearCustomWeights.z; \ + color += tex.Load( bilinearOrigin, int2( 1, 1 ) ) * bilinearCustomWeights.w; \ /* Normalize similarly to "STL::Filtering::ApplyBilinearCustomWeights()" */ \ sum = dot( bilinearCustomWeights, 1.0 ); \ - color = sum < 0.0001 ? 0 : color * rcp( sum ); + color = sum < 0.0001 ? 0 : color / sum; diff --git a/Shaders/Include/NRD.hlsli b/Shaders/Include/NRD.hlsli index 631b593..d667d67 100644 --- a/Shaders/Include/NRD.hlsli +++ b/Shaders/Include/NRD.hlsli @@ -8,7 +8,7 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -// NRD v4.3 +// NRD v4.4 //================================================================================================================================= // INPUT PARAMETERS @@ -17,12 +17,14 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. float3 radiance: - radiance should not include material information ( use material de-modulation to decouple materials ) - radiance should not be premultiplied by "exposure" + - for Primary Surface Replacements ( PSR ) throughput should be de-modulated as much as possible ( see test 184 from the sample and TraceOpaque.hlsl ) - for diffuse rays - use COS-distribution ( or custom importance sampling ) - if radiance is the result of path tracing, pass normalized hit distance as the sum of 1-all hits (always ignore primary hit!) - for specular - use VNDF sampling ( or custom importance sampling ) - - if radiance is the result of path tracing, pass normalized hit distance as the sum of first 1-3 hits (always ignore primary hit!) + - most advanced v3 version: https://gpuopen.com/download/publications/Bounded_VNDF_Sampling_for_Smith-GGX_Reflections.pdf + - if radiance is the result of path tracing, pass hit distance for the 1st bounce for the first time (always ignore primary hit!) float hitDist: - can't be negative @@ -71,9 +73,12 @@ float tanOfLightAngularRadius: // SETTINGS //================================================================================================================================= -// ( Optional ) Register spaces +// ( Optional ) Bindings #define NRD_CONSTANT_BUFFER_SPACE_INDEX 0 -#define NRD_SAMPLERS_SPACE_INDEX 0 +#define NRD_CONSTANT_BUFFER_REGISTER_INDEX 0 + +#define NRD_SAMPLERS_SPACE_INDEX 0 // TODO: better keep in a separate space for sharing + #define NRD_RESOURCES_SPACE_INDEX 0 // ( Optional ) Entry point @@ -90,33 +95,44 @@ float tanOfLightAngularRadius: #define NRD_MERGE_TOKENS_( _0, _1 ) _0 ## _1 #define NRD_MERGE_TOKENS( _0, _1 ) NRD_MERGE_TOKENS_( _0, _1 ) -// Custom engine that has already defined all the macros -#if( defined( NRD_INPUT_TEXTURE ) && defined( NRD_OUTPUT_TEXTURE ) && defined( NRD_CONSTANTS_START ) && defined( NRD_CONSTANT ) && defined( NRD_CONSTANTS_END ) ) +// Custom engine that defined all the macros +#if( defined( NRD_CONSTANTS_START ) && \ + defined( NRD_CONSTANT ) && \ + defined( NRD_CONSTANTS_END ) && \ + defined( NRD_INPUTS_START ) && \ + defined( NRD_INPUT ) && \ + defined( NRD_INPUTS_END ) && \ + defined( NRD_OUTPUTS_START ) && \ + defined( NRD_OUTPUT ) && \ + defined( NRD_OUTPUTS_END ) && \ + defined( NRD_SAMPLERS_START ) && \ + defined( NRD_SAMPLER ) && \ + defined( NRD_SAMPLERS_END ) ) #define NRD_EXPORT // DXC #elif( defined( NRD_COMPILER_DXC ) || defined( __hlsl_dx_compiler ) ) - #define NRD_CONSTANTS_START cbuffer globalConstants : register( b0, NRD_MERGE_TOKENS( space, NRD_CONSTANT_BUFFER_SPACE_INDEX ) ) { + #define NRD_CONSTANTS_START( resourceName ) cbuffer resourceName : register( NRD_MERGE_TOKENS( b, NRD_CONSTANT_BUFFER_REGISTER_INDEX ), NRD_MERGE_TOKENS( space, NRD_CONSTANT_BUFFER_SPACE_INDEX ) ) { #define NRD_CONSTANT( constantType, constantName ) constantType constantName; #define NRD_CONSTANTS_END }; - #define NRD_INPUT_TEXTURE_START - #define NRD_INPUT_TEXTURE( resourceType, resourceName, regName, bindingIndex ) resourceType resourceName : register( regName ## bindingIndex, NRD_MERGE_TOKENS( space, NRD_RESOURCES_SPACE_INDEX ) ); - #define NRD_INPUT_TEXTURE_END + #define NRD_INPUTS_START + #define NRD_INPUT( resourceType, resourceName, regName, bindingIndex ) resourceType resourceName : register( NRD_MERGE_TOKENS( regName, bindingIndex ), NRD_MERGE_TOKENS( space, NRD_RESOURCES_SPACE_INDEX ) ); + #define NRD_INPUTS_END - #define NRD_OUTPUT_TEXTURE_START - #define NRD_OUTPUT_TEXTURE( resourceType, resourceName, regName, bindingIndex ) resourceType resourceName : register( regName ## bindingIndex, NRD_MERGE_TOKENS( space, NRD_RESOURCES_SPACE_INDEX ) ); - #define NRD_OUTPUT_TEXTURE_END + #define NRD_OUTPUTS_START + #define NRD_OUTPUT( resourceType, resourceName, regName, bindingIndex ) resourceType resourceName : register( NRD_MERGE_TOKENS( regName, bindingIndex ), NRD_MERGE_TOKENS( space, NRD_RESOURCES_SPACE_INDEX ) ); + #define NRD_OUTPUTS_END - #define NRD_SAMPLER_START - #define NRD_SAMPLER( resourceType, resourceName, regName, bindingIndex ) resourceType resourceName : register( regName ## bindingIndex, NRD_MERGE_TOKENS( space, NRD_SAMPLERS_SPACE_INDEX ) ); - #define NRD_SAMPLER_END + #define NRD_SAMPLERS_START + #define NRD_SAMPLER( resourceType, resourceName, regName, bindingIndex ) resourceType resourceName : register( NRD_MERGE_TOKENS( regName, bindingIndex ), NRD_MERGE_TOKENS( space, NRD_SAMPLERS_SPACE_INDEX ) ); + #define NRD_SAMPLERS_END #define NRD_EXPORT -// PlayStation +// PlayStation // TODO: register spaces? #elif( defined( NRD_COMPILER_PSSLC ) || defined( __PSSL__ ) ) #define EXPAND( x ) x @@ -129,21 +145,21 @@ float tanOfLightAngularRadius: #define GatherGreen3( a, b, c ) GatherGreen( ( a ), ( b ), int2( c ) ) #define GatherGreen2( a, b ) GatherGreen( ( a ), ( b ) ) - #define NRD_CONSTANTS_START ConstantBuffer globalConstants : register( b0 ) { + #define NRD_CONSTANTS_START( resourceName ) ConstantBuffer resourceName : register( NRD_MERGE_TOKENS( b, NRD_CONSTANT_BUFFER_REGISTER_INDEX ) ) { #define NRD_CONSTANT( constantType, constantName ) constantType constantName; #define NRD_CONSTANTS_END }; - #define NRD_INPUT_TEXTURE_START - #define NRD_INPUT_TEXTURE( resourceType, resourceName, regName, bindingIndex ) resourceType resourceName : register( regName ## bindingIndex ); - #define NRD_INPUT_TEXTURE_END + #define NRD_INPUTS_START + #define NRD_INPUT( resourceType, resourceName, regName, bindingIndex ) resourceType resourceName : register( NRD_MERGE_TOKENS( regName, bindingIndex ) ); + #define NRD_INPUTS_END - #define NRD_OUTPUT_TEXTURE_START - #define NRD_OUTPUT_TEXTURE( resourceType, resourceName, regName, bindingIndex ) resourceType resourceName : register( regName ## bindingIndex ); - #define NRD_OUTPUT_TEXTURE_END + #define NRD_OUTPUTS_START + #define NRD_OUTPUT( resourceType, resourceName, regName, bindingIndex ) resourceType resourceName : register( NRD_MERGE_TOKENS( regName, bindingIndex ) ); + #define NRD_OUTPUTS_END - #define NRD_SAMPLER_START - #define NRD_SAMPLER( resourceType, resourceName, regName, bindingIndex ) resourceType resourceName : register( regName ## bindingIndex ); - #define NRD_SAMPLER_END + #define NRD_SAMPLERS_START + #define NRD_SAMPLER( resourceType, resourceName, regName, bindingIndex ) resourceType resourceName : register( NRD_MERGE_TOKENS( regName, bindingIndex ) ); + #define NRD_SAMPLERS_END #define numthreads NUM_THREADS #define groupshared thread_group_memory @@ -172,52 +188,69 @@ float tanOfLightAngularRadius: // Unreal Engine #elif( defined( NRD_COMPILER_UNREAL_ENGINE ) ) // TODO: is there a predefined macro in UE? - #define NRD_CONSTANTS_START + #define NRD_CONSTANTS_START( resourceName ) #define NRD_CONSTANT( constantType, constantName ) constantType constantName; #define NRD_CONSTANTS_END - #define NRD_INPUT_TEXTURE_START - #define NRD_INPUT_TEXTURE( resourceType, resourceName, regName, bindingIndex ) resourceType resourceName; - #define NRD_INPUT_TEXTURE_END + #define NRD_INPUTS_START + #define NRD_INPUT( resourceType, resourceName, regName, bindingIndex ) resourceType resourceName; + #define NRD_INPUTS_END - #define NRD_OUTPUT_TEXTURE_START - #define NRD_OUTPUT_TEXTURE( resourceType, resourceName, regName, bindingIndex ) resourceType resourceName; - #define NRD_OUTPUT_TEXTURE_END + #define NRD_OUTPUTS_START + #define NRD_OUTPUT( resourceType, resourceName, regName, bindingIndex ) resourceType resourceName; + #define NRD_OUTPUTS_END - #define NRD_SAMPLER_START + #define NRD_SAMPLERS_START #define NRD_SAMPLER( resourceType, resourceName, regName, bindingIndex ) resourceType resourceName; - #define NRD_SAMPLER_END + #define NRD_SAMPLERS_END #define NRD_EXPORT // FXC #else // TODO: is there a predefined macro in FXC? - #define NRD_CONSTANTS_START cbuffer globalConstants : register( b0 ) { + #define NRD_CONSTANTS_START( resourceName ) cbuffer resourceName : register( NRD_MERGE_TOKENS( b, NRD_CONSTANT_BUFFER_REGISTER_INDEX ) ) { #define NRD_CONSTANT( constantType, constantName ) constantType constantName; #define NRD_CONSTANTS_END }; - #define NRD_INPUT_TEXTURE_START - #define NRD_INPUT_TEXTURE( resourceType, resourceName, regName, bindingIndex ) resourceType resourceName : register( regName ## bindingIndex ); - #define NRD_INPUT_TEXTURE_END + #define NRD_INPUTS_START + #define NRD_INPUT( resourceType, resourceName, regName, bindingIndex ) resourceType resourceName : register( NRD_MERGE_TOKENS( regName, bindingIndex ) ); + #define NRD_INPUTS_END - #define NRD_OUTPUT_TEXTURE_START - #define NRD_OUTPUT_TEXTURE( resourceType, resourceName, regName, bindingIndex ) resourceType resourceName : register( regName ## bindingIndex ); - #define NRD_OUTPUT_TEXTURE_END + #define NRD_OUTPUTS_START + #define NRD_OUTPUT( resourceType, resourceName, regName, bindingIndex ) resourceType resourceName : register( NRD_MERGE_TOKENS( regName, bindingIndex ) ); + #define NRD_OUTPUTS_END - #define NRD_SAMPLER_START - #define NRD_SAMPLER( resourceType, resourceName, regName, bindingIndex ) resourceType resourceName : register( regName ## bindingIndex ); - #define NRD_SAMPLER_END + #define NRD_SAMPLERS_START + #define NRD_SAMPLER( resourceType, resourceName, regName, bindingIndex ) resourceType resourceName : register( NRD_MERGE_TOKENS( regName, bindingIndex ) ); + #define NRD_SAMPLERS_END #define NRD_EXPORT #endif +//================================================================================================================================= +// GLSL +//================================================================================================================================= + +#ifdef NRD_GLSL + #define float4 vec4 + #define float3 vec3 + #define float2 vec2 + #define float2x3 mat2x3 + #define float3x3 mat3x3 + #define rsqrt inversesqrt + #define saturate( x ) clamp( x, 0.0, 1.0 ) + #define lerp mix + #define mul( x, y ) ( x * y ) +#endif + //================================================================================================================================= // PRIVATE //================================================================================================================================= #ifdef NRD_INTERNAL + // Explicitly set matrix layout for shader compilation outside of NRD environment #pragma pack_matrix( column_major ) #endif @@ -247,17 +280,23 @@ float tanOfLightAngularRadius: #define NRD_EPS 1e-6 #define NRD_REJITTER_VIEWZ_THRESHOLD 0.01 // normalized % #define NRD_ROUGHNESS_EPS sqrt( sqrt( NRD_EPS ) ) // "m2" fitting in FP32 to "linear roughness" +#define NRD_INF 1e6 -// ViewZ packing into FP16 +// Misc float _NRD_PackViewZ( float z ) { return clamp( z * NRD_FP16_VIEWZ_SCALE, -NRD_FP16_MAX, NRD_FP16_MAX ); } +float3 _NRD_SafeNormalize( float3 v ) +{ + return v * rsqrt( dot( v, v ) + 1e-9 ); +} + // Oct packing -float2 _NRD_EncodeUnitVector( float3 v, const bool bSigned = false ) +float2 _NRD_EncodeUnitVector( float3 v, const bool bSigned ) { - v /= dot( abs( v ), 1.0 ); + v /= dot( abs( v ), float3( 1.0, 1.0, 1.0 ) ); float2 octWrap = ( 1.0 - abs( v.yx ) ) * ( step( 0.0, v.xy ) * 2.0 - 1.0 ); v.xy = v.z >= 0.0 ? v.xy : octWrap; @@ -265,7 +304,7 @@ float2 _NRD_EncodeUnitVector( float3 v, const bool bSigned = false ) return bSigned ? v.xy : v.xy * 0.5 + 0.5; } -float3 _NRD_DecodeUnitVector( float2 p, const bool bSigned = false, const bool bNormalize = true ) +float3 _NRD_DecodeUnitVector( float2 p, const bool bSigned, const bool bNormalize ) { p = bSigned ? p : ( p * 2.0 - 1.0 ); @@ -419,11 +458,22 @@ float2 _NRD_ComputeBrdfs( float3 Ld, float3 Ls, float3 N, float3 V, float Rf0, f } // Hit distance normalization -float _REBLUR_GetHitDistanceNormalization( float viewZ, float4 hitDistParams, float roughness = 1.0 ) +float _REBLUR_GetHitDistanceNormalization( float viewZ, float4 hitDistParams, float roughness ) { return ( hitDistParams.x + abs( viewZ ) * hitDistParams.y ) * lerp( 1.0, hitDistParams.z, saturate( exp2( hitDistParams.w * roughness * roughness ) ) ); } +// Is valid? +bool _NRD_IsInvalid( float3 x ) +{ + return any( isnan( x ) ) || any( isinf( x ) ); +} + +bool _NRD_IsInvalid( float x ) +{ + return isnan( x ) || isinf( x ); +} + //============================================================================================================================================== // SPHERICAL HARMONICS: https://media.contentapi.ea.com/content/dam/eacom/frostbite/files/gdc2018-precomputedgiobalilluminationinfrostbite.pdf // SPHERICAL GAUSSIAN: https://therealmjp.github.io/posts/sg-series-part-1-a-brief-and-incomplete-history-of-baked-lighting-representations/ @@ -507,7 +557,7 @@ float4 NRD_FrontEnd_UnpackNormalAndRoughness( float4 p, out float materialID ) materialID = 0; #endif - r.xyz = normalize( r.xyz ); + r.xyz = _NRD_SafeNormalize( r.xyz ); #if( NRD_ROUGHNESS_ENCODING == NRD_ROUGHNESS_ENCODING_SQRT_LINEAR ) r.w *= r.w; @@ -528,7 +578,7 @@ float4 NRD_FrontEnd_UnpackNormalAndRoughness( float4 p ) // Not used in NRD // X => IN_NORMAL_ROUGHNESS -float4 NRD_FrontEnd_PackNormalAndRoughness( float3 N, float roughness, float materialID = 0.0 ) +float4 NRD_FrontEnd_PackNormalAndRoughness( float3 N, float roughness, float materialID ) { float4 p; @@ -557,12 +607,31 @@ float4 NRD_FrontEnd_PackNormalAndRoughness( float3 N, float roughness, float mat return p; } +//================================================================================================================================= +// FRONT-END - SPECULAR HIT DISTANCE AVERAGING ( in case of rpp > 1 ) +//================================================================================================================================= + +float NRD_FrontEnd_SpecHitDistAveraging_Begin( ) +{ + return NRD_INF; +} + +void NRD_FrontEnd_SpecHitDistAveraging_Add( inout float accumulatedSpecHitDist, float hitDist ) +{ + accumulatedSpecHitDist = min( accumulatedSpecHitDist, hitDist == 0.0 ? NRD_INF : hitDist ); +} + +void NRD_FrontEnd_SpecHitDistAveraging_End( inout float accumulatedSpecHitDist ) +{ + accumulatedSpecHitDist = accumulatedSpecHitDist == NRD_INF ? 0.0 : accumulatedSpecHitDist; +} + //================================================================================================================================= // FRONT-END - REBLUR //================================================================================================================================= // This function returns AO / SO which REBLUR can decode back to "hit distance" internally -float REBLUR_FrontEnd_GetNormHitDist( float hitDist, float viewZ, float4 hitDistParams, float roughness = 1.0 ) +float REBLUR_FrontEnd_GetNormHitDist( float hitDist, float viewZ, float4 hitDistParams, float roughness ) { // TODO: Sampling can produce rays pointing inside surface, i.e. "hitDist = 0". But due to ray offsetting // actual "hitDist" can be a very small value in this case. Since NRD handles "hitDist = 0" case, should be @@ -576,12 +645,12 @@ float REBLUR_FrontEnd_GetNormHitDist( float hitDist, float viewZ, float4 hitDist // X => IN_DIFF_RADIANCE_HITDIST // X => IN_SPEC_RADIANCE_HITDIST // normHitDist must be packed by "REBLUR_FrontEnd_GetNormHitDist" -float4 REBLUR_FrontEnd_PackRadianceAndNormHitDist( float3 radiance, float normHitDist, bool sanitize = true ) +float4 REBLUR_FrontEnd_PackRadianceAndNormHitDist( float3 radiance, float normHitDist, bool sanitize ) { if( sanitize ) { - radiance = any( isnan( radiance ) | isinf( radiance ) ) ? 0 : clamp( radiance, 0, NRD_FP16_MAX ); - normHitDist = ( isnan( normHitDist ) | isinf( normHitDist ) ) ? 0 : saturate( normHitDist ); + radiance = _NRD_IsInvalid( radiance ) ? float3( 0, 0, 0 ) : clamp( radiance, 0, NRD_FP16_MAX ); + normHitDist = _NRD_IsInvalid( normHitDist ) ? 0 : saturate( normHitDist ); } radiance = _NRD_LinearToYCoCg( radiance ); @@ -592,13 +661,13 @@ float4 REBLUR_FrontEnd_PackRadianceAndNormHitDist( float3 radiance, float normHi // X => IN_DIFF_SH0 and IN_DIFF_SH1 // X => IN_SPEC_SH0 and IN_SPEC_SH1 // normHitDist must be packed by "REBLUR_FrontEnd_GetNormHitDist" -float4 REBLUR_FrontEnd_PackSh( float3 radiance, float normHitDist, float3 direction, out float4 out1, bool sanitize = true ) +float4 REBLUR_FrontEnd_PackSh( float3 radiance, float normHitDist, float3 direction, out float4 out1, bool sanitize ) { if( sanitize ) { - radiance = any( isnan( radiance ) | isinf( radiance ) ) ? 0 : clamp( radiance, 0, NRD_FP16_MAX ); - normHitDist = ( isnan( normHitDist ) | isinf( normHitDist ) ) ? 0 : saturate( normHitDist ); - direction = any( isnan( direction ) | isinf( direction ) ) ? 0 : clamp( direction, -NRD_FP16_MAX, NRD_FP16_MAX ); + radiance = _NRD_IsInvalid( radiance ) ? float3( 0, 0, 0 ) : clamp( radiance, 0, NRD_FP16_MAX ); + normHitDist = _NRD_IsInvalid( normHitDist ) ? 0 : saturate( normHitDist ); + direction = _NRD_IsInvalid( direction ) ? float3( 0, 0, 0 ) : clamp( direction, -1.0, 1.0 ); } NRD_SG sg = _NRD_SG_Create( radiance, direction, normHitDist ); @@ -614,15 +683,15 @@ float4 REBLUR_FrontEnd_PackSh( float3 radiance, float normHitDist, float3 direct // X => IN_DIFF_DIRECTION_HITDIST // normHitDist must be packed by "REBLUR_FrontEnd_GetNormHitDist" -float4 REBLUR_FrontEnd_PackDirectionalOcclusion( float3 direction, float normHitDist, bool sanitize = true ) +float4 REBLUR_FrontEnd_PackDirectionalOcclusion( float3 direction, float normHitDist, bool sanitize ) { if( sanitize ) { - direction = any( isnan( direction ) | isinf( direction ) ) ? 0 : direction; - normHitDist = ( isnan( normHitDist ) | isinf( normHitDist ) ) ? 0 : saturate( normHitDist ); + direction = _NRD_IsInvalid( direction ) ? float3( 0, 0, 0 ) : clamp( direction, -1.0, 1.0 ); + normHitDist = _NRD_IsInvalid( normHitDist ) ? 0 : saturate( normHitDist ); } - NRD_SG sg = _NRD_SG_Create( normHitDist, direction, normHitDist ); + NRD_SG sg = _NRD_SG_Create( normHitDist.xxx, direction, normHitDist ); return float4( sg.c1, sg.c0 ); } @@ -633,12 +702,12 @@ float4 REBLUR_FrontEnd_PackDirectionalOcclusion( float3 direction, float normHit // X => IN_DIFF_RADIANCE_HITDIST // X => IN_SPEC_RADIANCE_HITDIST -float4 RELAX_FrontEnd_PackRadianceAndHitDist( float3 radiance, float hitDist, bool sanitize = true ) +float4 RELAX_FrontEnd_PackRadianceAndHitDist( float3 radiance, float hitDist, bool sanitize ) { if( sanitize ) { - radiance = any( isnan( radiance ) | isinf( radiance ) ) ? 0 : clamp( radiance, 0, NRD_FP16_MAX ); - hitDist = ( isnan( hitDist ) | isinf( hitDist ) ) ? 0 : clamp( hitDist, 0, NRD_FP16_MAX ); + radiance = _NRD_IsInvalid( radiance ) ? float3( 0, 0, 0 ) : clamp( radiance, 0, NRD_FP16_MAX ); + hitDist = _NRD_IsInvalid( hitDist ) ? 0 : clamp( hitDist, 0, NRD_FP16_MAX ); } return float4( radiance, hitDist ); @@ -646,12 +715,13 @@ float4 RELAX_FrontEnd_PackRadianceAndHitDist( float3 radiance, float hitDist, bo // X => IN_DIFF_SH0 and IN_DIFF_SH1 // X => IN_SPEC_SH0 and IN_SPEC_SH1 -float4 RELAX_FrontEnd_PackSh( float3 radiance, float hitDist, float3 direction, out float4 out1, bool sanitize = true ) +float4 RELAX_FrontEnd_PackSh( float3 radiance, float hitDist, float3 direction, out float4 out1, bool sanitize ) { if( sanitize ) { - radiance = any( isnan( radiance ) | isinf( radiance ) ) ? 0 : clamp( radiance, 0, NRD_FP16_MAX ); - hitDist = ( isnan( hitDist ) | isinf( hitDist ) ) ? 0 : clamp( hitDist, 0, NRD_FP16_MAX ); + radiance = _NRD_IsInvalid( radiance ) ? float3( 0, 0, 0 ) : clamp( radiance, 0, NRD_FP16_MAX ); + hitDist = _NRD_IsInvalid( hitDist ) ? 0 : clamp( hitDist, 0, NRD_FP16_MAX ); + direction = _NRD_IsInvalid( direction ) ? float3( 0, 0, 0 ) : clamp( direction, -1.0, 1.0 ); } // IN_DIFF_SH0 / IN_SPEC_SH0 @@ -676,7 +746,6 @@ float2 SIGMA_FrontEnd_PackShadow( float viewZ, float distanceToOccluder, float t r.x = 0.0; r.y = _NRD_PackViewZ( viewZ ); - [flatten] if( distanceToOccluder == NRD_FP16_MAX ) r.x = NRD_FP16_MAX; else if( distanceToOccluder != 0.0 ) @@ -705,9 +774,9 @@ float2 SIGMA_FrontEnd_PackShadow( float viewZ, float distanceToOccluder, float t #define SIGMA_MULTILIGHT_DATATYPE float2x3 -SIGMA_MULTILIGHT_DATATYPE SIGMA_FrontEnd_MultiLightStart() +SIGMA_MULTILIGHT_DATATYPE SIGMA_FrontEnd_MultiLightStart( ) { - return ( SIGMA_MULTILIGHT_DATATYPE )0; + return float2x3( float3( 0, 0, 0 ), float3( 0, 0, 0 ) ); } void SIGMA_FrontEnd_MultiLightUpdate( float3 L, float distanceToOccluder, float tanOfLightAngularRadius, float weight, inout SIGMA_MULTILIGHT_DATATYPE multiLightShadowData ) @@ -817,7 +886,8 @@ NRD_SG RELAX_BackEnd_UnpackSh( float4 sh0, float4 sh1 ) // float3 finalShadowCommon = lerp( shadowData.yzw, 1.0, shadowData.x ); // or // float3 finalShadowExotic = shadowData.yzw * shadowData.x; // or // float3 finalShadowMoreExotic = shadowData.yzw; -#define SIGMA_BackEnd_UnpackShadow( color ) ( color * color ) +// IMPORTANT: use "^ 3" to compensate over-blurring ( it really makes the result closer to the reference ) +#define SIGMA_BackEnd_UnpackShadow( color ) ( color * color * color ) //================================================================================================================================= // BACK-END - HIGH QUALITY RESOLVE @@ -856,7 +926,7 @@ float3 NRD_SG_ResolveDiffuse( NRD_SG sg, float3 N ) float e = exp( -sg.sharpness ); float e2 = e * e; - float r = rcp( sg.sharpness ); + float r = 1.0 / sg.sharpness; float scale = 1.0 + 2.0 * e2 - r; float bias = ( e - e2 ) * r - e2; @@ -878,10 +948,12 @@ float3 NRD_SG_ResolveDiffuse( NRD_SG sg, float3 N ) sg.sharpness = 2.0; // TODO: another sharpness = another normalization needed... // Approximate NDF - NRD_SG ndf = ( NRD_SG )0; + NRD_SG ndf; ndf.c0 = 1.0; ndf.c1 = N; ndf.sharpness = 2.0; + ndf.chroma = float2( 0, 0 ); + ndf.normHitDist = 0; // Non-magic scale ndf.c0 *= 0.75; @@ -910,19 +982,23 @@ float3 NRD_SG_ResolveSpecular( NRD_SG sg, float3 N, float3 V, float roughness ) float m = roughness * roughness; float m2 = m * m; - NRD_SG ndf = ( NRD_SG )0; + NRD_SG ndf; ndf.c0 = 1.0 / ( NRD_PI * m2 ); ndf.c1 = H; ndf.sharpness = 2.0 / m2; + ndf.chroma = float2( 0, 0 ); + ndf.normHitDist = 0; // Non-magic scale ndf.c0 *= lerp( 1.0, 0.75 * 2.0 * NRD_PI, m2 ); // Warp NDF NRD_SG ndfWarped; - ndfWarped.c1 = reflect( -V, ndf.c1 ); ndfWarped.c0 = ndf.c0; + ndfWarped.c1 = reflect( -V, ndf.c1 ); ndfWarped.sharpness = ndf.sharpness / ( 4.0 * abs( dot( ndf.c1, V ) ) + NRD_EPS ); + ndfWarped.chroma = float2( 0, 0 ); + ndfWarped.normHitDist = 0; // Cosine term & visibility term evaluated at the center of the warped BRDF lobe float NoV = abs( dot( N, V ) ); @@ -990,7 +1066,7 @@ float2 NRD_SG_ReJitter( float2 f = ( brdfCenter * 4.0 + NRD_EPS ) / ( brdfAverage + NRD_EPS ); // Use re-jitter only if all samples are valid to minimize ringing - return sum != 4 ? 1.0 : clamp( f, 1.0 / NRD_PI, NRD_PI ); + return sum != 4 ? float2( 1, 1 ) : clamp( f, 1.0 / NRD_PI, NRD_PI ); } //================================================================================================================================= @@ -1022,7 +1098,7 @@ float3 NRD_SH_ResolveSpecular( NRD_SG sh, float3 N, float3 V, float roughness ) // Needs to be used to avoid summing up NAN/INF values in many rays per pixel scenarios bool NRD_IsValidRadiance( float3 radiance ) { - return any( isnan( radiance ) | isinf( radiance ) ) ? false : true; + return _NRD_IsInvalid( radiance ); } // Scales normalized hit distance back to real length diff --git a/Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_Blur.hlsli b/Shaders/Include/REBLUR_Blur.hlsli similarity index 85% rename from Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_Blur.hlsli rename to Shaders/Include/REBLUR_Blur.hlsli index 78a6f88..0721214 100644 --- a/Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_Blur.hlsli +++ b/Shaders/Include/REBLUR_Blur.hlsli @@ -11,16 +11,13 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. [numthreads( GROUP_X, GROUP_Y, 1 )] NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : SV_DispatchThreadId, uint threadIndex : SV_GroupIndex ) { - uint2 pixelPosUser = gRectOrigin + pixelPos; - float2 pixelUv = float2( pixelPos + 0.5 ) * gInvRectSize; - // Tile-based early out float isSky = gIn_Tiles[ pixelPos >> 4 ]; - if( isSky != 0.0 || pixelPos.x >= gRectSize.x || pixelPos.y >= gRectSize.y ) + if( isSky != 0.0 || any( pixelPos > gRectSizeMinusOne ) ) return; // Early out - float viewZ = abs( gIn_ViewZ[ pixelPosUser ] ); + float viewZ = abs( gIn_ViewZ[ WithRectOrigin( pixelPos ) ] ); gOut_ViewZ[ pixelPos ] = PackViewZ( viewZ ); if( viewZ > gDenoisingRange ) @@ -28,7 +25,7 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : // Normal and roughness float materialID; - float4 normalAndRoughness = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pixelPosUser ], materialID ); + float4 normalAndRoughness = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ WithRectOrigin( pixelPos ) ], materialID ); float3 N = normalAndRoughness.xyz; float3 Nv = STL::Geometry::RotateVectorInverse( gViewToWorld, N ); float roughness = normalAndRoughness.w; @@ -36,6 +33,7 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : // Shared data float4 data1 = UnpackData1( gIn_Data1[ pixelPos ] ); + float2 pixelUv = float2( pixelPos + 0.5 ) * gRectSizeInv; float3 Xv = STL::Geometry::ReconstructViewPosition( pixelUv, gFrustum, viewZ, gOrthoMode ); float4 rotator = GetBlurKernelRotation( REBLUR_BLUR_ROTATOR_MODE, pixelPos, gRotator, gFrameIndex ); @@ -46,20 +44,26 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : #define REBLUR_SPATIAL_MODE REBLUR_BLUR #ifdef REBLUR_DIFFUSE + { + float sum = 1.0; REBLUR_TYPE diff = gIn_Diff[ pixelPos ]; #ifdef REBLUR_SH float4 diffSh = gIn_DiffSh[ pixelPos ]; #endif #include "REBLUR_Common_DiffuseSpatialFilter.hlsli" + } #endif #ifdef REBLUR_SPECULAR + { + float sum = 1.0; REBLUR_TYPE spec = gIn_Spec[ pixelPos ]; #ifdef REBLUR_SH float4 specSh = gIn_SpecSh[ pixelPos ]; #endif #include "REBLUR_Common_SpecularSpatialFilter.hlsli" + } #endif } diff --git a/Shaders/Include/REBLUR/REBLUR_Common.hlsli b/Shaders/Include/REBLUR_Common.hlsli similarity index 90% rename from Shaders/Include/REBLUR/REBLUR_Common.hlsli rename to Shaders/Include/REBLUR_Common.hlsli index b90f219..3cd7c20 100644 --- a/Shaders/Include/REBLUR/REBLUR_Common.hlsli +++ b/Shaders/Include/REBLUR_Common.hlsli @@ -14,6 +14,31 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_BLUR 1 #define REBLUR_POST_BLUR 2 +// Kernels +static const float3 g_Special6[ 6 ] = +{ + // https://www.desmos.com/calculator/e5mttzlg6v + float3( -0.50 * sqrt( 3.0 ) , -0.50 , 1.0 ), + float3( 0.00 , 1.00 , 1.0 ), + float3( 0.50 * sqrt( 3.0 ) , -0.50 , 1.0 ), + float3( 0.00 , -0.30 , 0.3 ), + float3( 0.15 * sqrt( 3.0 ) , 0.15 , 0.3 ), + float3( -0.15 * sqrt( 3.0 ) , 0.15 , 0.3 ), +}; + +static const float3 g_Special8[ 8 ] = +{ + // https://www.desmos.com/calculator/abaqyvswem + float3( -1.00 , 0.00 , 1.0 ), + float3( 0.00 , 1.00 , 1.0 ), + float3( 1.00 , 0.00 , 1.0 ), + float3( 0.00 , -1.00 , 1.0 ), + float3( -0.25 * sqrt( 2.0 ) , 0.25 * sqrt( 2.0 ) , 0.5 ), + float3( 0.25 * sqrt( 2.0 ) , 0.25 * sqrt( 2.0 ) , 0.5 ), + float3( 0.25 * sqrt( 2.0 ) , -0.25 * sqrt( 2.0 ) , 0.5 ), + float3( -0.25 * sqrt( 2.0 ) , -0.25 * sqrt( 2.0 ) , 0.5 ) +}; + // Storage #define REBLUR_MAX_ACCUM_FRAME_NUM 63.0 @@ -35,7 +60,7 @@ float4 UnpackNormalAndRoughness( float4 p, bool isNormalized = true ) p.xyz = p.xyz * 2.0 - 1.0; if( isNormalized ) - p.xyz /= max( length( p.xyz ), NRD_EPS ); + p.xyz = _NRD_SafeNormalize( p.xyz ); return p; } @@ -351,7 +376,7 @@ float2 GetTemporalAccumulationParams( float isInScreenMulFootprintQuality, float // Weights void BicubicFilterNoCornersWithFallbackToBilinearFilterWithCustomWeights( - float2 samplePos, float2 invTextureSize, + float2 samplePos, float2 invResourceSize, float4 bilinearCustomWeights, bool useBicubic, Texture2D tex0, out REBLUR_TYPE c0 ) // main - CatRom { @@ -360,7 +385,7 @@ void BicubicFilterNoCornersWithFallbackToBilinearFilterWithCustomWeights( } void BicubicFilterNoCornersWithFallbackToBilinearFilterWithCustomWeights( - float2 samplePos, float2 invTextureSize, + float2 samplePos, float2 invResourceSize, float4 bilinearCustomWeights, bool useBicubic, Texture2D tex0, out REBLUR_TYPE c0, // main - CatRom Texture2D tex1, out REBLUR_FAST_TYPE c1 ) // fast - bilinear @@ -371,7 +396,7 @@ void BicubicFilterNoCornersWithFallbackToBilinearFilterWithCustomWeights( } void BicubicFilterNoCornersWithFallbackToBilinearFilterWithCustomWeights( - float2 samplePos, float2 invTextureSize, + float2 samplePos, float2 invResourceSize, float4 bilinearCustomWeights, bool useBicubic, Texture2D tex0, out REBLUR_TYPE c0, // main - CatRom Texture2D tex1, out REBLUR_SH_TYPE c1 ) // SH - bilinear @@ -382,7 +407,7 @@ void BicubicFilterNoCornersWithFallbackToBilinearFilterWithCustomWeights( } void BicubicFilterNoCornersWithFallbackToBilinearFilterWithCustomWeights( - float2 samplePos, float2 invTextureSize, + float2 samplePos, float2 invResourceSize, float4 bilinearCustomWeights, bool useBicubic, Texture2D tex0, out REBLUR_TYPE c0, // main - CatRom Texture2D tex1, out REBLUR_FAST_TYPE c1, // fast - bilinear diff --git a/Shaders/Include/REBLUR/REBLUR_Common_DiffuseSpatialFilter.hlsli b/Shaders/Include/REBLUR_Common_DiffuseSpatialFilter.hlsli similarity index 71% rename from Shaders/Include/REBLUR/REBLUR_Common_DiffuseSpatialFilter.hlsli rename to Shaders/Include/REBLUR_Common_DiffuseSpatialFilter.hlsli index ad446dc..cfba0a9 100644 --- a/Shaders/Include/REBLUR/REBLUR_Common_DiffuseSpatialFilter.hlsli +++ b/Shaders/Include/REBLUR_Common_DiffuseSpatialFilter.hlsli @@ -22,13 +22,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. { #if( REBLUR_SPATIAL_MODE == REBLUR_PRE_BLUR ) - float sum = hasData; - if( gDiffPrepassBlurRadius != 0.0 ) { float diffNonLinearAccumSpeed = REBLUR_PRE_BLUR_NON_LINEAR_ACCUM_SPEED; -#else - float sum = 1.0; #endif float fractionScale = 1.0; @@ -91,11 +87,6 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. float minHitDistWeight = REBLUR_HIT_DIST_MIN_WEIGHT( 1.0 ) * fractionScale; // Sampling - diff *= sum; - #ifdef REBLUR_SH - diffSh *= sum; - #endif - float2x3 TvBv = GetKernelBasis( Nv, Nv, 1.0 ); // D = N float worldRadius = PixelRadiusToWorld( gUnproject, gOrthoMode, blurRadius, viewZ ); @@ -109,47 +100,44 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. // Sample coordinates #if( REBLUR_USE_SCREEN_SPACE_SAMPLING == 1 || REBLUR_SPATIAL_MODE == REBLUR_PRE_BLUR ) - float2 uv = pixelUv + STL::Geometry::RotateVector( rotator, offset.xy ) * gInvScreenSize * blurRadius; + float2 uv = pixelUv + STL::Geometry::RotateVector( rotator, offset.xy ) * gRectSizeInv * blurRadius; #else float2 uv = GetKernelSampleCoordinates( gViewToClip, offset, Xv, TvBv[ 0 ], TvBv[ 1 ], rotator ); #endif + // Snap to the pixel center! + uv = ( floor( uv * gRectSize ) + 0.5 ) * gRectSizeInv; + + // Apply checkerboard shift #if( REBLUR_SPATIAL_MODE == REBLUR_PRE_BLUR ) - if( gDiffCheckerboard != 2 ) - uv = ApplyCheckerboardShift( uv, gDiffCheckerboard, n, gRectSize, gInvRectSize, gFrameIndex ); + uv = ApplyCheckerboardShift( uv * gRectSize, gDiffCheckerboard, n, gFrameIndex ) * gRectSizeInv; #endif - float2 uvScaled = uv * gResolutionScale; - float2 uvScaledWithOffset = gRectOffset + uvScaled; + // Texture coordinates + float2 uvScaled = ClampUvToViewport( uv ); float2 checkerboardUvScaled = uvScaled; - #if( REBLUR_SPATIAL_MODE == REBLUR_PRE_BLUR ) - checkerboardUvScaled = gRectOffset + float2( uvScaled.x * ( gDiffCheckerboard != 2 ? 0.5 : 1.0 ), uvScaled.y ); - #endif - - #if( REBLUR_USE_LOADS == 1 ) - uint2 uvScaledi = clamp( uvScaled * gScreenSize, 0.0, gScreenSize - 1.0 ); - uint2 uvScaledWithOffseti = clamp( uvScaledWithOffset * gScreenSize, 0.0, gScreenSize - 1.0 ); - uint2 checkerboardUvScaledi = clamp( checkerboardUvScaled * gScreenSize, 0.0, gScreenSize - 1.0 ); + if( gDiffCheckerboard != 2 ) + checkerboardUvScaled.x *= 0.5; #endif // Fetch data #if( REBLUR_SPATIAL_MODE == REBLUR_POST_BLUR ) - float zs = UnpackViewZ( REBLUR_SAMPLE_TEXTURE( gIn_ViewZ, uvScaled ) ); + float zs = UnpackViewZ( gIn_ViewZ.SampleLevel( gNearestClamp, uvScaled, 0 ) ); #else - float zs = abs( REBLUR_SAMPLE_TEXTURE( gIn_ViewZ, uvScaledWithOffset ) ); + float zs = abs( gIn_ViewZ.SampleLevel( gNearestClamp, WithRectOffset( uvScaled ), 0 ) ); #endif - REBLUR_TYPE s = REBLUR_SAMPLE_TEXTURE( gIn_Diff, checkerboardUvScaled ); - float3 Xvs = STL::Geometry::ReconstructViewPosition( uv, gFrustum, zs, gOrthoMode ); float materialIDs; - float4 Ns = REBLUR_SAMPLE_TEXTURE( gIn_Normal_Roughness, uvScaledWithOffset ); + float4 Ns = gIn_Normal_Roughness.SampleLevel( gNearestClamp, WithRectOffset( uvScaled ), 0 ); Ns = NRD_FrontEnd_UnpackNormalAndRoughness( Ns, materialIDs ); - // Sample weights - float w = CompareMaterials( materialID, materialIDs, gDiffMaterialMask ); + // Weight + float w = IsInScreenNearest( uv ); + w *= float( zs < gDenoisingRange ); + w *= CompareMaterials( materialID, materialIDs, gDiffMaterialMask ); float2 x; x.x = dot( Nv, Xvs ); @@ -157,20 +145,21 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. x = ComputeWeight( x, px, py ); w *= x.x * x.y; - w *= GetGaussianWeight( offset.z ); - w *= lerp( minHitDistWeight, 1.0, ComputeExponentialWeight( ExtractHitDist( s ), hitDistanceWeightParams.x, hitDistanceWeightParams.y ) ); + REBLUR_TYPE s = gIn_Diff.SampleLevel( gNearestClamp, checkerboardUvScaled, 0 ); + s = Denanify( w, s ); - // Get rid of potential NANs outside of rendering rectangle or denoising range - w = ( IsInScreen( uv ) && !isnan( w ) ) ? w : 0.0; - s = w != 0.0 ? s : 0.0; + w *= lerp( minHitDistWeight, 1.0, ComputeExponentialWeight( ExtractHitDist( s ), hitDistanceWeightParams.x, hitDistanceWeightParams.y ) ); + w *= GetGaussianWeight( offset.z ); // Accumulate sum += w; + diff += s * w; - #ifdef REBLUR_SH - float4 sh = REBLUR_SAMPLE_TEXTURE( gIn_DiffSh, checkerboardUvScaled ); - diffSh += sh * w; - #endif + #ifdef REBLUR_SH + float4 sh = gIn_DiffSh.SampleLevel( gNearestClamp, checkerboardUvScaled, 0 ); + sh = Denanify( w, sh ); + diffSh += sh * w; + #endif } float invSum = STL::Math::PositiveRcp( sum ); @@ -184,27 +173,25 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. // Checkerboard resolve ( if pre-pass failed ) [branch] - if( !hasData && sum == 0.0 ) + if( sum == 0.0 ) { - REBLUR_TYPE s0 = gIn_Diff[ checkerboardPos.xy ]; - REBLUR_TYPE s1 = gIn_Diff[ checkerboardPos.zy ]; + REBLUR_TYPE s0 = gIn_Diff[ checkerboardPos.xz ]; + REBLUR_TYPE s1 = gIn_Diff[ checkerboardPos.yz ]; - // Get rid of potential NANs outside of rendering rectangle or denoising range - s0 = wc.x != 0.0 ? s0 : 0; - s1 = wc.y != 0.0 ? s1 : 0; + s0 = Denanify( wc.x, s0 ); + s1 = Denanify( wc.y, s1 ); diff = s0 * wc.x + s1 * wc.y; - #ifdef REBLUR_SH - float4 sh0 = gIn_DiffSh[ checkerboardPos.xy ]; - float4 sh1 = gIn_DiffSh[ checkerboardPos.zy ]; + #ifdef REBLUR_SH + float4 sh0 = gIn_DiffSh[ checkerboardPos.xz ]; + float4 sh1 = gIn_DiffSh[ checkerboardPos.yz ]; - // Get rid of potential NANs outside of rendering rectangle or denoising range - sh0 = wc.x != 0.0 ? sh0 : 0; - sh1 = wc.y != 0.0 ? sh1 : 0; + sh0 = Denanify( wc.x, sh0 ); + sh1 = Denanify( wc.y, sh1 ); - diffSh = sh0 * wc.x + sh1 * wc.y; - #endif + diffSh = sh0 * wc.x + sh1 * wc.y; + #endif } #endif diff --git a/Shaders/Include/REBLUR/REBLUR_Common_SpecularSpatialFilter.hlsli b/Shaders/Include/REBLUR_Common_SpecularSpatialFilter.hlsli similarity index 79% rename from Shaders/Include/REBLUR/REBLUR_Common_SpecularSpatialFilter.hlsli rename to Shaders/Include/REBLUR_Common_SpecularSpatialFilter.hlsli index 403cc66..d00fc3d 100644 --- a/Shaders/Include/REBLUR/REBLUR_Common_SpecularSpatialFilter.hlsli +++ b/Shaders/Include/REBLUR_Common_SpecularSpatialFilter.hlsli @@ -24,15 +24,11 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. float smc = GetSpecMagicCurve( roughness ); #if( REBLUR_SPATIAL_MODE == REBLUR_PRE_BLUR ) - float sum = hasData; - if( gSpecPrepassBlurRadius != 0.0 ) { STL::Rng::Hash::Initialize( pixelPos, gFrameIndex ); float specNonLinearAccumSpeed = REBLUR_PRE_BLUR_NON_LINEAR_ACCUM_SPEED; -#else - float sum = 1.0; #endif float fractionScale = 1.0; @@ -110,11 +106,6 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. float minHitDistWeight = REBLUR_HIT_DIST_MIN_WEIGHT( smc ) * fractionScale; // Sampling - spec *= sum; - #ifdef REBLUR_SH - specSh *= sum; - #endif - float2x3 TvBv = GetKernelBasis( Dv.xyz, Nv, NoD, roughness, specNonLinearAccumSpeed ); float worldRadius = PixelRadiusToWorld( gUnproject, gOrthoMode, blurRadius, viewZ ); @@ -128,47 +119,44 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. // Sample coordinates #if( REBLUR_USE_SCREEN_SPACE_SAMPLING == 1 || REBLUR_SPATIAL_MODE == REBLUR_PRE_BLUR ) - float2 uv = pixelUv + STL::Geometry::RotateVector( rotator, offset.xy ) * gInvScreenSize * blurRadius; + float2 uv = pixelUv + STL::Geometry::RotateVector( rotator, offset.xy ) * gRectSizeInv * blurRadius; #else float2 uv = GetKernelSampleCoordinates( gViewToClip, offset, Xv, TvBv[ 0 ], TvBv[ 1 ], rotator ); #endif + // Snap to the pixel center! + uv = ( floor( uv * gRectSize ) + 0.5 ) * gRectSizeInv; + + // Apply checkerboard shift #if( REBLUR_SPATIAL_MODE == REBLUR_PRE_BLUR ) - if( gSpecCheckerboard != 2 ) - uv = ApplyCheckerboardShift( uv, gSpecCheckerboard, n, gRectSize, gInvRectSize, gFrameIndex ); + uv = ApplyCheckerboardShift( uv * gRectSize, gSpecCheckerboard, n, gFrameIndex ) * gRectSizeInv; #endif - float2 uvScaled = uv * gResolutionScale; - float2 uvScaledWithOffset = gRectOffset + uvScaled; + // Texture coordinates + float2 uvScaled = ClampUvToViewport( uv ); float2 checkerboardUvScaled = uvScaled; - #if( REBLUR_SPATIAL_MODE == REBLUR_PRE_BLUR ) - checkerboardUvScaled = gRectOffset + float2( uvScaled.x * ( gSpecCheckerboard != 2 ? 0.5 : 1.0 ), uvScaled.y ); - #endif - - #if( REBLUR_USE_LOADS == 1 ) - uint2 uvScaledi = clamp( uvScaled * gScreenSize, 0.0, gScreenSize - 1.0 ); - uint2 uvScaledWithOffseti = clamp( uvScaledWithOffset * gScreenSize, 0.0, gScreenSize - 1.0 ); - uint2 checkerboardUvScaledi = clamp( checkerboardUvScaled * gScreenSize, 0.0, gScreenSize - 1.0 ); + if( gSpecCheckerboard != 2 ) + checkerboardUvScaled.x *= 0.5; #endif // Fetch data #if( REBLUR_SPATIAL_MODE == REBLUR_POST_BLUR ) - float zs = UnpackViewZ( REBLUR_SAMPLE_TEXTURE( gIn_ViewZ, uvScaled ) ); + float zs = UnpackViewZ( gIn_ViewZ.SampleLevel( gNearestClamp, uvScaled, 0 ) ); #else - float zs = abs( REBLUR_SAMPLE_TEXTURE( gIn_ViewZ, uvScaledWithOffset ) ); + float zs = abs( gIn_ViewZ.SampleLevel( gNearestClamp, WithRectOffset( uvScaled ), 0 ) ); #endif - REBLUR_TYPE s = REBLUR_SAMPLE_TEXTURE( gIn_Spec, checkerboardUvScaled ); - float3 Xvs = STL::Geometry::ReconstructViewPosition( uv, gFrustum, zs, gOrthoMode ); float materialIDs; - float4 Ns = REBLUR_SAMPLE_TEXTURE( gIn_Normal_Roughness, uvScaledWithOffset ); + float4 Ns = gIn_Normal_Roughness.SampleLevel( gNearestClamp, WithRectOffset( uvScaled ), 0 ); Ns = NRD_FrontEnd_UnpackNormalAndRoughness( Ns, materialIDs ); - // Sample weights - float w = CompareMaterials( materialID, materialIDs, gSpecMaterialMask ); + // Weight + float w = IsInScreenNearest( uv ); + w *= float( zs < gDenoisingRange ); + w *= CompareMaterials( materialID, materialIDs, gSpecMaterialMask ); float3 x; x.x = dot( Nv, Xvs ); @@ -177,31 +165,15 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. x = ComputeWeight( x, px, py ); w *= x.x * x.y * x.z; - float geometryWeight = w; - w *= GetGaussianWeight( offset.z ); - w *= lerp( minHitDistWeight, 1.0, ComputeExponentialWeight( ExtractHitDist( s ), hitDistanceWeightParams.x, hitDistanceWeightParams.y ) ); - - // Get rid of potential NANs outside of rendering rectangle or denoising range - w = ( IsInScreen( uv ) && !isnan( w ) ) ? w : 0.0; - s = w != 0.0 ? s : 0.0; + REBLUR_TYPE s = gIn_Spec.SampleLevel( gNearestClamp, checkerboardUvScaled, 0 ); + s = Denanify( w, s ); #if( REBLUR_SPATIAL_MODE == REBLUR_PRE_BLUR ) - // Decrease weight for samples that most likely are very close to reflection contact which should not be blurred - float d = length( Xvs - Xv ) + NRD_EPS; - float hs = ExtractHitDist( s ) * _REBLUR_GetHitDistanceNormalization( zs, gHitDistParams, Ns.w ); - float t = hs / ( d + hitDist ); - w *= lerp( saturate( t ), 1.0, STL::Math::LinearStep( 0.5, 1.0, roughness ) ); - - // Adjust blur radius "on the fly" if taps have short hit distances - #if( REBLUR_USE_ADJUSTED_ON_THE_FLY_BLUR_RADIUS_IN_PRE_BLUR == 1 ) - float hitDistFactorAtSample = GetHitDistFactor( hs * NoD, frustumSize ); - float blurRadiusScale = lerp( hitDistFactorAtSample, 1.0, NoD ); - blurRadius *= lerp( 1.0, blurRadiusScale, n / ( 1.0 + n ) ); - #endif - // Min hit distance for tracking, ignoring 0 values ( which still can be produced by VNDF sampling ) // TODO: if trimming is off min hitDist can come from samples with very low probabilities, it worsens reprojection - geometryWeight *= saturate( hs / d ); + float hs = ExtractHitDist( s ) * _REBLUR_GetHitDistanceNormalization( zs, gHitDistParams, Ns.w ); + float d = length( Xvs - Xv ) + NRD_EPS; + float geometryWeight = w * saturate( hs / d ); if( STL::Rng::Hash::GetFloat( ) < geometryWeight ) minHitDist = min( minHitDist, hs ); @@ -211,22 +183,37 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. // on its side too. Diffuse pre-pass can be just disabled, but for specular it's still needed // to find an optimal hit distance for tracking. w *= gUsePrepassNotOnlyForSpecularMotionEstimation; // TODO: is there a better solution? + + // Decrease weight for samples that most likely are very close to reflection contact which should not be blurred + float t = hs / ( d + hitDist ); + w *= lerp( saturate( t ), 1.0, STL::Math::LinearStep( 0.5, 1.0, roughness ) ); + + // Adjust blur radius "on the fly" if taps have short hit distances + #if( REBLUR_USE_ADJUSTED_ON_THE_FLY_BLUR_RADIUS_IN_PRE_BLUR == 1 ) + float hitDistFactorAtSample = GetHitDistFactor( hs * NoD, frustumSize ); + float blurRadiusScale = lerp( hitDistFactorAtSample, 1.0, NoD ); + blurRadius *= lerp( 1.0, blurRadiusScale, n / ( 1.0 + n ) ); + #endif #endif + w *= lerp( minHitDistWeight, 1.0, ComputeExponentialWeight( ExtractHitDist( s ), hitDistanceWeightParams.x, hitDistanceWeightParams.y ) ); + w *= GetGaussianWeight( offset.z ); // Accumulate sum += w; + spec += s * w; - #ifdef REBLUR_SH - float4 sh = REBLUR_SAMPLE_TEXTURE( gIn_SpecSh, checkerboardUvScaled ); - specSh.xyz += sh.xyz * w; - #endif + #ifdef REBLUR_SH + float4 sh = gIn_SpecSh.SampleLevel( gNearestClamp, checkerboardUvScaled, 0 ); + sh = Denanify( w, sh ); + specSh.xyz += sh.xyz * w; // see TA + #endif } float invSum = STL::Math::PositiveRcp( sum ); spec *= invSum; - #ifdef REBLUR_SH - specSh.xyz *= invSum; - #endif + #ifdef REBLUR_SH + specSh.xyz *= invSum; + #endif #if( REBLUR_SPATIAL_MODE == REBLUR_PRE_BLUR ) // Output @@ -235,27 +222,25 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. // Checkerboard resolve ( if pre-pass failed ) [branch] - if( !hasData && sum == 0.0 ) + if( sum == 0.0 ) { - REBLUR_TYPE s0 = gIn_Spec[ checkerboardPos.xy ]; - REBLUR_TYPE s1 = gIn_Spec[ checkerboardPos.zy ]; + REBLUR_TYPE s0 = gIn_Spec[ checkerboardPos.xz ]; + REBLUR_TYPE s1 = gIn_Spec[ checkerboardPos.yz ]; - // Get rid of potential NANs outside of rendering rectangle or denoising range - s0 = wc.x != 0.0 ? s0 : 0; - s1 = wc.y != 0.0 ? s1 : 0; + s0 = Denanify( wc.x, s0 ); + s1 = Denanify( wc.y, s1 ); spec = s0 * wc.x + s1 * wc.y; - #ifdef REBLUR_SH - float4 sh0 = gIn_SpecSh[ checkerboardPos.xy ]; - float4 sh1 = gIn_SpecSh[ checkerboardPos.zy ]; + #ifdef REBLUR_SH + float4 sh0 = gIn_SpecSh[ checkerboardPos.xz ]; + float4 sh1 = gIn_SpecSh[ checkerboardPos.yz ]; - // Get rid of potential NANs outside of rendering rectangle or denoising range - sh0 = wc.x != 0.0 ? sh0 : 0; - sh1 = wc.y != 0.0 ? sh1 : 0; + sh0 = Denanify( wc.x, sh0 ); + sh1 = Denanify( wc.y, sh1 ); - specSh = sh0 * wc.x + sh1 * wc.y; - #endif + specSh = sh0 * wc.x + sh1 * wc.y; + #endif } #endif diff --git a/Shaders/Include/REBLUR/REBLUR_Config.hlsli b/Shaders/Include/REBLUR_Config.hlsli similarity index 81% rename from Shaders/Include/REBLUR/REBLUR_Config.hlsli rename to Shaders/Include/REBLUR_Config.hlsli index 95a80df..e09928c 100644 --- a/Shaders/Include/REBLUR/REBLUR_Config.hlsli +++ b/Shaders/Include/REBLUR_Config.hlsli @@ -8,15 +8,7 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -// Data types -#ifdef REBLUR_OCCLUSION - #define REBLUR_TYPE float -#else - #define REBLUR_TYPE float4 -#endif - -#define REBLUR_SH_TYPE float4 -#define REBLUR_FAST_TYPE float +#define REBLUR // Switches ( default 1 ) #define REBLUR_USE_CATROM_FOR_SURFACE_MOTION_IN_TA 1 @@ -33,7 +25,6 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_USE_ANTILAG_NOT_INVOKING_HISTORY_FIX 0 #define REBLUR_USE_DECOMPRESSED_HIT_DIST_IN_RECONSTRUCTION 0 // compression helps to preserve "lobe important" values #define REBLUR_USE_ADJUSTED_ON_THE_FLY_BLUR_RADIUS_IN_PRE_BLUR 0 // TODO: verify that not needed and delete... -#define REBLUR_USE_LOADS 0 // replaced "SampleLevel"s with "Load"s in spatial filtering #ifdef REBLUR_OCCLUSION #undef REBLUR_USE_ANTIFIREFLY @@ -56,7 +47,7 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SHOW 0 // 0 or "REBLUR_SHOW_X" -// Other +// Settings #define REBLUR_PRE_BLUR_POISSON_SAMPLE_NUM 8 #define REBLUR_PRE_BLUR_POISSON_SAMPLES( i ) g_Special8[ i ] @@ -78,8 +69,6 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_VIRTUAL_MOTION_PREV_PREV_WEIGHT_ITERATION_NUM 2 #define REBLUR_COLOR_CLAMPING_SIGMA_SCALE 2.0 // using smaller values leads to bias if camera rotates slowly due to reprojection instabilities -#define REBLUR_HISTORY_FIX_THRESHOLD_1 0.111 // was 0.01 -#define REBLUR_HISTORY_FIX_THRESHOLD_2 0.333 // was 0.25 #define REBLUR_HISTORY_FIX_BUMPED_ROUGHNESS 0.08 #define REBLUR_FIREFLY_SUPPRESSOR_MAX_RELATIVE_INTENSITY float2( 10.0, 1.1 ) #define REBLUR_FIREFLY_SUPPRESSOR_RADIUS_SCALE 0.1 @@ -87,25 +76,48 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_ANTI_FIREFLY_SIGMA_SCALE 2.0 #define REBLUR_SAMPLES_PER_FRAME 1.0 // TODO: expose in settings, it will become useful with very clean signals, when max number of accumulated frames is low -// Shared data -#define REBLUR_SHARED_CB_DATA \ +// Data types +#ifdef REBLUR_OCCLUSION + #define REBLUR_TYPE float +#else + #define REBLUR_TYPE float4 +#endif + +#define REBLUR_SH_TYPE float4 +#define REBLUR_FAST_TYPE float + +// Shared constants +#define REBLUR_SHARED_CONSTANTS \ NRD_CONSTANT( float4x4, gViewToClip ) \ NRD_CONSTANT( float4x4, gViewToWorld ) \ + NRD_CONSTANT( float4x4, gWorldToViewPrev ) \ + NRD_CONSTANT( float4x4, gWorldToClipPrev ) \ + NRD_CONSTANT( float4x4, gWorldPrevToWorld ) \ NRD_CONSTANT( float4, gFrustum ) \ + NRD_CONSTANT( float4, gFrustumPrev ) \ + NRD_CONSTANT( float4, gCameraDelta ) \ + NRD_CONSTANT( float4, gAntilagParams ) \ NRD_CONSTANT( float4, gHitDistParams ) \ NRD_CONSTANT( float4, gViewVectorWorld ) \ NRD_CONSTANT( float4, gViewVectorWorldPrev ) \ - NRD_CONSTANT( float3, gMvScale ) \ - NRD_CONSTANT( float, gDebug ) \ - NRD_CONSTANT( float2, gInvScreenSize ) \ - NRD_CONSTANT( float2, gScreenSize ) \ - NRD_CONSTANT( float2, gInvRectSize ) \ + NRD_CONSTANT( float4, gMvScale ) \ + NRD_CONSTANT( float2, gResourceSize ) \ + NRD_CONSTANT( float2, gResourceSizeInv ) \ + NRD_CONSTANT( float2, gResourceSizeInvPrev ) \ NRD_CONSTANT( float2, gRectSize ) \ + NRD_CONSTANT( float2, gRectSizeInv ) \ + NRD_CONSTANT( float2, gRectSizePrev ) \ NRD_CONSTANT( float2, gResolutionScale ) \ NRD_CONSTANT( float2, gResolutionScalePrev ) \ - NRD_CONSTANT( float2, gRectSizePrev ) \ NRD_CONSTANT( float2, gRectOffset ) \ + NRD_CONSTANT( float2, gSpecProbabilityThresholdsForMvModification ) \ + NRD_CONSTANT( float2, gJitter ) \ NRD_CONSTANT( uint2, gRectOrigin ) \ + NRD_CONSTANT( int2, gRectSizeMinusOne ) \ + NRD_CONSTANT( float, gDisocclusionThreshold ) \ + NRD_CONSTANT( float, gDisocclusionThresholdAlternate ) \ + NRD_CONSTANT( float, gStabilizationStrength ) \ + NRD_CONSTANT( float, gDebug ) \ NRD_CONSTANT( float, gOrthoMode ) \ NRD_CONSTANT( float, gUnproject ) \ NRD_CONSTANT( float, gDenoisingRange ) \ @@ -123,44 +135,18 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. NRD_CONSTANT( float, gHistoryFixFrameNum ) \ NRD_CONSTANT( float, gMinRectDimMulUnproject ) \ NRD_CONSTANT( float, gUsePrepassNotOnlyForSpecularMotionEstimation ) \ - NRD_CONSTANT( uint, gIsWorldSpaceMotionEnabled ) \ + NRD_CONSTANT( float, gSplitScreen ) \ + NRD_CONSTANT( float, gCheckerboardResolveAccumSpeed ) \ + NRD_CONSTANT( uint, gHasHistoryConfidence ) \ + NRD_CONSTANT( uint, gHasDisocclusionThresholdMix ) \ + NRD_CONSTANT( uint, gDiffCheckerboard ) \ + NRD_CONSTANT( uint, gSpecCheckerboard ) \ NRD_CONSTANT( uint, gFrameIndex ) \ NRD_CONSTANT( uint, gDiffMaterialMask ) \ NRD_CONSTANT( uint, gSpecMaterialMask ) \ + NRD_CONSTANT( uint, gIsRectChanged ) \ NRD_CONSTANT( uint, gResetHistory ) -// Texture access -#if( REBLUR_USE_LOADS == 1 ) - #define REBLUR_SAMPLE_TEXTURE( tex, uv ) tex[ uv ## i ] -#else - #define REBLUR_SAMPLE_TEXTURE( tex, uv ) tex.SampleLevel( gNearestClamp, uv, 0 ) -#endif - -// Kernels -static const float3 g_Special6[ 6 ] = -{ - // https://www.desmos.com/calculator/e5mttzlg6v - float3( -0.50 * sqrt( 3.0 ) , -0.50 , 1.0 ), - float3( 0.00 , 1.00 , 1.0 ), - float3( 0.50 * sqrt( 3.0 ) , -0.50 , 1.0 ), - float3( 0.00 , -0.30 , 0.3 ), - float3( 0.15 * sqrt( 3.0 ) , 0.15 , 0.3 ), - float3( -0.15 * sqrt( 3.0 ) , 0.15 , 0.3 ), -}; - -static const float3 g_Special8[ 8 ] = -{ - // https://www.desmos.com/calculator/abaqyvswem - float3( -1.00 , 0.00 , 1.0 ), - float3( 0.00 , 1.00 , 1.0 ), - float3( 1.00 , 0.00 , 1.0 ), - float3( 0.00 , -1.00 , 1.0 ), - float3( -0.25 * sqrt( 2.0 ) , 0.25 * sqrt( 2.0 ) , 0.5 ), - float3( 0.25 * sqrt( 2.0 ) , 0.25 * sqrt( 2.0 ) , 0.5 ), - float3( 0.25 * sqrt( 2.0 ) , -0.25 * sqrt( 2.0 ) , 0.5 ), - float3( -0.25 * sqrt( 2.0 ) , -0.25 * sqrt( 2.0 ) , 0.5 ) -}; - #ifdef REBLUR_DIRECTIONAL_OCCLUSION #undef REBLUR_USE_CATROM_FOR_SURFACE_MOTION_IN_TA #define REBLUR_USE_CATROM_FOR_SURFACE_MOTION_IN_TA 0 diff --git a/Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_CopyStabilizedHistory.hlsli b/Shaders/Include/REBLUR_Copy.hlsli similarity index 100% rename from Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_CopyStabilizedHistory.hlsli rename to Shaders/Include/REBLUR_Copy.hlsli diff --git a/Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_HistoryFix.hlsli b/Shaders/Include/REBLUR_HistoryFix.hlsli similarity index 72% rename from Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_HistoryFix.hlsli rename to Shaders/Include/REBLUR_HistoryFix.hlsli index 25bc052..586e2a9 100644 --- a/Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_HistoryFix.hlsli +++ b/Shaders/Include/REBLUR_HistoryFix.hlsli @@ -14,7 +14,7 @@ groupshared float s_SpecLuma[ BUFFER_Y ][ BUFFER_X ]; void Preload( uint2 sharedPos, int2 globalPos ) { - globalPos = clamp( globalPos, 0, gRectSize - 1.0 ); + globalPos = clamp( globalPos, 0, gRectSizeMinusOne ); s_FrameNum[ sharedPos.y ][ sharedPos.x ] = UnpackData1( gIn_Data1[ globalPos ] ).xz; @@ -33,38 +33,39 @@ void Preload( uint2 sharedPos, int2 globalPos ) [numthreads( GROUP_X, GROUP_Y, 1 )] NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : SV_DispatchThreadId, uint threadIndex : SV_GroupIndex ) { - float2 pixelUv = float2( pixelPos + 0.5 ) * gInvRectSize; - int2 pixelPosUser = gRectOrigin + pixelPos; - // Preload float isSky = gIn_Tiles[ pixelPos >> 4 ]; PRELOAD_INTO_SMEM_WITH_TILE_CHECK; // Tile-based early out - if( isSky != 0.0 || pixelPos.x >= gRectSize.x || pixelPos.y >= gRectSize.y ) + if( isSky != 0.0 || any( pixelPos > gRectSizeMinusOne ) ) return; // Early out - float viewZ = abs( gIn_ViewZ[ pixelPosUser ] ); + float viewZ = abs( gIn_ViewZ[ WithRectOrigin( pixelPos ) ] ); if( viewZ > gDenoisingRange ) return; // Center data float materialID; - float4 normalAndRoughness = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pixelPosUser ], materialID ); + float4 normalAndRoughness = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ WithRectOrigin( pixelPos ) ], materialID ); float3 N = normalAndRoughness.xyz; float roughness = normalAndRoughness.w; float frustumSize = GetFrustumSize( gMinRectDimMulUnproject, gOrthoMode, viewZ ); + float2 pixelUv = float2( pixelPos + 0.5 ) * gRectSizeInv; float3 Xv = STL::Geometry::ReconstructViewPosition( pixelUv, gFrustum, viewZ, gOrthoMode ); float3 Nv = STL::Geometry::RotateVectorInverse( gViewToWorld, N ); + float3 Vv = GetViewVector( Xv, true ); + float NoV = abs( dot( Nv, Vv ) ); + float slopeScale = 1.0 / max( NoV, 0.2 ); // TODO: bigger scale introduces ghosting // Smooth number of accumulated frames int2 smemPos = threadPos + BORDER; - float2 frameNumUnclamped = s_FrameNum[ smemPos.y ][ smemPos.x ]; float invHistoryFixFrameNum = STL::Math::PositiveRcp( gHistoryFixFrameNum ); - float2 normFrameNum = saturate( frameNumUnclamped * invHistoryFixFrameNum ); - float2 c = normFrameNum; + float2 frameNum = s_FrameNum[ smemPos.y ][ smemPos.x ]; // unsmoothed + float2 frameNumNorm = saturate( frameNum * invHistoryFixFrameNum ); // smoothed + float2 c = frameNumNorm; float2 sum = 1.0; [unroll] @@ -84,18 +85,19 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : int2 pos = threadPos + int2( i, j ); - float2 s = saturate( s_FrameNum[ pos.y ][ pos.x ] * invHistoryFixFrameNum ); - float2 w = step( c, s ); + float2 f = s_FrameNum[ pos.y ][ pos.x ]; + float2 fn = saturate( f * invHistoryFixFrameNum ); + float2 w = step( c, fn ); // use only neighbors with longer history - normFrameNum += s * w; + frameNumNorm += fn * w; sum += w; } } - normFrameNum *= rcp( sum ); + frameNumNorm /= sum; - float2 scale = saturate( 1.0 - normFrameNum ) * float( gHistoryFixFrameNum != 0.0 ); - float2 frameNum = normFrameNum * gHistoryFixFrameNum; + // IMPORTANT: progression is "{8, 4, 2, 1} + 1". "+1" is important to better break blobs + float2 stride = exp2( gHistoryFixFrameNum - frameNumNorm * gHistoryFixFrameNum ) + 1.0; // Diffuse #ifdef REBLUR_DIFFUSE @@ -104,18 +106,26 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : float4 diffSh = gIn_DiffSh[ pixelPos ]; #endif + // Stride between taps + float diffStride = stride.x * float( frameNum.x < gHistoryFixFrameNum ); + diffStride = floor( diffStride ); + // History reconstruction - if( scale.x > REBLUR_HISTORY_FIX_THRESHOLD_1 ) // TODO: use REBLUR_HISTORY_FIX_THRESHOLD_2 to switch to 3x3? + if( diffStride != 0.0 ) { - scale.x = gHistoryFixStrideBetweenSamples / ( 2.0 + frameNum.x ); // TODO: 2 to match RELAX logic, where HistoryFix uses "1 / ( 1 + "N + 1" )" + int diffStridei = int( diffStride + 0.5 ); // Parameters float diffNonLinearAccumSpeed = 1.0 / ( 1.0 + frameNum.x ); float diffNormalWeightParam = GetNormalWeightParams( diffNonLinearAccumSpeed, 1.0 ); - float2 diffGeometryWeightParams = GetGeometryWeightParams( gPlaneDistSensitivity, frustumSize, Xv, Nv, diffNonLinearAccumSpeed ); + float2 diffGeometryWeightParams = GetGeometryWeightParams( gPlaneDistSensitivity * slopeScale, frustumSize, Xv, Nv, diffNonLinearAccumSpeed ); - float sumd = 1.0; + float sumd = 1.0 + frameNum.x; + #ifdef REBLUR_PERFORMANCE_MODE + sumd = 1.0 + 1.0 / ( 1.0 + gMaxAccumulatedFrameNum ) - diffNonLinearAccumSpeed; + #endif + diff *= sumd; [unroll] for( j = -2; j <= 2; j++ ) @@ -132,14 +142,16 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : continue; // Sample uv - float2 uv = pixelUv + float2( i, j ) * gInvRectSize * scale.x; - float2 uvScaled = uv * gResolutionScale; + float2 uv = pixelUv + float2( i, j ) * diffStride * gRectSizeInv; + + int2 pos = pixelPos + int2( i, j ) * diffStridei; + pos = clamp( pos, 0, gRectSizeMinusOne ); // Fetch data - float z = abs( gIn_ViewZ.SampleLevel( gNearestClamp, uvScaled + gRectOffset, 0 ) ); + float z = abs( gIn_ViewZ[ WithRectOrigin( pos ) ] ); float materialIDs; - float4 Ns = gIn_Normal_Roughness.SampleLevel( gNearestClamp, uvScaled + gRectOffset, 0 ); + float4 Ns = gIn_Normal_Roughness[ WithRectOrigin( pos ) ]; Ns = NRD_FrontEnd_UnpackNormalAndRoughness( Ns, materialIDs ); float3 Xvs = STL::Geometry::ReconstructViewPosition( uv, gFrustum, z, gOrthoMode ); @@ -147,23 +159,26 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : float angle = STL::Math::AcosApprox( dot( Ns.xyz, N ) ); - // Accumulate - float w = IsInScreen( uv ); + // Weight + float w = IsInScreenNearest( uv ); + w *= float( z < gDenoisingRange ); w *= CompareMaterials( materialID, materialIDs, gDiffMaterialMask ); w *= ComputeWeight( NoX, diffGeometryWeightParams.x, diffGeometryWeightParams.y ); w *= ComputeExponentialWeight( angle, diffNormalWeightParam, 0.0 ); - REBLUR_TYPE s = gIn_Diff.SampleLevel( gNearestClamp, uvScaled, 0 ); - - // Get rid of potential NANs outside of rendering rectangle or denoising range - w = IsInScreen( uv ) ? w : 0.0; // no "!isnan" because "s" is not used for "w" calculations - s = w != 0.0 ? s : 0.0; + #ifndef REBLUR_PERFORMANCE_MODE + w *= 1.0 + UnpackData1( gIn_Data1[ pos ] ).x; + #endif - diff += s * w; + // Accumulate sumd += w; + REBLUR_TYPE s = gIn_Diff[ pos ]; + s = Denanify( w, s ); + diff += s * w; #ifdef REBLUR_SH - float4 sh = gIn_DiffSh.SampleLevel( gNearestClamp, uvScaled, 0 ); + float4 sh = gIn_DiffSh[ pos ]; + sh = Denanify( w, sh ); diffSh += sh * w; #endif } @@ -220,10 +235,9 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : if( abs( i ) <= 1 && abs( j ) <= 1 ) continue; - float2 uv = pixelUv + float2( i, j ) * gInvRectSize; - float2 uvScaled = uv * gResolutionScale; + int2 pos = clamp( pixelPos + int2( i, j ), 0, gRectSizeMinusOne ); + float d = gIn_DiffFast[ pos ].x; - float d = gIn_DiffFast.SampleLevel( gNearestClamp, uvScaled, 0 ).x; m1 += d; m2 += d * d; } @@ -246,7 +260,7 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : float diffMax = diffM1 + diffSigma; float diffLumaClamped = clamp( diffLuma, diffMin, diffMax ); - diffLuma = lerp( diffLumaClamped, diffLuma, 1.0 / ( 1.0 + float( gMaxFastAccumulatedFrameNum < gMaxAccumulatedFrameNum ) * frameNumUnclamped.x * 2.0 ) ); + diffLuma = lerp( diffLumaClamped, diffLuma, 1.0 / ( 1.0 + float( gMaxFastAccumulatedFrameNum < gMaxAccumulatedFrameNum ) * frameNum.x * 2.0 ) ); // Change luma #if( REBLUR_SHOW == REBLUR_SHOW_FAST_HISTORY ) @@ -272,42 +286,39 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : float4 specSh = gIn_SpecSh[ pixelPos ]; #endif + // Stride between taps + float smc = GetSpecMagicCurve( roughness ); + float specStride = stride.y * float( frameNum.y < gHistoryFixFrameNum ); + specStride *= lerp( 0.5, 1.0, smc ); // TODO: seems to work better than "minBlurRadius" + specStride = floor( specStride ); + // History reconstruction - if( scale.y > REBLUR_HISTORY_FIX_THRESHOLD_1 ) // TODO: use REBLUR_HISTORY_FIX_THRESHOLD_2 to switch to 3x3? + if( specStride != 0 ) { - scale.y = gHistoryFixStrideBetweenSamples / ( 2.0 + frameNum.y ); // TODO: 2 to match RELAX logic, where HistoryFix uses "1 / ( 1 + "N + 1" )" - // TODO: introduce IN_SECONDARY_ROUGHNESS: // - to allow blur on diffuse-like surfaces in reflection // - use "hitDistanceWeight" only for very low primary roughness to avoid color bleeding from one surface to another - // Adjust scale to respect the specular lobe - float hitDistScale = _REBLUR_GetHitDistanceNormalization( viewZ, gHitDistParams, roughness ); - float hitDist = ExtractHitDist( spec ) * hitDistScale; - float3 Vv = GetViewVector( Xv, true ); - float4 Dv = STL::ImportanceSampling::GetSpecularDominantDirection( Nv, Vv, roughness, STL_SPECULAR_DOMINANT_DIRECTION_G2 ); - float NoD = abs( dot( Nv, Dv.xyz ) ); - float lobeTanHalfAngle = STL::ImportanceSampling::GetSpecularLobeTanHalfAngle( max( REBLUR_HISTORY_FIX_BUMPED_ROUGHNESS, roughness ), 0.65 ); // TODO: 65% energy to better follow the lobe? - float lobeRadius = hitDist * NoD * lobeTanHalfAngle; - float minBlurRadius = lobeRadius / PixelRadiusToWorld( gUnproject, gOrthoMode, 1.0, viewZ + hitDist * Dv.w ); - scale.y = min( scale.y, minBlurRadius / 2.0 ); + int specStridei = int( specStride + 0.5 ); // Parameters float specNonLinearAccumSpeed = 1.0 / ( 1.0 + frameNum.y ); + float hitDistNormAtCenter = ExtractHitDist( spec ); float lobeEnergy = lerp( 0.75, 0.85, specNonLinearAccumSpeed ); float lobeHalfAngle = STL::ImportanceSampling::GetSpecularLobeHalfAngle( roughness, lobeEnergy ); // up to 85% energy to depend less on normal weight lobeHalfAngle *= specNonLinearAccumSpeed; float specNormalWeightParam = 1.0 / max( lobeHalfAngle, NRD_NORMAL_ULP ); - float2 specGeometryWeightParams = GetGeometryWeightParams( gPlaneDistSensitivity, frustumSize, Xv, Nv, specNonLinearAccumSpeed ); + float2 specGeometryWeightParams = GetGeometryWeightParams( gPlaneDistSensitivity * slopeScale, frustumSize, Xv, Nv, specNonLinearAccumSpeed ); float2 relaxedRoughnessWeightParams = GetRelaxedRoughnessWeightParams( roughness * roughness, sqrt( gRoughnessFraction ) ); + float2 hitDistanceWeightParams = GetHitDistanceWeightParams( hitDistNormAtCenter, specNonLinearAccumSpeed, roughness ); - float hitDistNormAtCenter = ExtractHitDist( spec ); - float smc = GetSpecMagicCurve( roughness ); - float hitDistWeightScale = 20.0 * STL::Math::LinearStep( REBLUR_HISTORY_FIX_BUMPED_ROUGHNESS, 0.0, roughness ); - - float sums = 1.0; + float sums = 1.0 + frameNum.y; + #ifdef REBLUR_PERFORMANCE_MODE + sums = 1.0 + 1.0 / ( 1.0 + gMaxAccumulatedFrameNum ) - specNonLinearAccumSpeed; + #endif + spec *= sums; [unroll] for( j = -2; j <= 2; j++ ) @@ -324,14 +335,16 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : continue; // Sample uv - float2 uv = pixelUv + float2( i, j ) * gInvRectSize * scale.y; - float2 uvScaled = uv * gResolutionScale; + float2 uv = pixelUv + float2( i, j ) * specStride * gRectSizeInv; + + int2 pos = pixelPos + int2( i, j ) * specStridei; + pos = clamp( pos, 0, gRectSizeMinusOne ); // Fetch data - float z = abs( gIn_ViewZ.SampleLevel( gNearestClamp, uvScaled + gRectOffset, 0 ) ); + float z = abs( gIn_ViewZ[ WithRectOrigin( pos ) ] ); float materialIDs; - float4 Ns = gIn_Normal_Roughness.SampleLevel( gNearestClamp, uvScaled + gRectOffset, 0 ); + float4 Ns = gIn_Normal_Roughness[ WithRectOrigin( pos ) ]; Ns = NRD_FrontEnd_UnpackNormalAndRoughness( Ns, materialIDs ); float3 Xvs = STL::Geometry::ReconstructViewPosition( uv, gFrustum, z, gOrthoMode ); @@ -339,30 +352,34 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : float angle = STL::Math::AcosApprox( dot( Ns.xyz, N ) ); - // Accumulate - float w = IsInScreen( uv ); + // Weight + float w = IsInScreenNearest( uv ); + w *= float( z < gDenoisingRange ); w *= CompareMaterials( materialID, materialIDs, gSpecMaterialMask ); w *= ComputeWeight( NoX, specGeometryWeightParams.x, specGeometryWeightParams.y ); w *= ComputeExponentialWeight( angle, specNormalWeightParam, 0.0 ); w *= ComputeExponentialWeight( Ns.w * Ns.w, relaxedRoughnessWeightParams.x, relaxedRoughnessWeightParams.y ); - REBLUR_TYPE s = gIn_Spec.SampleLevel( gNearestClamp, uvScaled, 0 ); + #ifndef REBLUR_PERFORMANCE_MODE + w *= 1.0 + UnpackData1( gIn_Data1[ pos ] ).z; + #endif // TODO: ideally "diffuseness at hit" needed... // TODO: for roughness closer to REBLUR_HISTORY_FIX_BUMPED_ROUGHNESS "saturate( hitDistNormAtCenter - ExtractHitDist( s ) )" could be used. // It allows bleeding of background to foreground, but not vice versa ( doesn't suit for 0 roughness ) - w *= saturate( 1.0 - hitDistWeightScale * abs( ExtractHitDist( s ) - hitDistNormAtCenter ) / ( max( ExtractHitDist( s ), hitDistNormAtCenter ) + NRD_EPS ) ); + REBLUR_TYPE s = gIn_Spec[ pos ]; + s = Denanify( w, s ); - // Get rid of potential NANs outside of rendering rectangle or denoising range - w = ( IsInScreen( uv ) && !isnan( w ) ) ? w : 0.0; - s = w != 0.0 ? s : 0.0; + w *= ComputeExponentialWeight( ExtractHitDist( s ), hitDistanceWeightParams.x, hitDistanceWeightParams.y ); - spec += s * w; + // Accumulate sums += w; + spec += s * w; #ifdef REBLUR_SH - float4 sh = gIn_SpecSh.SampleLevel( gNearestClamp, uvScaled, 0 ); - specSh += sh * w; + float4 sh = gIn_SpecSh[ pos ]; + sh = Denanify( w, sh ); + specSh.xyz += sh.xyz * w; // see TA #endif } } @@ -418,10 +435,9 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : if( abs( i ) <= 1 && abs( j ) <= 1 ) continue; - float2 uv = pixelUv + float2( i, j ) * gInvRectSize; - float2 uvScaled = uv * gResolutionScale; + int2 pos = clamp( pixelPos + int2( i, j ), 0, gRectSizeMinusOne ); + float s = gIn_SpecFast[ pos ].x; - float s = gIn_SpecFast.SampleLevel( gNearestClamp, uvScaled, 0 ).x; m1 += s; m2 += s * s; } @@ -444,7 +460,7 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : float specMax = specM1 + specSigma; float specLumaClamped = clamp( specLuma, specMin, specMax ); - specLuma = lerp( specLumaClamped, specLuma, 1.0 / ( 1.0 + float( gMaxFastAccumulatedFrameNum < gMaxAccumulatedFrameNum ) * frameNumUnclamped.y * 2.0 ) ); + specLuma = lerp( specLumaClamped, specLuma, 1.0 / ( 1.0 + float( gMaxFastAccumulatedFrameNum < gMaxAccumulatedFrameNum ) * frameNum.y * 2.0 ) ); // Change luma #if( REBLUR_SHOW == REBLUR_SHOW_FAST_HISTORY ) diff --git a/Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli b/Shaders/Include/REBLUR_HitDistReconstruction.hlsli similarity index 87% rename from Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli rename to Shaders/Include/REBLUR_HitDistReconstruction.hlsli index f85d340..1d23252 100644 --- a/Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli +++ b/Shaders/Include/REBLUR_HitDistReconstruction.hlsli @@ -13,15 +13,14 @@ groupshared float3 s_HitDist_ViewZ[ BUFFER_Y ][ BUFFER_X ]; void Preload( uint2 sharedPos, int2 globalPos ) { - globalPos = clamp( globalPos, 0, gRectSize - 1.0 ); - uint2 globalIdUser = gRectOrigin + globalPos; + globalPos = clamp( globalPos, 0, gRectSizeMinusOne ); - float viewZ = abs( gIn_ViewZ[ globalIdUser ] ); + float viewZ = abs( gIn_ViewZ[ WithRectOrigin( globalPos ) ] ); - float4 normalAndRoughness = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ globalIdUser ] ); + float4 normalAndRoughness = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ WithRectOrigin( globalPos ) ] ); s_Normal_Roughness[ sharedPos.y ][ sharedPos.x ] = normalAndRoughness; - float2 hitDist = 1.0; + float2 hitDist = 0.0; #ifdef REBLUR_DIFFUSE hitDist.x = ExtractHitDist( gIn_Diff[ globalPos ] ); @@ -38,24 +37,18 @@ void Preload( uint2 sharedPos, int2 globalPos ) #endif #endif - // Get rid of potential NANs outside of rendering rectangle or denoising range - hitDist = viewZ > gDenoisingRange ? 0 : hitDist; - s_HitDist_ViewZ[ sharedPos.y ][ sharedPos.x ] = float3( hitDist, viewZ ); } [numthreads( GROUP_X, GROUP_Y, 1 )] NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : SV_DispatchThreadId, uint threadIndex : SV_GroupIndex ) { - uint2 pixelPosUser = gRectOrigin + pixelPos; - float2 pixelUv = float2( pixelPos + 0.5 ) * gInvRectSize; - // Preload float isSky = gIn_Tiles[ pixelPos >> 4 ]; PRELOAD_INTO_SMEM_WITH_TILE_CHECK; // Tile-based early out - if( isSky != 0.0 || pixelPos.x >= gRectSize.x || pixelPos.y >= gRectSize.y ) + if( isSky != 0.0 || any( pixelPos > gRectSizeMinusOne ) ) return; // Early out @@ -70,6 +63,7 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : float roughness = normalAndRoughness.w; float frustumSize = GetFrustumSize( gMinRectDimMulUnproject, gOrthoMode, center.z ); + float2 pixelUv = float2( pixelPos + 0.5 ) * gRectSizeInv; float3 Xv = STL::Geometry::ReconstructViewPosition( pixelUv, gFrustum, center.z, gOrthoMode ); float3 Nv = STL::Geometry::RotateVectorInverse( gViewToWorld, N ); float2 geometryWeightParams = GetGeometryWeightParams( gPlaneDistSensitivity, frustumSize, Xv, Nv, 1.0 ); @@ -95,15 +89,17 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : int2 pos = threadPos + int2( i, j ); float3 temp = s_HitDist_ViewZ[ pos.y ][ pos.x ]; - float w = IsInScreen( pixelUv + o * gInvRectSize ); + // Weight + float w = IsInScreenNearest( pixelUv + o * gRectSizeInv ); + w *= float( temp.z < gDenoisingRange ); w *= GetGaussianWeight( length( o ) * 0.5 ); // This weight is strict ( non exponential ) because we need to avoid accessing data from other surfaces - float3 Xvs = STL::Geometry::ReconstructViewPosition( pixelUv + o * gInvRectSize, gFrustum, temp.z, gOrthoMode ); + float3 Xvs = STL::Geometry::ReconstructViewPosition( pixelUv + o * gRectSizeInv, gFrustum, temp.z, gOrthoMode ); float NoX = dot( Nv, Xvs ); w *= ComputeWeight( NoX, geometryWeightParams.x, geometryWeightParams.y ); - float2 ww = w * float2( temp.xy != 0.0 ); + float2 ww = w; #ifndef REBLUR_PERFORMANCE_MODE float4 normalAndRoughness = s_Normal_Roughness[ pos.y ][ pos.x ]; @@ -116,6 +112,11 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : ww.y *= ComputeExponentialWeight( normalAndRoughness.w * normalAndRoughness.w, relaxedRoughnessWeightParams.x, relaxedRoughnessWeightParams.y ); #endif + temp.x = Denanify( ww.x, temp.x ); + temp.y = Denanify( ww.y, temp.y ); + ww *= float2( temp.xy != 0.0 ); + + // Accumulate center.xy += temp.xy * ww; sum += ww; } diff --git a/Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli b/Shaders/Include/REBLUR_PostBlur.hlsli similarity index 89% rename from Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli rename to Shaders/Include/REBLUR_PostBlur.hlsli index 862f565..b1172e6 100644 --- a/Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli +++ b/Shaders/Include/REBLUR_PostBlur.hlsli @@ -11,12 +11,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. [numthreads( GROUP_X, GROUP_Y, 1 )] NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : SV_DispatchThreadId, uint threadIndex : SV_GroupIndex ) { - uint2 pixelPosUser = gRectOrigin + pixelPos; - float2 pixelUv = float2( pixelPos + 0.5 ) * gInvRectSize; - // Tile-based early out float isSky = gIn_Tiles[ pixelPos >> 4 ]; - if( isSky != 0.0 || pixelPos.x >= gRectSize.x || pixelPos.y >= gRectSize.y ) + if( isSky != 0.0 || any( pixelPos > gRectSizeMinusOne ) ) { // ~0 normal is needed to allow bilinear filter in TA ( 0 can't be used due to "division by zero" in "UnpackNormalRoughness" ) gOut_Normal_Roughness[ pixelPos ] = PackNormalRoughness( 1.0 / 255.0 ); @@ -26,7 +23,7 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : // Early out float viewZ = UnpackViewZ( gIn_ViewZ[ pixelPos ] ); - if( viewZ > gDenoisingRange || pixelPos.x >= gRectSize.x || pixelPos.y >= gRectSize.y ) + if( viewZ > gDenoisingRange ) { // ~0 normal is needed to allow bilinear filter in TA ( 0 can't be used due to "division by zero" in "UnpackNormalRoughness" ) gOut_Normal_Roughness[ pixelPos ] = PackNormalRoughness( 1.0 / 255.0 ); @@ -36,7 +33,7 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : // Normal and roughness float materialID; - float4 normalAndRoughness = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pixelPosUser ], materialID ); + float4 normalAndRoughness = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ WithRectOrigin( pixelPos ) ], materialID ); float3 N = normalAndRoughness.xyz; float3 Nv = STL::Geometry::RotateVectorInverse( gViewToWorld, N ); float roughness = normalAndRoughness.w; @@ -44,6 +41,7 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : // Shared data float4 data1 = UnpackData1( gIn_Data1[ pixelPos ] ); + float2 pixelUv = float2( pixelPos + 0.5 ) * gRectSizeInv; float3 Xv = STL::Geometry::ReconstructViewPosition( pixelUv, gFrustum, viewZ, gOrthoMode ); float4 rotator = GetBlurKernelRotation( REBLUR_POST_BLUR_ROTATOR_MODE, pixelPos, gRotator, gFrameIndex ); @@ -60,20 +58,26 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : #define REBLUR_SPATIAL_MODE REBLUR_POST_BLUR #ifdef REBLUR_DIFFUSE + { + float sum = 1.0; REBLUR_TYPE diff = gIn_Diff[ pixelPos ]; #ifdef REBLUR_SH float4 diffSh = gIn_DiffSh[ pixelPos ]; #endif #include "REBLUR_Common_DiffuseSpatialFilter.hlsli" + } #endif #ifdef REBLUR_SPECULAR + { + float sum = 1.0; REBLUR_TYPE spec = gIn_Spec[ pixelPos ]; #ifdef REBLUR_SH float4 specSh = gIn_SpecSh[ pixelPos ]; #endif #include "REBLUR_Common_SpecularSpatialFilter.hlsli" + } #endif } diff --git a/Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_PrePass.hlsli b/Shaders/Include/REBLUR_PrePass.hlsli similarity index 63% rename from Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_PrePass.hlsli rename to Shaders/Include/REBLUR_PrePass.hlsli index 5b7676d..b11918b 100644 --- a/Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_PrePass.hlsli +++ b/Shaders/Include/REBLUR_PrePass.hlsli @@ -11,41 +11,39 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. [numthreads( GROUP_X, GROUP_Y, 1 )] NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : SV_DispatchThreadId, uint threadIndex : SV_GroupIndex ) { - float2 pixelUv = float2( pixelPos + 0.5 ) * gInvRectSize; - int2 pixelPosUser = gRectOrigin + pixelPos; - // Tile-based early out float isSky = gIn_Tiles[ pixelPos >> 4 ]; - if( isSky != 0.0 || pixelPos.x >= gRectSize.x || pixelPos.y >= gRectSize.y ) + if( isSky != 0.0 || any( pixelPos > gRectSizeMinusOne ) ) return; // Early out - float viewZ = abs( gIn_ViewZ[ pixelPosUser ] ); + float viewZ = abs( gIn_ViewZ[ WithRectOrigin( pixelPos ) ] ); if( viewZ > gDenoisingRange ) return; // Checkerboard resolve uint checkerboard = STL::Sequence::CheckerBoard( pixelPos, gFrameIndex ); - float viewZ0 = abs( gIn_ViewZ[ pixelPosUser + int2( -1, 0 ) ] ); - float viewZ1 = abs( gIn_ViewZ[ pixelPosUser + int2( 1, 0 ) ] ); + int3 checkerboardPos = pixelPos.xxy + int3( -1, 1, 0 ); + checkerboardPos.x = max( checkerboardPos.x, 0 ); + checkerboardPos.y = min( checkerboardPos.y, gRectSizeMinusOne.x ); + float viewZ0 = abs( gIn_ViewZ[ WithRectOrigin( checkerboardPos.xz ) ] ); + float viewZ1 = abs( gIn_ViewZ[ WithRectOrigin( checkerboardPos.yz ) ] ); float2 wc = GetBilateralWeight( float2( viewZ0, viewZ1 ), viewZ ); + wc.x = ( viewZ0 > gDenoisingRange || pixelPos.x < 1 ) ? 0.0 : wc.x; + wc.y = ( viewZ1 > gDenoisingRange || pixelPos.x >= gRectSizeMinusOne.x ) ? 0.0 : wc.y; wc *= STL::Math::PositiveRcp( wc.x + wc.y ); - - int3 checkerboardPos = pixelPos.xyx + int3( -1, 0, 1 ); - checkerboardPos.xz >>= 1; - checkerboardPos.x = max( checkerboardPos.x, 0 ); - checkerboardPos.z = min( checkerboardPos.z, gRectSize.x * 0.5 - 1.0 ); - checkerboardPos += gRectOrigin.xyx; + checkerboardPos.xy >>= 1; // Normal and roughness float materialID; - float4 normalAndRoughness = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pixelPosUser ], materialID ); + float4 normalAndRoughness = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ WithRectOrigin( pixelPos ) ], materialID ); float3 N = normalAndRoughness.xyz; float3 Nv = STL::Geometry::RotateVectorInverse( gViewToWorld, N ); float roughness = normalAndRoughness.w; // Shared data + float2 pixelUv = float2( pixelPos + 0.5 ) * gRectSizeInv; float3 Xv = STL::Geometry::ReconstructViewPosition( pixelUv, gFrustum, viewZ, gOrthoMode ); float4 rotator = GetBlurKernelRotation( REBLUR_PRE_BLUR_ROTATOR_MODE, pixelPos, gRotator, gFrameIndex ); @@ -57,19 +55,23 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : #ifdef REBLUR_DIFFUSE { uint2 pos = pixelPos; - bool hasData = true; - if( gDiffCheckerboard != 2 ) - { - hasData = checkerboard == gDiffCheckerboard; - pos.x >>= 1; - } - pos += gRectOrigin; + pos.x >>= gDiffCheckerboard == 2 ? 0 : 1; + float sum = 1.0; REBLUR_TYPE diff = gIn_Diff[ pos ]; #ifdef REBLUR_SH float4 diffSh = gIn_DiffSh[ pos ]; #endif + if( gDiffCheckerboard != 2 && checkerboard != gDiffCheckerboard ) + { + sum = 0; + diff = 0; + #ifdef REBLUR_SH + diffSh = 0; + #endif + } + #include "REBLUR_Common_DiffuseSpatialFilter.hlsli" } #endif @@ -77,19 +79,23 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : #ifdef REBLUR_SPECULAR { uint2 pos = pixelPos; - bool hasData = true; - if( gSpecCheckerboard != 2 ) - { - hasData = checkerboard == gSpecCheckerboard; - pos.x >>= 1; - } - pos += gRectOrigin; + pos.x >>= gSpecCheckerboard == 2 ? 0 : 1; + float sum = 1.0; REBLUR_TYPE spec = gIn_Spec[ pos ]; #ifdef REBLUR_SH float4 specSh = gIn_SpecSh[ pos ]; #endif + if( gSpecCheckerboard != 2 && checkerboard != gSpecCheckerboard ) + { + sum = 0; + spec = 0; + #ifdef REBLUR_SH + specSh = 0; + #endif + } + #include "REBLUR_Common_SpecularSpatialFilter.hlsli" } #endif diff --git a/Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_SplitScreen.hlsli b/Shaders/Include/REBLUR_SplitScreen.hlsli similarity index 69% rename from Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_SplitScreen.hlsli rename to Shaders/Include/REBLUR_SplitScreen.hlsli index 6296e14..177438b 100644 --- a/Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_SplitScreen.hlsli +++ b/Shaders/Include/REBLUR_SplitScreen.hlsli @@ -11,23 +11,21 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. [numthreads( GROUP_X, GROUP_Y, 1)] NRD_EXPORT void NRD_CS_MAIN( int2 pixelPos : SV_DispatchThreadId) { - float2 pixelUv = float2( pixelPos + 0.5 ) * gInvRectSize; - uint2 pixelPosUser = gRectOrigin + pixelPos; - - if( pixelUv.x > gSplitScreen || pixelPos.x >= gRectSize.x || pixelPos.y >= gRectSize.y ) + float2 pixelUv = float2( pixelPos + 0.5 ) * gRectSizeInv; + if( pixelUv.x > gSplitScreen || any( pixelPos > gRectSizeMinusOne ) ) return; - float viewZ = gIn_ViewZ[ pixelPosUser ]; + float viewZ = gIn_ViewZ[ WithRectOrigin( pixelPos ) ]; uint2 checkerboardPos = pixelPos; #ifdef REBLUR_DIFFUSE checkerboardPos.x = pixelPos.x >> ( gDiffCheckerboard != 2 ? 1 : 0 ); - float4 diff = gIn_Diff[ gRectOrigin + checkerboardPos ]; + float4 diff = gIn_Diff[ checkerboardPos ]; gOut_Diff[ pixelPos ] = diff * float( viewZ < gDenoisingRange ); #ifdef REBLUR_SH - float4 diffSh = gIn_DiffSh[ gRectOrigin + checkerboardPos ]; + float4 diffSh = gIn_DiffSh[ checkerboardPos ]; gOut_DiffSh[ pixelPos ] = diffSh * float( viewZ < gDenoisingRange ); #endif #endif @@ -35,11 +33,11 @@ NRD_EXPORT void NRD_CS_MAIN( int2 pixelPos : SV_DispatchThreadId) #ifdef REBLUR_SPECULAR checkerboardPos.x = pixelPos.x >> ( gSpecCheckerboard != 2 ? 1 : 0 ); - float4 spec = gIn_Spec[ gRectOrigin + checkerboardPos ]; + float4 spec = gIn_Spec[ checkerboardPos ]; gOut_Spec[ pixelPos ] = spec * float( viewZ < gDenoisingRange ); #ifdef REBLUR_SH - float4 specSh = gIn_SpecSh[ gRectOrigin + checkerboardPos ]; + float4 specSh = gIn_SpecSh[ checkerboardPos ]; gOut_SpecSh[ pixelPos ] = specSh * float( viewZ < gDenoisingRange ); #endif #endif diff --git a/Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli b/Shaders/Include/REBLUR_TemporalAccumulation.hlsli similarity index 81% rename from Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli rename to Shaders/Include/REBLUR_TemporalAccumulation.hlsli index 7715a21..f4b08bd 100644 --- a/Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli +++ b/Shaders/Include/REBLUR_TemporalAccumulation.hlsli @@ -13,18 +13,17 @@ groupshared float s_HitDistForTracking[ BUFFER_Y ][ BUFFER_X ]; void Preload( uint2 sharedPos, int2 globalPos ) { - globalPos = clamp( globalPos, 0, gRectSize - 1.0 ); - uint2 globalIdUser = gRectOrigin + globalPos; + globalPos = clamp( globalPos, 0, gRectSizeMinusOne ); - float4 temp = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ globalIdUser ] ); + float4 temp = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ WithRectOrigin( globalPos ) ] ); s_Normal_Roughness[ sharedPos.y ][ sharedPos.x ] = temp; #ifdef REBLUR_SPECULAR #ifdef REBLUR_OCCLUSION uint shift = gSpecCheckerboard != 2 ? 1 : 0; - uint2 pos = uint2( globalPos.x >> shift, globalPos.y ) + gRectOrigin; + uint2 pos = uint2( globalPos.x >> shift, globalPos.y ); #else - uint2 pos = globalPos + ( gIsPrepassEnabled ? 0 : gRectOrigin ); + uint2 pos = globalPos; #endif REBLUR_TYPE spec = gIn_Spec[ pos ]; @@ -41,23 +40,21 @@ void Preload( uint2 sharedPos, int2 globalPos ) [numthreads( GROUP_X, GROUP_Y, 1 )] NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : SV_DispatchThreadId, uint threadIndex : SV_GroupIndex ) { - uint2 pixelPosUser = gRectOrigin + pixelPos; - float2 pixelUv = float2( pixelPos + 0.5 ) * gInvRectSize; - // Preload float isSky = gIn_Tiles[ pixelPos >> 4 ]; PRELOAD_INTO_SMEM_WITH_TILE_CHECK; // Tile-based early out - if( isSky != 0.0 || pixelPos.x >= gRectSize.x || pixelPos.y >= gRectSize.y ) + if( isSky != 0.0 || any( pixelPos > gRectSizeMinusOne ) ) return; // Early out - float viewZ = abs( gIn_ViewZ[ pixelPosUser ] ); + float viewZ = abs( gIn_ViewZ[ WithRectOrigin( pixelPos ) ] ); if( viewZ > gDenoisingRange ) return; // Current position + float2 pixelUv = float2( pixelPos + 0.5 ) * gRectSizeInv; float3 Xv = STL::Geometry::ReconstructViewPosition( pixelUv, gFrustum, viewZ, gOrthoMode ); float3 X = STL::Geometry::RotateVector( gViewToWorld, Xv ); @@ -99,7 +96,7 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : // Normal and roughness float materialID; - float4 normalAndRoughness = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pixelPosUser ], materialID ); + float4 normalAndRoughness = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ WithRectOrigin( pixelPos ) ], materialID ); float3 N = normalAndRoughness.xyz; float roughness = normalAndRoughness.w; @@ -125,27 +122,28 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : #endif // Previous position and surface motion uv - float3 mv = gIn_Mv[ pixelPosUser ] * gMvScale; - if( gMvScale.z == 0.0 ) - mv.z = STL::Geometry::AffineTransform( gWorldToViewPrev, X ).z - viewZ; - + float3 mv = gIn_Mv[ WithRectOrigin( pixelPos ) ] * gMvScale.xyz; float3 Xprev = X; float2 smbPixelUv = pixelUv + mv.xy; - if( gIsWorldSpaceMotionEnabled ) + + if( gMvScale.w != 0.0 ) { Xprev += mv; smbPixelUv = STL::Geometry::GetScreenUv( gWorldToClipPrev, Xprev ); } else { + if( gMvScale.z == 0.0 ) + mv.z = STL::Geometry::AffineTransform( gWorldToViewPrev, X ).z - viewZ; + float viewZprev = viewZ + mv.z; float3 Xvprevlocal = STL::Geometry::ReconstructViewPosition( smbPixelUv, gFrustumPrev, viewZprev, gOrthoMode ); // TODO: use gOrthoModePrev - Xprev = STL::Geometry::RotateVectorInverse( gWorldToViewPrev, Xvprevlocal ) + gCameraDelta; + Xprev = STL::Geometry::RotateVectorInverse( gWorldToViewPrev, Xvprevlocal ) + gCameraDelta.xyz; } // Parallax - float smbParallaxInPixels = ComputeParallaxInPixels( Xprev - gCameraDelta, gOrthoMode == 0.0 ? pixelUv : smbPixelUv, gWorldToClip, gRectSize ); + float smbParallaxInPixels = ComputeParallaxInPixels( Xprev + gCameraDelta.xyz, gOrthoMode == 0.0 ? smbPixelUv : pixelUv, gWorldToClipPrev, gRectSize ); // Previous viewZ ( 4x4, surface motion ) /* @@ -162,7 +160,7 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : 2z 3z */ STL::Filtering::CatmullRom smbCatromFilter = STL::Filtering::GetCatmullRomFilter( smbPixelUv, gRectSizePrev ); - float2 smbCatromGatherUv = smbCatromFilter.origin * gInvScreenSize; + float2 smbCatromGatherUv = smbCatromFilter.origin * gResourceSizeInvPrev; float4 smbViewZ0 = gIn_Prev_ViewZ.GatherRed( gNearestClamp, smbCatromGatherUv, float2( 1, 1 ) ).wzxy; float4 smbViewZ1 = gIn_Prev_ViewZ.GatherRed( gNearestClamp, smbCatromGatherUv, float2( 3, 1 ) ).wzxy; float4 smbViewZ2 = gIn_Prev_ViewZ.GatherRed( gNearestClamp, smbCatromGatherUv, float2( 1, 3 ) ).wzxy; @@ -176,41 +174,28 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : // Previous normal averaged for all pixels in 2x2 footprint // IMPORTANT: bilinear filter can touch sky pixels, due to this reason "Post Blur" writes special values into sky-pixels STL::Filtering::Bilinear smbBilinearFilter = STL::Filtering::GetBilinearFilter( smbPixelUv, gRectSizePrev ); - - float2 smbBilinearGatherUv = ( smbBilinearFilter.origin + 1.0 ) * gInvScreenSize; + float2 smbBilinearGatherUv = ( smbBilinearFilter.origin + 1.0 ) * gResourceSizeInvPrev; float3 prevNavg = UnpackNormalAndRoughness( gIn_Prev_Normal_Roughness.SampleLevel( gLinearClamp, smbBilinearGatherUv, 0 ), false ).xyz; prevNavg = STL::Geometry::RotateVector( gWorldPrevToWorld, prevNavg ); - // Previous accum speed and materialID // TODO: 4x4 materialID footprint is reduced to 2x2 only - uint4 smbInternalData = gIn_Prev_InternalData.GatherRed( gNearestClamp, smbBilinearGatherUv ).wzxy; - - float3 internalData00 = UnpackInternalData( smbInternalData.x ); - float3 internalData10 = UnpackInternalData( smbInternalData.y ); - float3 internalData01 = UnpackInternalData( smbInternalData.z ); - float3 internalData11 = UnpackInternalData( smbInternalData.w ); - - float4 diffAccumSpeeds = float4( internalData00.x, internalData10.x, internalData01.x, internalData11.x ); - float4 specAccumSpeeds = float4( internalData00.y, internalData10.y, internalData01.y, internalData11.y ); - float4 prevMaterialIDs = float4( internalData00.z, internalData10.z, internalData01.z, internalData11.z ); - - // Disocclusion threshold + // Disocclusion: threshold float disocclusionThresholdMulFrustumSize = gDisocclusionThreshold; if( gHasDisocclusionThresholdMix ) - disocclusionThresholdMulFrustumSize = lerp( gDisocclusionThreshold, gDisocclusionThresholdAlternate, gIn_DisocclusionThresholdMix[ pixelPosUser ] ); + disocclusionThresholdMulFrustumSize = lerp( gDisocclusionThreshold, gDisocclusionThresholdAlternate, gIn_DisocclusionThresholdMix[ WithRectOrigin( pixelPos ) ] ); float frustumSize = GetFrustumSize( gMinRectDimMulUnproject, gOrthoMode, viewZ ); disocclusionThresholdMulFrustumSize *= frustumSize; - // Surface motion - plane distance based disocclusion float3 V = GetViewVector( X ); float NoV = abs( dot( N, V ) ); float mvLengthFactor = STL::Math::LinearStep( 0.5, 1.0, smbParallaxInPixels ); float frontFacing = lerp( cos( STL::Math::DegToRad( 135.0 ) ), cos( STL::Math::DegToRad( 91.0 ) ), mvLengthFactor ); - float4 smbDisocclusionThreshold = disocclusionThresholdMulFrustumSize / lerp( 0.05 + 0.95 * NoV, 1.0, saturate( smbParallaxInPixels / 30.0 ) ); + float4 smbDisocclusionThreshold = disocclusionThresholdMulFrustumSize / lerp( lerp( 0.05, 1.0, NoV ), 1.0, saturate( smbParallaxInPixels / 30.0 ) ); smbDisocclusionThreshold *= float( dot( prevNavg, Navg ) > frontFacing ); - smbDisocclusionThreshold *= IsInScreen2x2( smbBilinearFilter.origin, gRectSizePrev ); + smbDisocclusionThreshold *= IsInScreenBilinear( smbBilinearFilter.origin, gRectSizePrev ); smbDisocclusionThreshold -= NRD_EPS; + // Disocclusion: plane distance float3 Xvprev = STL::Geometry::AffineTransform( gWorldToViewPrev, Xprev ); float3 smbPlaneDist0 = abs( prevViewZ0 - Xvprev.z ); float3 smbPlaneDist1 = abs( prevViewZ1 - Xvprev.z ); @@ -221,213 +206,110 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : float3 smbOcclusion2 = step( smbPlaneDist2, smbDisocclusionThreshold.z ); float3 smbOcclusion3 = step( smbPlaneDist3, smbDisocclusionThreshold.w ); + // Disocclusion: materialID + #if( NRD_NORMAL_ENCODING == NRD_NORMAL_ENCODING_R10G10B10A2_UNORM ) + uint4 smbInternalData0 = gIn_Prev_InternalData.GatherRed( gNearestClamp, smbCatromGatherUv, float2( 1, 1 ) ).wzxy; + uint4 smbInternalData1 = gIn_Prev_InternalData.GatherRed( gNearestClamp, smbCatromGatherUv, float2( 3, 1 ) ).wzxy; + uint4 smbInternalData2 = gIn_Prev_InternalData.GatherRed( gNearestClamp, smbCatromGatherUv, float2( 1, 3 ) ).wzxy; + uint4 smbInternalData3 = gIn_Prev_InternalData.GatherRed( gNearestClamp, smbCatromGatherUv, float2( 3, 3 ) ).wzxy; + + float3 prevMaterialID0 = float3( UnpackInternalData( smbInternalData0.y ).z, UnpackInternalData( smbInternalData0.z ).z, UnpackInternalData( smbInternalData0.w ).z ); + float3 prevMaterialID1 = float3( UnpackInternalData( smbInternalData1.x ).z, UnpackInternalData( smbInternalData1.z ).z, UnpackInternalData( smbInternalData1.w ).z ); + float3 prevMaterialID2 = float3( UnpackInternalData( smbInternalData2.x ).z, UnpackInternalData( smbInternalData2.y ).z, UnpackInternalData( smbInternalData2.w ).z ); + float3 prevMaterialID3 = float3( UnpackInternalData( smbInternalData3.x ).z, UnpackInternalData( smbInternalData3.y ).z, UnpackInternalData( smbInternalData3.z ).z ); + + uint mask = gSpecMaterialMask | gDiffMaterialMask; // TODO: separation is expensive + smbOcclusion0 *= CompareMaterials( materialID, prevMaterialID0, mask ); + smbOcclusion1 *= CompareMaterials( materialID, prevMaterialID1, mask ); + smbOcclusion2 *= CompareMaterials( materialID, prevMaterialID2, mask ); + smbOcclusion3 *= CompareMaterials( materialID, prevMaterialID3, mask ); + + uint4 smbInternalData = uint4( smbInternalData0.w, smbInternalData1.z, smbInternalData2.y, smbInternalData3.x ); + #else + uint4 smbInternalData = gIn_Prev_InternalData.GatherRed( gNearestClamp, smbBilinearGatherUv ).wzxy; + #endif + + // 2x2 occlusion weights float4 smbOcclusionWeights = STL::Filtering::GetBilinearCustomWeights( smbBilinearFilter, float4( smbOcclusion0.z, smbOcclusion1.y, smbOcclusion2.y, smbOcclusion3.x ) ); bool smbAllowCatRom = dot( smbOcclusion0 + smbOcclusion1 + smbOcclusion2 + smbOcclusion3, 1.0 ) > 11.5 && REBLUR_USE_CATROM_FOR_SURFACE_MOTION_IN_TA; - float smbFootprintQuality = STL::Filtering::ApplyBilinearFilter( smbOcclusion0.z, smbOcclusion1.y, smbOcclusion2.y, smbOcclusion3.x, smbBilinearFilter ); - smbFootprintQuality = STL::Math::Sqrt01( smbFootprintQuality ); - // Bits - // IMPORTANT: MaterialID check is not needed for TS float fbits = smbOcclusion0.z * 1.0; fbits += smbOcclusion1.y * 2.0; fbits += smbOcclusion2.y * 4.0; fbits += smbOcclusion3.x * 8.0; - // Material ID check - float4 materialCmps = CompareMaterials( materialID, prevMaterialIDs, 1 ); - smbOcclusion0.z *= materialCmps.x; - smbOcclusion1.y *= materialCmps.y; - smbOcclusion2.y *= materialCmps.z; - smbOcclusion3.x *= materialCmps.w; - - float4 smbOcclusionWeightsWithMaterialID = STL::Filtering::GetBilinearCustomWeights( smbBilinearFilter, float4( smbOcclusion0.z, smbOcclusion1.y, smbOcclusion2.y, smbOcclusion3.x ) ); - bool smbAllowCatRomWithMaterialID = smbAllowCatRom && dot( materialCmps, 1.0 ) > 3.5 && REBLUR_USE_CATROM_FOR_SURFACE_MOTION_IN_TA; - float smbFootprintQualityWithMaterialID = STL::Filtering::ApplyBilinearFilter( smbOcclusion0.z, smbOcclusion1.y, smbOcclusion2.y, smbOcclusion3.x, smbBilinearFilter ); - smbFootprintQualityWithMaterialID = STL::Math::Sqrt01( smbFootprintQualityWithMaterialID ); - - // Avoid footprint momentary stretching due to changed viewing angle - float3 smbVprev = GetViewVectorPrev( Xprev, gCameraDelta ); - float NoVprev = abs( dot( N, smbVprev ) ); // TODO: should be prevNavg ( normalized? ), but jittering breaks logic - float sizeQuality = ( NoVprev + 1e-3 ) / ( NoV + 1e-3 ); // this order because we need to fix stretching only, shrinking is OK - sizeQuality *= sizeQuality; - sizeQuality = lerp( 0.1, 1.0, saturate( sizeQuality ) ); - - smbFootprintQuality *= sizeQuality; - smbFootprintQualityWithMaterialID *= sizeQuality; + // Accumulation speed + float2 internalData00 = UnpackInternalData( smbInternalData.x ).xy; + float2 internalData10 = UnpackInternalData( smbInternalData.y ).xy; + float2 internalData01 = UnpackInternalData( smbInternalData.z ).xy; + float2 internalData11 = UnpackInternalData( smbInternalData.w ).xy; - // Update accumulation speeds #ifdef REBLUR_DIFFUSE - float4 diffOcclusionWeights = gDiffMaterialMask ? smbOcclusionWeightsWithMaterialID : smbOcclusionWeights; - float diffHistoryConfidence = gDiffMaterialMask ? smbFootprintQualityWithMaterialID : smbFootprintQuality; - bool diffAllowCatRom = gDiffMaterialMask ? smbAllowCatRomWithMaterialID : smbAllowCatRom; - - if( gHasHistoryConfidence ) - diffHistoryConfidence *= gIn_Diff_Confidence[ pixelPosUser ]; - - float diffAccumSpeed = STL::Filtering::ApplyBilinearCustomWeights( diffAccumSpeeds.x, diffAccumSpeeds.y, diffAccumSpeeds.z, diffAccumSpeeds.w, diffOcclusionWeights ); - diffAccumSpeed *= lerp( diffHistoryConfidence, 1.0, 1.0 / ( 1.0 + diffAccumSpeed ) ); - diffAccumSpeed = min( diffAccumSpeed, gMaxAccumulatedFrameNum ); + float4 diffAccumSpeeds = float4( internalData00.x, internalData10.x, internalData01.x, internalData11.x ); + float diffAccumSpeed = STL::Filtering::ApplyBilinearCustomWeights( diffAccumSpeeds.x, diffAccumSpeeds.y, diffAccumSpeeds.z, diffAccumSpeeds.w, smbOcclusionWeights ); #endif #ifdef REBLUR_SPECULAR - float4 specOcclusionWeights = gSpecMaterialMask ? smbOcclusionWeightsWithMaterialID : smbOcclusionWeights; - float specHistoryConfidence = gSpecMaterialMask ? smbFootprintQualityWithMaterialID : smbFootprintQuality; - bool specAllowCatRom = gSpecMaterialMask ? smbAllowCatRomWithMaterialID : smbAllowCatRom; + float4 specAccumSpeeds = float4( internalData00.y, internalData10.y, internalData01.y, internalData11.y ); + float smbSpecAccumSpeed = STL::Filtering::ApplyBilinearCustomWeights( specAccumSpeeds.x, specAccumSpeeds.y, specAccumSpeeds.z, specAccumSpeeds.w, smbOcclusionWeights ); + #endif - if( gHasHistoryConfidence ) - specHistoryConfidence *= gIn_Spec_Confidence[ pixelPosUser ]; + // Footprint quality + float3 smbVprev = GetViewVectorPrev( Xprev, gCameraDelta.xyz ); + float NoVprev = abs( dot( N, smbVprev ) ); // TODO: should be prevNavg ( normalized? ), but jittering breaks logic + float sizeQuality = ( NoVprev + 1e-3 ) / ( NoV + 1e-3 ); // this order because we need to fix stretching only, shrinking is OK + sizeQuality *= sizeQuality; + sizeQuality = lerp( 0.1, 1.0, saturate( sizeQuality ) ); - float smbSpecAccumSpeed = STL::Filtering::ApplyBilinearCustomWeights( specAccumSpeeds.x, specAccumSpeeds.y, specAccumSpeeds.z, specAccumSpeeds.w, specOcclusionWeights ); - smbSpecAccumSpeed *= lerp( specHistoryConfidence, 1.0, 1.0 / ( 1.0 + smbSpecAccumSpeed ) ); - smbSpecAccumSpeed = min( smbSpecAccumSpeed, gMaxAccumulatedFrameNum ); - #endif + float smbFootprintQuality = STL::Filtering::ApplyBilinearFilter( smbOcclusion0.z, smbOcclusion1.y, smbOcclusion2.y, smbOcclusion3.x, smbBilinearFilter ); + smbFootprintQuality = STL::Math::Sqrt01( smbFootprintQuality ); + smbFootprintQuality *= sizeQuality; // avoid footprint momentary stretching due to changed viewing angle + // Checkerboard resolve uint checkerboard = STL::Sequence::CheckerBoard( pixelPos, gFrameIndex ); #ifdef REBLUR_OCCLUSION - int3 checkerboardPos = pixelPosUser.xyx + int3( -1, 0, 1 ); - float viewZ0 = abs( gIn_ViewZ[ checkerboardPos.xy ] ); - float viewZ1 = abs( gIn_ViewZ[ checkerboardPos.zy ] ); + int3 checkerboardPos = pixelPos.xxy + int3( -1, 1, 0 ); + checkerboardPos.x = max( checkerboardPos.x, 0 ); + checkerboardPos.y = min( checkerboardPos.y, gRectSizeMinusOne.x ); + float viewZ0 = abs( gIn_ViewZ[ WithRectOrigin( checkerboardPos.xz ) ] ); + float viewZ1 = abs( gIn_ViewZ[ WithRectOrigin( checkerboardPos.yz ) ] ); float2 wc = GetBilateralWeight( float2( viewZ0, viewZ1 ), viewZ ); + wc.x = ( viewZ0 > gDenoisingRange || pixelPos.x < 1 ) ? 0.0 : wc.x; + wc.y = ( viewZ1 > gDenoisingRange || pixelPos.x >= gRectSizeMinusOne.x ) ? 0.0 : wc.y; wc *= STL::Math::PositiveRcp( wc.x + wc.y ); - #endif - - // Diffuse - #ifdef REBLUR_DIFFUSE - bool diffHasData = gDiffCheckerboard == 2 || checkerboard == gDiffCheckerboard; - #ifdef REBLUR_OCCLUSION - uint diffShift = gDiffCheckerboard != 2 ? 1 : 0; - uint2 diffPos = uint2( pixelPos.x >> diffShift, pixelPos.y ) + gRectOrigin; - diffPos.x = min( diffPos.x, gRectSize.x * ( gDiffCheckerboard != 2 ? 0.5 : 1.0 ) - 1.0 ); - #else - uint2 diffPos = pixelPos; - #endif - - REBLUR_TYPE diff = gIn_Diff[ diffPos ]; - #ifdef REBLUR_SH - float4 diffSh = gIn_DiffSh[ diffPos ]; - #endif - - // Sample history - surface motion - REBLUR_TYPE smbDiffHistory; - REBLUR_FAST_TYPE smbDiffFastHistory; - REBLUR_SH_TYPE smbDiffShHistory; - - BicubicFilterNoCornersWithFallbackToBilinearFilterWithCustomWeights( - saturate( smbPixelUv ) * gRectSizePrev, gInvScreenSize, - diffOcclusionWeights, diffAllowCatRom, - gIn_Diff_History, smbDiffHistory, - gIn_DiffFast_History, smbDiffFastHistory - #ifdef REBLUR_SH - , gIn_DiffSh_History, smbDiffShHistory - #endif - ); - - // Avoid negative values - smbDiffHistory = ClampNegativeToZero( smbDiffHistory ); - - // Accumulation with checkerboard resolve // TODO: materialID support? - #ifdef REBLUR_OCCLUSION - int3 diffCheckerboardPos = pixelPos.xyx + int3( -1, 0, 1 ); - diffCheckerboardPos.xz >>= diffShift; - diffCheckerboardPos.x = max( diffCheckerboardPos.x, 0 ); - diffCheckerboardPos.z = min( diffCheckerboardPos.z, gRectSize.x * ( gDiffCheckerboard != 2 ? 0.5 : 1.0 ) - 1.0 ); - diffCheckerboardPos += gRectOrigin.xyx; - - float d0 = gIn_Diff[ diffCheckerboardPos.xy ]; - float d1 = gIn_Diff[ diffCheckerboardPos.zy ]; - - if( !diffHasData ) - { - diff *= saturate( 1.0 - wc.x - wc.y ); - diff += d0 * wc.x + d1 * wc.y; - } - #endif - - float diffNonLinearAccumSpeed = 1.0 / ( 1.0 + diffAccumSpeed ); - if( !diffHasData ) - diffNonLinearAccumSpeed *= lerp( 1.0 - gCheckerboardResolveAccumSpeed, 1.0, diffNonLinearAccumSpeed ); - - REBLUR_TYPE diffResult = MixHistoryAndCurrent( smbDiffHistory, diff, diffNonLinearAccumSpeed ); - #ifdef REBLUR_SH - float4 diffShResult = MixHistoryAndCurrent( smbDiffShHistory, diffSh, diffNonLinearAccumSpeed ); - #endif - - // Anti-firefly suppressor - float diffAntifireflyFactor = diffAccumSpeed * gBlurRadius * REBLUR_FIREFLY_SUPPRESSOR_RADIUS_SCALE; - diffAntifireflyFactor /= 1.0 + diffAntifireflyFactor; - - float diffHitDistResult = ExtractHitDist( diffResult ); - float diffHitDistClamped = min( diffHitDistResult, ExtractHitDist( smbDiffHistory ) * REBLUR_FIREFLY_SUPPRESSOR_MAX_RELATIVE_INTENSITY.y ); - diffHitDistClamped = lerp( diffHitDistResult, diffHitDistClamped, diffAntifireflyFactor ); - - #if( defined REBLUR_OCCLUSION || defined REBLUR_DIRECTIONAL_OCCLUSION ) - diffResult = ChangeLuma( diffResult, diffHitDistClamped ); - #else - float diffLumaResult = GetLuma( diffResult ); - float diffLumaClamped = min( diffLumaResult, GetLuma( smbDiffHistory ) * REBLUR_FIREFLY_SUPPRESSOR_MAX_RELATIVE_INTENSITY.x ); - diffLumaClamped = lerp( diffLumaResult, diffLumaClamped, diffAntifireflyFactor ); - - diffResult = ChangeLuma( diffResult, diffLumaClamped ); - diffResult.w = diffHitDistClamped; - - #ifdef REBLUR_SH - diffShResult.xyz *= GetLumaScale( length( diffShResult.xyz ), diffLumaClamped ); - #endif - #endif - - // Output - float diffError = GetColorErrorForAdaptiveRadiusScale( diffResult, smbDiffHistory, diffAccumSpeed ); - - gOut_Diff[ pixelPos ] = diffResult; - #ifdef REBLUR_SH - gOut_DiffSh[ pixelPos ] = diffShResult; - #endif - - // Fast history - float diffFastAccumSpeed = min( diffAccumSpeed, gMaxFastAccumulatedFrameNum ); - float diffFastNonLinearAccumSpeed = 1.0 / ( 1.0 + diffFastAccumSpeed ); - if( !diffHasData ) - diffFastNonLinearAccumSpeed *= lerp( 1.0 - gCheckerboardResolveAccumSpeed, 1.0, diffFastNonLinearAccumSpeed ); - - float diffFastResult = lerp( smbDiffFastHistory.x, GetLuma( diff ), diffFastNonLinearAccumSpeed ); - - gOut_DiffFast[ pixelPos ] = diffFastResult; - #else - float diffAccumSpeed = 0; - float diffError = 0; + checkerboardPos.xy >>= 1; #endif // Specular #ifdef REBLUR_SPECULAR + // Accumulation speed + float specHistoryConfidence = smbFootprintQuality; + if( gHasHistoryConfidence ) + specHistoryConfidence *= gIn_Spec_Confidence[ WithRectOrigin( pixelPos ) ]; + + smbSpecAccumSpeed *= lerp( specHistoryConfidence, 1.0, 1.0 / ( 1.0 + smbSpecAccumSpeed ) ); + smbSpecAccumSpeed = min( smbSpecAccumSpeed, gMaxAccumulatedFrameNum ); + + // Current bool specHasData = gSpecCheckerboard == 2 || checkerboard == gSpecCheckerboard; + uint2 specPos = pixelPos; #ifdef REBLUR_OCCLUSION - uint specShift = gSpecCheckerboard != 2 ? 1 : 0; - uint2 specPos = uint2( pixelPos.x >> specShift, pixelPos.y ) + gRectOrigin; - specPos.x = min( specPos.x, gRectSize.x * ( gSpecCheckerboard != 2 ? 0.5 : 1.0 ) - 1.0 ); - #else - uint2 specPos = pixelPos; + specPos.x >>= gSpecCheckerboard == 2 ? 0 : 1; #endif REBLUR_TYPE spec = gIn_Spec[ specPos ]; - #ifdef REBLUR_SH - float4 specSh = gIn_SpecSh[ specPos ]; - #endif // Checkerboard resolve // TODO: materialID support? #ifdef REBLUR_OCCLUSION - int3 specCheckerboardPos = pixelPos.xyx + int3( -1, 0, 1 ); - specCheckerboardPos.xz >>= specShift; - specCheckerboardPos.x = max( specCheckerboardPos.x, 0 ); - specCheckerboardPos.z = min( specCheckerboardPos.z, gRectSize.x * ( gSpecCheckerboard != 2 ? 0.5 : 1.0 ) - 1.0 ); - specCheckerboardPos += gRectOrigin.xyx; - - float s0 = gIn_Spec[ specCheckerboardPos.xy ]; - float s1 = gIn_Spec[ specCheckerboardPos.zy ]; - if( !specHasData ) { - spec *= saturate( 1.0 - wc.x - wc.y ); - spec += s0 * wc.x + s1 * wc.y; + float s0 = gIn_Spec[ checkerboardPos.xz ]; + float s1 = gIn_Spec[ checkerboardPos.yz ]; + + s0 = Denanify( wc.x, s0 ); + s1 = Denanify( wc.y, s1 ); + + spec = s0 * wc.x + s1 * wc.y; } #endif @@ -435,7 +317,7 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : // Curvature estimation along predicted motion ( tests 15, 40, 76, 133, 146, 147, 148 ) /* - TODO: curvature! (╯°□°)╯︵ ┻━┻ + TODO: curvature! (-_-) - by design: curvature = 0 on static objects if camera is static - quantization errors hurt - curvature on bumpy surfaces is just wrong, pulling virtual positions into a surface and introducing lags @@ -449,14 +331,14 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : { // IMPORTANT: this code allows to get non-zero parallax on objects attached to the camera float2 uvForZeroParallax = gOrthoMode == 0.0 ? smbPixelUv : pixelUv; - float2 deltaUv = STL::Geometry::GetScreenUv( gWorldToClipPrev, Xprev - gCameraDelta ) - uvForZeroParallax; + float2 deltaUv = STL::Geometry::GetScreenUv( gWorldToClipPrev, Xprev - gCameraDelta.xyz ) - uvForZeroParallax; deltaUv *= gRectSize; float deltaUvLen = length( deltaUv ); deltaUv /= max( deltaUvLen, 1.0 / 256.0 ); - float2 motionUv = pixelUv + 0.99 * deltaUv * gInvRectSize; // stay in SMEM + float2 motionUv = pixelUv + 0.99 * deltaUv * gRectSizeInv; // stay in SMEM // Construct the other edge point "x" - float z = abs( gIn_ViewZ.SampleLevel( gLinearClamp, gRectOffset + motionUv * gResolutionScale, 0 ) ); + float z = abs( gIn_ViewZ.SampleLevel( gLinearClamp, WithRectOffset( motionUv * gResolutionScale ), 0 ) ); float3 x = STL::Geometry::ReconstructViewPosition( motionUv, gFrustum, z, gOrthoMode ); x = STL::Geometry::RotateVector( gViewToWorld, x ); @@ -471,16 +353,16 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : float3 n01 = s_Normal_Roughness[ pos.y + 1 ][ pos.x ].xyz; float3 n11 = s_Normal_Roughness[ pos.y + 1 ][ pos.x + 1 ].xyz; - float3 n = normalize( STL::Filtering::ApplyBilinearFilter( n00, n10, n01, n11, f ) ); + float3 n = _NRD_SafeNormalize( STL::Filtering::ApplyBilinearFilter( n00, n10, n01, n11, f ) ); // ( Optional ) High parallax - flattens surface on high motion ( test 132, e9 ) // IMPORTANT: a must for 8-bit and 10-bit normals ( tests b7, b10, b33 ) float deltaUvLenFixed = deltaUvLen * ( NRD_USE_HIGH_PARALLAX_CURVATURE_SILHOUETTE_FIX ? NoV : 1.0 ); // it fixes silhouettes, but leads to less flattening - float2 motionUvHigh = pixelUv + deltaUvLenFixed * deltaUv * gInvRectSize; - if( NRD_USE_HIGH_PARALLAX_CURVATURE && deltaUvLenFixed > 1.0 && IsInScreen( motionUvHigh ) ) + float2 motionUvHigh = pixelUv + deltaUvLenFixed * deltaUv * gRectSizeInv; + if( NRD_USE_HIGH_PARALLAX_CURVATURE && deltaUvLenFixed > 1.0 && IsInScreenNearest( motionUvHigh ) ) { // Construct the other edge point "xHigh" - float zHigh = abs( gIn_ViewZ.SampleLevel( gLinearClamp, gRectOffset + motionUvHigh * gResolutionScale, 0 ) ); + float zHigh = abs( gIn_ViewZ.SampleLevel( gLinearClamp, WithRectOffset( motionUvHigh * gResolutionScale ), 0 ) ); float3 xHigh = STL::Geometry::ReconstructViewPosition( motionUvHigh, gFrustum, zHigh, gOrthoMode ); xHigh = STL::Geometry::RotateVector( gViewToWorld, xHigh ); @@ -488,17 +370,17 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : #if( NRD_NORMAL_ENCODING == NRD_NORMAL_ENCODING_R10G10B10A2_UNORM ) f = STL::Filtering::GetBilinearFilter( motionUvHigh, gRectSize ); + f.origin = clamp( f.origin, 0, gRectSize - 2.0 ); pos = gRectOrigin + int2( f.origin ); - pos = clamp( pos, 0, int2( gRectSize ) - 2 ); n00 = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pos ] ).xyz; n10 = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pos + int2( 1, 0 ) ] ).xyz; n01 = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pos + int2( 0, 1 ) ] ).xyz; n11 = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pos + int2( 1, 1 ) ] ).xyz; - float3 nHigh = normalize( STL::Filtering::ApplyBilinearFilter( n00, n10, n01, n11, f ) ); + float3 nHigh = _NRD_SafeNormalize( STL::Filtering::ApplyBilinearFilter( n00, n10, n01, n11, f ) ); #else - float3 nHigh = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness.SampleLevel( gLinearClamp, gRectOffset + motionUvHigh * gResolutionScale, 0 ) ).xyz; + float3 nHigh = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness.SampleLevel( gLinearClamp, WithRectOffset( motionUvHigh * gResolutionScale ), 0 ) ).xyz; #endif // Replace if same surface @@ -523,7 +405,7 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : float2 uv1 = STL::Geometry::GetScreenUv( gWorldToClipPrev, X - V * ApplyThinLensEquation( NoV, hitDistForTracking, curvature ) ); float2 uv2 = STL::Geometry::GetScreenUv( gWorldToClipPrev, X ); float a = length( ( uv1 - uv2 ) * gRectSize ); - curvature *= float( a < 3.0 * deltaUvLen + gInvRectSize.x ); // TODO:it's a hack, incompatible with concave mirrors ( tests 22b, 23b, 25b ) + curvature *= float( a < 3.0 * deltaUvLen + gRectSizeInv.x ); // TODO:it's a hack, incompatible with concave mirrors ( tests 22b, 23b, 25b ) // Smooth virtual motion delta ( omitting huge values if curvature is negative and curvature radius is very small ) float3 Xvirtual = GetXvirtual( NoV, hitDistForTracking, max( curvature, 0.0 ), X, Xprev, V, Dfactor ); @@ -553,31 +435,39 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : // Virtual motion - roughness STL::Filtering::Bilinear vmbBilinearFilter = STL::Filtering::GetBilinearFilter( vmbPixelUv, gRectSizePrev ); - float2 vmbBilinearGatherUv = ( vmbBilinearFilter.origin + 1.0 ) * gInvScreenSize; + float2 vmbBilinearGatherUv = ( vmbBilinearFilter.origin + 1.0 ) * gResourceSizeInvPrev; float2 relaxedRoughnessWeightParams = GetRelaxedRoughnessWeightParams( roughness * roughness, gRoughnessFraction, roughnessSensitivity ); float4 vmbRoughness = gIn_Prev_Normal_Roughness.GatherAlpha( gNearestClamp, vmbBilinearGatherUv ).wzxy; float4 roughnessWeight = ComputeNonExponentialWeightWithSigma( vmbRoughness * vmbRoughness, relaxedRoughnessWeightParams.x, relaxedRoughnessWeightParams.y, roughnessSigma ); roughnessWeight = lerp( STL::Math::SmoothStep( 1.0, 0.0, smbParallaxInPixels ), 1.0, roughnessWeight ); // jitter friendly float virtualHistoryRoughnessBasedConfidence = STL::Filtering::ApplyBilinearFilter( roughnessWeight.x, roughnessWeight.y, roughnessWeight.z, roughnessWeight.w, vmbBilinearFilter ); + // Virtual motion - normal: parallax ( test 132 ) + float4 vmbNormalAndRoughness = UnpackNormalAndRoughness( gIn_Prev_Normal_Roughness.SampleLevel( gLinearClamp, vmbPixelUv * gResolutionScalePrev, 0 ) ); + float3 vmbN = STL::Geometry::RotateVector( gWorldPrevToWorld, vmbNormalAndRoughness.xyz ); + + float hitDist = ExtractHitDist( spec ) * _REBLUR_GetHitDistanceNormalization( viewZ, gHitDistParams, roughness ); + float parallaxEstimation = smbParallaxInPixels * GetHitDistFactor( hitDist, frustumSize ); + float virtualHistoryNormalBasedConfidence = 1.0 / ( 1.0 + 0.5 * Dfactor * saturate( length( N - vmbN ) - NRD_NORMAL_ULP ) * max( parallaxEstimation, vmbPixelsTraveled ) ); + // Virtual motion - disocclusion: plane distance and roughness - // IMPORTANT: use "Navg" in this test to avoid false reaction on bumpy surfaces ( test 181 ) - float4 vmbViewZs = UnpackViewZ( gIn_Prev_ViewZ.GatherRed( gNearestClamp, vmbBilinearGatherUv ).wzxy ); - float4 vmbBilinearFilterMask = IsInScreen2x2( vmbBilinearFilter.origin, gRectSizePrev ); float4 vmbOcclusionThreshold = disocclusionThresholdMulFrustumSize; - vmbOcclusionThreshold *= vmbBilinearFilterMask; + vmbOcclusionThreshold *= lerp( 0.05, 1.0, NoV ); // yes, "*" not "/" + vmbOcclusionThreshold *= float( dot( vmbN, N ) > 0.0 ); // TODO: Navg? + vmbOcclusionThreshold *= IsInScreenBilinear( vmbBilinearFilter.origin, gRectSizePrev ); vmbOcclusionThreshold -= NRD_EPS; + float4 vmbViewZ = UnpackViewZ( gIn_Prev_ViewZ.GatherRed( gNearestClamp, vmbBilinearGatherUv ).wzxy ); float3 vmbVv = STL::Geometry::ReconstructViewPosition( vmbPixelUv, gFrustumPrev, 1.0 ); // unnormalized, orthoMode = 0 - float3 Nvprev = STL::Geometry::RotateVector( gWorldToViewPrev, Navg ); - float NoXreal = dot( Navg, X - gCameraDelta ); - float4 NoX = ( Nvprev.x * vmbVv.x + Nvprev.y * vmbVv.y ) * ( gOrthoMode == 0 ? vmbViewZs : gOrthoMode ) + Nvprev.z * vmbVv.z * vmbViewZs; - float4 vmbPlaneDist = abs( NoX - NoXreal ); + float3 vmbV = STL::Geometry::RotateVectorInverse( gWorldToViewPrev, vmbVv ); + float NoXcurr = dot( N, X - gCameraDelta.xyz ); + float4 NoXprev = ( N.x * vmbV.x + N.y * vmbV.y ) * ( gOrthoMode == 0 ? vmbViewZ : gOrthoMode ) + N.z * vmbV.z * vmbViewZ; + float4 vmbPlaneDist = abs( NoXprev - NoXcurr ); float4 vmbOcclusion = step( vmbPlaneDist, vmbOcclusionThreshold ); vmbOcclusion *= step( 0.5, roughnessWeight ); bool vmbAllowCatRom = dot( vmbOcclusion, 1.0 ) > 3.5 && REBLUR_USE_CATROM_FOR_VIRTUAL_MOTION_IN_TA; - vmbAllowCatRom = vmbAllowCatRom && specAllowCatRom; // helps to reduce over-sharpening in disoccluded areas + vmbAllowCatRom = vmbAllowCatRom && smbAllowCatRom; // helps to reduce over-sharpening in disoccluded areas // Bits fbits += vmbOcclusion.x * 16.0; @@ -600,23 +490,11 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : vmbFootprintQuality = STL::Math::Sqrt01( vmbFootprintQuality ); vmbSpecAccumSpeed *= lerp( vmbFootprintQuality, 1.0, 1.0 / ( 1.0 + vmbSpecAccumSpeed ) ); - // Virtual motion - normal: parallax ( test 132 ) - float4 vmbNormalAndRoughness = UnpackNormalAndRoughness( gIn_Prev_Normal_Roughness.SampleLevel( gLinearClamp, vmbPixelUv * gResolutionScalePrev, 0 ) ); - float3 vmbN = STL::Geometry::RotateVector( gWorldPrevToWorld, vmbNormalAndRoughness.xyz ); - - float hitDist = ExtractHitDist( spec ) * _REBLUR_GetHitDistanceNormalization( viewZ, gHitDistParams, roughness ); - float parallaxEstimation = smbParallaxInPixels * GetHitDistFactor( hitDist, frustumSize ); - float virtualHistoryNormalBasedConfidence = 1.0 / ( 1.0 + 0.5 * Dfactor * saturate( length( N - vmbN ) - NRD_NORMAL_ULP ) * max( parallaxEstimation, vmbPixelsTraveled ) ); - // Virtual motion - normal: lobe overlapping ( test 107 ) float normalWeight = GetEncodingAwareNormalWeight( N, vmbN, lobeHalfAngle, curvatureAngle ); normalWeight = lerp( STL::Math::SmoothStep( 1.0, 0.0, vmbPixelsTraveled ), 1.0, normalWeight ); // jitter friendly virtualHistoryNormalBasedConfidence = min( virtualHistoryNormalBasedConfidence, normalWeight ); - // Virtual motion - normal: front-facing - bool isFrontFace = dot( vmbN, Navg ) > 0.0; - virtualHistoryNormalBasedConfidence *= float( isFrontFace ); - // Virtual history amount - normal confidence ( tests 9e, 65, 66, 107, 111, 132 ) // IMPORTANT: this is currently needed for bumpy surfaces, because virtual motion gets ruined by big curvature float virtualHistoryAmount = virtualHistoryNormalBasedConfidence; @@ -664,7 +542,7 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : w.x = GetEncodingAwareNormalWeight( vmbNormalAndRoughness.xyz, vmbNormalAndRoughnessPrev.xyz, lobeHalfAngle, curvatureAngle * ( 1.0 + i * stepBetweenTaps ) ); w.y = ComputeNonExponentialWeightWithSigma( vmbNormalAndRoughnessPrev.w * vmbNormalAndRoughnessPrev.w, relaxedRoughnessWeightParams.x, relaxedRoughnessWeightParams.y, roughnessSigma ); - w = IsInScreen( vmbPixelUvPrev ) ? w : 1.0; + w = IsInScreenNearest( vmbPixelUvPrev ) ? w : 1.0; virtualHistoryNormalBasedConfidence = min( virtualHistoryNormalBasedConfidence, w.x ); virtualHistoryRoughnessBasedConfidence = min( virtualHistoryRoughnessBasedConfidence, w.y ); @@ -730,8 +608,8 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : REBLUR_SH_TYPE smbSpecShHistory; BicubicFilterNoCornersWithFallbackToBilinearFilterWithCustomWeights( - saturate( smbPixelUv ) * gRectSizePrev, gInvScreenSize, - specOcclusionWeights, specAllowCatRom, + saturate( smbPixelUv ) * gRectSizePrev, gResourceSizeInvPrev, + smbOcclusionWeights, smbAllowCatRom, gIn_Spec_History, smbSpecHistory, gIn_SpecFast_History, smbSpecFastHistory #ifdef REBLUR_SH @@ -744,7 +622,7 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : REBLUR_SH_TYPE vmbSpecShHistory; BicubicFilterNoCornersWithFallbackToBilinearFilterWithCustomWeights( - saturate( vmbPixelUv ) * gRectSizePrev, gInvScreenSize, + saturate( vmbPixelUv ) * gRectSizePrev, gResourceSizeInvPrev, vmbOcclusionWeights, vmbAllowCatRom, gIn_Spec_History, vmbSpecHistory, gIn_SpecFast_History, vmbSpecFastHistory @@ -757,7 +635,7 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : smbSpecHistory = ClampNegativeToZero( smbSpecHistory ); vmbSpecHistory = ClampNegativeToZero( vmbSpecHistory ); - // Accumulation with checkerboard resolve // TODO: materialID support? + // Accumulation float smbSpecNonLinearAccumSpeed = 1.0 / ( 1.0 + smbSpecAccumSpeedNoBoost ); float vmbSpecNonLinearAccumSpeed = 1.0 / ( 1.0 + vmbSpecAccumSpeed ); @@ -773,6 +651,7 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : REBLUR_TYPE specResult = lerp( smbSpec, vmbSpec, virtualHistoryAmount ); #ifdef REBLUR_SH + float4 specSh = gIn_SpecSh[ specPos ]; float4 smbShSpec = lerp( smbSpecShHistory, specSh, smbSpecNonLinearAccumSpeed ); float4 vmbShSpec = lerp( vmbSpecShHistory, specSh, vmbSpecNonLinearAccumSpeed ); @@ -862,9 +741,117 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : #endif // Output - gOut_Data1[ pixelPos ] = PackData1( diffAccumSpeed, diffError, specAccumSpeed, specError ); - #ifndef REBLUR_OCCLUSION gOut_Data2[ pixelPos ] = PackData2( fbits, curvature, virtualHistoryAmount ); #endif + + // Diffuse + #ifdef REBLUR_DIFFUSE + // Accumulation speed + float diffHistoryConfidence = smbFootprintQuality; + if( gHasHistoryConfidence ) + diffHistoryConfidence *= gIn_Diff_Confidence[ WithRectOrigin( pixelPos ) ]; + + diffAccumSpeed *= lerp( diffHistoryConfidence, 1.0, 1.0 / ( 1.0 + diffAccumSpeed ) ); + diffAccumSpeed = min( diffAccumSpeed, gMaxAccumulatedFrameNum ); + + // Current + bool diffHasData = gDiffCheckerboard == 2 || checkerboard == gDiffCheckerboard; + uint2 diffPos = pixelPos; + #ifdef REBLUR_OCCLUSION + diffPos.x >>= gDiffCheckerboard == 2 ? 0 : 1; + #endif + + REBLUR_TYPE diff = gIn_Diff[ diffPos ]; + + // Checkerboard resolve // TODO: materialID support? + #ifdef REBLUR_OCCLUSION + if( !diffHasData ) + { + float d0 = gIn_Diff[ checkerboardPos.xz ]; + float d1 = gIn_Diff[ checkerboardPos.yz ]; + + d0 = Denanify( wc.x, d0 ); + d1 = Denanify( wc.y, d1 ); + + diff = d0 * wc.x + d1 * wc.y; + } + #endif + + // Sample history - surface motion + REBLUR_TYPE smbDiffHistory; + REBLUR_FAST_TYPE smbDiffFastHistory; + REBLUR_SH_TYPE smbDiffShHistory; + + BicubicFilterNoCornersWithFallbackToBilinearFilterWithCustomWeights( + saturate( smbPixelUv ) * gRectSizePrev, gResourceSizeInvPrev, + smbOcclusionWeights, smbAllowCatRom, + gIn_Diff_History, smbDiffHistory, + gIn_DiffFast_History, smbDiffFastHistory + #ifdef REBLUR_SH + , gIn_DiffSh_History, smbDiffShHistory + #endif + ); + + // Avoid negative values + smbDiffHistory = ClampNegativeToZero( smbDiffHistory ); + + // Accumulation + float diffNonLinearAccumSpeed = 1.0 / ( 1.0 + diffAccumSpeed ); + if( !diffHasData ) + diffNonLinearAccumSpeed *= lerp( 1.0 - gCheckerboardResolveAccumSpeed, 1.0, diffNonLinearAccumSpeed ); + + REBLUR_TYPE diffResult = MixHistoryAndCurrent( smbDiffHistory, diff, diffNonLinearAccumSpeed ); + #ifdef REBLUR_SH + float4 diffSh = gIn_DiffSh[ diffPos ]; + float4 diffShResult = MixHistoryAndCurrent( smbDiffShHistory, diffSh, diffNonLinearAccumSpeed ); + #endif + + // Anti-firefly suppressor + float diffAntifireflyFactor = diffAccumSpeed * gBlurRadius * REBLUR_FIREFLY_SUPPRESSOR_RADIUS_SCALE; + diffAntifireflyFactor /= 1.0 + diffAntifireflyFactor; + + float diffHitDistResult = ExtractHitDist( diffResult ); + float diffHitDistClamped = min( diffHitDistResult, ExtractHitDist( smbDiffHistory ) * REBLUR_FIREFLY_SUPPRESSOR_MAX_RELATIVE_INTENSITY.y ); + diffHitDistClamped = lerp( diffHitDistResult, diffHitDistClamped, diffAntifireflyFactor ); + + #if( defined REBLUR_OCCLUSION || defined REBLUR_DIRECTIONAL_OCCLUSION ) + diffResult = ChangeLuma( diffResult, diffHitDistClamped ); + #else + float diffLumaResult = GetLuma( diffResult ); + float diffLumaClamped = min( diffLumaResult, GetLuma( smbDiffHistory ) * REBLUR_FIREFLY_SUPPRESSOR_MAX_RELATIVE_INTENSITY.x ); + diffLumaClamped = lerp( diffLumaResult, diffLumaClamped, diffAntifireflyFactor ); + + diffResult = ChangeLuma( diffResult, diffLumaClamped ); + diffResult.w = diffHitDistClamped; + + #ifdef REBLUR_SH + diffShResult.xyz *= GetLumaScale( length( diffShResult.xyz ), diffLumaClamped ); + #endif + #endif + + // Output + float diffError = GetColorErrorForAdaptiveRadiusScale( diffResult, smbDiffHistory, diffAccumSpeed ); + + gOut_Diff[ pixelPos ] = diffResult; + #ifdef REBLUR_SH + gOut_DiffSh[ pixelPos ] = diffShResult; + #endif + + // Fast history + float diffFastAccumSpeed = min( diffAccumSpeed, gMaxFastAccumulatedFrameNum ); + float diffFastNonLinearAccumSpeed = 1.0 / ( 1.0 + diffFastAccumSpeed ); + if( !diffHasData ) + diffFastNonLinearAccumSpeed *= lerp( 1.0 - gCheckerboardResolveAccumSpeed, 1.0, diffFastNonLinearAccumSpeed ); + + float diffFastResult = lerp( smbDiffFastHistory.x, GetLuma( diff ), diffFastNonLinearAccumSpeed ); + + gOut_DiffFast[ pixelPos ] = diffFastResult; + #else + float diffAccumSpeed = 0; + float diffError = 0; + #endif + + // Output + gOut_Data1[ pixelPos ] = PackData1( diffAccumSpeed, diffError, specAccumSpeed, specError ); } diff --git a/Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_TemporalStabilization.hlsli b/Shaders/Include/REBLUR_TemporalStabilization.hlsli similarity index 91% rename from Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_TemporalStabilization.hlsli rename to Shaders/Include/REBLUR_TemporalStabilization.hlsli index b3d2ad9..0e8147b 100644 --- a/Shaders/Include/REBLUR/REBLUR_DiffuseSpecular_TemporalStabilization.hlsli +++ b/Shaders/Include/REBLUR_TemporalStabilization.hlsli @@ -20,7 +20,7 @@ groupshared float4 s_Spec[ BUFFER_Y ][ BUFFER_X ]; void Preload( uint2 sharedPos, int2 globalPos ) { - globalPos = clamp( globalPos, 0, gRectSize - 1.0 ); + globalPos = clamp( globalPos, 0, gRectSizeMinusOne ); #ifdef REBLUR_DIFFUSE s_Diff[ sharedPos.y ][ sharedPos.x ] = gIn_Diff[ globalPos ]; @@ -40,29 +40,27 @@ void Preload( uint2 sharedPos, int2 globalPos ) [numthreads( GROUP_X, GROUP_Y, 1 )] NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : SV_DispatchThreadId, uint threadIndex : SV_GroupIndex ) { - uint2 pixelPosUser = gRectOrigin + pixelPos; - float2 pixelUv = float2( pixelPos + 0.5 ) * gInvRectSize; - // Preload float isSky = gIn_Tiles[ pixelPos >> 4 ]; PRELOAD_INTO_SMEM_WITH_TILE_CHECK; // Tile-based early out - if( isSky != 0.0 || pixelPos.x >= gRectSize.x || pixelPos.y >= gRectSize.y ) + if( isSky != 0.0 || any( pixelPos > gRectSizeMinusOne ) ) return; // Early out - float viewZ = UnpackViewZ( gIn_ViewZ[ pixelPosUser ] ); + float viewZ = UnpackViewZ( gIn_ViewZ[ WithRectOrigin( pixelPos ) ] ); if( viewZ > gDenoisingRange ) return; // IMPORTANT: no data output, must be rejected by the "viewZ" check! // Normal and roughness float materialID; - float4 normalAndRoughness = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pixelPosUser ], materialID ); + float4 normalAndRoughness = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ WithRectOrigin( pixelPos ) ], materialID ); float3 N = normalAndRoughness.xyz; float roughness = normalAndRoughness.w; // Position + float2 pixelUv = float2( pixelPos + 0.5 ) * gRectSizeInv; float3 Xv = STL::Geometry::ReconstructViewPosition( pixelUv, gFrustum, viewZ, gOrthoMode ); float3 X = STL::Geometry::RotateVector( gViewToWorld, Xv ); @@ -199,24 +197,25 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : #endif // Previous position and surface motion uv - float4 inMv = gInOut_Mv[ pixelPosUser ]; - float3 mv = inMv.xyz * gMvScale; - if( gMvScale.z == 0.0 ) - mv.z = STL::Geometry::AffineTransform( gWorldToViewPrev, X ).z - viewZ; - + float4 inMv = gInOut_Mv[ WithRectOrigin( pixelPos ) ]; + float3 mv = inMv.xyz * gMvScale.xyz; float3 Xprev = X; float2 smbPixelUv = pixelUv + mv.xy; - if( gIsWorldSpaceMotionEnabled ) + + if( gMvScale.w != 0.0 ) { Xprev += mv; smbPixelUv = STL::Geometry::GetScreenUv( gWorldToClipPrev, Xprev ); } else { + if( gMvScale.z == 0.0 ) + mv.z = STL::Geometry::AffineTransform( gWorldToViewPrev, X ).z - viewZ; + float viewZprev = viewZ + mv.z; float3 Xvprevlocal = STL::Geometry::ReconstructViewPosition( smbPixelUv, gFrustumPrev, viewZprev, gOrthoMode ); // TODO: use gOrthoModePrev - Xprev = STL::Geometry::RotateVectorInverse( gWorldToViewPrev, Xvprevlocal ) + gCameraDelta; + Xprev = STL::Geometry::RotateVectorInverse( gWorldToViewPrev, Xvprevlocal ) + gCameraDelta.xyz; } // Shared data @@ -241,7 +240,7 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : REBLUR_SH_TYPE smbDiffShHistory; BicubicFilterNoCornersWithFallbackToBilinearFilterWithCustomWeights( - saturate( smbPixelUv ) * gRectSizePrev, gInvScreenSize, + saturate( smbPixelUv ) * gRectSizePrev, gResourceSizeInvPrev, smbOcclusionWeights, smbAllowCatRom, gIn_Diff_StabilizedHistory, smbDiffHistory #ifdef REBLUR_SH @@ -305,38 +304,37 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : float2 vmbPixelUv = STL::Geometry::GetScreenUv( gWorldToClipPrev, Xvirtual ); // Modify MVs if requested - if( gSpecularProbabilityThresholdsForMvModification.x < 1.0 ) + if( gSpecProbabilityThresholdsForMvModification.x < 1.0 ) { - float4 baseColorMetalness = gIn_BaseColor_Metalness[ pixelPos ]; + float4 baseColorMetalness = gIn_BaseColor_Metalness[ WithRectOrigin( pixelPos ) ]; float3 albedo, Rf0; STL::BRDF::ConvertBaseColorMetalnessToAlbedoRf0( baseColorMetalness.xyz, baseColorMetalness.w, albedo, Rf0 ); float3 Fenv = STL::BRDF::EnvironmentTerm_Rtg( Rf0, NoV, roughness ); - float lumSpec = STL::Color::Luminance( Fenv ); + float lumSpec = STL::Color::Luminance( Fenv ) * virtualHistoryAmount; float lumDiff = STL::Color::Luminance( albedo * ( 1.0 - Fenv ) ); float specProb = lumSpec / ( lumDiff + lumSpec + NRD_EPS ); - float f = STL::Math::SmoothStep( gSpecularProbabilityThresholdsForMvModification.x, gSpecularProbabilityThresholdsForMvModification.y, specProb ); - f *= virtualHistoryAmount; - - if( f != 0.0 ) + STL::Rng::Hash::Initialize( pixelPos, gFrameIndex ); + float f = STL::Math::SmoothStep( gSpecProbabilityThresholdsForMvModification.x, gSpecProbabilityThresholdsForMvModification.y, specProb ); + if( STL::Rng::Hash::GetFloat( ) < f ) { float3 specMv = Xvirtual - X; // TODO: world-space delta fits badly into FP16 - if( !gIsWorldSpaceMotionEnabled ) + if( gMvScale.w == 0.0 ) { specMv.xy = vmbPixelUv - pixelUv; specMv.z = STL::Geometry::AffineTransform( gWorldToViewPrev, Xvirtual ).z - viewZ; // TODO: is it useful? } - mv = lerp( mv, specMv, f ); + mv = specMv; // Modify only .xy for 2D and .xyz for 2.5D and 3D MVs inMv.xy = mv.xy / gMvScale.xy; inMv.z = gMvScale.z == 0.0 ? inMv.z : mv.z / gMvScale.z; - gInOut_Mv[ pixelPosUser ] = inMv; + gInOut_Mv[ WithRectOrigin( pixelPos ) ] = inMv; } } @@ -345,7 +343,7 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : REBLUR_SH_TYPE smbSpecShHistory; BicubicFilterNoCornersWithFallbackToBilinearFilterWithCustomWeights( - saturate( smbPixelUv ) * gRectSizePrev, gInvScreenSize, + saturate( smbPixelUv ) * gRectSizePrev, gResourceSizeInvPrev, smbOcclusionWeights, smbAllowCatRom, gIn_Spec_StabilizedHistory, smbSpecHistory #ifdef REBLUR_SH @@ -366,7 +364,7 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : REBLUR_SH_TYPE vmbSpecShHistory; BicubicFilterNoCornersWithFallbackToBilinearFilterWithCustomWeights( - saturate( vmbPixelUv ) * gRectSizePrev, gInvScreenSize, + saturate( vmbPixelUv ) * gRectSizePrev, gResourceSizeInvPrev, vmbOcclusionWeights, vmbAllowCatRom, gIn_Spec_StabilizedHistory, vmbSpecHistory #ifdef REBLUR_SH diff --git a/Shaders/Include/RELAX/RELAX_Config.hlsli b/Shaders/Include/RELAX/RELAX_Config.hlsli deleted file mode 100644 index ea729a7..0000000 --- a/Shaders/Include/RELAX/RELAX_Config.hlsli +++ /dev/null @@ -1,58 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -#define RELAX_BLACK_OUT_INF_PIXELS 0 // 1 can be used to set colors of the pixels located beyond denoising range to zero -#define RELAX_MAX_ACCUM_FRAME_NUM 255 -#define RELAX_SPEC_DOMINANT_DIRECTION STL_SPECULAR_DOMINANT_DIRECTION_G2 -#define RELAX_HIT_DIST_MIN_WEIGHT 0.2 // Sacrifices spatial fidelity to improve temporal stability. Should be set to 0 for relatively clean input signals like RTXDI and 0.1 .. 0.2 for lower quality input signals -#define RELAX_ANTILAG_ACCELERATION_AMOUNT_SCALE 10.0 // Multiplier used to put RelaxAntilagSettings::accelerationAmount to convenient [0; 1] range - -// Shared constants common to all ReLAX denoisers -#define RELAX_SHARED_CB_DATA \ - NRD_CONSTANT( float4x4, gPrevWorldToClip ) \ - NRD_CONSTANT( float4x4, gPrevWorldToView ) \ - NRD_CONSTANT( float4x4, gWorldToClip ) \ - NRD_CONSTANT( float4x4, gWorldPrevToWorld ) \ - NRD_CONSTANT( float4x4, gViewToWorld ) \ - NRD_CONSTANT( float4, gFrustumRight ) \ - NRD_CONSTANT( float4, gFrustumUp ) \ - NRD_CONSTANT( float4, gFrustumForward ) \ - NRD_CONSTANT( float4, gPrevFrustumRight ) \ - NRD_CONSTANT( float4, gPrevFrustumUp ) \ - NRD_CONSTANT( float4, gPrevFrustumForward ) \ - NRD_CONSTANT( float4, gPrevCameraPosition ) \ - NRD_CONSTANT( float3, gMvScale ) \ - NRD_CONSTANT( float, gDebug ) \ - NRD_CONSTANT( float2, gResolutionScale) \ - NRD_CONSTANT( uint2, gRectOrigin ) \ - NRD_CONSTANT( float2, gRectOffset ) \ - NRD_CONSTANT( uint2, gRectSize ) \ - NRD_CONSTANT( float2, gInvResourceSize ) \ - NRD_CONSTANT( float2, gInvRectSize ) \ - NRD_CONSTANT( float2, gRectSizePrev ) \ - NRD_CONSTANT( uint, gIsWorldSpaceMotionEnabled ) \ - NRD_CONSTANT( float, gOrthoMode ) \ - NRD_CONSTANT( float, gUnproject ) \ - NRD_CONSTANT( uint, gFrameIndex ) \ - NRD_CONSTANT( float, gDenoisingRange ) \ - NRD_CONSTANT( float, gFramerateScale ) \ - NRD_CONSTANT( float, gCheckerboardResolveAccumSpeed ) \ - NRD_CONSTANT( float, gJitterDelta ) \ - NRD_CONSTANT( uint, gDiffMaterialMask ) \ - NRD_CONSTANT( uint, gSpecMaterialMask ) \ - NRD_CONSTANT( uint, gUseWorldPrevToWorld ) \ - NRD_CONSTANT( uint, gResetHistory ) \ - NRD_CONSTANT( uint, unused2 ) \ - NRD_CONSTANT( uint, unused3 ) - -#if( !defined RELAX_DIFFUSE && !defined RELAX_SPECULAR ) - #define RELAX_DIFFUSE - #define RELAX_SPECULAR -#endif \ No newline at end of file diff --git a/Shaders/Include/RELAX/RELAX_DiffuseSpecular_AntiFirefly.hlsli b/Shaders/Include/RELAX_AntiFirefly.hlsli similarity index 94% rename from Shaders/Include/RELAX/RELAX_DiffuseSpecular_AntiFirefly.hlsli rename to Shaders/Include/RELAX_AntiFirefly.hlsli index 57e990d..95771dc 100644 --- a/Shaders/Include/RELAX/RELAX_DiffuseSpecular_AntiFirefly.hlsli +++ b/Shaders/Include/RELAX_AntiFirefly.hlsli @@ -9,14 +9,14 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. */ #ifdef RELAX_SPECULAR - groupshared float4 sharedSpecular[BUFFER_X][BUFFER_Y]; + groupshared float4 sharedSpecular[BUFFER_Y][BUFFER_X]; #endif #ifdef RELAX_DIFFUSE - groupshared float4 sharedDiffuse[BUFFER_X][BUFFER_Y]; + groupshared float4 sharedDiffuse[BUFFER_Y][BUFFER_X]; #endif - groupshared float sharedMaterialID[BUFFER_X][BUFFER_Y]; + groupshared float sharedMaterialID[BUFFER_Y][BUFFER_X]; // Helper functions void Preload(uint2 sharedPos, int2 globalPos) @@ -28,11 +28,11 @@ void Preload(uint2 sharedPos, int2 globalPos) sharedMaterialID[sharedPos.y][sharedPos.x] = materialID; #ifdef RELAX_SPECULAR - sharedSpecular[sharedPos.y][sharedPos.x] = gSpecularIllumination[globalPos]; + sharedSpecular[sharedPos.y][sharedPos.x] = gSpecIllumination[globalPos]; #endif #ifdef RELAX_DIFFUSE - sharedDiffuse[sharedPos.y][sharedPos.x] = gDiffuseIllumination[globalPos]; + sharedDiffuse[sharedPos.y][sharedPos.x] = gDiffIllumination[globalPos]; #endif } @@ -166,7 +166,7 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPo PRELOAD_INTO_SMEM_WITH_TILE_CHECK; // Tile-based early out - if (isSky != 0.0) + if (isSky != 0.0 || pixelPos.x >= gRectSize.x || pixelPos.y >= gRectSize.y) return; // Early out if linearZ is beyond denoising range diff --git a/Shaders/Include/RELAX/RELAX_DiffuseSpecular_Atrous.hlsli b/Shaders/Include/RELAX_Atrous.hlsli similarity index 84% rename from Shaders/Include/RELAX/RELAX_DiffuseSpecular_Atrous.hlsli rename to Shaders/Include/RELAX_Atrous.hlsli index 05ddcec..fbed426 100644 --- a/Shaders/Include/RELAX/RELAX_DiffuseSpecular_Atrous.hlsli +++ b/Shaders/Include/RELAX_Atrous.hlsli @@ -13,33 +13,13 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId) { // Tile-based early out float isSky = gTiles[pixelPos >> 4]; - if (isSky != 0.0) - { -#if( RELAX_BLACK_OUT_INF_PIXELS == 1 ) -#ifdef RELAX_SPECULAR - gOutSpecularIlluminationAndVariance[pixelPos] = 0; -#endif -#ifdef RELAX_DIFFUSE - gOutDiffuseIlluminationAndVariance[pixelPos] = 0; -#endif -#endif + if (isSky != 0.0 || pixelPos.x >= gRectSize.x || pixelPos.y >= gRectSize.y) return; - } // Early out if linearZ is beyond denoising range float centerViewZ = abs(gViewZ[pixelPos]); if (centerViewZ > gDenoisingRange) - { -#if( RELAX_BLACK_OUT_INF_PIXELS == 1 ) -#ifdef RELAX_SPECULAR - gOutSpecularIlluminationAndVariance[pixelPos] = 0; -#endif -#ifdef RELAX_DIFFUSE - gOutDiffuseIlluminationAndVariance[pixelPos] = 0; -#endif -#endif return; - } float centerMaterialID; float4 centerNormalRoughness = NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness[pixelPos], centerMaterialID); @@ -49,28 +29,28 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId) // Diffuse normal weight is used for diffuse and can be used for specular depending on settings. // Weight strictness is higher as the Atrous step size increases. - float diffuseLobeAngleFraction = gDiffuseLobeAngleFraction / sqrt(gStepSize); + float diffuseLobeAngleFraction = gDiffLobeAngleFraction / sqrt(gStepSize); #ifdef RELAX_SH diffuseLobeAngleFraction = 1.0 / sqrt(gStepSize); #endif diffuseLobeAngleFraction = lerp(0.99, diffuseLobeAngleFraction, saturate(historyLength / 5.0)); #ifdef RELAX_SPECULAR - float4 centerSpecularIlluminationAndVariance = gSpecularIlluminationAndVariance[pixelPos]; + float4 centerSpecularIlluminationAndVariance = gSpecIlluminationAndVariance[pixelPos]; float centerSpecularLuminance = STL::Color::Luminance(centerSpecularIlluminationAndVariance.rgb); float centerSpecularVar = centerSpecularIlluminationAndVariance.a; - float specularReprojectionConfidence = gSpecularReprojectionConfidence[pixelPos]; + float specularReprojectionConfidence = gSpecReprojectionConfidence[pixelPos]; float specularLuminanceWeightRelaxation = 1.0; if (gStepSize <= 4) specularLuminanceWeightRelaxation = lerp(1.0, specularReprojectionConfidence, gLuminanceEdgeStoppingRelaxation); - float specularPhiLIlluminationInv = 1.0 / max(1.0e-4, gSpecularPhiLuminance * sqrt(centerSpecularVar)); + float specularPhiLIlluminationInv = 1.0 / max(1.0e-4, gSpecPhiLuminance * sqrt(centerSpecularVar)); float2 roughnessWeightParams = GetRoughnessWeightParams(centerRoughness, gRoughnessFraction); float diffuseLobeAngleFractionForSimplifiedSpecularNormalWeight = diffuseLobeAngleFraction; - float specularLobeAngleFraction = gSpecularLobeAngleFraction; + float specularLobeAngleFraction = gSpecLobeAngleFraction; if (gUseConfidenceInputs != 0) { @@ -95,22 +75,22 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId) specularReprojectionConfidence, gNormalEdgeStoppingRelaxation, specularLobeAngleFraction, - gSpecularLobeAngleSlack); + gSpecLobeAngleSlack); float sumWSpecular = 0.44198 * 0.44198; float4 sumSpecularIlluminationAndVariance = centerSpecularIlluminationAndVariance * float4(sumWSpecular.xxx, sumWSpecular * sumWSpecular); #ifdef RELAX_SH - float4 centerSpecularSH1 = gSpecularSH1[pixelPos]; + float4 centerSpecularSH1 = gSpecSH1[pixelPos]; float4 sumSpecularSH1 = centerSpecularSH1 * sumWSpecular; float roughnessModified = centerSpecularSH1.w; #endif #endif #ifdef RELAX_DIFFUSE - float4 centerDiffuseIlluminationAndVariance = gDiffuseIlluminationAndVariance[pixelPos]; + float4 centerDiffuseIlluminationAndVariance = gDiffIlluminationAndVariance[pixelPos]; float centerDiffuseLuminance = STL::Color::Luminance(centerDiffuseIlluminationAndVariance.rgb); float centerDiffuseVar = centerDiffuseIlluminationAndVariance.a; - float diffusePhiLIlluminationInv = 1.0 / max(1.0e-4, gDiffusePhiLuminance * sqrt(centerDiffuseVar)); + float diffusePhiLIlluminationInv = 1.0 / max(1.0e-4, gDiffPhiLuminance * sqrt(centerDiffuseVar)); float diffuseLuminanceWeightRelaxation = 1.0; if (gUseConfidenceInputs != 0) @@ -131,7 +111,7 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId) float sumWDiffuse = 0.44198 * 0.44198; float4 sumDiffuseIlluminationAndVariance = centerDiffuseIlluminationAndVariance * float4(sumWDiffuse.xxx, sumWDiffuse * sumWDiffuse); #ifdef RELAX_SH - float4 centerDiffuseSH1 = gDiffuseSH1[pixelPos]; + float4 centerDiffuseSH1 = gDiffSH1[pixelPos]; float4 sumDiffuseSH1 = centerDiffuseSH1 * sumWDiffuse; #endif #endif @@ -161,7 +141,7 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId) continue; bool isInside = all(p >= int2(0, 0)) && all(p < int2(gRectSize)); - float kernel = isInside ? kernelWeightGaussian3x3[abs(xx)] * kernelWeightGaussian3x3[abs(yy)] : 0.0; + float kernel = kernelWeightGaussian3x3[abs(xx)] * kernelWeightGaussian3x3[abs(yy)]; // Fetching normal, roughness, linear Z float sampleMaterialID; @@ -176,6 +156,7 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId) // Calculating geometry weight for diffuse and specular float geometryW = GetPlaneDistanceWeight_Atrous(centerWorldPos, centerNormal, sampleWorldPos, depthThreshold); geometryW *= kernel; + geometryW *= float(isInside && sampleViewZ < gDenoisingRange); #ifdef RELAX_SPECULAR // Getting sample view vector closer to center view vector @@ -194,18 +175,18 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId) wSpecular *= CompareMaterials(sampleMaterialID, centerMaterialID, gSpecMaterialMask); if (wSpecular > 1e-4) { - float4 sampleSpecularIlluminationAndVariance = gSpecularIlluminationAndVariance[p]; + float4 sampleSpecularIlluminationAndVariance = gSpecIlluminationAndVariance[p]; float sampleSpecularLuminance = STL::Color::Luminance(sampleSpecularIlluminationAndVariance.rgb); float specularLuminanceW = abs(centerSpecularLuminance - sampleSpecularLuminance) * specularPhiLIlluminationInv; - specularLuminanceW = min(gMaxSpecularLuminanceRelativeDifference, specularLuminanceW); + specularLuminanceW = min(gSpecMaxLuminanceRelativeDifference, specularLuminanceW); specularLuminanceW *= specularLuminanceWeightRelaxation; wSpecular *= exp(-specularLuminanceW); - sumSpecularIlluminationAndVariance += float4(wSpecular.xxx, wSpecular * wSpecular) * sampleSpecularIlluminationAndVariance; sumWSpecular += wSpecular; + sumSpecularIlluminationAndVariance += float4(wSpecular.xxx, wSpecular * wSpecular) * sampleSpecularIlluminationAndVariance; #ifdef RELAX_SH - sumSpecularSH1 += gSpecularSH1[p] * wSpecular; + sumSpecularSH1 += gSpecSH1[p] * wSpecular; #endif } #endif @@ -220,20 +201,19 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId) wDiffuse *= CompareMaterials(sampleMaterialID, centerMaterialID, gDiffMaterialMask); if (wDiffuse > 1e-4) { - float4 sampleDiffuseIlluminationAndVariance = gDiffuseIlluminationAndVariance[p]; + float4 sampleDiffuseIlluminationAndVariance = gDiffIlluminationAndVariance[p]; float sampleDiffuseLuminance = STL::Color::Luminance(sampleDiffuseIlluminationAndVariance.rgb); float diffuseLuminanceW = abs(centerDiffuseLuminance - sampleDiffuseLuminance) * diffusePhiLIlluminationInv; - diffuseLuminanceW = min(gMaxDiffuseLuminanceRelativeDifference, diffuseLuminanceW); + diffuseLuminanceW = min(gDiffMaxLuminanceRelativeDifference, diffuseLuminanceW); if (gUseConfidenceInputs != 0) - { diffuseLuminanceW *= diffuseLuminanceWeightRelaxation; - } wDiffuse *= exp(-diffuseLuminanceW); - sumDiffuseIlluminationAndVariance += float4(wDiffuse.xxx, wDiffuse * wDiffuse) * sampleDiffuseIlluminationAndVariance; + sumWDiffuse += wDiffuse; + sumDiffuseIlluminationAndVariance += float4(wDiffuse.xxx, wDiffuse * wDiffuse) * sampleDiffuseIlluminationAndVariance; #ifdef RELAX_SH - sumDiffuseSH1 += gDiffuseSH1[p] * wDiffuse; + sumDiffuseSH1 += gDiffSH1[p] * wDiffuse; #endif } #endif @@ -245,9 +225,7 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId) #ifdef RELAX_SH // Luminance output is expected in YCoCg color space in SH mode, converting to YCoCg in last A-Trous pass if (gIsLastPass == 1) - { filteredSpecularIlluminationAndVariance.rgb = _NRD_LinearToYCoCg(filteredSpecularIlluminationAndVariance.rgb); - } gOutSpecularSH1[pixelPos] = float4(sumSpecularSH1.rgb / sumWSpecular, roughnessModified); #endif gOutSpecularIlluminationAndVariance[pixelPos] = filteredSpecularIlluminationAndVariance; @@ -258,9 +236,7 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId) #ifdef RELAX_SH // Luminance output is expected in YCoCg color space in SH mode, converting to YCoCg in last A-Trous pass if (gIsLastPass == 1) - { filteredDiffuseIlluminationAndVariance.rgb = _NRD_LinearToYCoCg(filteredDiffuseIlluminationAndVariance.rgb); - } gOutDiffuseSH1[pixelPos] = sumDiffuseSH1 / sumWDiffuse; #endif gOutDiffuseIlluminationAndVariance[pixelPos] = filteredDiffuseIlluminationAndVariance; diff --git a/Shaders/Include/RELAX/RELAX_DiffuseSpecular_AtrousSmem.hlsli b/Shaders/Include/RELAX_AtrousSmem.hlsli similarity index 92% rename from Shaders/Include/RELAX/RELAX_DiffuseSpecular_AtrousSmem.hlsli rename to Shaders/Include/RELAX_AtrousSmem.hlsli index 216dcfd..6bc10a3 100644 --- a/Shaders/Include/RELAX/RELAX_DiffuseSpecular_AtrousSmem.hlsli +++ b/Shaders/Include/RELAX_AtrousSmem.hlsli @@ -9,21 +9,21 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. */ #ifdef RELAX_DIFFUSE - groupshared float4 sharedDiffuse[BUFFER_X][BUFFER_Y]; + groupshared float4 sharedDiffuse[BUFFER_Y][BUFFER_X]; #ifdef RELAX_SH - groupshared float4 sharedDiffuseSH1[BUFFER_X][BUFFER_Y]; + groupshared float4 sharedDiffuseSH1[BUFFER_Y][BUFFER_X]; #endif #endif #ifdef RELAX_SPECULAR - groupshared float4 sharedSpecular[BUFFER_X][BUFFER_Y]; + groupshared float4 sharedSpecular[BUFFER_Y][BUFFER_X]; #ifdef RELAX_SH - groupshared float4 sharedSpecularSH1[BUFFER_X][BUFFER_Y]; + groupshared float4 sharedSpecularSH1[BUFFER_Y][BUFFER_X]; #endif #endif -groupshared float4 sharedNormalRoughness[BUFFER_X][BUFFER_Y]; -groupshared float4 sharedWorldPosMaterialID[BUFFER_X][BUFFER_Y]; +groupshared float4 sharedNormalRoughness[BUFFER_Y][BUFFER_X]; +groupshared float4 sharedWorldPosMaterialID[BUFFER_Y][BUFFER_X]; // Helper functions @@ -88,16 +88,16 @@ void Preload(uint2 sharedPos, int2 globalPos) globalPos = clamp(globalPos, 0, gRectSize - 1.0); #ifdef RELAX_SPECULAR - sharedSpecular[sharedPos.y][sharedPos.x] = gSpecularIlluminationAnd2ndMoment[globalPos]; + sharedSpecular[sharedPos.y][sharedPos.x] = gSpecIlluminationAnd2ndMoment[globalPos]; #ifdef RELAX_SH - sharedSpecularSH1[sharedPos.y][sharedPos.x] = gSpecularSH1[globalPos]; + sharedSpecularSH1[sharedPos.y][sharedPos.x] = gSpecSH1[globalPos]; #endif #endif #ifdef RELAX_DIFFUSE - sharedDiffuse[sharedPos.y][sharedPos.x] = gDiffuseIlluminationAnd2ndMoment[globalPos]; + sharedDiffuse[sharedPos.y][sharedPos.x] = gDiffIlluminationAnd2ndMoment[globalPos]; #ifdef RELAX_SH - sharedDiffuseSH1[sharedPos.y][sharedPos.x] = gDiffuseSH1[globalPos]; + sharedDiffuseSH1[sharedPos.y][sharedPos.x] = gDiffSH1[globalPos]; #endif #endif float materialID; @@ -137,7 +137,7 @@ NRD_EXPORT void NRD_CS_MAIN(int2 pixelPos : SV_DispatchThreadId, uint2 threadPos #endif // Tile-based early out - if (isSky != 0.0) + if (isSky != 0.0 || pixelPos.x >= (int)gRectSize.x || pixelPos.y >= (int)gRectSize.y) return; // Early out if linearZ is beyond denoising range @@ -150,7 +150,7 @@ NRD_EXPORT void NRD_CS_MAIN(int2 pixelPos : SV_DispatchThreadId, uint2 threadPos float historyLength = 255.0 * gHistoryLength[pixelPos]; [branch] - if (historyLength >= float(gHistoryThreshold)) // Running Atrous 3x3 + if (historyLength >= gHistoryThreshold) // Running Atrous 3x3 { // Calculating variance, filtered using 3x3 gaussin blur #ifdef RELAX_SPECULAR @@ -170,18 +170,18 @@ NRD_EXPORT void NRD_CS_MAIN(int2 pixelPos : SV_DispatchThreadId, uint2 threadPos ); // Diffuse normal weight is used for diffuse and can be used for specular depending on settings. - float diffuseLobeAngleFraction = gDiffuseLobeAngleFraction; + float diffuseLobeAngleFraction = gDiffLobeAngleFraction; #ifdef RELAX_SPECULAR - float specularReprojectionConfidence = gSpecularReprojectionConfidence[pixelPos]; + float specularReprojectionConfidence = gSpecReprojectionConfidence[pixelPos]; float specularLuminanceWeightRelaxation = lerp(1.0, specularReprojectionConfidence, gLuminanceEdgeStoppingRelaxation); float centerSpecularLuminance = STL::Color::Luminance(sharedSpecular[sharedMemoryIndex.y][sharedMemoryIndex.x].rgb); - float specularPhiLIlluminationInv = 1.0 / max(1.0e-4, gSpecularPhiLuminance * sqrt(centerSpecularVar)); + float specularPhiLIlluminationInv = 1.0 / max(1.0e-4, gSpecPhiLuminance * sqrt(centerSpecularVar)); float2 roughnessWeightParams = GetRoughnessWeightParams(centerRoughness, gRoughnessFraction); float diffuseLobeAngleFractionForSimplifiedSpecularNormalWeight = diffuseLobeAngleFraction; - float specularLobeAngleFraction = gSpecularLobeAngleFraction; + float specularLobeAngleFraction = gSpecLobeAngleFraction; if (gUseConfidenceInputs != 0) { @@ -206,7 +206,7 @@ NRD_EXPORT void NRD_CS_MAIN(int2 pixelPos : SV_DispatchThreadId, uint2 threadPos specularReprojectionConfidence, gNormalEdgeStoppingRelaxation, specularLobeAngleFraction, - gSpecularLobeAngleSlack); + gSpecLobeAngleSlack); float sumWSpecular = 0; float4 sumSpecularIlluminationAnd2ndMoment = 0; @@ -219,7 +219,7 @@ NRD_EXPORT void NRD_CS_MAIN(int2 pixelPos : SV_DispatchThreadId, uint2 threadPos #ifdef RELAX_DIFFUSE float centerDiffuseLuminance = STL::Color::Luminance(sharedDiffuse[sharedMemoryIndex.y][sharedMemoryIndex.x].rgb); - float diffusePhiLIlluminationInv = 1.0 / max(1.0e-4, gDiffusePhiLuminance * sqrt(centerDiffuseVar)); + float diffusePhiLIlluminationInv = 1.0 / max(1.0e-4, gDiffPhiLuminance * sqrt(centerDiffuseVar)); float diffuseLuminanceWeightRelaxation = 1.0; if (gUseConfidenceInputs != 0) @@ -255,7 +255,7 @@ NRD_EXPORT void NRD_CS_MAIN(int2 pixelPos : SV_DispatchThreadId, uint2 threadPos { const int2 p = pixelPos + int2(cx, cy); const bool isCenter = ((cx == 0) && (cy == 0)); - const bool isInside = all(p >= int2(0, 0)) && all(p < int2(gResourceSize)); + const bool isInside = all(p >= 0) && all(p < int2(gRectSize)); const float kernel = isInside ? kernelWeightGaussian3x3[abs(cx)] * kernelWeightGaussian3x3[abs(cy)] : 0.0; int2 sharedMemoryIndexP = sharedMemoryIndex + int2(cx, cy); @@ -294,7 +294,7 @@ NRD_EXPORT void NRD_CS_MAIN(int2 pixelPos : SV_DispatchThreadId, uint2 threadPos float sampleSpecularLuminance = STL::Color::Luminance(sampleSpecularIlluminationAnd2ndMoment.rgb); float specularLuminanceW = abs(centerSpecularLuminance - sampleSpecularLuminance) * specularPhiLIlluminationInv; - specularLuminanceW = min(gMaxSpecularLuminanceRelativeDifference, specularLuminanceW); + specularLuminanceW = min(gSpecMaxLuminanceRelativeDifference, specularLuminanceW); specularLuminanceW *= specularLuminanceWeightRelaxation; float wSpecular = geometryW * exp(-specularLuminanceW); @@ -305,7 +305,7 @@ NRD_EXPORT void NRD_CS_MAIN(int2 pixelPos : SV_DispatchThreadId, uint2 threadPos sumWSpecular += wSpecular; sumSpecularIlluminationAnd2ndMoment += wSpecular * sampleSpecularIlluminationAnd2ndMoment; #ifdef RELAX_SH - sumSpecularSH1 += wSpecular * sharedSpecularSH1[sharedMemoryIndexP.y][sharedMemoryIndexP.x];; + sumSpecularSH1 += wSpecular * sharedSpecularSH1[sharedMemoryIndexP.y][sharedMemoryIndexP.x]; #endif #endif #ifdef RELAX_DIFFUSE @@ -318,11 +318,10 @@ NRD_EXPORT void NRD_CS_MAIN(int2 pixelPos : SV_DispatchThreadId, uint2 threadPos float sampleDiffuseLuminance = STL::Color::Luminance(sampleDiffuseIlluminationAnd2ndMoment.rgb); float diffuseLuminanceW = abs(centerDiffuseLuminance - sampleDiffuseLuminance) * diffusePhiLIlluminationInv; - diffuseLuminanceW = min(gMaxDiffuseLuminanceRelativeDifference, diffuseLuminanceW); + diffuseLuminanceW = min(gDiffMaxLuminanceRelativeDifference, diffuseLuminanceW); if (gUseConfidenceInputs != 0) - { diffuseLuminanceW *= diffuseLuminanceWeightRelaxation; - } + float wDiffuse = geometryW * normalWDiffuse * exp(-diffuseLuminanceW); wDiffuse = isCenter ? kernel : wDiffuse; wDiffuse *= CompareMaterials(sampleMaterialID, centerMaterialID, gDiffMaterialMask); @@ -330,7 +329,7 @@ NRD_EXPORT void NRD_CS_MAIN(int2 pixelPos : SV_DispatchThreadId, uint2 threadPos sumWDiffuse += wDiffuse; sumDiffuseIlluminationAnd2ndMoment += wDiffuse * sampleDiffuseIlluminationAnd2ndMoment; #ifdef RELAX_SH - sumDiffuseSH1 += wDiffuse * sharedDiffuseSH1[sharedMemoryIndexP.y][sharedMemoryIndexP.x];; + sumDiffuseSH1 += wDiffuse * sharedDiffuseSH1[sharedMemoryIndexP.y][sharedMemoryIndexP.x]; #endif #endif } @@ -384,7 +383,7 @@ NRD_EXPORT void NRD_CS_MAIN(int2 pixelPos : SV_DispatchThreadId, uint2 threadPos #endif // Normal weight is same for diffuse and specular during spatial variance estimation - float diffuseNormalWeightParams = GetNormalWeightParams(1.0, gDiffuseLobeAngleFraction); + float diffuseNormalWeightParams = GetNormalWeightParams(1.0, gDiffLobeAngleFraction); // Compute first and second moment spatially. This code also applies cross-bilateral // filtering on the input illumination. diff --git a/Shaders/Include/RELAX/RELAX_Common.hlsli b/Shaders/Include/RELAX_Common.hlsli similarity index 97% rename from Shaders/Include/RELAX/RELAX_Common.hlsli rename to Shaders/Include/RELAX_Common.hlsli index 2247d78..3b05c9d 100644 --- a/Shaders/Include/RELAX/RELAX_Common.hlsli +++ b/Shaders/Include/RELAX_Common.hlsli @@ -11,7 +11,7 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. float4 UnpackPrevNormalRoughness(float4 packedData) { float4 result; - result.rgb = normalize(packedData.rgb * 2.0 - 1.0); + result.rgb = _NRD_SafeNormalize(packedData.rgb * 2.0 - 1.0); result.a = packedData.a; return result; @@ -65,7 +65,7 @@ float4 BilinearWithCustomWeightsFloat4(Texture2D tex0, int2 position, fl float3 GetCurrentWorldPosFromPixelPos(int2 pixelPos, float viewZ) { - float2 clipSpaceXY = ((float2)pixelPos + float2(0.5, 0.5)) * gInvRectSize * 2.0 - 1.0; + float2 clipSpaceXY = ((float2)pixelPos + float2(0.5, 0.5)) * gRectSizeInv * 2.0 - 1.0; return (gOrthoMode == 0) ? viewZ * (gFrustumForward.xyz + gFrustumRight.xyz * clipSpaceXY.x - gFrustumUp.xyz * clipSpaceXY.y) : @@ -162,7 +162,7 @@ float GetNormalWeight(float3 Ncurr, float3 Nprev, float maxAngle) } void BicubicFilterNoCornersWithFallbackToBilinearFilterWithCustomWeights( - float2 samplePos, float2 invTextureSize, + float2 samplePos, float2 invResourceSize, float4 bilinearCustomWeights, bool useBicubic, Texture2D tex0, out float4 c0 ) { @@ -171,7 +171,7 @@ void BicubicFilterNoCornersWithFallbackToBilinearFilterWithCustomWeights( } void BicubicFilterNoCornersWithFallbackToBilinearFilterWithCustomWeights( - float2 samplePos, float2 invTextureSize, + float2 samplePos, float2 invResourceSize, float4 bilinearCustomWeights, bool useBicubic, Texture2D tex0, out float4 c0, Texture2D tex1, out float4 c1 ) diff --git a/Shaders/Include/RELAX_Config.hlsli b/Shaders/Include/RELAX_Config.hlsli new file mode 100644 index 0000000..6bb7440 --- /dev/null +++ b/Shaders/Include/RELAX_Config.hlsli @@ -0,0 +1,97 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#define RELAX + +// Settings +#define RELAX_MAX_ACCUM_FRAME_NUM 255 +#define RELAX_SPEC_DOMINANT_DIRECTION STL_SPECULAR_DOMINANT_DIRECTION_G2 // TODO: move to Common, change REBLUR too +#define RELAX_HIT_DIST_MIN_WEIGHT 0.2 // Sacrifices spatial fidelity to improve temporal stability. Should be set to 0 for relatively clean input signals like RTXDI and 0.1 .. 0.2 for lower quality input signals +#define RELAX_ANTILAG_ACCELERATION_AMOUNT_SCALE 10.0 // Multiplier used to put RelaxAntilagSettings::accelerationAmount to convenient [0; 1] range + +// Shared constants +#define RELAX_SHARED_CONSTANTS \ + NRD_CONSTANT( float4x4, gWorldToClipPrev ) \ + NRD_CONSTANT( float4x4, gWorldToViewPrev ) \ + NRD_CONSTANT( float4x4, gWorldPrevToWorld ) \ + NRD_CONSTANT( float4, gFrustumRight ) \ + NRD_CONSTANT( float4, gFrustumUp ) \ + NRD_CONSTANT( float4, gFrustumForward ) \ + NRD_CONSTANT( float4, gPrevFrustumRight ) \ + NRD_CONSTANT( float4, gPrevFrustumUp ) \ + NRD_CONSTANT( float4, gPrevFrustumForward ) \ + NRD_CONSTANT( float4, gCameraDelta ) \ + NRD_CONSTANT( float4, gMvScale ) \ + NRD_CONSTANT( float2, gJitter ) \ + NRD_CONSTANT( float2, gResolutionScale ) \ + NRD_CONSTANT( float2, gRectOffset ) \ + NRD_CONSTANT( float2, gResourceSizeInv ) \ + NRD_CONSTANT( float2, gResourceSize ) \ + NRD_CONSTANT( float2, gRectSizeInv ) \ + NRD_CONSTANT( float2, gRectSizePrev ) \ + NRD_CONSTANT( float2, gResourceSizeInvPrev ) \ + NRD_CONSTANT( uint2, gRectOrigin ) \ + NRD_CONSTANT( uint2, gRectSize ) \ + NRD_CONSTANT( float, gSpecMaxAccumulatedFrameNum ) \ + NRD_CONSTANT( float, gSpecMaxFastAccumulatedFrameNum ) \ + NRD_CONSTANT( float, gDiffMaxAccumulatedFrameNum ) \ + NRD_CONSTANT( float, gDiffMaxFastAccumulatedFrameNum ) \ + NRD_CONSTANT( float, gDisocclusionDepthThreshold ) \ + NRD_CONSTANT( float, gDisocclusionDepthThresholdAlternate ) \ + NRD_CONSTANT( float, gRoughnessFraction ) \ + NRD_CONSTANT( float, gSpecVarianceBoost ) \ + NRD_CONSTANT( float, gSplitScreen ) \ + NRD_CONSTANT( float, gDiffBlurRadius ) \ + NRD_CONSTANT( float, gSpecBlurRadius ) \ + NRD_CONSTANT( float, gDepthThreshold ) \ + NRD_CONSTANT( float, gDiffLobeAngleFraction ) \ + NRD_CONSTANT( float, gSpecLobeAngleFraction ) \ + NRD_CONSTANT( float, gSpecLobeAngleSlack ) \ + NRD_CONSTANT( float, gHistoryFixEdgeStoppingNormalPower ) \ + NRD_CONSTANT( float, gRoughnessEdgeStoppingRelaxation ) \ + NRD_CONSTANT( float, gNormalEdgeStoppingRelaxation ) \ + NRD_CONSTANT( float, gColorBoxSigmaScale ) \ + NRD_CONSTANT( float, gHistoryAccelerationAmount ) \ + NRD_CONSTANT( float, gHistoryResetTemporalSigmaScale ) \ + NRD_CONSTANT( float, gHistoryResetSpatialSigmaScale ) \ + NRD_CONSTANT( float, gHistoryResetAmount ) \ + NRD_CONSTANT( float, gDenoisingRange ) \ + NRD_CONSTANT( float, gSpecPhiLuminance ) \ + NRD_CONSTANT( float, gDiffPhiLuminance ) \ + NRD_CONSTANT( float, gDiffMaxLuminanceRelativeDifference ) \ + NRD_CONSTANT( float, gSpecMaxLuminanceRelativeDifference ) \ + NRD_CONSTANT( float, gLuminanceEdgeStoppingRelaxation ) \ + NRD_CONSTANT( float, gConfidenceDrivenRelaxationMultiplier ) \ + NRD_CONSTANT( float, gConfidenceDrivenLuminanceEdgeStoppingRelaxation ) \ + NRD_CONSTANT( float, gConfidenceDrivenNormalEdgeStoppingRelaxation ) \ + NRD_CONSTANT( float, gDebug ) \ + NRD_CONSTANT( float, gOrthoMode ) \ + NRD_CONSTANT( float, gUnproject ) \ + NRD_CONSTANT( float, gFramerateScale ) \ + NRD_CONSTANT( float, gCheckerboardResolveAccumSpeed ) \ + NRD_CONSTANT( float, gJitterDelta ) \ + NRD_CONSTANT( float, gHistoryFixFrameNum ) \ + NRD_CONSTANT( float, gHistoryThreshold ) \ + NRD_CONSTANT( uint, gRoughnessEdgeStoppingEnabled ) \ + NRD_CONSTANT( uint, gFrameIndex ) \ + NRD_CONSTANT( uint, gDiffCheckerboard ) \ + NRD_CONSTANT( uint, gSpecCheckerboard ) \ + NRD_CONSTANT( uint, gUseConfidenceInputs ) \ + NRD_CONSTANT( uint, gUseDisocclusionThresholdMix ) \ + NRD_CONSTANT( uint, gDiffMaterialMask ) \ + NRD_CONSTANT( uint, gSpecMaterialMask ) \ + NRD_CONSTANT( uint, gResetHistory ) + +#define gResolutionScalePrev ( gRectSizePrev * gResourceSizeInvPrev ) + +#if( !defined RELAX_DIFFUSE && !defined RELAX_SPECULAR ) + #define RELAX_DIFFUSE + #define RELAX_SPECULAR +#endif \ No newline at end of file diff --git a/Shaders/Include/RELAX/RELAX_DiffuseSpecular_Copy.hlsli b/Shaders/Include/RELAX_Copy.hlsli similarity index 71% rename from Shaders/Include/RELAX/RELAX_DiffuseSpecular_Copy.hlsli rename to Shaders/Include/RELAX_Copy.hlsli index 31d67e7..967858b 100644 --- a/Shaders/Include/RELAX/RELAX_DiffuseSpecular_Copy.hlsli +++ b/Shaders/Include/RELAX_Copy.hlsli @@ -9,13 +9,13 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. */ [numthreads( GROUP_X, GROUP_Y, 1 )] -NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPos : SV_GroupThreadId, uint threadIndex : SV_GroupIndex) +NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId) { #ifdef RELAX_SPECULAR - gOutSpecularIllumination[pixelPos.xy] = gSpecularIllumination[pixelPos.xy]; + gOutSpecularIllumination[pixelPos.xy] = gSpecIllumination[pixelPos.xy]; #endif #ifdef RELAX_DIFFUSE - gOutDiffuseIllumination[pixelPos.xy] = gDiffuseIllumination[pixelPos.xy]; + gOutDiffuseIllumination[pixelPos.xy] = gDiffIllumination[pixelPos.xy]; #endif } diff --git a/Shaders/Include/RELAX/RELAX_DiffuseSpecular_HistoryClamping.hlsli b/Shaders/Include/RELAX_HistoryClamping.hlsli similarity index 93% rename from Shaders/Include/RELAX/RELAX_DiffuseSpecular_HistoryClamping.hlsli rename to Shaders/Include/RELAX_HistoryClamping.hlsli index 5a1781f..2807271 100644 --- a/Shaders/Include/RELAX/RELAX_DiffuseSpecular_HistoryClamping.hlsli +++ b/Shaders/Include/RELAX_HistoryClamping.hlsli @@ -9,13 +9,13 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. */ #ifdef RELAX_SPECULAR - groupshared float4 sharedSpecularResponsiveYCoCg[GROUP_Y + BORDER * 2][GROUP_X + BORDER * 2]; - groupshared float4 sharedSpecularNoisyAnd2ndMoment[GROUP_Y + BORDER * 2][GROUP_X + BORDER * 2]; + groupshared float4 sharedSpecularResponsiveYCoCg[BUFFER_Y][BUFFER_X]; + groupshared float4 sharedSpecularNoisyAnd2ndMoment[BUFFER_Y][BUFFER_X]; #endif #ifdef RELAX_DIFFUSE - groupshared float4 sharedDiffuseNoisyAnd2ndMoment[GROUP_Y + BORDER * 2][GROUP_X + BORDER * 2]; - groupshared float4 sharedDiffuseResponsiveYCoCg[GROUP_Y + BORDER * 2][GROUP_X + BORDER * 2]; + groupshared float4 sharedDiffuseNoisyAnd2ndMoment[BUFFER_Y][BUFFER_X]; + groupshared float4 sharedDiffuseResponsiveYCoCg[BUFFER_Y][BUFFER_X]; #endif void Preload(uint2 sharedPos, int2 globalPos) @@ -23,7 +23,7 @@ void Preload(uint2 sharedPos, int2 globalPos) globalPos = clamp(globalPos, 0, gRectSize - 1.0); #ifdef RELAX_SPECULAR - float4 specularResponsive = gSpecularIlluminationResponsive[globalPos]; + float4 specularResponsive = gSpecIlluminationResponsive[globalPos]; sharedSpecularResponsiveYCoCg[sharedPos.y][sharedPos.x] = float4(STL::Color::LinearToYCoCg(specularResponsive.rgb), specularResponsive.a); float4 specularNoisy = gNoisySpecularIllumination[globalPos]; @@ -33,7 +33,7 @@ void Preload(uint2 sharedPos, int2 globalPos) #endif #ifdef RELAX_DIFFUSE - float4 diffuseResponsive = gDiffuseIlluminationResponsive[globalPos]; + float4 diffuseResponsive = gDiffIlluminationResponsive[globalPos]; sharedDiffuseResponsiveYCoCg[sharedPos.y][sharedPos.x] = float4(STL::Color::LinearToYCoCg(diffuseResponsive.rgb), diffuseResponsive.a); float4 diffuseNoisy = gNoisyDiffuseIllumination[globalPos]; @@ -50,7 +50,7 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPo PRELOAD_INTO_SMEM_WITH_TILE_CHECK; // Tile-based early out - if (isSky != 0.0) + if (isSky != 0.0 || pixelPos.x >= gRectSize.x || pixelPos.y >= gRectSize.y) return; // Reading history length @@ -119,10 +119,10 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPo specularResponsiveColorMaxYCoCg = max(specularResponsiveColorMaxYCoCg, specularResponsiveCenterYCoCg.rgb); // Clamping color with color box expansion - float4 specularIlluminationAnd2ndMoment = gSpecularIllumination[pixelPos]; + float4 specularIlluminationAnd2ndMoment = gSpecIllumination[pixelPos]; float3 specularYCoCg = STL::Color::LinearToYCoCg(specularIlluminationAnd2ndMoment.rgb); float3 clampedSpecularYCoCg = specularYCoCg; - if (gSpecFastHistory) + if (gSpecMaxFastAccumulatedFrameNum < gSpecMaxAccumulatedFrameNum) clampedSpecularYCoCg = clamp(specularYCoCg, specularResponsiveColorMinYCoCg, specularResponsiveColorMaxYCoCg); float3 clampedSpecular = STL::Color::YCoCgToLinear(clampedSpecularYCoCg); @@ -188,7 +188,7 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPo float noisyspecularSpatialSigma = gHistoryResetSpatialSigmaScale * specularResponsiveSigmaYCoCg.x; float specularHistoryResetAmount = 0.5 * gHistoryResetAmount * max(0, abs(specularL - specularNoisyInputL) - noisyspecularSpatialSigma - noisyspecularTemporalSigma) / (1.0e-6 + max(specularL, specularNoisyInputL) + noisyspecularSpatialSigma + noisyspecularTemporalSigma); specularHistoryResetAmount = saturate(specularHistoryResetAmount); - + // Resetting history outSpecular.rgb = lerp(outSpecular.rgb, sharedSpecularNoisyAnd2ndMoment[sharedMemoryIndex.y][sharedMemoryIndex.x].rgb, specularHistoryResetAmount); outSpecularResponsive.rgb = lerp(outSpecularResponsive.rgb, sharedSpecularNoisyAnd2ndMoment[sharedMemoryIndex.y][sharedMemoryIndex.x].rgb, specularHistoryResetAmount); @@ -205,8 +205,8 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPo gOutSpecularIlluminationResponsive[pixelPos.xy] = outSpecularResponsive; #ifdef RELAX_SH - float4 specularSH1 = gSpecularSH1[pixelPos.xy]; - float4 specularResponsiveSH1 = gSpecularResponsiveSH1[pixelPos.xy]; + float4 specularSH1 = gSpecSH1[pixelPos.xy]; + float4 specularResponsiveSH1 = gSpecResponsiveSH1[pixelPos.xy]; gOutSpecularSH1[pixelPos.xy] = lerp(specularSH1, specularResponsiveSH1, specClampingFactor); gOutSpecularResponsiveSH1[pixelPos.xy] = specularResponsiveSH1; @@ -231,10 +231,10 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPo // Clamping color with color box expansion - float4 diffuseIlluminationAnd2ndMoment = gDiffuseIllumination[pixelPos]; + float4 diffuseIlluminationAnd2ndMoment = gDiffIllumination[pixelPos]; float3 diffuseYCoCg = STL::Color::LinearToYCoCg(diffuseIlluminationAnd2ndMoment.rgb); float3 clampedDiffuseYCoCg = diffuseYCoCg; - if (gDiffFastHistory) + if (gDiffMaxFastAccumulatedFrameNum < gDiffMaxAccumulatedFrameNum) clampedDiffuseYCoCg = clamp(diffuseYCoCg, diffuseResponsiveColorMinYCoCg, diffuseResponsiveColorMaxYCoCg); float3 clampedDiffuse = STL::Color::YCoCgToLinear(clampedDiffuseYCoCg); @@ -271,7 +271,7 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPo float diffuseColorDistanceToNoisyInputL = STL::Color::Luminance(abs(diffuseColorDistanceToNoisyInput)); - float3 diffuseColorAcceleration = (diffuseColorDistanceToNoisyInputL == 0) ? + float3 diffuseColorAcceleration = (diffuseColorDistanceToNoisyInputL == 0) ? 0.0 : diffuseColorDistanceToNoisyInput * diffuseHistoryDifferenceL / diffuseColorDistanceToNoisyInputL; // Preventing overshooting and noise amplification by making sure luminance of accelerated responsive history @@ -302,7 +302,7 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPo // Resetting history outDiffuse.rgb = lerp(outDiffuse.rgb, sharedDiffuseNoisyAnd2ndMoment[sharedMemoryIndex.y][sharedMemoryIndex.x].rgb, diffuseHistoryResetAmount); outDiffuseResponsive.rgb = lerp(outDiffuseResponsive.rgb, sharedDiffuseNoisyAnd2ndMoment[sharedMemoryIndex.y][sharedMemoryIndex.x].rgb, diffuseHistoryResetAmount); - + // 2nd moment correction float outDiffuseL = STL::Color::Luminance(outDiffuse.rgb); float diffuseMomentCorrection = (outDiffuseL * outDiffuseL - diffuseL * diffuseL); @@ -315,8 +315,8 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPo gOutDiffuseIlluminationResponsive[pixelPos.xy] = outDiffuseResponsive; #ifdef RELAX_SH - float4 diffuseSH1 = gDiffuseSH1[pixelPos.xy]; - float4 diffuseResponsiveSH1 = gDiffuseResponsiveSH1[pixelPos.xy]; + float4 diffuseSH1 = gDiffSH1[pixelPos.xy]; + float4 diffuseResponsiveSH1 = gDiffResponsiveSH1[pixelPos.xy]; gOutDiffuseSH1[pixelPos.xy] = lerp(diffuseSH1, diffuseResponsiveSH1, diffClampingFactor); gOutDiffuseResponsiveSH1[pixelPos.xy] = diffuseResponsiveSH1; diff --git a/Shaders/Include/RELAX/RELAX_DiffuseSpecular_HistoryFix.hlsli b/Shaders/Include/RELAX_HistoryFix.hlsli similarity index 86% rename from Shaders/Include/RELAX/RELAX_DiffuseSpecular_HistoryFix.hlsli rename to Shaders/Include/RELAX_HistoryFix.hlsli index 7e19347..1abd137 100644 --- a/Shaders/Include/RELAX/RELAX_DiffuseSpecular_HistoryFix.hlsli +++ b/Shaders/Include/RELAX_HistoryFix.hlsli @@ -14,26 +14,26 @@ float getDiffuseNormalWeight(float3 centerNormal, float3 pointNormal) return pow(max(0.01, dot(centerNormal, pointNormal)), max(gHistoryFixEdgeStoppingNormalPower, 0.01)); } -float getRadius(float numFramesInHistory) +float getRadius(float historyLength) { - return gHistoryFixStrideBetweenSamples / (numFramesInHistory + 1.0); + // IMPORTANT: progression is "{8, 4, 2, 1} + 1". "+1" is important to better break blobs + return exp2(gHistoryFixFrameNum - historyLength) + 1.0; } // Main [numthreads(GROUP_X, GROUP_Y, 1)] NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId) { - // Tile-based early out float isSky = gTiles[pixelPos >> 4]; - if (isSky != 0.0) + if (isSky != 0.0 || pixelPos.x >= gRectSize.x || pixelPos.y >= gRectSize.y) return; // Early out if linearZ is beyond denoising range // Early out if no disocclusion detected float centerViewZ = abs(gViewZ[pixelPos]); float historyLength = 255.0 * gHistoryLength[pixelPos]; - if ((centerViewZ > gDenoisingRange) || (historyLength > gHistoryFixFrameNum)) + if ((centerViewZ > gDenoisingRange) || (historyLength > gHistoryFixFrameNum || gHistoryFixFrameNum == 1.0)) return; // Loading center data @@ -46,16 +46,16 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId) float depthThreshold = gDepthThreshold * (gOrthoMode == 0 ? centerViewZ : 1.0); #ifdef RELAX_DIFFUSE - float4 diffuseIlluminationAnd2ndMomentSum = gDiffuseIllumination[pixelPos]; + float4 diffuseIlluminationAnd2ndMomentSum = gDiffIllumination[pixelPos]; #ifdef RELAX_SH - float4 diffuseSumSH1 = gDiffuseSH1[pixelPos]; + float4 diffuseSumSH1 = gDiffSH1[pixelPos]; #endif float diffuseWSum = 1; #endif #ifdef RELAX_SPECULAR - float4 specularIlluminationAnd2ndMomentSum = gSpecularIllumination[pixelPos]; + float4 specularIlluminationAnd2ndMomentSum = gSpecIllumination[pixelPos]; #ifdef RELAX_SH - float4 specularSumSH1 = gSpecularSH1[pixelPos]; + float4 specularSumSH1 = gSpecSH1[pixelPos]; float roughnessModified = specularSumSH1.w; #endif float specularWSum = 1; @@ -65,8 +65,8 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId) 5.0, // History length, 1.0, // Specular reprojection confidence 0.0, // Normal edge stopping relaxation - gSpecularLobeAngleFraction, - gSpecularLobeAngleSlack); + gSpecLobeAngleFraction, + gSpecLobeAngleSlack); #endif // Running sparse cross-bilateral filter @@ -106,10 +106,10 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId) if (diffuseW > 1e-4) { - float4 sampleDiffuseIlluminationAnd2ndMoment = gDiffuseIllumination[samplePosInt]; + float4 sampleDiffuseIlluminationAnd2ndMoment = gDiffIllumination[samplePosInt]; diffuseIlluminationAnd2ndMomentSum += sampleDiffuseIlluminationAnd2ndMoment * diffuseW; #ifdef RELAX_SH - float4 sampleDiffuseSH1 = gDiffuseSH1[samplePosInt]; + float4 sampleDiffuseSH1 = gDiffSH1[samplePosInt]; diffuseSumSH1 += sampleDiffuseSH1 * diffuseW; #endif diffuseWSum += diffuseW; @@ -117,23 +117,23 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId) #endif #ifdef RELAX_SPECULAR // Getting sample view vector closer to center view vector - // by adding gRoughnessEdgeStoppingRelaxation * centerWorldPos + // by adding gRoughnessEdgeStoppingRelaxation * centerWorldPos // relaxes view direction based rejection float3 sampleV = -normalize(sampleWorldPos + gRoughnessEdgeStoppingRelaxation * centerWorldPos); // Summing up specular result float specularW = geometryWeight; - specularW *= + specularW *= GetSpecularNormalWeight_ATrous(specularNormalWeightParams, centerNormal, sampleNormal, centerV, sampleV); specularW = isInside ? specularW : 0; specularW *= CompareMaterials(sampleMaterialID, centerMaterialID, gSpecMaterialMask); if (specularW > 1e-4) { - float4 sampleSpecularIlluminationAnd2ndMoment = gSpecularIllumination[samplePosInt]; + float4 sampleSpecularIlluminationAnd2ndMoment = gSpecIllumination[samplePosInt]; specularIlluminationAnd2ndMomentSum += sampleSpecularIlluminationAnd2ndMoment * specularW; #ifdef RELAX_SH - float4 sampleSpecularSH1 = gSpecularSH1[samplePosInt]; + float4 sampleSpecularSH1 = gSpecSH1[samplePosInt]; specularSumSH1 += sampleSpecularSH1 * specularW; #endif specularWSum += specularW; diff --git a/Shaders/Include/RELAX/RELAX_DiffuseSpecular_HitDistReconstruction.hlsli b/Shaders/Include/RELAX_HitDistReconstruction.hlsli similarity index 84% rename from Shaders/Include/RELAX/RELAX_DiffuseSpecular_HitDistReconstruction.hlsli rename to Shaders/Include/RELAX_HitDistReconstruction.hlsli index 6f2296d..457e1c3 100644 --- a/Shaders/Include/RELAX/RELAX_DiffuseSpecular_HitDistReconstruction.hlsli +++ b/Shaders/Include/RELAX_HitDistReconstruction.hlsli @@ -22,19 +22,18 @@ float GetNormalWeightParams(float nonLinearAccumSpeed, float fraction, float rou void Preload(uint2 sharedPos, int2 globalPos) { globalPos = clamp(globalPos, 0, gRectSize - 1.0); - uint2 globalIdUser = gRectOrigin + globalPos; // It's ok that we don't use materialID in Hitdist reconstruction - float4 normalRoughness = NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness[globalIdUser]); - float viewZ = abs(gViewZ[globalIdUser]); + float4 normalRoughness = NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness[WithRectOrigin(globalPos)]); + float viewZ = abs(gViewZ[WithRectOrigin(globalPos)]); float2 hitDist = gDenoisingRange; #ifdef RELAX_SPECULAR - hitDist.x = gSpecularIllumination[globalPos].w; + hitDist.x = gSpecIllumination[globalPos].w; #endif #ifdef RELAX_DIFFUSE - hitDist.y = gDiffuseIllumination[globalPos].w; + hitDist.y = gDiffIllumination[globalPos].w; #endif sharedNormalRoughness[sharedPos.y][sharedPos.x] = normalRoughness; @@ -44,15 +43,14 @@ void Preload(uint2 sharedPos, int2 globalPos) [numthreads( GROUP_X, GROUP_Y, 1 )] NRD_EXPORT void NRD_CS_MAIN(int2 threadPos : SV_GroupThreadId, int2 pixelPos : SV_DispatchThreadId, uint threadIndex : SV_GroupIndex) { - uint2 pixelPosUser = gRectOrigin + pixelPos; - float2 pixelUv = float2(pixelPos + 0.5) * gInvRectSize; + float2 pixelUv = float2(pixelPos + 0.5) * gRectSizeInv; // Preload float isSky = gTiles[pixelPos >> 4]; PRELOAD_INTO_SMEM_WITH_TILE_CHECK; // Tile-based early out - if (isSky != 0.0) + if (isSky != 0.0 || pixelPos.x >= (int)gRectSize.x || pixelPos.y >= (int)gRectSize.y) return; int2 smemPos = threadPos + BORDER; @@ -64,13 +62,13 @@ NRD_EXPORT void NRD_CS_MAIN(int2 threadPos : SV_GroupThreadId, int2 pixelPos : S return; // Center data - float4 normalAndRoughness = NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness[pixelPosUser]); + float4 normalAndRoughness = NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness[WithRectOrigin( pixelPos )]); float3 centerNormal = normalAndRoughness.xyz; float centerRoughness = normalAndRoughness.w; // Hit distance reconstruction #ifdef RELAX_SPECULAR - float3 centerSpecularIllumination = gSpecularIllumination[pixelPos].xyz; + float3 centerSpecularIllumination = gSpecIllumination[pixelPos].xyz; float centerSpecularHitDist = centerHitdistViewZ.x; float2 relaxedRoughnessWeightParams = GetRelaxedRoughnessWeightParams(centerRoughness * centerRoughness); float specularNormalWeightParam = GetNormalWeightParams(1.0, 1.0, centerRoughness); @@ -80,7 +78,7 @@ NRD_EXPORT void NRD_CS_MAIN(int2 threadPos : SV_GroupThreadId, int2 pixelPos : S #endif #ifdef RELAX_DIFFUSE - float3 centerDiffuseIllumination = gDiffuseIllumination[pixelPos].xyz; + float3 centerDiffuseIllumination = gDiffIllumination[pixelPos].xyz; float centerDiffuseHitDist = centerHitdistViewZ.y; float diffuseNormalWeightParam = GetNormalWeightParams(1.0, 1.0, 1.0); @@ -108,27 +106,35 @@ NRD_EXPORT void NRD_CS_MAIN(int2 threadPos : SV_GroupThreadId, int2 pixelPos : S float cosa = dot(centerNormal, sampleNormal); float angle = STL::Math::AcosApprox(cosa); - float w = IsInScreen(pixelUv + o * gInvRectSize); + float w = IsInScreenNearest(pixelUv + o * gRectSizeInv); + w *= float(sampleViewZ < gDenoisingRange); w *= GetGaussianWeight(length(o) * 0.5); w *= GetBilateralWeight(sampleViewZ, centerViewZ); #ifdef RELAX_SPECULAR - float sampleSpecularHitDist = sampleHitdistViewZ.x; float specularWeight = w; specularWeight *= ComputeExponentialWeight(angle, specularNormalWeightParam, 0.0); specularWeight *= ComputeExponentialWeight(normalAndRoughness.w * normalAndRoughness.w, relaxedRoughnessWeightParams.x, relaxedRoughnessWeightParams.y); + + float sampleSpecularHitDist = sampleHitdistViewZ.x; + sampleSpecularHitDist = Denanify( specularWeight, sampleSpecularHitDist ); + specularWeight *= float(sampleSpecularHitDist != 0.0); + sumSpecularHitDist += sampleSpecularHitDist * specularWeight; sumSpecularWeight += specularWeight; #endif #ifdef RELAX_DIFFUSE - float sampleDiffuseHitDist = sampleHitdistViewZ.y; float diffuseWeight = w; diffuseWeight *= ComputeExponentialWeight(angle, diffuseNormalWeightParam, 0.0); + + float sampleDiffuseHitDist = sampleHitdistViewZ.y; + sampleDiffuseHitDist = Denanify( diffuseWeight, sampleDiffuseHitDist ); + diffuseWeight *= float(sampleDiffuseHitDist != 0.0); - sumDiffuseHitDist += sampleDiffuseHitDist * diffuseWeight; + sumDiffuseHitDist += diffuseWeight == 0.0 ? 0.0 : sampleDiffuseHitDist * diffuseWeight; sumDiffuseWeight += diffuseWeight; #endif } diff --git a/Shaders/Include/RELAX/RELAX_DiffuseSpecular_PrePass.hlsli b/Shaders/Include/RELAX_PrePass.hlsli similarity index 56% rename from Shaders/Include/RELAX/RELAX_DiffuseSpecular_PrePass.hlsli rename to Shaders/Include/RELAX_PrePass.hlsli index 9261704..e113dcd 100644 --- a/Shaders/Include/RELAX/RELAX_DiffuseSpecular_PrePass.hlsli +++ b/Shaders/Include/RELAX_PrePass.hlsli @@ -11,120 +11,115 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define POISSON_SAMPLE_NUM 8 #define POISSON_SAMPLES g_Poisson8 -#ifdef RELAX_DIFFUSE -int2 DiffCheckerboard(int2 pos) -{ - int2 result = pos; - if (gDiffuseCheckerboard != 2) - result.x >>= 1; - - return result; -} -#endif - -#ifdef RELAX_SPECULAR -int2 SpecCheckerboard(int2 pos) -{ - int2 result = pos; - if (gSpecularCheckerboard != 2) - result.x >>= 1; - - return result; -} -#endif - [numthreads(GROUP_X, GROUP_Y, 1)] NRD_EXPORT void NRD_CS_MAIN(int2 pixelPos : SV_DispatchThreadId, uint2 threadPos : SV_GroupThreadId, uint threadIndex : SV_GroupIndex) { - // Calculating checkerboard fields - uint checkerboard = STL::Sequence::CheckerBoard(pixelPos, gFrameIndex); - // Tile-based early out float isSky = gTiles[pixelPos >> 4]; - if (isSky != 0.0) + if (isSky != 0.0 || pixelPos.x >= (int)gRectSize.x || pixelPos.y >= (int)gRectSize.y) return; // Early out if linearZ is beyond denoising range - float centerViewZ = abs(gViewZ[pixelPos + gRectOrigin]); + float centerViewZ = abs(gViewZ[WithRectOrigin(pixelPos)]); if (centerViewZ > gDenoisingRange) return; // Checkerboard resolve weights + uint checkerboard = STL::Sequence::CheckerBoard(pixelPos, gFrameIndex); + + int3 checkerboardPos = pixelPos.xxy + int3( -1, 1, 0 ); + checkerboardPos.x = max( checkerboardPos.x, 0 ); + checkerboardPos.y = min( checkerboardPos.y, gRectSize.x - 1 ); + + float materialID0 = 0; + float materialID1 = 0; float2 checkerboardResolveWeights = 1.0; #if( defined RELAX_DIFFUSE && defined RELAX_SPECULAR ) - if ((gSpecularCheckerboard != 2) || (gDiffuseCheckerboard != 2)) + if ((gSpecCheckerboard != 2) || (gDiffCheckerboard != 2)) #elif( defined RELAX_DIFFUSE ) - if (gDiffuseCheckerboard != 2) + if (gDiffCheckerboard != 2) #elif( defined RELAX_SPECULAR ) - if (gSpecularCheckerboard != 2) + if (gSpecCheckerboard != 2) #endif { - float viewZ0 = abs(gViewZ[pixelPos + int2(-1, 0) + gRectOrigin]); - float viewZ1 = abs(gViewZ[pixelPos + int2(1, 0) + gRectOrigin]); + float viewZ0 = abs(gViewZ[WithRectOrigin(checkerboardPos.xz)]); + float viewZ1 = abs(gViewZ[WithRectOrigin(checkerboardPos.yz)]); + + #if( NRD_NORMAL_ENCODING == NRD_NORMAL_ENCODING_R10G10B10A2_UNORM ) + NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness[WithRectOrigin(checkerboardPos.xz)], materialID0); + NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness[WithRectOrigin(checkerboardPos.yz)], materialID1); + #endif checkerboardResolveWeights = GetBilateralWeight(float2(viewZ0, viewZ1), centerViewZ); - checkerboardResolveWeights *= STL::Math::PositiveRcp(checkerboardResolveWeights.x + checkerboardResolveWeights.y); + checkerboardResolveWeights.x = (viewZ0 > gDenoisingRange || pixelPos.x < 1) ? 0.0 : checkerboardResolveWeights.x; + checkerboardResolveWeights.y = (viewZ1 > gDenoisingRange || pixelPos.x > (int)gRectSize.x - 2) ? 0.0 : checkerboardResolveWeights.y; } + checkerboardPos.xy >>= 1; + float centerMaterialID; - float4 centerNormalRoughness = NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness[pixelPos + gRectOrigin], centerMaterialID); + float4 centerNormalRoughness = NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness[WithRectOrigin(pixelPos)], centerMaterialID); float3 centerNormal = centerNormalRoughness.xyz; float centerRoughness = centerNormalRoughness.w; float3 centerWorldPos = GetCurrentWorldPosFromPixelPos(pixelPos, centerViewZ); float4 rotator = GetBlurKernelRotation(NRD_FRAME, pixelPos, gRotator, gFrameIndex); - float2 pixelUv = float2(pixelPos + 0.5) * gInvRectSize; + float2 pixelUv = float2(pixelPos + 0.5) * gRectSizeInv; #ifdef RELAX_DIFFUSE + bool diffHasData = true; + int2 diffPos = pixelPos; + if (gDiffCheckerboard != 2) + { + diffHasData = (checkerboard == gDiffCheckerboard); + diffPos.x >>= 1; + } + // Reading diffuse & resolving diffuse checkerboard - float4 diffuseIllumination = gDiffuseIllumination[DiffCheckerboard(pixelPos + gRectOrigin)]; + float4 diffuseIllumination = gDiffIllumination[diffPos]; #ifdef RELAX_SH - float4 diffuseSH1 = gDiffuseSH1[DiffCheckerboard(pixelPos + gRectOrigin)]; + float4 diffuseSH1 = gDiffSH1[diffPos]; #endif - bool diffHasData = true; - if (gDiffuseCheckerboard != 2) - diffHasData = (checkerboard == gDiffuseCheckerboard); - if (!diffHasData) { - float4 d0 = gDiffuseIllumination[DiffCheckerboard(pixelPos + int2(-1, 0) + gRectOrigin)]; - float4 d1 = gDiffuseIllumination[DiffCheckerboard(pixelPos + int2(1, 0) + gRectOrigin)]; - float2 diffCheckerboardResolveWeights = checkerboardResolveWeights; + float2 wc = checkerboardResolveWeights; #if( NRD_NORMAL_ENCODING == NRD_NORMAL_ENCODING_R10G10B10A2_UNORM ) - float materialID0; - float materialID1; - NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness[pixelPos + int2(-1, 0) + gRectOrigin], materialID0); - NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness[pixelPos + int2(1, 0) + gRectOrigin], materialID1); - diffCheckerboardResolveWeights.x *= CompareMaterials(centerMaterialID, materialID0, gDiffMaterialMask); - diffCheckerboardResolveWeights.y *= CompareMaterials(centerMaterialID, materialID1, gDiffMaterialMask); - diffCheckerboardResolveWeights *= STL::Math::PositiveRcp(diffCheckerboardResolveWeights.x + diffCheckerboardResolveWeights.y + 1.0e-4); + wc.x *= CompareMaterials(centerMaterialID, materialID0, gDiffMaterialMask); + wc.y *= CompareMaterials(centerMaterialID, materialID1, gDiffMaterialMask); #endif - diffuseIllumination *= saturate(1.0 - diffCheckerboardResolveWeights.x - diffCheckerboardResolveWeights.y); - diffuseIllumination += d0 * diffCheckerboardResolveWeights.x + d1 * diffCheckerboardResolveWeights.y; + wc *= STL::Math::PositiveRcp( wc.x + wc.y ); + + float4 d0 = gDiffIllumination[checkerboardPos.xz]; + float4 d1 = gDiffIllumination[checkerboardPos.yz]; + d0 = Denanify( wc.x, d0 ); + d1 = Denanify( wc.y, d1 ); + diffuseIllumination = d0 * wc.x + d1 * wc.y; + #ifdef RELAX_SH - float4 d0SH1 = gDiffuseSH1[DiffCheckerboard(pixelPos + int2(-1, 0) + gRectOrigin)]; - float4 d1SH1 = gDiffuseSH1[DiffCheckerboard(pixelPos + int2(1, 0) + gRectOrigin)]; - diffuseSH1 *= saturate(1.0 - diffCheckerboardResolveWeights.x - diffCheckerboardResolveWeights.y); - diffuseSH1 += d0SH1 * diffCheckerboardResolveWeights.x + d1SH1 * diffCheckerboardResolveWeights.y; + float4 d0SH1 = gDiffSH1[checkerboardPos.xz]; + float4 d1SH1 = gDiffSH1[checkerboardPos.yz]; + d0SH1 = Denanify( wc.x, d0SH1 ); + d1SH1 = Denanify( wc.y, d1SH1 ); + diffuseSH1 = d0SH1 * wc.x + d1SH1 * wc.y; #endif } // Pre-blur for diffuse - if (gDiffuseBlurRadius > 0) + if (gDiffBlurRadius > 0) { // Diffuse blur radius float frustumSize = PixelRadiusToWorld(gUnproject, gOrthoMode, min(gRectSize.x, gRectSize.y), centerViewZ); float hitDist = (diffuseIllumination.w == 0.0 ? 1.0 : diffuseIllumination.w); float hitDistFactor = GetHitDistFactor(hitDist, frustumSize); // NoD = 1 - float blurRadius = gDiffuseBlurRadius * hitDistFactor; + float blurRadius = gDiffBlurRadius * hitDistFactor; if (diffuseIllumination.w == 0.0) blurRadius = max(blurRadius, 1.0); float worldBlurRadius = PixelRadiusToWorld(gUnproject, gOrthoMode, blurRadius, centerViewZ) * min(gResolutionScale.x, gResolutionScale.y); - float normalWeightParams = GetNormalWeightParams(1.0, 0.25 * gDiffuseLobeAngleFraction); + float normalWeightParams = GetNormalWeightParams(1.0, 0.25 * gDiffLobeAngleFraction); float2 hitDistanceWeightParams = GetHitDistanceWeightParams(diffuseIllumination.w, 1.0 / 9.0); float weightSum = 1.0; @@ -138,24 +133,22 @@ NRD_EXPORT void NRD_CS_MAIN(int2 pixelPos : SV_DispatchThreadId, uint2 threadPos float3 offset = POISSON_SAMPLES[i]; // Sample coordinates - float2 uv = pixelUv + STL::Geometry::RotateVector(rotator, offset.xy) * gInvResourceSize * blurRadius; + float2 uv = pixelUv * gRectSize + STL::Geometry::RotateVector(rotator, offset.xy) * blurRadius; + uv = floor(uv) + 0.5; + uv = ApplyCheckerboardShift(uv, gDiffCheckerboard, i, gFrameIndex) * gRectSizeInv; - if (gDiffuseCheckerboard != 2) - uv = ApplyCheckerboardShift(uv, gDiffuseCheckerboard, i, gRectSize, gInvRectSize, gFrameIndex); + float2 uvScaled = ClampUvToViewport( uv ); + float2 checkerboardUvScaled = float2( uvScaled.x * ( gDiffCheckerboard != 2 ? 0.5 : 1.0 ), uvScaled.y ); // Fetch data - float2 uvScaled = uv * gResolutionScale; - float2 checkerboardUvScaled = float2( uvScaled.x * ( gDiffuseCheckerboard != 2 ? 0.5 : 1.0 ), uvScaled.y ) + gRectOffset; - float sampleMaterialID; - float3 sampleNormal = NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness.SampleLevel(gNearestClamp, uvScaled, 0), sampleMaterialID).rgb; - float sampleViewZ = abs(gViewZ.SampleLevel(gNearestClamp, uvScaled, 0)); + float3 sampleNormal = NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness.SampleLevel(gNearestClamp, WithRectOffset(uvScaled), 0), sampleMaterialID).rgb; + float sampleViewZ = abs(gViewZ.SampleLevel(gNearestClamp, WithRectOffset(uvScaled), 0)); float3 sampleWorldPos = GetCurrentWorldPosFromClipSpaceXY(uv * 2.0 - 1.0, sampleViewZ); - float4 sampleDiffuseIllumination = gDiffuseIllumination.SampleLevel(gNearestClamp, checkerboardUvScaled, 0); // Sample weight - float sampleWeight = IsInScreen(uv); - sampleWeight *= GetGaussianWeight(offset.z); + float sampleWeight = IsInScreenNearest(uv); + sampleWeight *= float(sampleViewZ < gDenoisingRange); sampleWeight *= CompareMaterials(centerMaterialID, sampleMaterialID, gDiffMaterialMask); sampleWeight *= GetPlaneDistanceWeight( @@ -168,16 +161,21 @@ NRD_EXPORT void NRD_CS_MAIN(int2 pixelPos : SV_DispatchThreadId, uint2 threadPos float angle = STL::Math::AcosApprox(dot(centerNormal, sampleNormal)); sampleWeight *= ComputeWeight(angle, normalWeightParams, 0.0); + float4 sampleDiffuseIllumination = gDiffIllumination.SampleLevel(gNearestClamp, checkerboardUvScaled, 0); + sampleDiffuseIllumination = Denanify( sampleWeight, sampleDiffuseIllumination ); + sampleWeight *= lerp(diffMinHitDistanceWeight, 1.0, ComputeExponentialWeight(sampleDiffuseIllumination.a, hitDistanceWeightParams.x, hitDistanceWeightParams.y)); + sampleWeight *= GetGaussianWeight(offset.z); - diffuseIllumination += (sampleWeight > 0) ? sampleDiffuseIllumination * sampleWeight : 0; + // Accumulate + weightSum += sampleWeight; + diffuseIllumination += sampleDiffuseIllumination * sampleWeight; #ifdef RELAX_SH - float4 sampleDiffuseSH1 = gDiffuseSH1.SampleLevel(gNearestClamp, checkerboardUvScaled, 0); - diffuseSH1 += (sampleWeight > 0) ? sampleDiffuseSH1 * sampleWeight : 0; + float4 sampleDiffuseSH1 = gDiffSH1.SampleLevel(gNearestClamp, checkerboardUvScaled, 0); + sampleDiffuseSH1 = Denanify( sampleWeight, sampleDiffuseSH1 ); + diffuseSH1 += sampleDiffuseSH1 * sampleWeight; #endif - - weightSum += sampleWeight; } diffuseIllumination /= weightSum; @@ -193,44 +191,48 @@ NRD_EXPORT void NRD_CS_MAIN(int2 pixelPos : SV_DispatchThreadId, uint2 threadPos #endif #ifdef RELAX_SPECULAR + bool specHasData = true; + int2 specPos = pixelPos; + if (gSpecCheckerboard != 2) + { + specHasData = (checkerboard == gSpecCheckerboard); + specPos.x >>= 1; + } + // Reading specular & resolving specular checkerboard - float4 specularIllumination = gSpecularIllumination[SpecCheckerboard(pixelPos + gRectOrigin)]; + float4 specularIllumination = gSpecIllumination[specPos]; #ifdef RELAX_SH - float4 specularSH1 = gSpecularSH1[SpecCheckerboard(pixelPos + gRectOrigin)]; + float4 specularSH1 = gSpecSH1[specPos]; #endif - bool specHasData = true; - if (gSpecularCheckerboard != 2) - specHasData = (checkerboard == gSpecularCheckerboard); - if (!specHasData) { - float4 s0 = gSpecularIllumination[SpecCheckerboard(pixelPos + int2(-1, 0) + gRectOrigin)]; - float4 s1 = gSpecularIllumination[SpecCheckerboard(pixelPos + int2(1, 0) + gRectOrigin)]; - float2 specCheckerboardResolveWeights = checkerboardResolveWeights; + float2 wc = checkerboardResolveWeights; #if( NRD_NORMAL_ENCODING == NRD_NORMAL_ENCODING_R10G10B10A2_UNORM ) - float materialID0; - float materialID1; - NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness[pixelPos + int2(-1, 0) + gRectOrigin], materialID0); - NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness[pixelPos + int2(1, 0) + gRectOrigin], materialID1); - specCheckerboardResolveWeights.x *= CompareMaterials(centerMaterialID, materialID0, gSpecMaterialMask); - specCheckerboardResolveWeights.y *= CompareMaterials(centerMaterialID, materialID1, gSpecMaterialMask); - specCheckerboardResolveWeights *= STL::Math::PositiveRcp(specCheckerboardResolveWeights.x + specCheckerboardResolveWeights.y + 1.0e-4); + wc.x *= CompareMaterials(centerMaterialID, materialID0, gSpecMaterialMask); + wc.y *= CompareMaterials(centerMaterialID, materialID1, gSpecMaterialMask); #endif - specularIllumination *= saturate(1.0 - specCheckerboardResolveWeights.x - specCheckerboardResolveWeights.y); - specularIllumination += s0 * specCheckerboardResolveWeights.x + s1 * specCheckerboardResolveWeights.y; + wc *= STL::Math::PositiveRcp( wc.x + wc.y ); + + float4 s0 = gSpecIllumination[checkerboardPos.xz]; + float4 s1 = gSpecIllumination[checkerboardPos.yz]; + s0 = Denanify( wc.x, s0 ); + s1 = Denanify( wc.y, s1 ); + specularIllumination = s0 * wc.x + s1 * wc.y; + #ifdef RELAX_SH - float4 s0SH1 = gSpecularSH1[SpecCheckerboard(pixelPos + int2(-1, 0) + gRectOrigin)]; - float4 s1SH1 = gSpecularSH1[SpecCheckerboard(pixelPos + int2(1, 0) + gRectOrigin)]; - specularSH1 *= saturate(1.0 - specCheckerboardResolveWeights.x - specCheckerboardResolveWeights.y); - specularSH1 += s0SH1 * specCheckerboardResolveWeights.x + s1SH1 * specCheckerboardResolveWeights.y; + float4 s0SH1 = gSpecSH1[checkerboardPos.xz]; + float4 s1SH1 = gSpecSH1[checkerboardPos.yz]; + s0SH1 = Denanify( wc.x, s0SH1 ); + s1SH1 = Denanify( wc.y, s1SH1 ); + specularSH1 = s0SH1 * wc.x + s1SH1 * wc.y; #endif } specularIllumination.a = max(0, min(gDenoisingRange, specularIllumination.a)); // Pre-blur for specular - if (gSpecularBlurRadius > 0) + if (gSpecBlurRadius > 0) { // Specular blur radius float3 viewVector = (gOrthoMode == 0) ? normalize(-centerWorldPos) : gFrustumForward.xyz; @@ -242,7 +244,7 @@ NRD_EXPORT void NRD_CS_MAIN(int2 pixelPos : SV_DispatchThreadId, uint2 threadPos float hitDistFactor = GetHitDistFactor(hitDist * NoD, frustumSize); - float blurRadius = gSpecularBlurRadius * hitDistFactor * GetSpecMagicCurve(centerRoughness); + float blurRadius = gSpecBlurRadius * hitDistFactor * GetSpecMagicCurve(centerRoughness); float lobeTanHalfAngle = STL::ImportanceSampling::GetSpecularLobeTanHalfAngle(centerRoughness); float lobeRadius = hitDist * NoD * lobeTanHalfAngle; float minBlurRadius = lobeRadius / PixelRadiusToWorld(gUnproject, gOrthoMode, 1.0, centerViewZ + hitDist * D.w); @@ -252,7 +254,7 @@ NRD_EXPORT void NRD_CS_MAIN(int2 pixelPos : SV_DispatchThreadId, uint2 threadPos if (specularIllumination.w == 0.0) blurRadius = max(blurRadius, 1.0); - float normalWeightParams = GetNormalWeightParams(centerRoughness, 0.5 * gSpecularLobeAngleFraction); + float normalWeightParams = GetNormalWeightParams(centerRoughness, 0.5 * gSpecLobeAngleFraction); float2 hitDistanceWeightParams = GetHitDistanceWeightParams(specularIllumination.w, 1.0 / 9.0, centerRoughness); float2 roughnessWeightParams = GetRoughnessWeightParams(centerRoughness, gRoughnessFraction); @@ -271,26 +273,24 @@ NRD_EXPORT void NRD_CS_MAIN(int2 pixelPos : SV_DispatchThreadId, uint2 threadPos float3 offset = POISSON_SAMPLES[i]; // Sample coordinates - float2 uv = pixelUv + STL::Geometry::RotateVector(rotator, offset.xy) * gInvResourceSize * blurRadius; + float2 uv = pixelUv * gRectSize + STL::Geometry::RotateVector(rotator, offset.xy) * blurRadius; + uv = floor(uv) + 0.5; + uv = ApplyCheckerboardShift(uv, gSpecCheckerboard, i, gFrameIndex) * gRectSizeInv; - if (gSpecularCheckerboard != 2) - uv = ApplyCheckerboardShift(uv, gSpecularCheckerboard, i, gRectSize, gInvRectSize, gFrameIndex); + float2 uvScaled = ClampUvToViewport( uv ); + float2 checkerboardUvScaled = float2( uvScaled.x * ( gSpecCheckerboard != 2 ? 0.5 : 1.0 ), uvScaled.y ); - float2 uvScaled = uv * gResolutionScale; - float2 checkerboardUvScaled = float2( uvScaled.x * ( gSpecularCheckerboard != 2 ? 0.5 : 1.0 ), uvScaled.y ) + gRectOffset; // Fetch data - float4 sampleSpecularIllumination = gSpecularIllumination.SampleLevel(gNearestClamp, checkerboardUvScaled, 0); - float sampleMaterialID; - float4 sampleNormalRoughness = NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness.SampleLevel(gNearestClamp, uvScaled, 0), sampleMaterialID); + float4 sampleNormalRoughness = NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness.SampleLevel(gNearestClamp, WithRectOffset(uvScaled), 0), sampleMaterialID); float3 sampleNormal = sampleNormalRoughness.rgb; float sampleRoughness = sampleNormalRoughness.a; - float sampleViewZ = abs(gViewZ.SampleLevel(gNearestClamp, uvScaled, 0)); + float sampleViewZ = abs(gViewZ.SampleLevel(gNearestClamp, WithRectOffset(uvScaled), 0)); // Sample weight - float sampleWeight = IsInScreen(uv); - sampleWeight *= GetGaussianWeight(offset.z); + float sampleWeight = IsInScreenNearest(uv); + sampleWeight *= float(sampleViewZ < gDenoisingRange); sampleWeight *= CompareMaterials(centerMaterialID, sampleMaterialID, gSpecMaterialMask); sampleWeight *= ComputeWeight(sampleRoughness, roughnessWeightParams.x, roughnessWeightParams.y); @@ -305,25 +305,30 @@ NRD_EXPORT void NRD_CS_MAIN(int2 pixelPos : SV_DispatchThreadId, uint2 threadPos sampleWorldPos, gDepthThreshold); + float4 sampleSpecularIllumination = gSpecIllumination.SampleLevel(gNearestClamp, checkerboardUvScaled, 0); + sampleSpecularIllumination = Denanify( sampleWeight, sampleSpecularIllumination ); + sampleWeight *= lerp(specMinHitDistanceWeight, 1.0, ComputeExponentialWeight(sampleSpecularIllumination.a, hitDistanceWeightParams.x, hitDistanceWeightParams.y)); + sampleWeight *= GetGaussianWeight(offset.z); - // Decreasing weight for samples that most likely are very close to reflection contact - // which should not be pre-blurred + // Decreasing weight for samples that most likely are very close to reflection contact which should not be pre-blurred float d = length(sampleWorldPos - centerWorldPos); float h = sampleSpecularIllumination.a; float t = h / (specularIllumination.a + d); sampleWeight *= lerp(saturate(t), 1.0, STL::Math::LinearStep(0.5, 1.0, centerRoughness)); - specularIllumination.rgb += (sampleWeight > 0) ? sampleSpecularIllumination.rgb * sampleWeight : 0; + // Accumulate + weightSum += sampleWeight; + + specularIllumination.rgb += sampleSpecularIllumination.rgb * sampleWeight; #ifdef RELAX_SH - float4 sampleSpecularSH1 = gSpecularSH1.SampleLevel(gNearestClamp, checkerboardUvScaled, 0); - specularSH1 += (sampleWeight > 0) ? sampleSpecularSH1 * sampleWeight : 0; + float4 sampleSpecularSH1 = gSpecSH1.SampleLevel(gNearestClamp, checkerboardUvScaled, 0); + sampleSpecularSH1 = Denanify( sampleWeight, sampleSpecularSH1 ); + specularSH1 += sampleSpecularSH1 * sampleWeight; #endif - weightSum += sampleWeight; if (sampleWeight != 0.0) minHitT = min(minHitT, sampleSpecularIllumination.a == 0.0 ? NRD_INF : sampleSpecularIllumination.a); - } specularIllumination.rgb /= weightSum; specularIllumination.a = minHitT == NRD_INF ? 0.0 : minHitT; diff --git a/Shaders/Include/RELAX/RELAX_DiffuseSpecular_SplitScreen.hlsli b/Shaders/Include/RELAX_SplitScreen.hlsli similarity index 74% rename from Shaders/Include/RELAX/RELAX_DiffuseSpecular_SplitScreen.hlsli rename to Shaders/Include/RELAX_SplitScreen.hlsli index ec1a4fc..073abd2 100644 --- a/Shaders/Include/RELAX/RELAX_DiffuseSpecular_SplitScreen.hlsli +++ b/Shaders/Include/RELAX_SplitScreen.hlsli @@ -11,24 +11,23 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. [numthreads( GROUP_X, GROUP_Y, 1 )] NRD_EXPORT void NRD_CS_MAIN( uint2 pixelPos : SV_DispatchThreadId) { - float2 pixelUv = float2( pixelPos + 0.5 ) * gInvRectSize; - uint2 pixelPosUser = gRectOrigin + pixelPos; + float2 pixelUv = float2( pixelPos + 0.5 ) * gRectSizeInv; - if( pixelUv.x > gSplitScreen ) + if( pixelUv.x > gSplitScreen || pixelPos.x >= gRectSize.x || pixelPos.y >= gRectSize.y ) return; - float viewZ = gIn_ViewZ[ pixelPosUser ]; + float viewZ = gIn_ViewZ[ WithRectOrigin( pixelPos ) ]; uint2 checkerboardPos = pixelPos; #ifdef RELAX_DIFFUSE checkerboardPos.x = pixelPos.x >> ( gDiffCheckerboard != 2 ? 1 : 0 ); - float4 diffResult = gIn_Diff[ gRectOrigin + checkerboardPos ]; + float4 diffResult = gIn_Diff[ checkerboardPos ]; gOut_Diff[ pixelPos ] = diffResult * float( viewZ < gDenoisingRange ); #endif #ifdef RELAX_SPECULAR checkerboardPos.x = pixelPos.x >> ( gSpecCheckerboard != 2 ? 1 : 0 ); - float4 specResult = gIn_Spec[ gRectOrigin + checkerboardPos ]; + float4 specResult = gIn_Spec[ checkerboardPos ]; gOut_Spec[ pixelPos ] = specResult * float( viewZ < gDenoisingRange ); #endif } diff --git a/Shaders/Include/RELAX/RELAX_DiffuseSpecular_TemporalAccumulation.hlsli b/Shaders/Include/RELAX_TemporalAccumulation.hlsli similarity index 86% rename from Shaders/Include/RELAX/RELAX_DiffuseSpecular_TemporalAccumulation.hlsli rename to Shaders/Include/RELAX_TemporalAccumulation.hlsli index 43e8b87..4f7c5a7 100644 --- a/Shaders/Include/RELAX/RELAX_DiffuseSpecular_TemporalAccumulation.hlsli +++ b/Shaders/Include/RELAX_TemporalAccumulation.hlsli @@ -70,12 +70,6 @@ float loadSurfaceMotionBasedPrevData( int2 bilinearOrigin = int2(floor(prevPixelPosFloat - 0.5)); float2 bilinearWeights = frac(prevPixelPosFloat - 0.5); - // Consider reprojection to the same pixel index a small motion. - // It is useful for skipping reprojection test for static camera when the jitter is the only source of motion. - int2 prevPixelPosInt = int2(prevPixelPosFloat); - bool isSmallMotion = all(prevPixelPosInt == pixelPos); - bool skipReprojectionTest = gSkipReprojectionTestWithoutMotion && isSmallMotion; - // Checking bicubic footprint (with cut corners) // remembering bilinear taps validity and worldspace position along the way, // for faster weighted bilinear and for calculating previous worldspace position @@ -88,10 +82,10 @@ float loadSurfaceMotionBasedPrevData( // -- bc bc -- /// Fetching previous viewZs and materialIDs - float2 gatherOrigin00 = (float2(bilinearOrigin)+float2(0.0, 0.0)) * gInvResourceSize; - float2 gatherOrigin10 = (float2(bilinearOrigin)+float2(2.0, 0.0)) * gInvResourceSize; - float2 gatherOrigin01 = (float2(bilinearOrigin)+float2(0.0, 2.0)) * gInvResourceSize; - float2 gatherOrigin11 = (float2(bilinearOrigin)+float2(2.0, 2.0)) * gInvResourceSize; + float2 gatherOrigin00 = (float2(bilinearOrigin)+float2(0.0, 0.0)) * gResourceSizeInvPrev; + float2 gatherOrigin10 = (float2(bilinearOrigin)+float2(2.0, 0.0)) * gResourceSizeInvPrev; + float2 gatherOrigin01 = (float2(bilinearOrigin)+float2(0.0, 2.0)) * gResourceSizeInvPrev; + float2 gatherOrigin11 = (float2(bilinearOrigin)+float2(2.0, 2.0)) * gResourceSizeInvPrev; float4 prevViewZs00 = gPrevViewZ.GatherRed(gNearestClamp, gatherOrigin00).wzxy; float4 prevViewZs10 = gPrevViewZ.GatherRed(gNearestClamp, gatherOrigin10).wzxy; float4 prevViewZs01 = gPrevViewZ.GatherRed(gNearestClamp, gatherOrigin01).wzxy; @@ -105,11 +99,11 @@ float loadSurfaceMotionBasedPrevData( float pixelSize = PixelRadiusToWorld(gUnproject, gOrthoMode, 1.0, currentLinearZ); float frustumSize = pixelSize * min(gRectSize.x, gRectSize.y); float4 disocclusionThreshold = mixedDisocclusionDepthThreshold * frustumSize / lerp(NdotV, 1.0, saturate(parallaxInPixels / 30.0)); - disocclusionThreshold *= IsInScreen2x2( bilinearOrigin, gRectSizePrev ); + disocclusionThreshold *= IsInScreenBilinear( bilinearOrigin, gRectSizePrev ); disocclusionThreshold -= NRD_EPS; // Calculating validity of 12 bicubic taps, 4 of those are bilinear taps - float3 prevViewPos = STL::Geometry::AffineTransform(gPrevWorldToView, prevWorldPos); + float3 prevViewPos = STL::Geometry::AffineTransform(gWorldToViewPrev, prevWorldPos); float3 planeDist0 = abs(prevViewZs00.yzw - prevViewPos.zzz); float3 planeDist1 = abs(prevViewZs10.xzw - prevViewPos.zzz); float3 planeDist2 = abs(prevViewZs01.xyw - prevViewPos.zzz); @@ -125,12 +119,11 @@ float loadSurfaceMotionBasedPrevData( float bicubicFootprintValid = dot(tapsValid0 + tapsValid1 + tapsValid2 + tapsValid3, 1.0) > 11.5 ? 1.0 : 0.0; float4 bilinearTapsValid = float4(tapsValid0.z, tapsValid1.y, tapsValid2.y, tapsValid3.x); - bilinearTapsValid = skipReprojectionTest ? float4(1.0, 1.0, 1.0, 1.0) : bilinearTapsValid; // Using bilinear to average 4 normal samples - float2 uv = (float2(bilinearOrigin)+float2(1.0, 1.0)) * gInvResourceSize; + float2 uv = (float2(bilinearOrigin)+float2(1.0, 1.0)) * gResourceSizeInvPrev; float3 prevNormalFlat = UnpackPrevNormalRoughness(gPrevNormalRoughness.SampleLevel(gLinearClamp, uv, 0)).xyz; - prevNormalFlat = gUseWorldPrevToWorld ? STL::Geometry::RotateVector(gWorldPrevToWorld, prevNormalFlat) : prevNormalFlat; + prevNormalFlat = STL::Geometry::RotateVector(gWorldPrevToWorld, prevNormalFlat); // Reject backfacing history: if angle between current normal and previous normal is larger than 90 deg [flatten] @@ -149,7 +142,7 @@ float loadSurfaceMotionBasedPrevData( // Fetching normal history BicubicFilterNoCornersWithFallbackToBilinearFilterWithCustomWeights( - prevPixelPosFloat, gInvResourceSize, + prevPixelPosFloat, gResourceSizeInvPrev, bilinearCustomWeights, useBicubic #ifdef RELAX_DIFFUSE , gPrevDiffuseIllumination, prevDiffuseIllumAnd2ndMoment @@ -163,7 +156,7 @@ float loadSurfaceMotionBasedPrevData( float4 spec; float4 diff; BicubicFilterNoCornersWithFallbackToBilinearFilterWithCustomWeights( - prevPixelPosFloat, gInvResourceSize, + prevPixelPosFloat, gResourceSizeInvPrev, bilinearCustomWeights, useBicubic #ifdef RELAX_DIFFUSE , gPrevDiffuseIlluminationResponsive, diff @@ -195,7 +188,7 @@ float loadSurfaceMotionBasedPrevData( #endif // Fitering more previous data that does not need bicubic - float2 gatherOrigin = (float2(bilinearOrigin) + 1.0) * gInvResourceSize; + float2 gatherOrigin = (float2(bilinearOrigin) + 1.0) * gResourceSizeInvPrev; float4 prevHistoryLengths = gPrevHistoryLength.GatherRed(gNearestClamp, gatherOrigin).wzxy; historyLength = 255.0 * BilinearWithCustomWeightsImmediateFloat( prevHistoryLengths.x, @@ -265,29 +258,23 @@ float loadVirtualMotionBasedPrevData( float currentViewVectorLength = length(currentViewVector); float accumulatedSpecularVMBZ = currentViewVectorLength + hitDistFocused; - float4 prevVirtualClipPos = mul(gPrevWorldToClip, float4(prevVirtualWorldPos, 1.0)); + float4 prevVirtualClipPos = mul(gWorldToClipPrev, float4(prevVirtualWorldPos, 1.0)); prevVirtualClipPos.xy /= prevVirtualClipPos.w; prevUVVMB = prevVirtualClipPos.xy * float2(0.5, -0.5) + float2(0.5, 0.5); float2 prevVirtualPixelPosFloat = prevUVVMB * gRectSizePrev; - // Consider reprojection to the same pixel index a small motion. - // It is useful for skipping reprojection test for static camera when the jitter is the only source of motion. - int2 prevVirtualPixelPosInt = int2(prevVirtualPixelPosFloat); - bool isSmallVirtualMotion = all(prevVirtualPixelPosInt == pixelPos); - bool skipReprojectionTest = gSkipReprojectionTestWithoutMotion && isSmallVirtualMotion; - // Calculating footprint origin and weights int2 bilinearOrigin = int2(floor(prevVirtualPixelPosFloat - 0.5)); float2 bilinearWeights = frac(prevVirtualPixelPosFloat - 0.5); - float2 gatherOrigin = (bilinearOrigin + 1.0) * gInvResourceSize; + float2 gatherOrigin = (bilinearOrigin + 1.0) * gResourceSizeInvPrev; // Taking care of camera motion, because world-space is always centered at camera position in NRD - currentWorldPos -= gPrevCameraPosition.xyz; + currentWorldPos -= gCameraDelta.xyz; // Calculating disocclusion threshold float4 disocclusionThreshold = mixedDisocclusionDepthThreshold * (gOrthoMode == 0 ? currentLinearZ : 1.0); - disocclusionThreshold *= IsInScreen2x2( bilinearOrigin, gRectSizePrev ); + disocclusionThreshold *= IsInScreenBilinear( bilinearOrigin, gRectSizePrev ); disocclusionThreshold -= NRD_EPS; // Checking bilinear footprint only for virtual motion based specular reprojection @@ -306,7 +293,6 @@ float loadVirtualMotionBasedPrevData( bilinearTapsValid.w = isReprojectionTapValid(currentWorldPos, prevWorldPosInTap, currentNormal, disocclusionThreshold.w); bilinearTapsValid *= CompareMaterials(currentMaterialID.xxxx, prevMaterialIDs.xyzw, materialIDMask); - bilinearTapsValid = skipReprojectionTest ? float4(1.0, 1.0, 1.0, 1.0) : bilinearTapsValid; // Applying reprojection prevSpecularIllumAnd2ndMoment = 0; @@ -331,7 +317,7 @@ float loadVirtualMotionBasedPrevData( // Fetching normal virtual motion based specular history BicubicFilterNoCornersWithFallbackToBilinearFilterWithCustomWeights( - prevVirtualPixelPosFloat, gInvResourceSize, + prevVirtualPixelPosFloat, gResourceSizeInvPrev, bilinearCustomWeights, useBicubic, gPrevSpecularIllumination, prevSpecularIllumAnd2ndMoment); @@ -339,7 +325,7 @@ float loadVirtualMotionBasedPrevData( // Fetching fast virtual motion based specular history BicubicFilterNoCornersWithFallbackToBilinearFilterWithCustomWeights( - prevVirtualPixelPosFloat, gInvResourceSize, + prevVirtualPixelPosFloat, gResourceSizeInvPrev, bilinearCustomWeights, useBicubic, gPrevSpecularIlluminationResponsive, prevSpecularResponsiveIllum); @@ -352,13 +338,12 @@ float loadVirtualMotionBasedPrevData( #endif // Fitering previous data that does not need bicubic - prevReflectionHitT = gPrevReflectionHitT.SampleLevel(gLinearClamp, prevUVVMB, 0).x; + prevReflectionHitT = gPrevReflectionHitT.SampleLevel(gLinearClamp, prevUVVMB * gResolutionScalePrev, 0).x; prevReflectionHitT = max(0.001, prevReflectionHitT); - float2 prevUVVMBforGBuffer = prevUVVMB * gRectSizePrev * gInvResourceSize; - float4 prevNormalRoughness = UnpackPrevNormalRoughness(gPrevNormalRoughness.SampleLevel(gLinearClamp, prevUVVMBforGBuffer, 0)); + float4 prevNormalRoughness = UnpackPrevNormalRoughness(gPrevNormalRoughness.SampleLevel(gLinearClamp, prevUVVMB * gResolutionScalePrev, 0)); prevNormal = prevNormalRoughness.xyz; - prevNormal = gUseWorldPrevToWorld ? STL::Geometry::RotateVector(gWorldPrevToWorld, prevNormal) : prevNormal; + prevNormal = STL::Geometry::RotateVector(gWorldPrevToWorld, prevNormal); prevRoughness = prevNormalRoughness.w; } // Using all() marks entire virtual motion based specular history footprint @@ -372,11 +357,11 @@ void Preload(uint2 sharedPos, int2 globalPos) { globalPos = clamp(globalPos, 0, gRectSize - 1.0); - float4 normalRoughness = NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness[globalPos + gRectOrigin]); + float4 normalRoughness = NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness[WithRectOrigin(globalPos)]); float4 normalSpecHitT = normalRoughness; #ifdef RELAX_SPECULAR - float4 inSpecularIllumination = gSpecularIllumination[globalPos + gRectOrigin]; + float4 inSpecularIllumination = gSpecIllumination[globalPos]; normalSpecHitT.a = inSpecularIllumination.a; #endif @@ -391,11 +376,11 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPo PRELOAD_INTO_SMEM_WITH_TILE_CHECK; // Tile-based early out - if (isSky != 0.0) + if (isSky != 0.0 || pixelPos.x >= gRectSize.x || pixelPos.y >= gRectSize.y) return; // Early out if linearZ is beyond denoising range - float currentLinearZ = abs(gViewZ[pixelPos.xy + gRectOrigin]); + float currentLinearZ = abs(gViewZ[WithRectOrigin(pixelPos.xy)]); if (currentLinearZ > gDenoisingRange) return; @@ -403,45 +388,47 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPo // Reading current GBuffer data float currentMaterialID; - float4 currentNormalRoughness = NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness[gRectOrigin + pixelPos], currentMaterialID); + float4 currentNormalRoughness = NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness[WithRectOrigin(pixelPos)], currentMaterialID); float3 currentNormal = currentNormalRoughness.xyz; float currentRoughness = currentNormalRoughness.w; - // Getting current frame worldspace position and view vector for current pixel + // Getting current position and view vector for current pixel float3 currentWorldPos = GetCurrentWorldPosFromPixelPos(pixelPos, currentLinearZ); - float2 pixelUv = float2(pixelPos + 0.5) * gInvRectSize; - float3 mv = gMv[gRectOrigin + pixelPos] * gMvScale; - if (gMvScale.z == 0.0) - mv.z = STL::Geometry::AffineTransform(gPrevWorldToView, currentWorldPos).z - currentLinearZ; + float3 currentViewVector = (gOrthoMode == 0) ? currentWorldPos : currentLinearZ * normalize(gFrustumForward.xyz); + float3 V = -normalize(currentViewVector); + float NoV = abs(dot(currentNormal, V)); + // Getting previous position + float2 pixelUv = float2(pixelPos + 0.5) * gRectSizeInv; + float3 mv = gMv[WithRectOrigin(pixelPos)] * gMvScale.xyz; float3 prevWorldPos = currentWorldPos; float2 prevUVSMB = pixelUv + mv.xy; - if (gIsWorldSpaceMotionEnabled) + + if (gMvScale.w != 0.0) { prevWorldPos += mv; - prevUVSMB = STL::Geometry::GetScreenUv(gPrevWorldToClip, prevWorldPos); + prevUVSMB = STL::Geometry::GetScreenUv(gWorldToClipPrev, prevWorldPos); } else - prevWorldPos = GetPreviousWorldPosFromClipSpaceXY(prevUVSMB * 2.0 - 1.0, currentLinearZ + mv.z) + gPrevCameraPosition.xyz; + { + if (gMvScale.z == 0.0) + mv.z = STL::Geometry::AffineTransform(gWorldToViewPrev, currentWorldPos).z - currentLinearZ; - float3 currentViewVector = (gOrthoMode == 0) ? - currentWorldPos : - currentLinearZ * normalize(gFrustumForward.xyz); - float3 V = -normalize(currentViewVector); - float NoV = abs(dot(currentNormal, V)); + prevWorldPos = GetPreviousWorldPosFromClipSpaceXY(prevUVSMB * 2.0 - 1.0, currentLinearZ + mv.z) + gCameraDelta.xyz; + } // Input noisy data #ifdef RELAX_DIFFUSE - float3 diffuseIllumination = gDiffuseIllumination[pixelPos.xy + gRectOrigin].rgb; + float3 diffuseIllumination = gDiffIllumination[pixelPos.xy].rgb; #ifdef RELAX_SH - float4 diffuseSH1 = gDiffuseSH1[pixelPos.xy + gRectOrigin]; + float4 diffuseSH1 = gDiffSH1[pixelPos.xy]; #endif #endif #ifdef RELAX_SPECULAR - float4 specularIllumination = gSpecularIllumination[pixelPos.xy + gRectOrigin]; + float4 specularIllumination = gSpecIllumination[pixelPos.xy]; #ifdef RELAX_SH - float4 specularSH1 = gSpecularSH1[pixelPos.xy + gRectOrigin]; + float4 specularSH1 = gSpecSH1[pixelPos.xy]; #endif #endif @@ -484,7 +471,7 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPo #endif // Calculating surface parallax - float parallaxInPixels = ComputeParallaxInPixels(prevWorldPos - gPrevCameraPosition.xyz, gOrthoMode == 0.0 ? pixelUv : prevUVSMB, gWorldToClip, gRectSize); + float parallaxInPixels = ComputeParallaxInPixels(prevWorldPos + gCameraDelta.xyz, gOrthoMode == 0.0 ? prevUVSMB : pixelUv, gWorldToClipPrev, gRectSize ); // Calculating disocclusion threshold float mixedDisocclusionDepthThreshold = gDisocclusionDepthThreshold; @@ -494,7 +481,7 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPo mixedDisocclusionDepthThreshold = lerp(gDisocclusionDepthThreshold, gDisocclusionDepthThresholdAlternate, - gDisocclusionThresholdMix[pixelPos.xy + gRectOrigin]); + gDisocclusionThresholdMix[WithRectOrigin(pixelPos.xy)]); } // Loading previous data based on surface motion vectors @@ -559,7 +546,7 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPo historyLength = min(RELAX_MAX_ACCUM_FRAME_NUM, historyLength); // Avoid footprint momentary stretching due to changed viewing angle - float3 Vprev = (gOrthoMode == 0) ? -normalize(prevWorldPos - gPrevCameraPosition.xyz) : -normalize(gPrevFrustumForward.xyz); + float3 Vprev = (gOrthoMode == 0) ? -normalize(prevWorldPos - gCameraDelta.xyz) : -normalize(gPrevFrustumForward.xyz); float NoVprev = abs(dot(currentNormal, Vprev)); float sizeQuality = (NoVprev + 1e-3) / (NoV + 1e-3); // this order because we need to fix stretching only, shrinking is OK sizeQuality *= sizeQuality; @@ -578,6 +565,16 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPo // Handling history reset if needed historyLength = (gResetHistory != 0) ? 1.0 : historyLength; + // Limiting history length: HistoryFix must be invoked if history length <= gHistoryFixFrameNum +#if( defined RELAX_DIFFUSE && defined RELAX_SPECULAR ) + float maxAccumulatedFrameNum = 1.0 + max( gDiffMaxAccumulatedFrameNum, gSpecMaxAccumulatedFrameNum ); +#elif( defined RELAX_DIFFUSE ) + float maxAccumulatedFrameNum = 1.0 + gDiffMaxAccumulatedFrameNum; +#else + float maxAccumulatedFrameNum = 1.0 + gSpecMaxAccumulatedFrameNum; +#endif + historyLength = min( historyLength, maxAccumulatedFrameNum ); + // Calculating checkerboard fields uint checkerboard = STL::Sequence::CheckerBoard(pixelPos, gFrameIndex); @@ -585,8 +582,8 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPo // DIFFUSE ACCUMULATION BELOW // // Temporal accumulation of diffuse illumination - float diffMaxAccumulatedFrameNum = gDiffuseMaxAccumulatedFrameNum; - float diffMaxFastAccumulatedFrameNum = gDiffuseMaxFastAccumulatedFrameNum; + float diffMaxAccumulatedFrameNum = gDiffMaxAccumulatedFrameNum; + float diffMaxFastAccumulatedFrameNum = gDiffMaxFastAccumulatedFrameNum; if (gUseConfidenceInputs) { @@ -602,9 +599,7 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPo bool diffHasData = true; if (gDiffCheckerboard != 2) - { diffHasData = checkerboard == gDiffCheckerboard; - } if ((!diffHasData) && (diffHistoryLength > 1.0)) { @@ -633,8 +628,8 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPo #ifdef RELAX_SPECULAR // SPECULAR ACCUMULATION BELOW // - float specMaxAccumulatedFrameNum = gSpecularMaxAccumulatedFrameNum; - float specMaxFastAccumulatedFrameNum = gSpecularMaxFastAccumulatedFrameNum; + float specMaxAccumulatedFrameNum = gSpecMaxAccumulatedFrameNum; + float specMaxFastAccumulatedFrameNum = gSpecMaxFastAccumulatedFrameNum; if (gUseConfidenceInputs) { float inSpecConfidence = gSpecConfidence[pixelPos]; @@ -652,14 +647,14 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPo // Calculating curvature along the direction of motion // IMPORTANT: this code allows to get non-zero parallax on objects attached to the camera float2 uvForZeroParallax = gOrthoMode == 0.0 ? prevUVSMB : pixelUv; - float2 deltaUv = STL::Geometry::GetScreenUv(gPrevWorldToClip, prevWorldPos - gPrevCameraPosition.xyz) - uvForZeroParallax; + float2 deltaUv = STL::Geometry::GetScreenUv(gWorldToClipPrev, prevWorldPos - gCameraDelta.xyz) - uvForZeroParallax; deltaUv *= gRectSize; float deltaUvLen = length(deltaUv); deltaUv /= max(deltaUvLen, 1.0 / 256.0); - float2 motionUv = pixelUv + 0.99 * deltaUv * gInvRectSize; // stay in SMEM + float2 motionUv = pixelUv + 0.99 * deltaUv * gRectSizeInv; // stay in SMEM // Construct the other edge point "x" - float z = abs(gViewZ.SampleLevel(gLinearClamp, gRectOffset + motionUv * gResolutionScale, 0)); + float z = abs(gViewZ.SampleLevel(gLinearClamp, WithRectOffset(motionUv * gResolutionScale), 0)); float3 x = GetCurrentWorldPosFromClipSpaceXY(motionUv * 2.0 - 1.0, z); // Interpolate normal at "x" @@ -673,31 +668,31 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPo float3 n01 = sharedNormalSpecHitT[pos.y + 1][pos.x].xyz; float3 n11 = sharedNormalSpecHitT[pos.y + 1][pos.x + 1].xyz; - float3 n = normalize(STL::Filtering::ApplyBilinearFilter(n00, n10, n01, n11, f)); + float3 n = _NRD_SafeNormalize(STL::Filtering::ApplyBilinearFilter(n00, n10, n01, n11, f)); // ( Optional ) High parallax - flattens surface on high motion ( test 132, e9 ) // IMPORTANT: a must for 8-bit and 10-bit normals ( tests b7, b10, b33 ) float deltaUvLenFixed = deltaUvLen * ( NRD_USE_HIGH_PARALLAX_CURVATURE_SILHOUETTE_FIX ? NoV : 1.0 ); // it fixes silhouettes, but leads to less flattening - float2 motionUvHigh = pixelUv + deltaUvLenFixed * deltaUv * gInvRectSize; - if (NRD_USE_HIGH_PARALLAX_CURVATURE && deltaUvLenFixed > 1.0 && IsInScreen(motionUvHigh)) + float2 motionUvHigh = pixelUv + deltaUvLenFixed * deltaUv * gRectSizeInv; + if (NRD_USE_HIGH_PARALLAX_CURVATURE && deltaUvLenFixed > 1.0 && IsInScreenNearest(motionUvHigh)) { - float zHigh = abs(gViewZ.SampleLevel(gLinearClamp, gRectOffset + motionUvHigh * gResolutionScale, 0)); + float zHigh = abs(gViewZ.SampleLevel(gLinearClamp, WithRectOffset(motionUvHigh * gResolutionScale), 0)); float3 xHigh = GetCurrentWorldPosFromClipSpaceXY(motionUvHigh * 2.0 - 1.0, zHigh); #if( NRD_NORMAL_ENCODING == NRD_NORMAL_ENCODING_R10G10B10A2_UNORM ) f = STL::Filtering::GetBilinearFilter(motionUvHigh, gRectSize); + f.origin = clamp(f.origin, 0, gRectSize - 2.0); pos = gRectOrigin + int2(f.origin); - pos = clamp(pos, 0, int2(gRectSize) - 2); n00 = NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness[pos]).xyz; n10 = NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness[pos + int2(1, 0)]).xyz; n01 = NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness[pos + int2(0, 1)]).xyz; n11 = NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness[pos + int2(1, 1)]).xyz; - float3 nHigh = normalize(STL::Filtering::ApplyBilinearFilter(n00, n10, n01, n11, f)); + float3 nHigh = _NRD_SafeNormalize(STL::Filtering::ApplyBilinearFilter(n00, n10, n01, n11, f)); #else - float3 nHigh = NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness.SampleLevel(gLinearClamp, gRectOffset + motionUvHigh * gResolutionScale, 0)).xyz; + float3 nHigh = NRD_FrontEnd_UnpackNormalAndRoughness(gNormalRoughness.SampleLevel(gLinearClamp, WithRectOffset(motionUvHigh * gResolutionScale), 0)).xyz; #endif float zError = abs(zHigh - currentLinearZ) * rcp(max(zHigh, currentLinearZ)); @@ -718,10 +713,10 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPo curvature *= s; // Correction #2 - very negative inconsistent with previous frame curvature blows up reprojection ( tests 164, 171 - 176 ) - float2 uv1 = STL::Geometry::GetScreenUv(gPrevWorldToClip, currentWorldPos - V * ApplyThinLensEquation(NoV, hitDist, curvature)); - float2 uv2 = STL::Geometry::GetScreenUv(gPrevWorldToClip, currentWorldPos); + float2 uv1 = STL::Geometry::GetScreenUv(gWorldToClipPrev, currentWorldPos - V * ApplyThinLensEquation(NoV, hitDist, curvature)); + float2 uv2 = STL::Geometry::GetScreenUv(gWorldToClipPrev, currentWorldPos); float a = length((uv1 - uv2) * gRectSize); - curvature *= float(a < 3.0 * deltaUvLen + gInvRectSize.x); // TODO:it's a hack, incompatible with concave mirrors ( tests 22b, 23b, 25b ) + curvature *= float(a < 3.0 * deltaUvLen + gRectSizeInv.x); // TODO:it's a hack, incompatible with concave mirrors ( tests 22b, 23b, 25b ) // Thin lens equation for adjusting reflection HitT float hitDistFocused = ApplyThinLensEquation(NoV, hitDist, curvature); @@ -808,14 +803,12 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPo uvDiff *= saturate(uvDiffLengthInPixels / 0.1) + uvDiffLengthInPixels / 2.0; float2 backUV1 = prevUVVMB + 1.0 * uvDiff; float2 backUV2 = prevUVVMB + 2.0 * uvDiff; - backUV1 *= (gInvResourceSize * gRectSizePrev); - backUV2 *= (gInvResourceSize * gRectSizePrev); - float4 backNormalRoughness1 = UnpackPrevNormalRoughness(gPrevNormalRoughness.SampleLevel(gLinearClamp, backUV1, 0)); - float4 backNormalRoughness2 = UnpackPrevNormalRoughness(gPrevNormalRoughness.SampleLevel(gLinearClamp, backUV2, 0)); - backNormalRoughness1.rgb = gUseWorldPrevToWorld ? STL::Geometry::RotateVector(gWorldPrevToWorld, backNormalRoughness1.rgb) : backNormalRoughness1.rgb; - backNormalRoughness2.rgb = gUseWorldPrevToWorld ? STL::Geometry::RotateVector(gWorldPrevToWorld, backNormalRoughness2.rgb) : backNormalRoughness2.rgb; - float prevPrevNormalWeight = IsInScreen(backUV1) ? GetEncodingAwareNormalWeight(prevNormalVMB, backNormalRoughness1.rgb, lobeHalfAngle, curvatureAngle * 2.0) : 1.0; - prevPrevNormalWeight *= IsInScreen(backUV2) ? GetEncodingAwareNormalWeight(prevNormalVMB, backNormalRoughness2.rgb, lobeHalfAngle, curvatureAngle * 3.0) : 1.0; + float4 backNormalRoughness1 = UnpackPrevNormalRoughness(gPrevNormalRoughness.SampleLevel(gLinearClamp, backUV1 * gResolutionScalePrev, 0)); + float4 backNormalRoughness2 = UnpackPrevNormalRoughness(gPrevNormalRoughness.SampleLevel(gLinearClamp, backUV2 * gResolutionScalePrev, 0)); + backNormalRoughness1.rgb = STL::Geometry::RotateVector(gWorldPrevToWorld, backNormalRoughness1.rgb); + backNormalRoughness2.rgb = STL::Geometry::RotateVector(gWorldPrevToWorld, backNormalRoughness2.rgb); + float prevPrevNormalWeight = IsInScreenNearest(backUV1) ? GetEncodingAwareNormalWeight(prevNormalVMB, backNormalRoughness1.rgb, lobeHalfAngle, curvatureAngle * 2.0) : 1.0; + prevPrevNormalWeight *= IsInScreenNearest(backUV2) ? GetEncodingAwareNormalWeight(prevNormalVMB, backNormalRoughness2.rgb, lobeHalfAngle, curvatureAngle * 3.0) : 1.0; virtualHistoryAmount *= 0.33 + 0.67 * prevPrevNormalWeight; specVMBConfidence *= 0.33 + 0.67 * prevPrevNormalWeight; // Taking in account roughness 1 and 2 frames back helps cleaning up surfaces wigh varying roughness @@ -840,11 +833,11 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPo float hitDistForTrackingPrev = prevSpecularIlluminationAnd2ndMomentVMBResponsive.a; float3 prevVirtualWorldPos = GetXvirtual(NoV, hitDistForTrackingPrev, curvature, currentWorldPos, prevWorldPos, V, D.w); float virtualWorldPosLengthPrev = length(prevVirtualWorldPos); - float2 prevUVVMBTest = STL::Geometry::GetScreenUv(gPrevWorldToClip, prevVirtualWorldPos, false); + float2 prevUVVMBTest = STL::Geometry::GetScreenUv(gWorldToClipPrev, prevVirtualWorldPos, false); float percentOfVolume = 0.6; float lobeTanHalfAngle = STL::ImportanceSampling::GetSpecularLobeTanHalfAngle(currentRoughness, percentOfVolume); - lobeTanHalfAngle = max(lobeTanHalfAngle, 0.5 * gInvRectSize.x); + lobeTanHalfAngle = max(lobeTanHalfAngle, 0.5 * gRectSizeInv.x); float unproj1 = min(hitDist, hitDistForTrackingPrev) / PixelRadiusToWorld(gUnproject, gOrthoMode, 1.0, max(virtualWorldPosLength, virtualWorldPosLengthPrev)); float lobeRadiusInPixels = lobeTanHalfAngle * unproj1; @@ -863,9 +856,7 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPo bool specHasData = true; if (gSpecCheckerboard != 2) - { specHasData = checkerboard == gSpecCheckerboard; - } if (!specHasData && (parallaxInPixels < 0.5)) { @@ -930,7 +921,7 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId, uint2 threadPo // If zero specular sample (color = 0), artificially adding variance for pixels with low reprojection confidence float specularHistoryConfidence = lerp(specSMBConfidence, specVMBConfidence, virtualHistoryAmount); - if (accumulatedSpecular2ndMoment == 0) accumulatedSpecular2ndMoment = gSpecularVarianceBoost * (1.0 - specularHistoryConfidence); + if (accumulatedSpecular2ndMoment == 0) accumulatedSpecular2ndMoment = gSpecVarianceBoost * (1.0 - specularHistoryConfidence); // Write out the results gOutSpecularIllumination[pixelPos] = float4(accumulatedSpecularIllumination, accumulatedSpecular2ndMoment); diff --git a/Shaders/Include/SIGMA/SIGMA_Shadow_Blur.hlsli b/Shaders/Include/SIGMA_Blur.hlsli similarity index 85% rename from Shaders/Include/SIGMA/SIGMA_Shadow_Blur.hlsli rename to Shaders/Include/SIGMA_Blur.hlsli index c3a10d2..cdeffd1 100644 --- a/Shaders/Include/SIGMA/SIGMA_Shadow_Blur.hlsli +++ b/Shaders/Include/SIGMA_Blur.hlsli @@ -13,10 +13,7 @@ groupshared SIGMA_TYPE s_Shadow_Translucency[ BUFFER_Y ][ BUFFER_X ]; void Preload( uint2 sharedPos, int2 globalPos ) { - globalPos = clamp( globalPos, 0, gRectSize - 1.0 ); - #ifdef SIGMA_FIRST_PASS - globalPos += gRectOrigin; - #endif + globalPos = clamp( globalPos, 0, gRectSizeMinusOne ); float2 data = gIn_Hit_ViewZ[ globalPos ]; data.y = abs( data.y ) / NRD_FP16_VIEWZ_SCALE; @@ -40,15 +37,12 @@ void Preload( uint2 sharedPos, int2 globalPos ) [numthreads( GROUP_X, GROUP_Y, 1 )] NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : SV_DispatchThreadId, uint threadIndex : SV_GroupIndex ) { - uint2 pixelPosUser = gRectOrigin + pixelPos; - float2 pixelUv = float2( pixelPos + 0.5 ) * gInvRectSize; - // Preload float isSky = gIn_Tiles[ pixelPos >> 4 ].y; PRELOAD_INTO_SMEM_WITH_TILE_CHECK; // Tile-based early out - if( isSky != 0.0 ) + if( isSky != 0.0 || any( pixelPos > gRectSizeMinusOne ) ) return; // Center data @@ -62,6 +56,7 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : if( viewZ > gDenoisingRange ) return; + float2 pixelUv = float2( pixelPos + 0.5 ) * gRectSizeInv; #ifdef SIGMA_FIRST_PASS // Copy history gOut_History[ pixelPos ] = gIn_History[ pixelPos ]; @@ -93,7 +88,7 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : float3 Xv = STL::Geometry::ReconstructViewPosition( pixelUv, gFrustum, viewZ, gOrthoMode ); // Normal - float4 normalAndRoughness = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pixelPosUser ] ); + float4 normalAndRoughness = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ WithRectOrigin( pixelPos ) ] ); float3 N = normalAndRoughness.xyz; float3 Nv = STL::Geometry::RotateVector( gWorldToView, N ); @@ -134,20 +129,23 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : hitDist *= invSum; // Blur radius + float unprojectZ = PixelRadiusToWorld( gUnproject, gOrthoMode, 1.0, viewZ ); + float innerShadowRadiusScale = lerp( 0.5, 1.0, result.x ); float outerShadowRadiusScale = 1.0; // TODO: find a way to improve penumbra - float worldRadius = hitDist * innerShadowRadiusScale * outerShadowRadiusScale * gBlurRadiusScale; - worldRadius *= tileValue; - - float unprojectZ = PixelRadiusToWorld( gUnproject, gOrthoMode, 1.0, viewZ ); - float pixelRadius = worldRadius * STL::Math::PositiveRcp( unprojectZ ); - pixelRadius = min( pixelRadius, SIGMA_MAX_PIXEL_RADIUS ); - worldRadius = pixelRadius * unprojectZ; + float pixelRadius = innerShadowRadiusScale * outerShadowRadiusScale; + pixelRadius *= tileValue; + pixelRadius *= hitDist / unprojectZ; + pixelRadius *= gBlurRadiusScale; float centerWeight = STL::Math::LinearStep( 0.9, 1.0, result.x ); - worldRadius += SIGMA_PENUMBRA_FIX_BLUR_RADIUS_ADDON * lerp( saturate( pixelRadius / 1.5 ), 1.0, centerWeight ) * unprojectZ * result.x; + float penumbraFixWeight = lerp( saturate( pixelRadius / 1.5 ), 1.0, centerWeight ) * result.x; + pixelRadius += SIGMA_PENUMBRA_FIX_BLUR_RADIUS_ADDON * penumbraFixWeight; // TODO: improve + + pixelRadius = min( pixelRadius, SIGMA_MAX_PIXEL_RADIUS ); // Tangent basis + float worldRadius = pixelRadius * unprojectZ; float3x3 mWorldToLocal = STL::Geometry::GetBasis( Nv ); float3 Tv = mWorldToLocal[ 0 ] * worldRadius; float3 Bv = mWorldToLocal[ 1 ] * worldRadius; @@ -168,42 +166,48 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : float3 offset = SIGMA_POISSON_SAMPLES[ n ]; float2 uv = GetKernelSampleCoordinates( gViewToClip, offset, Xv, Tv, Bv, rotator ); - // Fetch data - float2 uvScaled = uv * gResolutionScale; - #ifdef SIGMA_FIRST_PASS - uvScaled += gRectOffset; - #endif + // Snap to the pixel center! + uv = ( floor( uv * gRectSize ) + 0.5 ) * gRectSizeInv; + // Texture coordinates + float2 uvScaled = ClampUvToViewport( uv ); + + // Fetch data float2 data = gIn_Hit_ViewZ.SampleLevel( gNearestClamp, uvScaled, 0 ); float h = data.x; float signNoL = float( data.x != 0.0 ); float z = abs( data.y ) / NRD_FP16_VIEWZ_SCALE; + // Sample weight + float3 Xvs = STL::Geometry::ReconstructViewPosition( uv, gFrustum, z, gOrthoMode ); + float NoX = dot( Nv, Xvs ); + + float w = IsInScreenNearest( uv ); + w *= GetGaussianWeight( offset.z ); + w *= float( z < gDenoisingRange ); + w *= ComputeWeight( NoX, geometryWeightParams.x, geometryWeightParams.y ); + w *= saturate( 1.0 - abs( centerSignNoL - signNoL ) ); + SIGMA_TYPE s; #if( !defined SIGMA_FIRST_PASS || defined SIGMA_TRANSLUCENT ) s = gIn_Shadow_Translucency.SampleLevel( gNearestClamp, uvScaled, 0 ); #else s = float( h == NRD_FP16_MAX ); #endif + s = Denanify( w, s ); #ifndef SIGMA_FIRST_PASS s = UnpackShadowSpecial( s ); #endif - // Sample weight - float3 Xvs = STL::Geometry::ReconstructViewPosition( uv, gFrustum, z, gOrthoMode ); - float NoX = dot( Nv, Xvs ); - - float w = ComputeWeight( NoX, geometryWeightParams.x, geometryWeightParams.y ); - w *= saturate( 1.0 - abs( centerSignNoL - signNoL ) ); - w *= IsInScreen( uv ); - // Weight for outer shadow ( to avoid blurring of ~umbra ) w *= lerp( 1.0, s.x, centerWeight ); + // Accumulate + sum += w; + result += s * w; hitDist += h * float( s.x != 1.0 ) * w; - sum += w; } invSum = 1.0 / sum; diff --git a/Shaders/Include/SIGMA/SIGMA_Shadow_ClassifyTiles.hlsli b/Shaders/Include/SIGMA_ClassifyTiles.hlsli similarity index 100% rename from Shaders/Include/SIGMA/SIGMA_Shadow_ClassifyTiles.hlsli rename to Shaders/Include/SIGMA_ClassifyTiles.hlsli diff --git a/Shaders/Include/SIGMA/SIGMA_Common.hlsli b/Shaders/Include/SIGMA_Common.hlsli similarity index 92% rename from Shaders/Include/SIGMA/SIGMA_Common.hlsli rename to Shaders/Include/SIGMA_Common.hlsli index 533dd5b..b49384a 100644 --- a/Shaders/Include/SIGMA/SIGMA_Common.hlsli +++ b/Shaders/Include/SIGMA_Common.hlsli @@ -82,7 +82,7 @@ float TextureCubic(Texture2D tex, float2 uv) } void BicubicFilterNoCorners( - float2 samplePos, float2 invTextureSize, bool useBicubic, + float2 samplePos, float2 invResourceSize, bool useBicubic, Texture2D tex0, out float4 c0 ) { if( useBicubic ) @@ -93,11 +93,11 @@ void BicubicFilterNoCorners( _BicubicFilterNoCornersWithFallbackToBilinearFilterWithCustomWeights_Color( c0, tex0 ); } else - c0 = tex0.SampleLevel( gLinearClamp, samplePos * invTextureSize, 0 ); + c0 = tex0.SampleLevel( gLinearClamp, samplePos * invResourceSize, 0 ); } void BicubicFilterNoCorners( - float2 samplePos, float2 invTextureSize, bool useBicubic, + float2 samplePos, float2 invResourceSize, bool useBicubic, Texture2D tex0, out float c0 ) { if( useBicubic ) @@ -108,5 +108,5 @@ void BicubicFilterNoCorners( _BicubicFilterNoCornersWithFallbackToBilinearFilterWithCustomWeights_Color( c0, tex0 ); } else - c0 = tex0.SampleLevel( gLinearClamp, samplePos * invTextureSize, 0 ); + c0 = tex0.SampleLevel( gLinearClamp, samplePos * invResourceSize, 0 ); } diff --git a/Shaders/Include/SIGMA/SIGMA_Config.hlsli b/Shaders/Include/SIGMA_Config.hlsli similarity index 73% rename from Shaders/Include/SIGMA/SIGMA_Config.hlsli rename to Shaders/Include/SIGMA_Config.hlsli index 036a717..f3ec220 100644 --- a/Shaders/Include/SIGMA/SIGMA_Config.hlsli +++ b/Shaders/Include/SIGMA_Config.hlsli @@ -8,42 +8,52 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ +#define SIGMA + +// Switches ( default 1 ) +#define SIGMA_USE_CATROM 1 // sharper reprojection +#define SIGMA_5X5_TEMPORAL_KERNEL 1 // provides variance estimation in a wider radius +#define SIGMA_5X5_BLUR_RADIUS_ESTIMATION_KERNEL 1 // helps to improve stability, but adds 10% of overhead + +// Settings #define SIGMA_POISSON_SAMPLE_NUM 8 #define SIGMA_POISSON_SAMPLES g_Poisson8 #define SIGMA_MAX_PIXEL_RADIUS 32.0 #define SIGMA_MIN_HIT_DISTANCE_OUTPUT 0.0001 #define SIGMA_PENUMBRA_FIX_BLUR_RADIUS_ADDON 5.0 -#define SIGMA_MAX_SIGMA_SCALE 3.5 +#define SIGMA_MAX_SIGMA_SCALE 3.0 #define SIGMA_TS_MOTION_MAX_REUSE 0.11 -#define SIGMA_USE_CATROM 1 // sharper reprojection -#define SIGMA_5X5_TEMPORAL_KERNEL 1 // provides variance estimation in a wider radius -#define SIGMA_5X5_BLUR_RADIUS_ESTIMATION_KERNEL 0 // helps to improve stability, but adds 10% of overhead +// Data type #ifdef SIGMA_TRANSLUCENT #define SIGMA_TYPE float4 #else #define SIGMA_TYPE float #endif -// Shared data -#define SIGMA_SHARED_CB_DATA \ +// Shared constants +#define SIGMA_SHARED_CONSTANTS \ + NRD_CONSTANT( float4x4, gWorldToView ) \ NRD_CONSTANT( float4x4, gViewToClip ) \ + NRD_CONSTANT( float4x4, gWorldToClipPrev ) \ NRD_CONSTANT( float4, gFrustum ) \ - NRD_CONSTANT( float3, gMvScale ) \ - NRD_CONSTANT( float, gDebug ) \ - NRD_CONSTANT( float2, gInvScreenSize ) \ - NRD_CONSTANT( float2, gScreenSize ) \ - NRD_CONSTANT( float2, gInvRectSize ) \ + NRD_CONSTANT( float4, gMvScale ) \ + NRD_CONSTANT( float2, gResourceSizeInv ) \ + NRD_CONSTANT( float2, gResourceSizeInvPrev ) \ NRD_CONSTANT( float2, gRectSize ) \ + NRD_CONSTANT( float2, gRectSizeInv ) \ NRD_CONSTANT( float2, gRectSizePrev ) \ NRD_CONSTANT( float2, gResolutionScale ) \ NRD_CONSTANT( float2, gRectOffset ) \ NRD_CONSTANT( uint2, gRectOrigin ) \ + NRD_CONSTANT( int2, gRectSizeMinusOne ) \ + NRD_CONSTANT( int2, gTilesSizeMinusOne ) \ NRD_CONSTANT( float, gOrthoMode ) \ NRD_CONSTANT( float, gUnproject ) \ NRD_CONSTANT( float, gDenoisingRange ) \ NRD_CONSTANT( float, gPlaneDistSensitivity ) \ NRD_CONSTANT( float, gBlurRadiusScale ) \ NRD_CONSTANT( float, gContinueAccumulation ) \ - NRD_CONSTANT( uint, gIsWorldSpaceMotionEnabled ) \ + NRD_CONSTANT( float, gDebug ) \ + NRD_CONSTANT( float, gSplitScreen ) \ NRD_CONSTANT( uint, gFrameIndex ) diff --git a/Shaders/Include/SIGMA/SIGMA_Shadow_SplitScreen.hlsli b/Shaders/Include/SIGMA_SplitScreen.hlsli similarity index 69% rename from Shaders/Include/SIGMA/SIGMA_Shadow_SplitScreen.hlsli rename to Shaders/Include/SIGMA_SplitScreen.hlsli index a950f25..ad75497 100644 --- a/Shaders/Include/SIGMA/SIGMA_Shadow_SplitScreen.hlsli +++ b/Shaders/Include/SIGMA_SplitScreen.hlsli @@ -9,20 +9,18 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. */ [numthreads( GROUP_X, GROUP_Y, 1)] -NRD_EXPORT void NRD_CS_MAIN( uint2 pixelPos : SV_DispatchThreadId) +NRD_EXPORT void NRD_CS_MAIN( int2 pixelPos : SV_DispatchThreadId) { - float2 pixelUv = float2( pixelPos + 0.5 ) * gInvRectSize; - uint2 pixelPosUser = gRectOrigin + pixelPos; - - if( pixelUv.x > gSplitScreen ) + float2 pixelUv = float2( pixelPos + 0.5 ) * gRectSizeInv; + if( pixelUv.x > gSplitScreen || any( pixelPos > gRectSizeMinusOne ) ) return; - float2 data = gIn_Hit_ViewZ[ pixelPosUser ]; + float2 data = gIn_Hit_ViewZ[ pixelPos ]; float viewZ = abs( data.y ) / NRD_FP16_VIEWZ_SCALE; SIGMA_TYPE s; #ifdef SIGMA_TRANSLUCENT - s = gIn_Shadow_Translucency[ pixelPosUser ]; + s = gIn_Shadow_Translucency[ pixelPos ]; #else s = float( data.x == NRD_FP16_MAX ); #endif diff --git a/Shaders/Include/SIGMA/SIGMA_Shadow_TemporalStabilization.hlsli b/Shaders/Include/SIGMA_TemporalStabilization.hlsli similarity index 80% rename from Shaders/Include/SIGMA/SIGMA_Shadow_TemporalStabilization.hlsli rename to Shaders/Include/SIGMA_TemporalStabilization.hlsli index 75d8c7f..582ed11 100644 --- a/Shaders/Include/SIGMA/SIGMA_Shadow_TemporalStabilization.hlsli +++ b/Shaders/Include/SIGMA_TemporalStabilization.hlsli @@ -13,7 +13,7 @@ groupshared SIGMA_TYPE s_Shadow_Translucency[ BUFFER_Y ][ BUFFER_X ]; void Preload( uint2 sharedPos, int2 globalPos ) { - globalPos = clamp( globalPos, 0, gRectSize - 1.0 ); + globalPos = clamp( globalPos, 0, gRectSizeMinusOne ); float2 data = gIn_Hit_ViewZ[ globalPos ]; data.y = abs( data.y ) / NRD_FP16_VIEWZ_SCALE; @@ -29,15 +29,12 @@ void Preload( uint2 sharedPos, int2 globalPos ) [numthreads( GROUP_X, GROUP_Y, 1 )] NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : SV_DispatchThreadId, uint threadIndex : SV_GroupIndex ) { - uint2 pixelPosUser = pixelPos + gRectOrigin; - float2 pixelUv = ( float2( pixelPos ) + 0.5 ) * gInvRectSize; - // Preload float isSky = gIn_Tiles[ pixelPos >> 4 ].y; PRELOAD_INTO_SMEM_WITH_TILE_CHECK; // Tile-based early out - if( isSky != 0.0 ) + if( isSky != 0.0 || any( pixelPos > gRectSizeMinusOne ) ) return; // Center data @@ -89,8 +86,7 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : w = GetBilateralWeight( z, viewZ ); w *= saturate( 1.0 - abs( centerSignNoL - signNoL ) ); - int2 t1 = int2( i, j ) - BORDER; - if( ( abs( t1.x ) + abs( t1.y ) == 1 ) && z < viewZnearest ) + if( z < viewZnearest ) { viewZnearest = z; offseti = int2( i, j ); @@ -110,25 +106,18 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : SIGMA_TYPE sigma = GetStdDev( m1, m2 ); // Compute previous pixel position - offseti -= BORDER; - float2 offset = float2( offseti ) * gInvRectSize; - float3 Xvnearest = STL::Geometry::ReconstructViewPosition( pixelUv + offset, gFrustum, viewZnearest, gOrthoMode ); - float3 Xnearest = STL::Geometry::RotateVector( gViewToWorld, Xvnearest ); - float3 mv = gIn_Mv[ pixelPosUser + offseti ] * gMvScale; - - float2 pixelUvPrev = pixelUv + offset + mv.xy; - if( gIsWorldSpaceMotionEnabled ) - pixelUvPrev = STL::Geometry::GetScreenUv( gWorldToClipPrev, Xnearest + mv ); - pixelUvPrev -= offset; - - float isInScreen = IsInScreen( pixelUvPrev ); + float2 pixelUv = ( float2( pixelPos ) + 0.5 ) * gRectSizeInv; + float3 Xv = STL::Geometry::ReconstructViewPosition( pixelUv, gFrustum, viewZnearest, gOrthoMode ); + float3 X = STL::Geometry::RotateVectorInverse( gWorldToView, Xv ); + float3 mv = gIn_Mv[ WithRectOrigin( pixelPos ) + offseti - BORDER ] * gMvScale.xyz; + float2 pixelUvPrev = pixelUv + mv.xy; - // Clamp UV to prevent sampling from "invalid" regions - pixelUvPrev = clamp( pixelUvPrev, 1.5 / gRectSizePrev, 1.0 - 1.5 / gRectSizePrev ); + if( gMvScale.w != 0.0 ) + pixelUvPrev = STL::Geometry::GetScreenUv( gWorldToClipPrev, X + mv ); // Sample history SIGMA_TYPE history; - BicubicFilterNoCorners( pixelUvPrev * gRectSizePrev, gInvScreenSize, SIGMA_USE_CATROM, gIn_History, history ); + BicubicFilterNoCorners( saturate( pixelUvPrev ) * gRectSizePrev, gResourceSizeInvPrev, SIGMA_USE_CATROM, gIn_History, history ); history = max( history, 0.0 ); history = UnpackShadow( history ); @@ -144,7 +133,7 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : float2 ratio = abs( a - b ) / ( min( a, b ) + 0.05 ); float2 ratioNorm = ratio / ( 1.0 + ratio ); - float2 scale = 1.0 + SIGMA_MAX_SIGMA_SCALE * ( 1.0 - STL::Math::Sqrt01( ratioNorm ) ); + float2 scale = lerp( SIGMA_MAX_SIGMA_SCALE, 1.0, STL::Math::Sqrt01( ratioNorm ) ); #ifdef SIGMA_TRANSLUCENT sigma *= scale.xyyy; @@ -157,8 +146,9 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : SIGMA_TYPE historyClamped = clamp( history, inputMin, inputMax ); // History weight + float isInScreen = IsInScreenNearest( pixelUvPrev ); float motionLength = length( pixelUvPrev - pixelUv ); - float2 historyWeight = 0.95 * lerp( 1.0, 0.7, ratioNorm ); + float2 historyWeight = 0.93 * lerp( 1.0, 0.7, ratioNorm ); // use FPS-dependent value, like 0.25 * FPS historyWeight = lerp( historyWeight, 0.1, saturate( motionLength / SIGMA_TS_MOTION_MAX_REUSE ) ); historyWeight *= isInScreen; historyWeight *= gContinueAccumulation; diff --git a/Shaders/Resources/Clear_f.resources.hlsli b/Shaders/Resources/Clear_Float.resources.hlsli similarity index 52% rename from Shaders/Resources/Clear_f.resources.hlsli rename to Shaders/Resources/Clear_Float.resources.hlsli index 4f65fde..e85a08e 100644 --- a/Shaders/Resources/Clear_f.resources.hlsli +++ b/Shaders/Resources/Clear_Float.resources.hlsli @@ -8,10 +8,20 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -NRD_CONSTANTS_START - NRD_CONSTANT( float, gDebug ) // ( must be last ) used for availability in Common.hlsl only +NRD_CONSTANTS_START( Clear_FloatConstants ) + NRD_CONSTANT( float, gDebug ) // only for availability in Common.hlsl NRD_CONSTANTS_END -NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut, u, 0 ) -NRD_OUTPUT_TEXTURE_END +NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut, u, 0 ) +NRD_OUTPUTS_END + +// Macro magic +#define Clear_FloatGroupX 16 +#define Clear_FloatGroupY 16 + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X Clear_FloatGroupX +#define GROUP_Y Clear_FloatGroupY diff --git a/Shaders/Resources/Clear_ui.resources.hlsli b/Shaders/Resources/Clear_Uint.resources.hlsli similarity index 53% rename from Shaders/Resources/Clear_ui.resources.hlsli rename to Shaders/Resources/Clear_Uint.resources.hlsli index 2163f25..c267dcc 100644 --- a/Shaders/Resources/Clear_ui.resources.hlsli +++ b/Shaders/Resources/Clear_Uint.resources.hlsli @@ -8,10 +8,20 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -NRD_CONSTANTS_START - NRD_CONSTANT( float, gDebug ) // ( must be last ) used for availability in Common.hlsl only +NRD_CONSTANTS_START( Clear_UintConstants ) + NRD_CONSTANT( float, gDebug ) // only for availability in Common.hlsl NRD_CONSTANTS_END -NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut, u, 0 ) -NRD_OUTPUT_TEXTURE_END +NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut, u, 0 ) +NRD_OUTPUTS_END + +// Macro magic +#define Clear_UintGroupX 16 +#define Clear_UintGroupY 16 + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X Clear_UintGroupX +#define GROUP_Y Clear_UintGroupY diff --git a/Shaders/Resources/REBLUR_Blur.resources.hlsli b/Shaders/Resources/REBLUR_Blur.resources.hlsli new file mode 100644 index 0000000..9c33ec3 --- /dev/null +++ b/Shaders/Resources/REBLUR_Blur.resources.hlsli @@ -0,0 +1,98 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +NRD_CONSTANTS_START( REBLUR_BlurConstants ) + REBLUR_SHARED_CONSTANTS + NRD_CONSTANT( float4, gRotator ) +NRD_CONSTANTS_END + +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +#if( defined REBLUR_DIFFUSE && defined REBLUR_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Tiles, t, 0 ) + NRD_INPUT( Texture2D, gIn_Normal_Roughness, t, 1 ) + NRD_INPUT( Texture2D, gIn_Data1, t, 2 ) + NRD_INPUT( Texture2D, gIn_Diff, t, 3 ) + NRD_INPUT( Texture2D, gIn_Spec, t, 4 ) + NRD_INPUT( Texture2D, gIn_ViewZ, t, 5 ) + #ifdef REBLUR_SH + NRD_INPUT( Texture2D, gIn_DiffSh, t, 6 ) + NRD_INPUT( Texture2D, gIn_SpecSh, t, 7 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Diff, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOut_Spec, u, 1 ) + NRD_OUTPUT( RWTexture2D, gOut_ViewZ, u, 2 ) + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_DiffSh, u, 3 ) + NRD_OUTPUT( RWTexture2D, gOut_SpecSh, u, 4 ) + #endif + NRD_OUTPUTS_END + +#elif( defined REBLUR_DIFFUSE ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Tiles, t, 0 ) + NRD_INPUT( Texture2D, gIn_Normal_Roughness, t, 1 ) + NRD_INPUT( Texture2D, gIn_Data1, t, 2 ) + NRD_INPUT( Texture2D, gIn_Diff, t, 3 ) + NRD_INPUT( Texture2D, gIn_ViewZ, t, 4 ) + #ifdef REBLUR_SH + NRD_INPUT( Texture2D, gIn_DiffSh, t, 5 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Diff, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOut_ViewZ, u, 1 ) + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_DiffSh, u, 2 ) + #endif + NRD_OUTPUTS_END + +#else + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Tiles, t, 0 ) + NRD_INPUT( Texture2D, gIn_Normal_Roughness, t, 1 ) + NRD_INPUT( Texture2D, gIn_Data1, t, 2 ) + NRD_INPUT( Texture2D, gIn_Spec, t, 3 ) + NRD_INPUT( Texture2D, gIn_ViewZ, t, 4 ) + #ifdef REBLUR_SH + NRD_INPUT( Texture2D, gIn_SpecSh, t, 5 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Spec, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOut_ViewZ, u, 1 ) + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_SpecSh, u, 2 ) + #endif + NRD_OUTPUTS_END + +#endif + +// Macro magic +#define REBLUR_BlurGroupX 8 +#define REBLUR_BlurGroupY 16 + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X REBLUR_BlurGroupX +#define GROUP_Y REBLUR_BlurGroupY diff --git a/Shaders/Resources/REBLUR_ClassifyTiles.resources.hlsli b/Shaders/Resources/REBLUR_ClassifyTiles.resources.hlsli index 051d276..406e168 100644 --- a/Shaders/Resources/REBLUR_ClassifyTiles.resources.hlsli +++ b/Shaders/Resources/REBLUR_ClassifyTiles.resources.hlsli @@ -8,14 +8,24 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -NRD_CONSTANTS_START - NRD_CONSTANT( float, gDenoisingRange ) +NRD_CONSTANTS_START( REBLUR_ClassifyTilesConstants ) + REBLUR_SHARED_CONSTANTS NRD_CONSTANTS_END -NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 0 ) -NRD_INPUT_TEXTURE_END +NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_ViewZ, t, 0 ) +NRD_INPUTS_END -NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Tiles, u, 0 ) -NRD_OUTPUT_TEXTURE_END +NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Tiles, u, 0 ) +NRD_OUTPUTS_END + +// Macro magic +#define REBLUR_ClassifyTilesGroupX 16 +#define REBLUR_ClassifyTilesGroupY 16 + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X REBLUR_ClassifyTilesGroupX +#define GROUP_Y REBLUR_ClassifyTilesGroupY diff --git a/Shaders/Resources/REBLUR_Copy.resources.hlsli b/Shaders/Resources/REBLUR_Copy.resources.hlsli new file mode 100644 index 0000000..54d2bed --- /dev/null +++ b/Shaders/Resources/REBLUR_Copy.resources.hlsli @@ -0,0 +1,80 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +NRD_CONSTANTS_START( REBLUR_CopyConstants ) + REBLUR_SHARED_CONSTANTS +NRD_CONSTANTS_END + +#if( defined REBLUR_DIFFUSE && defined REBLUR_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Tiles, t, 0 ) + NRD_INPUT( Texture2D, gIn_Diff, t, 1 ) + NRD_INPUT( Texture2D, gIn_Spec, t, 2 ) + #ifdef REBLUR_SH + NRD_INPUT( Texture2D, gIn_DiffSh, t, 3 ) + NRD_INPUT( Texture2D, gIn_SpecSh, t, 4 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Diff, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOut_Spec, u, 1 ) + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_DiffSh, u, 2 ) + NRD_OUTPUT( RWTexture2D, gOut_SpecSh, u, 3 ) + #endif + NRD_OUTPUTS_END + +#elif( defined REBLUR_DIFFUSE ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Tiles, t, 0 ) + NRD_INPUT( Texture2D, gIn_Diff, t, 1 ) + #ifdef REBLUR_SH + NRD_INPUT( Texture2D, gIn_DiffSh, t, 2 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Diff, u, 0 ) + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_DiffSh, u, 1 ) + #endif + NRD_OUTPUTS_END + +#else + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Tiles, t, 0 ) + NRD_INPUT( Texture2D, gIn_Spec, t, 1 ) + #ifdef REBLUR_SH + NRD_INPUT( Texture2D, gIn_SpecSh, t, 2 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Spec, u, 0 ) + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_SpecSh, u, 1 ) + #endif + NRD_OUTPUTS_END + +#endif + +// Macro magic +#define REBLUR_CopyGroupX 8 +#define REBLUR_CopyGroupY 16 + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X REBLUR_CopyGroupX +#define GROUP_Y REBLUR_CopyGroupY diff --git a/Shaders/Resources/REBLUR_DiffuseSpecular_Blur.resources.hlsli b/Shaders/Resources/REBLUR_DiffuseSpecular_Blur.resources.hlsli deleted file mode 100644 index 6d02315..0000000 --- a/Shaders/Resources/REBLUR_DiffuseSpecular_Blur.resources.hlsli +++ /dev/null @@ -1,94 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -NRD_CONSTANTS_START - REBLUR_SHARED_CB_DATA - NRD_CONSTANT( float4, gRotator ) -NRD_CONSTANTS_END - -#if( defined REBLUR_DIFFUSE && defined REBLUR_SPECULAR ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Normal_Roughness, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Data1, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec, t, 4 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 5 ) - #ifdef REBLUR_SH - NRD_INPUT_TEXTURE( Texture2D, gIn_DiffSh, t, 6 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_SpecSh, t, 7 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Diff, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Spec, u, 1 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_ViewZ, u, 2 ) - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_DiffSh, u, 3 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_SpecSh, u, 4 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#elif( defined REBLUR_DIFFUSE ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Normal_Roughness, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Data1, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 4 ) - #ifdef REBLUR_SH - NRD_INPUT_TEXTURE( Texture2D, gIn_DiffSh, t, 5 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Diff, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_ViewZ, u, 1 ) - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_DiffSh, u, 2 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#else - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Normal_Roughness, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Data1, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 4 ) - #ifdef REBLUR_SH - NRD_INPUT_TEXTURE( Texture2D, gIn_SpecSh, t, 5 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Spec, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_ViewZ, u, 1 ) - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_SpecSh, u, 2 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#endif - -// Macro magic -#define GROUP_X 8 -#define GROUP_Y 8 diff --git a/Shaders/Resources/REBLUR_DiffuseSpecular_CopyStabilizedHistory.resources.hlsli b/Shaders/Resources/REBLUR_DiffuseSpecular_CopyStabilizedHistory.resources.hlsli deleted file mode 100644 index ff9a54c..0000000 --- a/Shaders/Resources/REBLUR_DiffuseSpecular_CopyStabilizedHistory.resources.hlsli +++ /dev/null @@ -1,71 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -NRD_CONSTANTS_START - NRD_CONSTANT( uint, gIsRectChanged ) - NRD_CONSTANT( float, gDebug ) // ( must be last ) used for availability in Common.hlsl only -NRD_CONSTANTS_END - -#if( defined REBLUR_DIFFUSE && defined REBLUR_SPECULAR ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec, t, 2 ) - #ifdef REBLUR_SH - NRD_INPUT_TEXTURE( Texture2D, gIn_DiffSh, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_SpecSh, t, 4 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Diff, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Spec, u, 1 ) - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_DiffSh, u, 2 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_SpecSh, u, 3 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#elif( defined REBLUR_DIFFUSE ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff, t, 1 ) - #ifdef REBLUR_SH - NRD_INPUT_TEXTURE( Texture2D, gIn_DiffSh, t, 2 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Diff, u, 0 ) - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_DiffSh, u, 1 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#else - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec, t, 1 ) - #ifdef REBLUR_SH - NRD_INPUT_TEXTURE( Texture2D, gIn_SpecSh, t, 2 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Spec, u, 0 ) - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_SpecSh, u, 1 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#endif diff --git a/Shaders/Resources/REBLUR_DiffuseSpecular_HistoryFix.resources.hlsli b/Shaders/Resources/REBLUR_DiffuseSpecular_HistoryFix.resources.hlsli deleted file mode 100644 index 82cf854..0000000 --- a/Shaders/Resources/REBLUR_DiffuseSpecular_HistoryFix.resources.hlsli +++ /dev/null @@ -1,98 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -NRD_CONSTANTS_START - REBLUR_SHARED_CB_DATA - NRD_CONSTANT( float, gHistoryFixStrideBetweenSamples ) -NRD_CONSTANTS_END - -#if( defined REBLUR_DIFFUSE && defined REBLUR_SPECULAR ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Normal_Roughness, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Data1, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff, t, 4 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec, t, 5 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_DiffFast, t, 6 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_SpecFast, t, 7 ) - #ifdef REBLUR_SH - NRD_INPUT_TEXTURE( Texture2D, gIn_DiffSh, t, 8 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_SpecSh, t, 9 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Diff, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Spec, u, 1 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_DiffFast, u, 2 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_SpecFast, u, 3 ) - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_DiffSh, u, 4 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_SpecSh, u, 5 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#elif( defined REBLUR_DIFFUSE ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Normal_Roughness, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Data1, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff, t, 4 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_DiffFast, t, 5 ) - #ifdef REBLUR_SH - NRD_INPUT_TEXTURE( Texture2D, gIn_DiffSh, t, 6 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Diff, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_DiffFast, u, 1 ) - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_DiffSh, u, 2 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#else - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Normal_Roughness, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Data1, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec, t, 4 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_SpecFast, t, 5 ) - #ifdef REBLUR_SH - NRD_INPUT_TEXTURE( Texture2D, gIn_SpecSh, t, 6 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Spec, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_SpecFast, u, 1 ) - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_SpecSh, u, 2 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#endif - -// Macro magic -#define NRD_USE_BORDER_2 diff --git a/Shaders/Resources/REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli b/Shaders/Resources/REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli deleted file mode 100644 index 03ca79c..0000000 --- a/Shaders/Resources/REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli +++ /dev/null @@ -1,71 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -NRD_CONSTANTS_START - REBLUR_SHARED_CB_DATA -NRD_CONSTANTS_END - -#if( defined REBLUR_DIFFUSE && defined REBLUR_SPECULAR ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Normal_Roughness, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec, t, 4 ) - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Diff, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Spec, u, 1 ) - NRD_OUTPUT_TEXTURE_END - -#elif( defined REBLUR_DIFFUSE ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Normal_Roughness, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff, t, 3 ) - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Diff, u, 0 ) - NRD_OUTPUT_TEXTURE_END - -#else - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Normal_Roughness, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec, t, 3 ) - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Spec, u, 0 ) - NRD_OUTPUT_TEXTURE_END - -#endif - -// Macro magic -#define GROUP_X 8 -#define GROUP_Y 8 - -#ifdef REBLUR_HITDIST_RECONSTRUCTION_5X5 - #define NRD_USE_BORDER_2 -#endif diff --git a/Shaders/Resources/REBLUR_DiffuseSpecular_PostBlur.resources.hlsli b/Shaders/Resources/REBLUR_DiffuseSpecular_PostBlur.resources.hlsli deleted file mode 100644 index 610aef7..0000000 --- a/Shaders/Resources/REBLUR_DiffuseSpecular_PostBlur.resources.hlsli +++ /dev/null @@ -1,116 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -NRD_CONSTANTS_START - REBLUR_SHARED_CB_DATA - NRD_CONSTANT( float4, gRotator ) -NRD_CONSTANTS_END - -#if( defined REBLUR_DIFFUSE && defined REBLUR_SPECULAR ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Normal_Roughness, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Data1, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec, t, 4 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 5 ) - #ifdef REBLUR_SH - NRD_INPUT_TEXTURE( Texture2D, gIn_DiffSh, t, 6 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_SpecSh, t, 7 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Normal_Roughness, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Diff, u, 1 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Spec, u, 2 ) - #ifdef REBLUR_NO_TEMPORAL_STABILIZATION - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_InternalData, u, 3 ) - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_DiffSh, u, 4 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_SpecSh, u, 5 ) - #endif - #else - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_DiffSh, u, 3 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_SpecSh, u, 4 ) - #endif - #endif - NRD_OUTPUT_TEXTURE_END - -#elif( defined REBLUR_DIFFUSE ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Normal_Roughness, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Data1, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 4 ) - #ifdef REBLUR_SH - NRD_INPUT_TEXTURE( Texture2D, gIn_DiffSh, t, 5 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Normal_Roughness, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Diff, u, 1 ) - #ifdef REBLUR_NO_TEMPORAL_STABILIZATION - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_InternalData, u, 2 ) - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_DiffSh, u, 3 ) - #endif - #else - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_DiffSh, u, 2 ) - #endif - #endif - NRD_OUTPUT_TEXTURE_END - -#else - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Normal_Roughness, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Data1, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 4 ) - #ifdef REBLUR_SH - NRD_INPUT_TEXTURE( Texture2D, gIn_SpecSh, t, 5 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Normal_Roughness, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Spec, u, 1 ) - #ifdef REBLUR_NO_TEMPORAL_STABILIZATION - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_InternalData, u, 2 ) - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_SpecSh, u, 3 ) - #endif - #else - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_SpecSh, u, 2 ) - #endif - #endif - NRD_OUTPUT_TEXTURE_END - -#endif - -// Macro magic -#define GROUP_X 8 -#define GROUP_Y 8 diff --git a/Shaders/Resources/REBLUR_DiffuseSpecular_PrePass.resources.hlsli b/Shaders/Resources/REBLUR_DiffuseSpecular_PrePass.resources.hlsli deleted file mode 100644 index 461869c..0000000 --- a/Shaders/Resources/REBLUR_DiffuseSpecular_PrePass.resources.hlsli +++ /dev/null @@ -1,88 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -NRD_CONSTANTS_START - REBLUR_SHARED_CB_DATA - NRD_CONSTANT( float4, gRotator ) - NRD_CONSTANT( uint, gDiffCheckerboard ) - NRD_CONSTANT( uint, gSpecCheckerboard ) -NRD_CONSTANTS_END - -#if( defined REBLUR_DIFFUSE && defined REBLUR_SPECULAR ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Normal_Roughness, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec, t, 4 ) - #ifdef REBLUR_SH - NRD_INPUT_TEXTURE( Texture2D, gIn_DiffSh, t, 5 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_SpecSh, t, 6 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Diff, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Spec, u, 1 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Spec_HitDistForTracking, u, 2 ) - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_DiffSh, u, 3 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_SpecSh, u, 4 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#elif( defined REBLUR_DIFFUSE ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Normal_Roughness, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff, t, 3 ) - #ifdef REBLUR_SH - NRD_INPUT_TEXTURE( Texture2D, gIn_DiffSh, t, 4 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Diff, u, 0 ) - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_DiffSh, u, 1 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#else - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Normal_Roughness, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec, t, 3 ) - #ifdef REBLUR_SH - NRD_INPUT_TEXTURE( Texture2D, gIn_SpecSh, t, 4 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Spec, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Spec_HitDistForTracking, u, 1 ) - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_SpecSh, u, 2 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#endif diff --git a/Shaders/Resources/REBLUR_DiffuseSpecular_SplitScreen.resources.hlsli b/Shaders/Resources/REBLUR_DiffuseSpecular_SplitScreen.resources.hlsli deleted file mode 100644 index 4669f3d..0000000 --- a/Shaders/Resources/REBLUR_DiffuseSpecular_SplitScreen.resources.hlsli +++ /dev/null @@ -1,80 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -NRD_CONSTANTS_START - REBLUR_SHARED_CB_DATA - NRD_CONSTANT( float, gSplitScreen ) - NRD_CONSTANT( uint, gDiffCheckerboard ) - NRD_CONSTANT( uint, gSpecCheckerboard ) -NRD_CONSTANTS_END - -#if( defined REBLUR_DIFFUSE && defined REBLUR_SPECULAR ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec, t, 2 ) - #ifdef REBLUR_SH - NRD_INPUT_TEXTURE( Texture2D, gIn_DiffSh, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_SpecSh, t, 4 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Diff, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Spec, u, 1 ) - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_DiffSh, u, 2 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_SpecSh, u, 3 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#elif( defined REBLUR_DIFFUSE ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff, t, 1 ) - #ifdef REBLUR_SH - NRD_INPUT_TEXTURE( Texture2D, gIn_DiffSh, t, 2 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Diff, u, 0 ) - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_DiffSh, u, 1 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#else - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec, t, 1 ) - #ifdef REBLUR_SH - NRD_INPUT_TEXTURE( Texture2D, gIn_SpecSh, t, 2 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Spec, u, 0 ) - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_SpecSh, u, 1 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#endif diff --git a/Shaders/Resources/REBLUR_DiffuseSpecular_TemporalAccumulation.resources.hlsli b/Shaders/Resources/REBLUR_DiffuseSpecular_TemporalAccumulation.resources.hlsli deleted file mode 100644 index e5ce4a5..0000000 --- a/Shaders/Resources/REBLUR_DiffuseSpecular_TemporalAccumulation.resources.hlsli +++ /dev/null @@ -1,158 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -NRD_CONSTANTS_START - REBLUR_SHARED_CB_DATA - NRD_CONSTANT( float4x4, gWorldToViewPrev ) - NRD_CONSTANT( float4x4, gWorldToClipPrev ) - NRD_CONSTANT( float4x4, gWorldToClip ) - NRD_CONSTANT( float4x4, gWorldPrevToWorld ) - NRD_CONSTANT( float4, gFrustumPrev ) - NRD_CONSTANT( float3, gCameraDelta ) - NRD_CONSTANT( float, gDisocclusionThreshold ) - NRD_CONSTANT( float, gDisocclusionThresholdAlternate ) - NRD_CONSTANT( float, gCheckerboardResolveAccumSpeed ) - NRD_CONSTANT( uint, gDiffCheckerboard ) - NRD_CONSTANT( uint, gSpecCheckerboard ) - NRD_CONSTANT( uint, gIsPrepassEnabled ) - NRD_CONSTANT( uint, gHasHistoryConfidence ) - NRD_CONSTANT( uint, gHasDisocclusionThresholdMix ) -NRD_CONSTANTS_END - -#if( defined REBLUR_DIFFUSE && defined REBLUR_SPECULAR ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Normal_Roughness, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Mv, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Prev_ViewZ, t, 4 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Prev_Normal_Roughness, t, 5 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Prev_InternalData, t, 6 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_DisocclusionThresholdMix, t, 7 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff_Confidence, t, 8 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec_Confidence, t, 9 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff, t, 10 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec, t, 11 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff_History, t, 12 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec_History, t, 13 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_DiffFast_History, t, 14 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_SpecFast_History, t, 15 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Prev_Spec_HitDistForTracking, t, 16 ) - #ifndef REBLUR_OCCLUSION - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec_HitDistForTracking, t, 17 ) - #endif - #ifdef REBLUR_SH - NRD_INPUT_TEXTURE( Texture2D, gIn_DiffSh, t, 18 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_SpecSh, t, 19 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_DiffSh_History, t, 20 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_SpecSh_History, t, 21 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Diff, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Spec, u, 1 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_DiffFast, u, 2 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_SpecFast, u, 3 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Spec_HitDistForTracking, u, 4 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Data1, u, 5 ) - #ifndef REBLUR_OCCLUSION - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Data2, u, 6 ) - #endif - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_DiffSh, u, 7 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_SpecSh, u, 8 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#elif( defined REBLUR_DIFFUSE ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Normal_Roughness, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Mv, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Prev_ViewZ, t, 4 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Prev_Normal_Roughness, t, 5 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Prev_InternalData, t, 6 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_DisocclusionThresholdMix, t, 7 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff_Confidence, t, 8 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff, t, 9 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff_History, t, 10 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_DiffFast_History, t, 11 ) - #ifdef REBLUR_SH - NRD_INPUT_TEXTURE( Texture2D, gIn_DiffSh, t, 12 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_DiffSh_History, t, 13 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Diff, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_DiffFast, u, 1 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Data1, u, 2 ) - #ifndef REBLUR_OCCLUSION - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Data2, u, 3 ) - #endif - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_DiffSh, u, 4 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#else - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Normal_Roughness, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Mv, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Prev_ViewZ, t, 4 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Prev_Normal_Roughness, t, 5 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Prev_InternalData, t, 6 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_DisocclusionThresholdMix, t, 7 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec_Confidence, t, 8 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec, t, 9 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec_History, t, 10 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_SpecFast_History, t, 11 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Prev_Spec_HitDistForTracking, t, 12 ) - #ifndef REBLUR_OCCLUSION - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec_HitDistForTracking, t, 13 ) - #endif - #ifdef REBLUR_SH - NRD_INPUT_TEXTURE( Texture2D, gIn_SpecSh, t, 14 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_SpecSh_History, t, 15 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Spec, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_SpecFast, u, 1 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Spec_HitDistForTracking, u, 2 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Data1, u, 3 ) - #ifndef REBLUR_OCCLUSION - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Data2, u, 4 ) - #endif - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_SpecSh, u, 5 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#endif - -// Macro magic -#define GROUP_X 8 -#define GROUP_Y 8 diff --git a/Shaders/Resources/REBLUR_DiffuseSpecular_TemporalStabilization.resources.hlsli b/Shaders/Resources/REBLUR_DiffuseSpecular_TemporalStabilization.resources.hlsli deleted file mode 100644 index 9a5c61c..0000000 --- a/Shaders/Resources/REBLUR_DiffuseSpecular_TemporalStabilization.resources.hlsli +++ /dev/null @@ -1,120 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -NRD_CONSTANTS_START - REBLUR_SHARED_CB_DATA - NRD_CONSTANT( float4x4, gWorldToClip ) - NRD_CONSTANT( float4x4, gWorldToClipPrev ) - NRD_CONSTANT( float4x4, gWorldToViewPrev ) - NRD_CONSTANT( float4, gFrustumPrev ) - NRD_CONSTANT( float3, gCameraDelta ) - NRD_CONSTANT( float, gStabilizationStrength ) - NRD_CONSTANT( float4, gAntilagParams ) - NRD_CONSTANT( float2, gSpecularProbabilityThresholdsForMvModification ) - NRD_CONSTANT( float, gSplitScreen ) -NRD_CONSTANTS_END - -#if( defined REBLUR_DIFFUSE && defined REBLUR_SPECULAR ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Normal_Roughness, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_BaseColor_Metalness, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Data1, t, 4 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Data2, t, 5 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff, t, 6 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec, t, 7 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff_StabilizedHistory, t, 8 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec_StabilizedHistory, t, 9 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec_HitDistForTracking, t, 10 ) - #ifdef REBLUR_SH - NRD_INPUT_TEXTURE( Texture2D, gIn_DiffSh, t, 11 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_SpecSh, t, 12 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_DiffSh_StabilizedHistory, t, 13 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_SpecSh_StabilizedHistory, t, 14 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gInOut_Mv, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_InternalData, u, 1 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Diff, u, 2 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Spec, u, 3 ) - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_DiffSh, u, 4 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_SpecSh, u, 5 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#elif( defined REBLUR_DIFFUSE ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Normal_Roughness, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Data1, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Data2, t, 4 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff, t, 5 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff_StabilizedHistory, t, 6 ) - #ifdef REBLUR_SH - NRD_INPUT_TEXTURE( Texture2D, gIn_DiffSh, t, 7 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_DiffSh_StabilizedHistory, t, 8 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gInOut_Mv, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_InternalData, u, 1 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Diff, u, 2 ) - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_DiffSh, u, 3 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#else - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Normal_Roughness, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_BaseColor_Metalness, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Data1, t, 4 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Data2, t, 5 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec, t, 6 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec_StabilizedHistory, t, 7 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec_HitDistForTracking, t, 8 ) - #ifdef REBLUR_SH - NRD_INPUT_TEXTURE( Texture2D, gIn_SpecSh, t, 9 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_SpecSh_StabilizedHistory, t, 10 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gInOut_Mv, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_InternalData, u, 1 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Spec, u, 2 ) - #ifdef REBLUR_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_SpecSh, u, 3 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#endif - -// Macro magic -#define GROUP_X 8 -#define GROUP_Y 8 diff --git a/Shaders/Resources/REBLUR_HistoryFix.resources.hlsli b/Shaders/Resources/REBLUR_HistoryFix.resources.hlsli new file mode 100644 index 0000000..7b46627 --- /dev/null +++ b/Shaders/Resources/REBLUR_HistoryFix.resources.hlsli @@ -0,0 +1,104 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +NRD_CONSTANTS_START( REBLUR_HistoryFixConstants ) + REBLUR_SHARED_CONSTANTS +NRD_CONSTANTS_END + +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +#if( defined REBLUR_DIFFUSE && defined REBLUR_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Tiles, t, 0 ) + NRD_INPUT( Texture2D, gIn_Normal_Roughness, t, 1 ) + NRD_INPUT( Texture2D, gIn_Data1, t, 2 ) + NRD_INPUT( Texture2D, gIn_ViewZ, t, 3 ) + NRD_INPUT( Texture2D, gIn_Diff, t, 4 ) + NRD_INPUT( Texture2D, gIn_Spec, t, 5 ) + NRD_INPUT( Texture2D, gIn_DiffFast, t, 6 ) + NRD_INPUT( Texture2D, gIn_SpecFast, t, 7 ) + #ifdef REBLUR_SH + NRD_INPUT( Texture2D, gIn_DiffSh, t, 8 ) + NRD_INPUT( Texture2D, gIn_SpecSh, t, 9 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Diff, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOut_Spec, u, 1 ) + NRD_OUTPUT( RWTexture2D, gOut_DiffFast, u, 2 ) + NRD_OUTPUT( RWTexture2D, gOut_SpecFast, u, 3 ) + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_DiffSh, u, 4 ) + NRD_OUTPUT( RWTexture2D, gOut_SpecSh, u, 5 ) + #endif + NRD_OUTPUTS_END + +#elif( defined REBLUR_DIFFUSE ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Tiles, t, 0 ) + NRD_INPUT( Texture2D, gIn_Normal_Roughness, t, 1 ) + NRD_INPUT( Texture2D, gIn_Data1, t, 2 ) + NRD_INPUT( Texture2D, gIn_ViewZ, t, 3 ) + NRD_INPUT( Texture2D, gIn_Diff, t, 4 ) + NRD_INPUT( Texture2D, gIn_DiffFast, t, 5 ) + #ifdef REBLUR_SH + NRD_INPUT( Texture2D, gIn_DiffSh, t, 6 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Diff, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOut_DiffFast, u, 1 ) + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_DiffSh, u, 2 ) + #endif + NRD_OUTPUTS_END + +#else + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Tiles, t, 0 ) + NRD_INPUT( Texture2D, gIn_Normal_Roughness, t, 1 ) + NRD_INPUT( Texture2D, gIn_Data1, t, 2 ) + NRD_INPUT( Texture2D, gIn_ViewZ, t, 3 ) + NRD_INPUT( Texture2D, gIn_Spec, t, 4 ) + NRD_INPUT( Texture2D, gIn_SpecFast, t, 5 ) + #ifdef REBLUR_SH + NRD_INPUT( Texture2D, gIn_SpecSh, t, 6 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Spec, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOut_SpecFast, u, 1 ) + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_SpecSh, u, 2 ) + #endif + NRD_OUTPUTS_END + +#endif + +// Macro magic +#define REBLUR_HistoryFixGroupX 8 +#define REBLUR_HistoryFixGroupY 16 + +#define NRD_USE_BORDER_2 + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X REBLUR_HistoryFixGroupX +#define GROUP_Y REBLUR_HistoryFixGroupY diff --git a/Shaders/Resources/REBLUR_HitDistReconstruction.resources.hlsli b/Shaders/Resources/REBLUR_HitDistReconstruction.resources.hlsli new file mode 100644 index 0000000..efc1f9f --- /dev/null +++ b/Shaders/Resources/REBLUR_HitDistReconstruction.resources.hlsli @@ -0,0 +1,75 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +NRD_CONSTANTS_START( REBLUR_HitDistReconstructionConstants ) + REBLUR_SHARED_CONSTANTS +NRD_CONSTANTS_END + +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +#if( defined REBLUR_DIFFUSE && defined REBLUR_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Tiles, t, 0 ) + NRD_INPUT( Texture2D, gIn_Normal_Roughness, t, 1 ) + NRD_INPUT( Texture2D, gIn_ViewZ, t, 2 ) + NRD_INPUT( Texture2D, gIn_Diff, t, 3 ) + NRD_INPUT( Texture2D, gIn_Spec, t, 4 ) + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Diff, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOut_Spec, u, 1 ) + NRD_OUTPUTS_END + +#elif( defined REBLUR_DIFFUSE ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Tiles, t, 0 ) + NRD_INPUT( Texture2D, gIn_Normal_Roughness, t, 1 ) + NRD_INPUT( Texture2D, gIn_ViewZ, t, 2 ) + NRD_INPUT( Texture2D, gIn_Diff, t, 3 ) + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Diff, u, 0 ) + NRD_OUTPUTS_END + +#else + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Tiles, t, 0 ) + NRD_INPUT( Texture2D, gIn_Normal_Roughness, t, 1 ) + NRD_INPUT( Texture2D, gIn_ViewZ, t, 2 ) + NRD_INPUT( Texture2D, gIn_Spec, t, 3 ) + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Spec, u, 0 ) + NRD_OUTPUTS_END + +#endif + +// Macro magic +#define REBLUR_HitDistReconstructionGroupX 8 +#define REBLUR_HitDistReconstructionGroupY 16 + +#ifdef REBLUR_HITDIST_RECONSTRUCTION_5X5 + #define NRD_USE_BORDER_2 +#endif + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X REBLUR_HitDistReconstructionGroupX +#define GROUP_Y REBLUR_HitDistReconstructionGroupY diff --git a/Shaders/Resources/REBLUR_PostBlur.resources.hlsli b/Shaders/Resources/REBLUR_PostBlur.resources.hlsli new file mode 100644 index 0000000..5cb0207 --- /dev/null +++ b/Shaders/Resources/REBLUR_PostBlur.resources.hlsli @@ -0,0 +1,120 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +NRD_CONSTANTS_START( REBLUR_PostBlurConstants ) + REBLUR_SHARED_CONSTANTS + NRD_CONSTANT( float4, gRotator ) +NRD_CONSTANTS_END + +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +#if( defined REBLUR_DIFFUSE && defined REBLUR_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Tiles, t, 0 ) + NRD_INPUT( Texture2D, gIn_Normal_Roughness, t, 1 ) + NRD_INPUT( Texture2D, gIn_Data1, t, 2 ) + NRD_INPUT( Texture2D, gIn_Diff, t, 3 ) + NRD_INPUT( Texture2D, gIn_Spec, t, 4 ) + NRD_INPUT( Texture2D, gIn_ViewZ, t, 5 ) + #ifdef REBLUR_SH + NRD_INPUT( Texture2D, gIn_DiffSh, t, 6 ) + NRD_INPUT( Texture2D, gIn_SpecSh, t, 7 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Normal_Roughness, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOut_Diff, u, 1 ) + NRD_OUTPUT( RWTexture2D, gOut_Spec, u, 2 ) + #ifdef REBLUR_NO_TEMPORAL_STABILIZATION + NRD_OUTPUT( RWTexture2D, gOut_InternalData, u, 3 ) + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_DiffSh, u, 4 ) + NRD_OUTPUT( RWTexture2D, gOut_SpecSh, u, 5 ) + #endif + #else + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_DiffSh, u, 3 ) + NRD_OUTPUT( RWTexture2D, gOut_SpecSh, u, 4 ) + #endif + #endif + NRD_OUTPUTS_END + +#elif( defined REBLUR_DIFFUSE ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Tiles, t, 0 ) + NRD_INPUT( Texture2D, gIn_Normal_Roughness, t, 1 ) + NRD_INPUT( Texture2D, gIn_Data1, t, 2 ) + NRD_INPUT( Texture2D, gIn_Diff, t, 3 ) + NRD_INPUT( Texture2D, gIn_ViewZ, t, 4 ) + #ifdef REBLUR_SH + NRD_INPUT( Texture2D, gIn_DiffSh, t, 5 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Normal_Roughness, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOut_Diff, u, 1 ) + #ifdef REBLUR_NO_TEMPORAL_STABILIZATION + NRD_OUTPUT( RWTexture2D, gOut_InternalData, u, 2 ) + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_DiffSh, u, 3 ) + #endif + #else + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_DiffSh, u, 2 ) + #endif + #endif + NRD_OUTPUTS_END + +#else + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Tiles, t, 0 ) + NRD_INPUT( Texture2D, gIn_Normal_Roughness, t, 1 ) + NRD_INPUT( Texture2D, gIn_Data1, t, 2 ) + NRD_INPUT( Texture2D, gIn_Spec, t, 3 ) + NRD_INPUT( Texture2D, gIn_ViewZ, t, 4 ) + #ifdef REBLUR_SH + NRD_INPUT( Texture2D, gIn_SpecSh, t, 5 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Normal_Roughness, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOut_Spec, u, 1 ) + #ifdef REBLUR_NO_TEMPORAL_STABILIZATION + NRD_OUTPUT( RWTexture2D, gOut_InternalData, u, 2 ) + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_SpecSh, u, 3 ) + #endif + #else + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_SpecSh, u, 2 ) + #endif + #endif + NRD_OUTPUTS_END + +#endif + +// Macro magic +#define REBLUR_PostBlurGroupX 8 +#define REBLUR_PostBlurGroupY 16 + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X REBLUR_PostBlurGroupX +#define GROUP_Y REBLUR_PostBlurGroupY diff --git a/Shaders/Resources/REBLUR_PrePass.resources.hlsli b/Shaders/Resources/REBLUR_PrePass.resources.hlsli new file mode 100644 index 0000000..fdd111d --- /dev/null +++ b/Shaders/Resources/REBLUR_PrePass.resources.hlsli @@ -0,0 +1,94 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +NRD_CONSTANTS_START( REBLUR_PrePassConstants ) + REBLUR_SHARED_CONSTANTS + NRD_CONSTANT( float4, gRotator ) +NRD_CONSTANTS_END + +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +#if( defined REBLUR_DIFFUSE && defined REBLUR_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Tiles, t, 0 ) + NRD_INPUT( Texture2D, gIn_Normal_Roughness, t, 1 ) + NRD_INPUT( Texture2D, gIn_ViewZ, t, 2 ) + NRD_INPUT( Texture2D, gIn_Diff, t, 3 ) + NRD_INPUT( Texture2D, gIn_Spec, t, 4 ) + #ifdef REBLUR_SH + NRD_INPUT( Texture2D, gIn_DiffSh, t, 5 ) + NRD_INPUT( Texture2D, gIn_SpecSh, t, 6 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Diff, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOut_Spec, u, 1 ) + NRD_OUTPUT( RWTexture2D, gOut_Spec_HitDistForTracking, u, 2 ) + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_DiffSh, u, 3 ) + NRD_OUTPUT( RWTexture2D, gOut_SpecSh, u, 4 ) + #endif + NRD_OUTPUTS_END + +#elif( defined REBLUR_DIFFUSE ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Tiles, t, 0 ) + NRD_INPUT( Texture2D, gIn_Normal_Roughness, t, 1 ) + NRD_INPUT( Texture2D, gIn_ViewZ, t, 2 ) + NRD_INPUT( Texture2D, gIn_Diff, t, 3 ) + #ifdef REBLUR_SH + NRD_INPUT( Texture2D, gIn_DiffSh, t, 4 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Diff, u, 0 ) + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_DiffSh, u, 1 ) + #endif + NRD_OUTPUTS_END + +#else + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Tiles, t, 0 ) + NRD_INPUT( Texture2D, gIn_Normal_Roughness, t, 1 ) + NRD_INPUT( Texture2D, gIn_ViewZ, t, 2 ) + NRD_INPUT( Texture2D, gIn_Spec, t, 3 ) + #ifdef REBLUR_SH + NRD_INPUT( Texture2D, gIn_SpecSh, t, 4 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Spec, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOut_Spec_HitDistForTracking, u, 1 ) + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_SpecSh, u, 2 ) + #endif + NRD_OUTPUTS_END + +#endif + +// Macro magic +#define REBLUR_PrePassGroupX 8 +#define REBLUR_PrePassGroupY 16 + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X REBLUR_PrePassGroupX +#define GROUP_Y REBLUR_PrePassGroupY diff --git a/Shaders/Resources/REBLUR_SplitScreen.resources.hlsli b/Shaders/Resources/REBLUR_SplitScreen.resources.hlsli new file mode 100644 index 0000000..5f123f8 --- /dev/null +++ b/Shaders/Resources/REBLUR_SplitScreen.resources.hlsli @@ -0,0 +1,85 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +NRD_CONSTANTS_START( REBLUR_SplitScreenConstants ) + REBLUR_SHARED_CONSTANTS +NRD_CONSTANTS_END + +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +#if( defined REBLUR_DIFFUSE && defined REBLUR_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_ViewZ, t, 0 ) + NRD_INPUT( Texture2D, gIn_Diff, t, 1 ) + NRD_INPUT( Texture2D, gIn_Spec, t, 2 ) + #ifdef REBLUR_SH + NRD_INPUT( Texture2D, gIn_DiffSh, t, 3 ) + NRD_INPUT( Texture2D, gIn_SpecSh, t, 4 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Diff, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOut_Spec, u, 1 ) + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_DiffSh, u, 2 ) + NRD_OUTPUT( RWTexture2D, gOut_SpecSh, u, 3 ) + #endif + NRD_OUTPUTS_END + +#elif( defined REBLUR_DIFFUSE ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_ViewZ, t, 0 ) + NRD_INPUT( Texture2D, gIn_Diff, t, 1 ) + #ifdef REBLUR_SH + NRD_INPUT( Texture2D, gIn_DiffSh, t, 2 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Diff, u, 0 ) + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_DiffSh, u, 1 ) + #endif + NRD_OUTPUTS_END + +#else + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_ViewZ, t, 0 ) + NRD_INPUT( Texture2D, gIn_Spec, t, 1 ) + #ifdef REBLUR_SH + NRD_INPUT( Texture2D, gIn_SpecSh, t, 2 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Spec, u, 0 ) + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_SpecSh, u, 1 ) + #endif + NRD_OUTPUTS_END + +#endif + +// Macro magic +#define REBLUR_SplitScreenGroupX 8 +#define REBLUR_SplitScreenGroupY 16 + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X REBLUR_SplitScreenGroupX +#define GROUP_Y REBLUR_SplitScreenGroupY diff --git a/Shaders/Resources/REBLUR_TemporalAccumulation.resources.hlsli b/Shaders/Resources/REBLUR_TemporalAccumulation.resources.hlsli new file mode 100644 index 0000000..e0078c1 --- /dev/null +++ b/Shaders/Resources/REBLUR_TemporalAccumulation.resources.hlsli @@ -0,0 +1,148 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +NRD_CONSTANTS_START( REBLUR_TemporalAccumulationConstants ) + REBLUR_SHARED_CONSTANTS +NRD_CONSTANTS_END + +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +#if( defined REBLUR_DIFFUSE && defined REBLUR_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Tiles, t, 0 ) + NRD_INPUT( Texture2D, gIn_Normal_Roughness, t, 1 ) + NRD_INPUT( Texture2D, gIn_ViewZ, t, 2 ) + NRD_INPUT( Texture2D, gIn_Mv, t, 3 ) + NRD_INPUT( Texture2D, gIn_Prev_ViewZ, t, 4 ) + NRD_INPUT( Texture2D, gIn_Prev_Normal_Roughness, t, 5 ) + NRD_INPUT( Texture2D, gIn_Prev_InternalData, t, 6 ) + NRD_INPUT( Texture2D, gIn_DisocclusionThresholdMix, t, 7 ) + NRD_INPUT( Texture2D, gIn_Diff_Confidence, t, 8 ) + NRD_INPUT( Texture2D, gIn_Spec_Confidence, t, 9 ) + NRD_INPUT( Texture2D, gIn_Diff, t, 10 ) + NRD_INPUT( Texture2D, gIn_Spec, t, 11 ) + NRD_INPUT( Texture2D, gIn_Diff_History, t, 12 ) + NRD_INPUT( Texture2D, gIn_Spec_History, t, 13 ) + NRD_INPUT( Texture2D, gIn_DiffFast_History, t, 14 ) + NRD_INPUT( Texture2D, gIn_SpecFast_History, t, 15 ) + NRD_INPUT( Texture2D, gIn_Prev_Spec_HitDistForTracking, t, 16 ) + #ifndef REBLUR_OCCLUSION + NRD_INPUT( Texture2D, gIn_Spec_HitDistForTracking, t, 17 ) + #endif + #ifdef REBLUR_SH + NRD_INPUT( Texture2D, gIn_DiffSh, t, 18 ) + NRD_INPUT( Texture2D, gIn_SpecSh, t, 19 ) + NRD_INPUT( Texture2D, gIn_DiffSh_History, t, 20 ) + NRD_INPUT( Texture2D, gIn_SpecSh_History, t, 21 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Diff, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOut_Spec, u, 1 ) + NRD_OUTPUT( RWTexture2D, gOut_DiffFast, u, 2 ) + NRD_OUTPUT( RWTexture2D, gOut_SpecFast, u, 3 ) + NRD_OUTPUT( RWTexture2D, gOut_Spec_HitDistForTracking, u, 4 ) + NRD_OUTPUT( RWTexture2D, gOut_Data1, u, 5 ) + #ifndef REBLUR_OCCLUSION + NRD_OUTPUT( RWTexture2D, gOut_Data2, u, 6 ) + #endif + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_DiffSh, u, 7 ) + NRD_OUTPUT( RWTexture2D, gOut_SpecSh, u, 8 ) + #endif + NRD_OUTPUTS_END + +#elif( defined REBLUR_DIFFUSE ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Tiles, t, 0 ) + NRD_INPUT( Texture2D, gIn_Normal_Roughness, t, 1 ) + NRD_INPUT( Texture2D, gIn_ViewZ, t, 2 ) + NRD_INPUT( Texture2D, gIn_Mv, t, 3 ) + NRD_INPUT( Texture2D, gIn_Prev_ViewZ, t, 4 ) + NRD_INPUT( Texture2D, gIn_Prev_Normal_Roughness, t, 5 ) + NRD_INPUT( Texture2D, gIn_Prev_InternalData, t, 6 ) + NRD_INPUT( Texture2D, gIn_DisocclusionThresholdMix, t, 7 ) + NRD_INPUT( Texture2D, gIn_Diff_Confidence, t, 8 ) + NRD_INPUT( Texture2D, gIn_Diff, t, 9 ) + NRD_INPUT( Texture2D, gIn_Diff_History, t, 10 ) + NRD_INPUT( Texture2D, gIn_DiffFast_History, t, 11 ) + #ifdef REBLUR_SH + NRD_INPUT( Texture2D, gIn_DiffSh, t, 12 ) + NRD_INPUT( Texture2D, gIn_DiffSh_History, t, 13 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Diff, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOut_DiffFast, u, 1 ) + NRD_OUTPUT( RWTexture2D, gOut_Data1, u, 2 ) + #ifndef REBLUR_OCCLUSION + NRD_OUTPUT( RWTexture2D, gOut_Data2, u, 3 ) + #endif + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_DiffSh, u, 4 ) + #endif + NRD_OUTPUTS_END + +#else + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Tiles, t, 0 ) + NRD_INPUT( Texture2D, gIn_Normal_Roughness, t, 1 ) + NRD_INPUT( Texture2D, gIn_ViewZ, t, 2 ) + NRD_INPUT( Texture2D, gIn_Mv, t, 3 ) + NRD_INPUT( Texture2D, gIn_Prev_ViewZ, t, 4 ) + NRD_INPUT( Texture2D, gIn_Prev_Normal_Roughness, t, 5 ) + NRD_INPUT( Texture2D, gIn_Prev_InternalData, t, 6 ) + NRD_INPUT( Texture2D, gIn_DisocclusionThresholdMix, t, 7 ) + NRD_INPUT( Texture2D, gIn_Spec_Confidence, t, 8 ) + NRD_INPUT( Texture2D, gIn_Spec, t, 9 ) + NRD_INPUT( Texture2D, gIn_Spec_History, t, 10 ) + NRD_INPUT( Texture2D, gIn_SpecFast_History, t, 11 ) + NRD_INPUT( Texture2D, gIn_Prev_Spec_HitDistForTracking, t, 12 ) + #ifndef REBLUR_OCCLUSION + NRD_INPUT( Texture2D, gIn_Spec_HitDistForTracking, t, 13 ) + #endif + #ifdef REBLUR_SH + NRD_INPUT( Texture2D, gIn_SpecSh, t, 14 ) + NRD_INPUT( Texture2D, gIn_SpecSh_History, t, 15 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Spec, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOut_SpecFast, u, 1 ) + NRD_OUTPUT( RWTexture2D, gOut_Spec_HitDistForTracking, u, 2 ) + NRD_OUTPUT( RWTexture2D, gOut_Data1, u, 3 ) + #ifndef REBLUR_OCCLUSION + NRD_OUTPUT( RWTexture2D, gOut_Data2, u, 4 ) + #endif + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_SpecSh, u, 5 ) + #endif + NRD_OUTPUTS_END + +#endif + +// Macro magic +#define REBLUR_TemporalAccumulationGroupX 8 +#define REBLUR_TemporalAccumulationGroupY 16 + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X REBLUR_TemporalAccumulationGroupX +#define GROUP_Y REBLUR_TemporalAccumulationGroupY diff --git a/Shaders/Resources/REBLUR_TemporalStabilization.resources.hlsli b/Shaders/Resources/REBLUR_TemporalStabilization.resources.hlsli new file mode 100644 index 0000000..60ffe07 --- /dev/null +++ b/Shaders/Resources/REBLUR_TemporalStabilization.resources.hlsli @@ -0,0 +1,115 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +NRD_CONSTANTS_START( REBLUR_TemporalStabilizationConstants ) + REBLUR_SHARED_CONSTANTS +NRD_CONSTANTS_END + +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +#if( defined REBLUR_DIFFUSE && defined REBLUR_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Tiles, t, 0 ) + NRD_INPUT( Texture2D, gIn_Normal_Roughness, t, 1 ) + NRD_INPUT( Texture2D, gIn_BaseColor_Metalness, t, 2 ) + NRD_INPUT( Texture2D, gIn_ViewZ, t, 3 ) + NRD_INPUT( Texture2D, gIn_Data1, t, 4 ) + NRD_INPUT( Texture2D, gIn_Data2, t, 5 ) + NRD_INPUT( Texture2D, gIn_Diff, t, 6 ) + NRD_INPUT( Texture2D, gIn_Spec, t, 7 ) + NRD_INPUT( Texture2D, gIn_Diff_StabilizedHistory, t, 8 ) + NRD_INPUT( Texture2D, gIn_Spec_StabilizedHistory, t, 9 ) + NRD_INPUT( Texture2D, gIn_Spec_HitDistForTracking, t, 10 ) + #ifdef REBLUR_SH + NRD_INPUT( Texture2D, gIn_DiffSh, t, 11 ) + NRD_INPUT( Texture2D, gIn_SpecSh, t, 12 ) + NRD_INPUT( Texture2D, gIn_DiffSh_StabilizedHistory, t, 13 ) + NRD_INPUT( Texture2D, gIn_SpecSh_StabilizedHistory, t, 14 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gInOut_Mv, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOut_InternalData, u, 1 ) + NRD_OUTPUT( RWTexture2D, gOut_Diff, u, 2 ) + NRD_OUTPUT( RWTexture2D, gOut_Spec, u, 3 ) + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_DiffSh, u, 4 ) + NRD_OUTPUT( RWTexture2D, gOut_SpecSh, u, 5 ) + #endif + NRD_OUTPUTS_END + +#elif( defined REBLUR_DIFFUSE ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Tiles, t, 0 ) + NRD_INPUT( Texture2D, gIn_Normal_Roughness, t, 1 ) + NRD_INPUT( Texture2D, gIn_ViewZ, t, 2 ) + NRD_INPUT( Texture2D, gIn_Data1, t, 3 ) + NRD_INPUT( Texture2D, gIn_Data2, t, 4 ) + NRD_INPUT( Texture2D, gIn_Diff, t, 5 ) + NRD_INPUT( Texture2D, gIn_Diff_StabilizedHistory, t, 6 ) + #ifdef REBLUR_SH + NRD_INPUT( Texture2D, gIn_DiffSh, t, 7 ) + NRD_INPUT( Texture2D, gIn_DiffSh_StabilizedHistory, t, 8 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gInOut_Mv, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOut_InternalData, u, 1 ) + NRD_OUTPUT( RWTexture2D, gOut_Diff, u, 2 ) + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_DiffSh, u, 3 ) + #endif + NRD_OUTPUTS_END + +#else + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Tiles, t, 0 ) + NRD_INPUT( Texture2D, gIn_Normal_Roughness, t, 1 ) + NRD_INPUT( Texture2D, gIn_BaseColor_Metalness, t, 2 ) + NRD_INPUT( Texture2D, gIn_ViewZ, t, 3 ) + NRD_INPUT( Texture2D, gIn_Data1, t, 4 ) + NRD_INPUT( Texture2D, gIn_Data2, t, 5 ) + NRD_INPUT( Texture2D, gIn_Spec, t, 6 ) + NRD_INPUT( Texture2D, gIn_Spec_StabilizedHistory, t, 7 ) + NRD_INPUT( Texture2D, gIn_Spec_HitDistForTracking, t, 8 ) + #ifdef REBLUR_SH + NRD_INPUT( Texture2D, gIn_SpecSh, t, 9 ) + NRD_INPUT( Texture2D, gIn_SpecSh_StabilizedHistory, t, 10 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gInOut_Mv, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOut_InternalData, u, 1 ) + NRD_OUTPUT( RWTexture2D, gOut_Spec, u, 2 ) + #ifdef REBLUR_SH + NRD_OUTPUT( RWTexture2D, gOut_SpecSh, u, 3 ) + #endif + NRD_OUTPUTS_END + +#endif + +// Macro magic +#define REBLUR_TemporalStabilizationGroupX 8 +#define REBLUR_TemporalStabilizationGroupY 16 + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X REBLUR_TemporalStabilizationGroupX +#define GROUP_Y REBLUR_TemporalStabilizationGroupY diff --git a/Shaders/Resources/REBLUR_Validation.resources.hlsli b/Shaders/Resources/REBLUR_Validation.resources.hlsli index d2ec143..1ec8e7b 100644 --- a/Shaders/Resources/REBLUR_Validation.resources.hlsli +++ b/Shaders/Resources/REBLUR_Validation.resources.hlsli @@ -8,33 +8,37 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -NRD_CONSTANTS_START - REBLUR_SHARED_CB_DATA - NRD_CONSTANT( float4x4, gWorldToClipPrev ) - NRD_CONSTANT( float2, gJitter ) +NRD_CONSTANTS_START( REBLUR_ValidationConstants ) + REBLUR_SHARED_CONSTANTS NRD_CONSTANT( uint, gHasDiffuse ) NRD_CONSTANT( uint, gHasSpecular ) - NRD_CONSTANT( uint, gDiffCheckerboard ) - NRD_CONSTANT( uint, gSpecCheckerboard ) NRD_CONSTANTS_END -NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Normal_Roughness, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Mv, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Data1, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Data2, t, 4 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff, t, 5 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec, t, 6 ) -NRD_INPUT_TEXTURE_END +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Normal_Roughness, t, 0 ) + NRD_INPUT( Texture2D, gIn_ViewZ, t, 1 ) + NRD_INPUT( Texture2D, gIn_Mv, t, 2 ) + NRD_INPUT( Texture2D, gIn_Data1, t, 3 ) + NRD_INPUT( Texture2D, gIn_Data2, t, 4 ) + NRD_INPUT( Texture2D, gIn_Diff, t, 5 ) + NRD_INPUT( Texture2D, gIn_Spec, t, 6 ) +NRD_INPUTS_END + +NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Validation, u, 0 ) +NRD_OUTPUTS_END + +// Macro magic +#define REBLUR_ValidationGroupX 8 +#define REBLUR_ValidationGroupY 16 -NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Validation, u, 0 ) -NRD_OUTPUT_TEXTURE_END +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X REBLUR_ValidationGroupX +#define GROUP_Y REBLUR_ValidationGroupY diff --git a/Shaders/Resources/REFERENCE_SplitScreen.resources.hlsli b/Shaders/Resources/REFERENCE_SplitScreen.resources.hlsli index 53cf89d..c42e6f4 100644 --- a/Shaders/Resources/REFERENCE_SplitScreen.resources.hlsli +++ b/Shaders/Resources/REFERENCE_SplitScreen.resources.hlsli @@ -8,21 +8,24 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -NRD_CONSTANTS_START - NRD_CONSTANT( float, gDebug ) // ( must be last ) used for availability in Common.hlsl only +NRD_CONSTANTS_START( REFERENCE_SplitScreenConstants ) + NRD_CONSTANT( float, gDebug ) // only for availability in Common.hlsl NRD_CONSTANTS_END -NRD_INPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( Texture2D, gIn_Input, t, 0 ) -NRD_INPUT_TEXTURE_END +NRD_INPUTS_START + NRD_OUTPUT( Texture2D, gIn_Input, t, 0 ) +NRD_INPUTS_END + +NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Output, u, 0 ) +NRD_OUTPUTS_END + +// Macro magic +#define REFERENCE_SplitScreenGroupX 16 +#define REFERENCE_SplitScreenGroupY 16 -NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Output, u, 0 ) -NRD_OUTPUT_TEXTURE_END +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X REFERENCE_SplitScreenGroupX +#define GROUP_Y REFERENCE_SplitScreenGroupY diff --git a/Shaders/Resources/REFERENCE_TemporalAccumulation.resources.hlsli b/Shaders/Resources/REFERENCE_TemporalAccumulation.resources.hlsli index 29d6a11..1bcac13 100644 --- a/Shaders/Resources/REFERENCE_TemporalAccumulation.resources.hlsli +++ b/Shaders/Resources/REFERENCE_TemporalAccumulation.resources.hlsli @@ -8,25 +8,28 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -NRD_CONSTANTS_START +NRD_CONSTANTS_START( REFERENCE_TemporalAccumulationConstants ) NRD_CONSTANT( uint2, gRectOrigin ) - NRD_CONSTANT( float2, gInvRectSize ) + NRD_CONSTANT( float2, gRectSizeInv ) NRD_CONSTANT( float, gSplitScreen ) NRD_CONSTANT( float, gAccumSpeed ) NRD_CONSTANT( float, gDebug ) NRD_CONSTANTS_END -NRD_INPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( Texture2D, gIn_Input, t, 0 ) -NRD_INPUT_TEXTURE_END +NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Input, t, 0 ) +NRD_INPUTS_END + +NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gInOut_History, u, 0 ) +NRD_OUTPUTS_END + +// Macro magic +#define REFERENCE_TemporalAccumulationGroupX 16 +#define REFERENCE_TemporalAccumulationGroupY 16 -NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gInOut_History, u, 0 ) -NRD_OUTPUT_TEXTURE_END +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X REFERENCE_TemporalAccumulationGroupX +#define GROUP_Y REFERENCE_TemporalAccumulationGroupY diff --git a/Shaders/Resources/RELAX_AntiFirefly.resources.hlsli b/Shaders/Resources/RELAX_AntiFirefly.resources.hlsli new file mode 100644 index 0000000..44f78a5 --- /dev/null +++ b/Shaders/Resources/RELAX_AntiFirefly.resources.hlsli @@ -0,0 +1,71 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +NRD_CONSTANTS_START( RELAX_AntiFireflyConstants ) + RELAX_SHARED_CONSTANTS +NRD_CONSTANTS_END + +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +#if( defined RELAX_DIFFUSE && defined RELAX_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gTiles, t, 0 ) + NRD_INPUT( Texture2D, gSpecIllumination, t, 1 ) + NRD_INPUT( Texture2D, gDiffIllumination, t, 2 ) + NRD_INPUT( Texture2D, gNormalRoughness, t, 3 ) + NRD_INPUT( Texture2D, gViewZ, t, 4 ) + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutSpecularIllumination, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOutDiffuseIllumination, u, 1 ) + NRD_OUTPUTS_END + +#elif( defined RELAX_DIFFUSE ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gTiles, t, 0 ) + NRD_INPUT( Texture2D, gDiffIllumination, t, 1 ) + NRD_INPUT( Texture2D, gNormalRoughness, t, 2 ) + NRD_INPUT(Texture2D, gViewZ, t, 3 ) + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutDiffuseIllumination, u, 0 ) + NRD_OUTPUTS_END + +#elif( defined RELAX_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gTiles, t, 0 ) + NRD_INPUT( Texture2D, gSpecIllumination, t, 1 ) + NRD_INPUT( Texture2D, gNormalRoughness, t, 2 ) + NRD_INPUT( Texture2D, gViewZ, t, 3 ) + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutSpecularIllumination, u, 0 ) + NRD_OUTPUTS_END + +#endif + +// Macro magic +#define RELAX_AntiFireflyGroupX 8 +#define RELAX_AntiFireflyGroupY 8 + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X RELAX_AntiFireflyGroupX +#define GROUP_Y RELAX_AntiFireflyGroupY diff --git a/Shaders/Resources/RELAX_Atrous.resources.hlsli b/Shaders/Resources/RELAX_Atrous.resources.hlsli new file mode 100644 index 0000000..964918d --- /dev/null +++ b/Shaders/Resources/RELAX_Atrous.resources.hlsli @@ -0,0 +1,102 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +NRD_CONSTANTS_START( RELAX_AtrousConstants ) + RELAX_SHARED_CONSTANTS + NRD_CONSTANT( uint, gStepSize ) + NRD_CONSTANT( uint, gIsLastPass ) +NRD_CONSTANTS_END + +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +#if( defined RELAX_DIFFUSE && defined RELAX_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gTiles, t, 0 ) + NRD_INPUT( Texture2D, gSpecIlluminationAndVariance, t, 1 ) + NRD_INPUT( Texture2D, gDiffIlluminationAndVariance, t, 2 ) + NRD_INPUT( Texture2D, gHistoryLength, t, 3 ) + NRD_INPUT( Texture2D, gSpecReprojectionConfidence, t, 4 ) + NRD_INPUT( Texture2D, gNormalRoughness, t, 5 ) + NRD_INPUT( Texture2D, gViewZ, t, 6 ) + NRD_INPUT( Texture2D, gSpecConfidence, t, 7 ) + NRD_INPUT( Texture2D, gDiffConfidence, t, 8 ) + #ifdef RELAX_SH + NRD_INPUT( Texture2D, gSpecSH1, t, 9 ) + NRD_INPUT( Texture2D, gDiffSH1, t, 10 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutSpecularIlluminationAndVariance, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOutDiffuseIlluminationAndVariance, u, 1 ) + #ifdef RELAX_SH + NRD_OUTPUT( RWTexture2D, gOutSpecularSH1, u, 2 ) + NRD_OUTPUT( RWTexture2D, gOutDiffuseSH1, u, 3 ) + #endif + NRD_OUTPUTS_END + +#elif( defined RELAX_DIFFUSE ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gTiles, t, 0 ) + NRD_INPUT( Texture2D, gDiffIlluminationAndVariance, t, 1 ) + NRD_INPUT( Texture2D, gHistoryLength, t, 2 ) + NRD_INPUT( Texture2D, gNormalRoughness, t, 3 ) + NRD_INPUT( Texture2D, gViewZ, t, 4 ) + NRD_INPUT( Texture2D, gDiffConfidence, t, 5 ) + #ifdef RELAX_SH + NRD_INPUT( Texture2D, gDiffSH1, t, 6 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutDiffuseIlluminationAndVariance, u, 0 ) + #ifdef RELAX_SH + NRD_OUTPUT( RWTexture2D, gOutDiffuseSH1, u, 1 ) + #endif + NRD_OUTPUTS_END + +#elif( defined RELAX_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gTiles, t, 0 ) + NRD_INPUT( Texture2D, gSpecIlluminationAndVariance, t, 1 ) + NRD_INPUT( Texture2D, gHistoryLength, t, 2 ) + NRD_INPUT( Texture2D, gSpecReprojectionConfidence, t, 3 ) + NRD_INPUT( Texture2D, gNormalRoughness, t, 4 ) + NRD_INPUT( Texture2D, gViewZ, t, 5 ) + NRD_INPUT( Texture2D, gSpecConfidence, t, 6 ) + #ifdef RELAX_SH + NRD_INPUT( Texture2D, gSpecSH1, t, 7 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutSpecularIlluminationAndVariance, u, 0 ) + #ifdef RELAX_SH + NRD_OUTPUT( RWTexture2D, gOutSpecularSH1, u, 1 ) + #endif + NRD_OUTPUTS_END + +#endif + +// Macro magic +#define RELAX_AtrousGroupX 16 +#define RELAX_AtrousGroupY 16 + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X RELAX_AtrousGroupX +#define GROUP_Y RELAX_AtrousGroupY diff --git a/Shaders/Resources/RELAX_AtrousSmem.resources.hlsli b/Shaders/Resources/RELAX_AtrousSmem.resources.hlsli new file mode 100644 index 0000000..82bd33d --- /dev/null +++ b/Shaders/Resources/RELAX_AtrousSmem.resources.hlsli @@ -0,0 +1,114 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +NRD_CONSTANTS_START( RELAX_AtrousSmemConstants ) + RELAX_SHARED_CONSTANTS + NRD_CONSTANT( uint, gStepSize ) + NRD_CONSTANT( uint, gIsLastPass ) +NRD_CONSTANTS_END + +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +#if( defined RELAX_DIFFUSE && defined RELAX_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gTiles, t, 0 ) + NRD_INPUT( Texture2D, gSpecIlluminationAnd2ndMoment, t, 1 ) + NRD_INPUT( Texture2D, gDiffIlluminationAnd2ndMoment, t, 2 ) + NRD_INPUT( Texture2D, gHistoryLength, t, 3 ) + NRD_INPUT( Texture2D, gSpecReprojectionConfidence, t, 4 ) + NRD_INPUT( Texture2D, gNormalRoughness, t, 5 ) + NRD_INPUT( Texture2D, gViewZ, t, 6 ) + NRD_INPUT( Texture2D, gSpecConfidence, t, 7 ) + NRD_INPUT( Texture2D, gDiffConfidence, t, 8 ) + #ifdef RELAX_SH + NRD_INPUT( Texture2D, gSpecSH1, t, 9 ) + NRD_INPUT( Texture2D, gDiffSH1, t, 10 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutSpecularIlluminationAndVariance, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOutDiffuseIlluminationAndVariance, u, 1 ) + NRD_OUTPUT( RWTexture2D, gOutNormalRoughness, u, 2 ) + NRD_OUTPUT( RWTexture2D, gOutMaterialID, u, 3 ) + NRD_OUTPUT( RWTexture2D, gOutViewZ, u, 4 ) + #ifdef RELAX_SH + NRD_OUTPUT( RWTexture2D, gOutSpecularSH1, u, 5 ) + NRD_OUTPUT( RWTexture2D, gOutDiffuseSH1, u, 6 ) + #endif + + NRD_OUTPUTS_END + +#elif( defined RELAX_DIFFUSE ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gTiles, t, 0 ) + NRD_INPUT( Texture2D, gDiffIlluminationAnd2ndMoment, t, 1 ) + NRD_INPUT( Texture2D, gHistoryLength, t, 2 ) + NRD_INPUT( Texture2D, gNormalRoughness, t, 3 ) + NRD_INPUT( Texture2D, gViewZ, t, 4 ) + NRD_INPUT( Texture2D, gDiffConfidence, t, 5 ) + #ifdef RELAX_SH + NRD_INPUT( Texture2D, gDiffSH1, t, 6 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutDiffuseIlluminationAndVariance, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOutNormalRoughness, u, 1 ) + NRD_OUTPUT( RWTexture2D, gOutMaterialID, u, 2 ) + NRD_OUTPUT( RWTexture2D, gOutViewZ, u, 3 ) + #ifdef RELAX_SH + NRD_OUTPUT( RWTexture2D, gOutDiffuseSH1, u, 4 ) + #endif + NRD_OUTPUTS_END + +#elif( defined RELAX_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gTiles, t, 0 ) + NRD_INPUT( Texture2D, gSpecIlluminationAnd2ndMoment, t, 1 ) + NRD_INPUT( Texture2D, gHistoryLength, t, 2 ) + NRD_INPUT( Texture2D, gSpecReprojectionConfidence, t, 3 ) + NRD_INPUT( Texture2D, gNormalRoughness, t, 4 ) + NRD_INPUT( Texture2D, gViewZ, t, 5 ) + NRD_INPUT( Texture2D, gSpecConfidence, t, 6 ) + #ifdef RELAX_SH + NRD_INPUT( Texture2D, gSpecSH1, t, 7 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutSpecularIlluminationAndVariance, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOutNormalRoughness, u, 1 ) + NRD_OUTPUT( RWTexture2D, gOutMaterialID, u, 2 ) + NRD_OUTPUT( RWTexture2D, gOutViewZ, u, 3 ) + #ifdef RELAX_SH + NRD_OUTPUT( RWTexture2D, gOutSpecularSH1, u, 4 ) + #endif + NRD_OUTPUTS_END + +#endif + +// Macro magic +#define RELAX_AtrousSmemGroupX 8 +#define RELAX_AtrousSmemGroupY 8 + +#define NRD_USE_BORDER_2 + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X RELAX_AtrousSmemGroupX +#define GROUP_Y RELAX_AtrousSmemGroupY diff --git a/Shaders/Resources/RELAX_ClassifyTiles.resources.hlsli b/Shaders/Resources/RELAX_ClassifyTiles.resources.hlsli index 051d276..8ea1847 100644 --- a/Shaders/Resources/RELAX_ClassifyTiles.resources.hlsli +++ b/Shaders/Resources/RELAX_ClassifyTiles.resources.hlsli @@ -8,14 +8,24 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -NRD_CONSTANTS_START - NRD_CONSTANT( float, gDenoisingRange ) +NRD_CONSTANTS_START( RELAX_ClassifyTilesConstants ) + RELAX_SHARED_CONSTANTS NRD_CONSTANTS_END -NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 0 ) -NRD_INPUT_TEXTURE_END +NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_ViewZ, t, 0 ) +NRD_INPUTS_END -NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Tiles, u, 0 ) -NRD_OUTPUT_TEXTURE_END +NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Tiles, u, 0 ) +NRD_OUTPUTS_END + +// Macro magic +#define RELAX_ClassifyTilesGroupX 16 +#define RELAX_ClassifyTilesGroupY 16 + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X RELAX_ClassifyTilesGroupX +#define GROUP_Y RELAX_ClassifyTilesGroupY diff --git a/Shaders/Resources/RELAX_Copy.resources.hlsli b/Shaders/Resources/RELAX_Copy.resources.hlsli new file mode 100644 index 0000000..a8091ba --- /dev/null +++ b/Shaders/Resources/RELAX_Copy.resources.hlsli @@ -0,0 +1,62 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +NRD_CONSTANTS_START( RELAX_CopyConstants ) + RELAX_SHARED_CONSTANTS +NRD_CONSTANTS_END + +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +#if( defined RELAX_DIFFUSE && defined RELAX_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gSpecIllumination, t, 0 ) + NRD_INPUT( Texture2D, gDiffIllumination, t, 1 ) + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutSpecularIllumination, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOutDiffuseIllumination, u, 1 ) + NRD_OUTPUTS_END + +#elif( defined RELAX_DIFFUSE ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gDiffIllumination, t, 0 ) + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutDiffuseIllumination, u, 0 ) + NRD_OUTPUTS_END + +#elif( defined RELAX_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gSpecIllumination, t, 0 ) + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutSpecularIllumination, u, 0 ) + NRD_OUTPUTS_END + +#endif + +// Macro magic +#define RELAX_CopyGroupX 8 +#define RELAX_CopyGroupY 8 + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X RELAX_CopyGroupX +#define GROUP_Y RELAX_CopyGroupY diff --git a/Shaders/Resources/RELAX_DiffuseSpecular_AntiFirefly.resources.hlsli b/Shaders/Resources/RELAX_DiffuseSpecular_AntiFirefly.resources.hlsli deleted file mode 100644 index 43e9107..0000000 --- a/Shaders/Resources/RELAX_DiffuseSpecular_AntiFirefly.resources.hlsli +++ /dev/null @@ -1,63 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -NRD_CONSTANTS_START - RELAX_SHARED_CB_DATA -NRD_CONSTANTS_END - -#if( defined RELAX_DIFFUSE && defined RELAX_SPECULAR ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gTiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecularIllumination, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseIllumination, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gNormalRoughness, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gViewZ, t, 4 ) - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularIllumination, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseIllumination, u, 1 ) - NRD_OUTPUT_TEXTURE_END - -#elif( defined RELAX_DIFFUSE ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gTiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseIllumination, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gNormalRoughness, t, 2 ) - NRD_INPUT_TEXTURE(Texture2D, gViewZ, t, 3 ) - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseIllumination, u, 0 ) - NRD_OUTPUT_TEXTURE_END - -#elif( defined RELAX_SPECULAR ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gTiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecularIllumination, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gNormalRoughness, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gViewZ, t, 3 ) - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularIllumination, u, 0 ) - NRD_OUTPUT_TEXTURE_END - -#endif diff --git a/Shaders/Resources/RELAX_DiffuseSpecular_Atrous.resources.hlsli b/Shaders/Resources/RELAX_DiffuseSpecular_Atrous.resources.hlsli deleted file mode 100644 index 63b0062..0000000 --- a/Shaders/Resources/RELAX_DiffuseSpecular_Atrous.resources.hlsli +++ /dev/null @@ -1,152 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -#if( defined RELAX_DIFFUSE && defined RELAX_SPECULAR ) - - NRD_CONSTANTS_START - RELAX_SHARED_CB_DATA - NRD_CONSTANT( float, gSpecularPhiLuminance ) - NRD_CONSTANT( float, gDiffusePhiLuminance ) - NRD_CONSTANT( float, gMaxDiffuseLuminanceRelativeDifference ) - NRD_CONSTANT( float, gMaxSpecularLuminanceRelativeDifference ) - NRD_CONSTANT( float, gDepthThreshold ) - NRD_CONSTANT( float, gDiffuseLobeAngleFraction ) - NRD_CONSTANT( float, gRoughnessFraction ) - NRD_CONSTANT( float, gSpecularLobeAngleFraction ) - NRD_CONSTANT( float, gSpecularLobeAngleSlack ) - NRD_CONSTANT( uint, gStepSize ) - NRD_CONSTANT( uint, gRoughnessEdgeStoppingEnabled ) - NRD_CONSTANT( float, gRoughnessEdgeStoppingRelaxation ) - NRD_CONSTANT( float, gNormalEdgeStoppingRelaxation ) - NRD_CONSTANT( float, gLuminanceEdgeStoppingRelaxation ) - NRD_CONSTANT( uint, gUseConfidenceInputs ) - NRD_CONSTANT( float, gConfidenceDrivenRelaxationMultiplier ) - NRD_CONSTANT( float, gConfidenceDrivenLuminanceEdgeStoppingRelaxation ) - NRD_CONSTANT( float, gConfidenceDrivenNormalEdgeStoppingRelaxation ) - #ifdef RELAX_SH - NRD_CONSTANT( uint, gIsLastPass ) - #endif - NRD_CONSTANTS_END - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gTiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecularIlluminationAndVariance, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseIlluminationAndVariance, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gHistoryLength, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecularReprojectionConfidence, t, 4 ) - NRD_INPUT_TEXTURE( Texture2D, gNormalRoughness, t, 5 ) - NRD_INPUT_TEXTURE( Texture2D, gViewZ, t, 6 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecConfidence, t, 7 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffConfidence, t, 8 ) - #ifdef RELAX_SH - NRD_INPUT_TEXTURE( Texture2D, gSpecularSH1, t, 9 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseSH1, t, 10 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularIlluminationAndVariance, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseIlluminationAndVariance, u, 1 ) - #ifdef RELAX_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularSH1, u, 2 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseSH1, u, 3 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#elif( defined RELAX_DIFFUSE ) - - NRD_CONSTANTS_START - RELAX_SHARED_CB_DATA - NRD_CONSTANT( float, gDiffusePhiLuminance ) - NRD_CONSTANT( float, gMaxDiffuseLuminanceRelativeDifference ) - NRD_CONSTANT( float, gDepthThreshold ) - NRD_CONSTANT( float, gDiffuseLobeAngleFraction ) - NRD_CONSTANT( uint, gStepSize ) - NRD_CONSTANT( uint, gUseConfidenceInputs ) - NRD_CONSTANT( float, gConfidenceDrivenRelaxationMultiplier ) - NRD_CONSTANT( float, gConfidenceDrivenLuminanceEdgeStoppingRelaxation ) - NRD_CONSTANT( float, gConfidenceDrivenNormalEdgeStoppingRelaxation ) - #ifdef RELAX_SH - NRD_CONSTANT( uint, gIsLastPass ) - #endif - NRD_CONSTANTS_END - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gTiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseIlluminationAndVariance, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gHistoryLength, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gNormalRoughness, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gViewZ, t, 4 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffConfidence, t, 5 ) - #ifdef RELAX_SH - NRD_INPUT_TEXTURE( Texture2D, gDiffuseSH1, t, 6 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseIlluminationAndVariance, u, 0 ) - #ifdef RELAX_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseSH1, u, 1 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#elif( defined RELAX_SPECULAR ) - - NRD_CONSTANTS_START - RELAX_SHARED_CB_DATA - NRD_CONSTANT( float, gSpecularPhiLuminance ) - NRD_CONSTANT( float, gMaxSpecularLuminanceRelativeDifference ) - NRD_CONSTANT( float, gDepthThreshold ) - NRD_CONSTANT( float, gDiffuseLobeAngleFraction ) - NRD_CONSTANT( float, gRoughnessFraction ) - NRD_CONSTANT( float, gSpecularLobeAngleFraction ) - NRD_CONSTANT( float, gSpecularLobeAngleSlack ) - NRD_CONSTANT( uint, gStepSize ) - NRD_CONSTANT( uint, gRoughnessEdgeStoppingEnabled ) - NRD_CONSTANT( float, gRoughnessEdgeStoppingRelaxation ) - NRD_CONSTANT( float, gNormalEdgeStoppingRelaxation ) - NRD_CONSTANT( float, gLuminanceEdgeStoppingRelaxation ) - NRD_CONSTANT( uint, gUseConfidenceInputs ) - NRD_CONSTANT( float, gConfidenceDrivenRelaxationMultiplier ) - NRD_CONSTANT( float, gConfidenceDrivenLuminanceEdgeStoppingRelaxation ) - NRD_CONSTANT( float, gConfidenceDrivenNormalEdgeStoppingRelaxation ) - #ifdef RELAX_SH - NRD_CONSTANT( uint, gIsLastPass ) - #endif - NRD_CONSTANTS_END - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gTiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecularIlluminationAndVariance, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gHistoryLength, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecularReprojectionConfidence, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gNormalRoughness, t, 4 ) - NRD_INPUT_TEXTURE( Texture2D, gViewZ, t, 5 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecConfidence, t, 6 ) - #ifdef RELAX_SH - NRD_INPUT_TEXTURE( Texture2D, gSpecularSH1, t, 7 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularIlluminationAndVariance, u, 0 ) - #ifdef RELAX_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularSH1, u, 1 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#endif diff --git a/Shaders/Resources/RELAX_DiffuseSpecular_AtrousSmem.resources.hlsli b/Shaders/Resources/RELAX_DiffuseSpecular_AtrousSmem.resources.hlsli deleted file mode 100644 index b598212..0000000 --- a/Shaders/Resources/RELAX_DiffuseSpecular_AtrousSmem.resources.hlsli +++ /dev/null @@ -1,164 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -#if( defined RELAX_DIFFUSE && defined RELAX_SPECULAR ) - - NRD_CONSTANTS_START - RELAX_SHARED_CB_DATA - NRD_CONSTANT( uint2, gResourceSize ) - NRD_CONSTANT( uint, gHistoryThreshold ) - NRD_CONSTANT( float, gSpecularPhiLuminance ) - NRD_CONSTANT( float, gDiffusePhiLuminance ) - NRD_CONSTANT( float, gMaxDiffuseLuminanceRelativeDifference ) - NRD_CONSTANT( float, gMaxSpecularLuminanceRelativeDifference ) - NRD_CONSTANT( float, gDepthThreshold ) - NRD_CONSTANT( float, gDiffuseLobeAngleFraction ) - NRD_CONSTANT( float, gRoughnessFraction ) - NRD_CONSTANT( float, gSpecularLobeAngleFraction ) - NRD_CONSTANT( float, gSpecularLobeAngleSlack ) - NRD_CONSTANT( uint, gStepSize ) - NRD_CONSTANT( uint, gRoughnessEdgeStoppingEnabled ) - NRD_CONSTANT( float, gRoughnessEdgeStoppingRelaxation ) - NRD_CONSTANT( float, gNormalEdgeStoppingRelaxation ) - NRD_CONSTANT( float, gLuminanceEdgeStoppingRelaxation ) - NRD_CONSTANT( uint, gUseConfidenceInputs ) - NRD_CONSTANT( float, gConfidenceDrivenRelaxationMultiplier ) - NRD_CONSTANT( float, gConfidenceDrivenLuminanceEdgeStoppingRelaxation ) - NRD_CONSTANT( float, gConfidenceDrivenNormalEdgeStoppingRelaxation ) - NRD_CONSTANTS_END - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gTiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecularIlluminationAnd2ndMoment, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseIlluminationAnd2ndMoment, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gHistoryLength, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecularReprojectionConfidence, t, 4 ) - NRD_INPUT_TEXTURE( Texture2D, gNormalRoughness, t, 5 ) - NRD_INPUT_TEXTURE( Texture2D, gViewZ, t, 6 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecConfidence, t, 7 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffConfidence, t, 8 ) - #ifdef RELAX_SH - NRD_INPUT_TEXTURE( Texture2D, gSpecularSH1, t, 9 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseSH1, t, 10 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularIlluminationAndVariance, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseIlluminationAndVariance, u, 1 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutNormalRoughness, u, 2 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutMaterialID, u, 3 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutViewZ, u, 4 ) - #ifdef RELAX_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularSH1, u, 5 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseSH1, u, 6 ) - #endif - - NRD_OUTPUT_TEXTURE_END - -#elif( defined RELAX_DIFFUSE ) - - NRD_CONSTANTS_START - RELAX_SHARED_CB_DATA - NRD_CONSTANT( uint2, gResourceSize ) - NRD_CONSTANT( uint, gHistoryThreshold ) - NRD_CONSTANT( float, gDiffusePhiLuminance ) - NRD_CONSTANT( float, gMaxDiffuseLuminanceRelativeDifference ) - NRD_CONSTANT( float, gDepthThreshold ) - NRD_CONSTANT( float, gDiffuseLobeAngleFraction ) - NRD_CONSTANT( uint, gStepSize ) - NRD_CONSTANT( uint, gUseConfidenceInputs ) - NRD_CONSTANT( float, gConfidenceDrivenRelaxationMultiplier ) - NRD_CONSTANT( float, gConfidenceDrivenLuminanceEdgeStoppingRelaxation ) - NRD_CONSTANT( float, gConfidenceDrivenNormalEdgeStoppingRelaxation ) - NRD_CONSTANTS_END - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gTiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseIlluminationAnd2ndMoment, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gHistoryLength, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gNormalRoughness, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gViewZ, t, 4 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffConfidence, t, 5 ) - #ifdef RELAX_SH - NRD_INPUT_TEXTURE( Texture2D, gDiffuseSH1, t, 6 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseIlluminationAndVariance, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutNormalRoughness, u, 1 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutMaterialID, u, 2 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutViewZ, u, 3 ) - #ifdef RELAX_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseSH1, u, 4 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#elif( defined RELAX_SPECULAR ) - - NRD_CONSTANTS_START - RELAX_SHARED_CB_DATA - NRD_CONSTANT( uint2, gResourceSize ) - NRD_CONSTANT( uint, gHistoryThreshold ) - NRD_CONSTANT( float, gSpecularPhiLuminance ) - NRD_CONSTANT( float, gMaxSpecularLuminanceRelativeDifference ) - NRD_CONSTANT( float, gDepthThreshold ) - NRD_CONSTANT( float, gDiffuseLobeAngleFraction ) - NRD_CONSTANT( float, gRoughnessFraction ) - NRD_CONSTANT( float, gSpecularLobeAngleFraction ) - NRD_CONSTANT( float, gSpecularLobeAngleSlack ) - NRD_CONSTANT( uint, gStepSize ) - NRD_CONSTANT( uint, gRoughnessEdgeStoppingEnabled ) - NRD_CONSTANT( float, gRoughnessEdgeStoppingRelaxation ) - NRD_CONSTANT( float, gNormalEdgeStoppingRelaxation ) - NRD_CONSTANT( float, gLuminanceEdgeStoppingRelaxation ) - NRD_CONSTANT( uint, gUseConfidenceInputs ) - NRD_CONSTANT( float, gConfidenceDrivenRelaxationMultiplier ) - NRD_CONSTANT( float, gConfidenceDrivenLuminanceEdgeStoppingRelaxation ) - NRD_CONSTANT( float, gConfidenceDrivenNormalEdgeStoppingRelaxation ) - NRD_CONSTANTS_END - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gTiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecularIlluminationAnd2ndMoment, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gHistoryLength, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecularReprojectionConfidence, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gNormalRoughness, t, 4 ) - NRD_INPUT_TEXTURE( Texture2D, gViewZ, t, 5 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecConfidence, t, 6 ) - #ifdef RELAX_SH - NRD_INPUT_TEXTURE( Texture2D, gSpecularSH1, t, 7 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularIlluminationAndVariance, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutNormalRoughness, u, 1 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutMaterialID, u, 2 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutViewZ, u, 3 ) - #ifdef RELAX_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularSH1, u, 4 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#endif - -// Macro magic -#define GROUP_X 8 -#define GROUP_Y 8 -#define NRD_USE_BORDER_2 diff --git a/Shaders/Resources/RELAX_DiffuseSpecular_Copy.resources.hlsli b/Shaders/Resources/RELAX_DiffuseSpecular_Copy.resources.hlsli deleted file mode 100644 index e219f91..0000000 --- a/Shaders/Resources/RELAX_DiffuseSpecular_Copy.resources.hlsli +++ /dev/null @@ -1,54 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -NRD_CONSTANTS_START - RELAX_SHARED_CB_DATA -NRD_CONSTANTS_END - -#if( defined RELAX_DIFFUSE && defined RELAX_SPECULAR ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gSpecularIllumination, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseIllumination, t, 1 ) - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularIllumination, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseIllumination, u, 1 ) - NRD_OUTPUT_TEXTURE_END - -#elif( defined RELAX_DIFFUSE ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gDiffuseIllumination, t, 0 ) - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseIllumination, u, 0 ) - NRD_OUTPUT_TEXTURE_END - -#elif( defined RELAX_SPECULAR ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gSpecularIllumination, t, 0 ) - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularIllumination, u, 0 ) - NRD_OUTPUT_TEXTURE_END - -#endif diff --git a/Shaders/Resources/RELAX_DiffuseSpecular_HistoryClamping.resources.hlsli b/Shaders/Resources/RELAX_DiffuseSpecular_HistoryClamping.resources.hlsli deleted file mode 100644 index 0464594..0000000 --- a/Shaders/Resources/RELAX_DiffuseSpecular_HistoryClamping.resources.hlsli +++ /dev/null @@ -1,121 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -NRD_CONSTANTS_START - RELAX_SHARED_CB_DATA - NRD_CONSTANT( float, gColorBoxSigmaScale ) - NRD_CONSTANT( float, gHistoryFixFrameNum ) - #if( defined RELAX_SPECULAR ) - NRD_CONSTANT( uint, gSpecFastHistory ) - #endif - #if( defined RELAX_DIFFUSE ) - NRD_CONSTANT( uint, gDiffFastHistory ) - #endif - NRD_CONSTANT(float, gHistoryAccelerationAmount) - NRD_CONSTANT(float, gHistoryResetTemporalSigmaScale) - NRD_CONSTANT(float, gHistoryResetSpatialSigmaScale) - NRD_CONSTANT(float, gHistoryResetAmount) -NRD_CONSTANTS_END - -#if( defined RELAX_DIFFUSE && defined RELAX_SPECULAR ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gTiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gNoisySpecularIllumination, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gNoisyDiffuseIllumination, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecularIllumination, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseIllumination, t, 4 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecularIlluminationResponsive, t, 5 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseIlluminationResponsive, t, 6 ) - NRD_INPUT_TEXTURE( Texture2D, gHistoryLength, t, 7 ) - #ifdef RELAX_SH - NRD_INPUT_TEXTURE( Texture2D, gSpecularSH1, t, 8 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseSH1, t, 9 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecularResponsiveSH1, t, 10 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseResponsiveSH1, t, 11 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularIllumination, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseIllumination, u, 1 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularIlluminationResponsive, u, 2 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseIlluminationResponsive, u, 3 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutHistoryLength, u, 4 ) - #ifdef RELAX_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularSH1, u, 5 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseSH1, u, 6 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularResponsiveSH1, u, 7 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseResponsiveSH1, u, 8 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#elif( defined RELAX_DIFFUSE ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gTiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gNoisyDiffuseIllumination, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseIllumination, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseIlluminationResponsive, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gHistoryLength, t, 4 ) - #ifdef RELAX_SH - NRD_INPUT_TEXTURE( Texture2D, gDiffuseSH1, t, 5 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseResponsiveSH1, t, 6 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseIllumination, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseIlluminationResponsive, u, 1 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutHistoryLength, u, 2 ) - #ifdef RELAX_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseSH1, u, 3 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseResponsiveSH1, u, 4 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#elif( defined RELAX_SPECULAR ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gTiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gNoisySpecularIllumination, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecularIllumination, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecularIlluminationResponsive, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gHistoryLength, t, 4 ) - #ifdef RELAX_SH - NRD_INPUT_TEXTURE( Texture2D, gSpecularSH1, t, 5 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecularResponsiveSH1, t, 6 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularIllumination, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularIlluminationResponsive, u, 1 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutHistoryLength, u, 2 ) - #ifdef RELAX_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularSH1, u, 3 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularResponsiveSH1, u, 4 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#endif - -// Macro magic -#define GROUP_X 8 -#define GROUP_Y 8 -#define NRD_USE_BORDER_2 - diff --git a/Shaders/Resources/RELAX_DiffuseSpecular_HistoryFix.resources.hlsli b/Shaders/Resources/RELAX_DiffuseSpecular_HistoryFix.resources.hlsli deleted file mode 100644 index 8bd428a..0000000 --- a/Shaders/Resources/RELAX_DiffuseSpecular_HistoryFix.resources.hlsli +++ /dev/null @@ -1,100 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -NRD_CONSTANTS_START - RELAX_SHARED_CB_DATA - NRD_CONSTANT( float, gDepthThreshold ) - NRD_CONSTANT( float, gHistoryFixEdgeStoppingNormalPower ) - NRD_CONSTANT( float, gHistoryFixStrideBetweenSamples ) - NRD_CONSTANT( float, gHistoryFixFrameNum ) - #if( defined RELAX_SPECULAR ) - NRD_CONSTANT(float, gSpecularLobeAngleFraction) - NRD_CONSTANT(float, gSpecularLobeAngleSlack) - NRD_CONSTANT(float, gRoughnessEdgeStoppingRelaxation) - NRD_CONSTANT(float, gNormalEdgeStoppingRelaxation) - #endif -NRD_CONSTANTS_END - -#if( defined RELAX_DIFFUSE && defined RELAX_SPECULAR ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gTiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecularIllumination, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseIllumination, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gHistoryLength, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gNormalRoughness, t, 4 ) - NRD_INPUT_TEXTURE( Texture2D, gViewZ, t, 5 ) - #ifdef RELAX_SH - NRD_INPUT_TEXTURE( Texture2D, gSpecularSH1, t, 6 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseSH1, t, 7 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularIllumination, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseIllumination, u, 1 ) - #ifdef RELAX_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularSH1, u, 2 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseSH1, u, 3 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#elif( defined RELAX_DIFFUSE ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gTiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseIllumination, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gHistoryLength, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gNormalRoughness, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gViewZ, t, 4 ) - #ifdef RELAX_SH - NRD_INPUT_TEXTURE( Texture2D, gDiffuseSH1, t, 5 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseIllumination, u, 0 ) - #ifdef RELAX_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseSH1, u, 1 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#elif( defined RELAX_SPECULAR ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gTiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecularIllumination, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gHistoryLength, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gNormalRoughness, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gViewZ, t, 4 ) - #ifdef RELAX_SH - NRD_INPUT_TEXTURE( Texture2D, gSpecularSH1, t, 5 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularIllumination, u, 0 ) - #ifdef RELAX_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularSH1, u, 1 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#endif - -// Macro magic -#define GROUP_X 8 -#define GROUP_Y 8 diff --git a/Shaders/Resources/RELAX_DiffuseSpecular_HitDistReconstruction.resources.hlsli b/Shaders/Resources/RELAX_DiffuseSpecular_HitDistReconstruction.resources.hlsli deleted file mode 100644 index a527804..0000000 --- a/Shaders/Resources/RELAX_DiffuseSpecular_HitDistReconstruction.resources.hlsli +++ /dev/null @@ -1,72 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -NRD_CONSTANTS_START - RELAX_SHARED_CB_DATA -NRD_CONSTANTS_END - -// This shader works on specular signal only - -#if( defined RELAX_DIFFUSE && defined RELAX_SPECULAR ) - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gTiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecularIllumination, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseIllumination, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gNormalRoughness, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gViewZ, t, 4 ) - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularIllumination, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseIllumination, u, 1 ) - NRD_OUTPUT_TEXTURE_END - -#elif( defined RELAX_DIFFUSE ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gTiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseIllumination, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gNormalRoughness, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gViewZ, t, 3 ) - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseIllumination, u, 0 ) - NRD_OUTPUT_TEXTURE_END - -#elif( defined RELAX_SPECULAR ) - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE(Texture2D, gTiles, t, 0) - NRD_INPUT_TEXTURE( Texture2D, gSpecularIllumination, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gNormalRoughness, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gViewZ, t, 3 ) - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularIllumination, u, 0 ) - NRD_OUTPUT_TEXTURE_END - -#endif - -// Macro magic -#define GROUP_X 8 -#define GROUP_Y 8 - -#ifdef RELAX_HITDIST_RECONSTRUCTION_5X5 - #define NRD_USE_BORDER_2 -#endif diff --git a/Shaders/Resources/RELAX_DiffuseSpecular_PrePass.resources.hlsli b/Shaders/Resources/RELAX_DiffuseSpecular_PrePass.resources.hlsli deleted file mode 100644 index 904d2e9..0000000 --- a/Shaders/Resources/RELAX_DiffuseSpecular_PrePass.resources.hlsli +++ /dev/null @@ -1,116 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -#if( defined RELAX_DIFFUSE && defined RELAX_SPECULAR ) - - NRD_CONSTANTS_START - RELAX_SHARED_CB_DATA - NRD_CONSTANT( float4, gRotator) - NRD_CONSTANT( uint, gDiffuseCheckerboard ) - NRD_CONSTANT( uint, gSpecularCheckerboard ) - NRD_CONSTANT( float, gDiffuseBlurRadius ) - NRD_CONSTANT( float, gSpecularBlurRadius ) - NRD_CONSTANT( float, gMeterToUnitsMultiplier ) - NRD_CONSTANT( float, gDepthThreshold ) - NRD_CONSTANT( float, gDiffuseLobeAngleFraction ) - NRD_CONSTANT( float, gSpecularLobeAngleFraction ) - NRD_CONSTANT( float, gSpecularLobeAngleSlack ) - NRD_CONSTANT( float, gRoughnessFraction ) - NRD_CONSTANTS_END - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gTiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecularIllumination, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseIllumination, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gNormalRoughness, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gViewZ, t, 4 ) - #ifdef RELAX_SH - NRD_INPUT_TEXTURE( Texture2D, gSpecularSH1, t, 5 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseSH1, t, 6 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularIllumination, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseIllumination, u, 1 ) - #ifdef RELAX_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularSH1, u, 2 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseSH1, u, 3 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#elif( defined RELAX_DIFFUSE ) - - NRD_CONSTANTS_START - RELAX_SHARED_CB_DATA - NRD_CONSTANT( float4, gRotator) - NRD_CONSTANT( uint, gDiffuseCheckerboard ) - NRD_CONSTANT( float, gDiffuseBlurRadius ) - NRD_CONSTANT( float, gMeterToUnitsMultiplier ) - NRD_CONSTANT( float, gDepthThreshold ) - NRD_CONSTANT( float, gDiffuseLobeAngleFraction ) - NRD_CONSTANTS_END - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gTiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseIllumination, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gNormalRoughness, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gViewZ, t, 3 ) - #ifdef RELAX_SH - NRD_INPUT_TEXTURE( Texture2D, gDiffuseSH1, t, 4 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseIllumination, u, 0 ) - #ifdef RELAX_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseSH1, u, 1 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#elif( defined RELAX_SPECULAR ) - - NRD_CONSTANTS_START - RELAX_SHARED_CB_DATA - NRD_CONSTANT( float4, gRotator) - NRD_CONSTANT( uint, gSpecularCheckerboard ) - NRD_CONSTANT( float, gSpecularBlurRadius ) - NRD_CONSTANT( float, gMeterToUnitsMultiplier ) - NRD_CONSTANT( float, gDepthThreshold ) - NRD_CONSTANT( float, gSpecularLobeAngleFraction ) - NRD_CONSTANT( float, gSpecularLobeAngleSlack ) - NRD_CONSTANT( float, gRoughnessFraction ) - NRD_CONSTANTS_END - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gTiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecularIllumination, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gNormalRoughness, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gViewZ, t, 3 ) - #ifdef RELAX_SH - NRD_INPUT_TEXTURE( Texture2D, gSpecularSH1, t, 4 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularIllumination, u, 0 ) - #ifdef RELAX_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularSH1, u, 1 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#endif diff --git a/Shaders/Resources/RELAX_DiffuseSpecular_SplitScreen.resources.hlsli b/Shaders/Resources/RELAX_DiffuseSpecular_SplitScreen.resources.hlsli deleted file mode 100644 index 8b451ce..0000000 --- a/Shaders/Resources/RELAX_DiffuseSpecular_SplitScreen.resources.hlsli +++ /dev/null @@ -1,72 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -#if( defined RELAX_DIFFUSE && defined RELAX_SPECULAR ) - - NRD_CONSTANTS_START - RELAX_SHARED_CB_DATA - NRD_CONSTANT( float, gSplitScreen ) - NRD_CONSTANT( uint, gDiffCheckerboard ) - NRD_CONSTANT( uint, gSpecCheckerboard ) - NRD_CONSTANTS_END - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec, t, 2 ) - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Diff, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Spec, u, 1 ) - NRD_OUTPUT_TEXTURE_END - -#elif( defined RELAX_DIFFUSE ) - - NRD_CONSTANTS_START - RELAX_SHARED_CB_DATA - NRD_CONSTANT( float, gSplitScreen ) - NRD_CONSTANT( uint, gDiffCheckerboard ) - NRD_CONSTANTS_END - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Diff, t, 1 ) - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Diff, u, 0 ) - NRD_OUTPUT_TEXTURE_END - -#else - - NRD_CONSTANTS_START - RELAX_SHARED_CB_DATA - NRD_CONSTANT( float, gSplitScreen ) - NRD_CONSTANT( uint, gSpecCheckerboard ) - NRD_CONSTANTS_END - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Spec, t, 1 ) - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Spec, u, 0 ) - NRD_OUTPUT_TEXTURE_END - -#endif diff --git a/Shaders/Resources/RELAX_DiffuseSpecular_TemporalAccumulation.resources.hlsli b/Shaders/Resources/RELAX_DiffuseSpecular_TemporalAccumulation.resources.hlsli deleted file mode 100644 index 2fb1322..0000000 --- a/Shaders/Resources/RELAX_DiffuseSpecular_TemporalAccumulation.resources.hlsli +++ /dev/null @@ -1,182 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -#if( defined RELAX_DIFFUSE && defined RELAX_SPECULAR ) - - NRD_CONSTANTS_START - RELAX_SHARED_CB_DATA - NRD_CONSTANT( float, gSpecularMaxAccumulatedFrameNum ) - NRD_CONSTANT( float, gSpecularMaxFastAccumulatedFrameNum ) - NRD_CONSTANT( float, gDiffuseMaxAccumulatedFrameNum ) - NRD_CONSTANT( float, gDiffuseMaxFastAccumulatedFrameNum ) - NRD_CONSTANT( uint, gDiffCheckerboard ) - NRD_CONSTANT( uint, gSpecCheckerboard ) - NRD_CONSTANT( float, gDisocclusionDepthThreshold ) - NRD_CONSTANT( float, gDisocclusionDepthThresholdAlternate ) - NRD_CONSTANT( float, gRoughnessFraction ) - NRD_CONSTANT( float, gSpecularVarianceBoost ) - NRD_CONSTANT( uint, gSkipReprojectionTestWithoutMotion ) - NRD_CONSTANT( uint, gUseConfidenceInputs ) - NRD_CONSTANT( uint, gUseDisocclusionThresholdMix ) - NRD_CONSTANTS_END - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gTiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecularIllumination, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseIllumination, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gMv, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gNormalRoughness, t, 4 ) - NRD_INPUT_TEXTURE( Texture2D, gViewZ, t, 5 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevSpecularIlluminationResponsive, t, 6 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevDiffuseIlluminationResponsive, t, 7 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevSpecularIllumination, t, 8 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevDiffuseIllumination, t, 9 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevNormalRoughness, t, 10 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevViewZ, t, 11 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevReflectionHitT, t, 12 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevHistoryLength, t, 13 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevMaterialID, t, 14 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecConfidence, t, 15 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffConfidence, t, 16 ) - NRD_INPUT_TEXTURE( Texture2D, gDisocclusionThresholdMix, t, 17) - #ifdef RELAX_SH - NRD_INPUT_TEXTURE( Texture2D, gSpecularSH1, t, 18 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseSH1, t, 19 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevSpecularResponsiveSH1, t, 20 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevDiffuseResponsiveSH1, t, 21 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevSpecularSH1, t, 22 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevDiffuseSH1, t, 23 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularIllumination, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseIllumination, u, 1 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularIlluminationResponsive, u, 2 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseIlluminationResponsive, u, 3 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutReflectionHitT, u, 4 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutHistoryLength, u, 5 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularReprojectionConfidence, u, 6 ) - #ifdef RELAX_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularSH1, u, 7 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseSH1, u, 8 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularResponsiveSH1, u, 9 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseResponsiveSH1, u, 10 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#elif( defined RELAX_DIFFUSE ) - - NRD_CONSTANTS_START - RELAX_SHARED_CB_DATA - NRD_CONSTANT( float, gDiffuseMaxAccumulatedFrameNum ) - NRD_CONSTANT( float, gDiffuseMaxFastAccumulatedFrameNum ) - NRD_CONSTANT( uint, gDiffCheckerboard ) - NRD_CONSTANT( float, gDisocclusionDepthThreshold ) - NRD_CONSTANT( float, gDisocclusionDepthThresholdAlternate ) - NRD_CONSTANT( uint, gSkipReprojectionTestWithoutMotion ) - NRD_CONSTANT( uint, gUseConfidenceInputs ) - NRD_CONSTANT( uint, gUseDisocclusionThresholdMix ) - NRD_CONSTANTS_END - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gTiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffuseIllumination, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gMv, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gNormalRoughness, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gViewZ, t, 4 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevDiffuseIlluminationResponsive, t, 5 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevDiffuseIllumination, t, 6 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevNormalRoughness, t, 7 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevViewZ, t, 8 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevHistoryLength, t, 9 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevMaterialID, t, 10 ) - NRD_INPUT_TEXTURE( Texture2D, gDiffConfidence, t, 11 ) - NRD_INPUT_TEXTURE( Texture2D, gDisocclusionThresholdMix, t, 12) - #ifdef RELAX_SH - NRD_INPUT_TEXTURE( Texture2D, gDiffuseSH1, t, 13 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevDiffuseResponsiveSH1, t, 14 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevDiffuseSH1, t, 15 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseIllumination, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseIlluminationResponsive, u, 1 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutHistoryLength, u, 2 ) - #ifdef RELAX_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseSH1, u, 3 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutDiffuseResponsiveSH1, u, 4 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#elif( defined RELAX_SPECULAR ) - - NRD_CONSTANTS_START - RELAX_SHARED_CB_DATA - NRD_CONSTANT( float, gSpecularMaxAccumulatedFrameNum ) - NRD_CONSTANT( float, gSpecularMaxFastAccumulatedFrameNum ) - NRD_CONSTANT( uint, gSpecCheckerboard ) - NRD_CONSTANT( float, gDisocclusionDepthThreshold ) - NRD_CONSTANT( float, gDisocclusionDepthThresholdAlternate ) - NRD_CONSTANT( float, gRoughnessFraction ) - NRD_CONSTANT( float, gSpecularVarianceBoost ) - NRD_CONSTANT( uint, gSkipReprojectionTestWithoutMotion ) - NRD_CONSTANT( uint, gUseConfidenceInputs ) - NRD_CONSTANT( uint, gUseDisocclusionThresholdMix ) - NRD_CONSTANTS_END - - NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gTiles, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecularIllumination, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gMv, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gNormalRoughness, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gViewZ, t, 4 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevSpecularIlluminationResponsive, t, 5 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevSpecularIllumination, t, 6 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevNormalRoughness, t, 7 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevViewZ, t, 8 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevReflectionHitT, t, 9 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevHistoryLength, t, 10 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevMaterialID, t, 11 ) - NRD_INPUT_TEXTURE( Texture2D, gSpecConfidence, t, 12 ) - NRD_INPUT_TEXTURE( Texture2D, gDisocclusionThresholdMix, t, 13) - #ifdef RELAX_SH - NRD_INPUT_TEXTURE( Texture2D, gSpecularSH1, t, 14 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevSpecularResponsiveSH1, t, 15 ) - NRD_INPUT_TEXTURE( Texture2D, gPrevSpecularSH1, t, 16 ) - #endif - NRD_INPUT_TEXTURE_END - - NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularIllumination, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularIlluminationResponsive, u, 1 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutReflectionHitT, u, 2 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutHistoryLength, u, 3 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularReprojectionConfidence, u, 4 ) - #ifdef RELAX_SH - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularSH1, u, 5 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOutSpecularResponsiveSH1, u, 6 ) - #endif - NRD_OUTPUT_TEXTURE_END - -#endif - -// Macro magic -#define GROUP_X 8 -#define GROUP_Y 8 -#define NRD_USE_BORDER_1 diff --git a/Shaders/Resources/RELAX_HistoryClamping.resources.hlsli b/Shaders/Resources/RELAX_HistoryClamping.resources.hlsli new file mode 100644 index 0000000..f3aa5ec --- /dev/null +++ b/Shaders/Resources/RELAX_HistoryClamping.resources.hlsli @@ -0,0 +1,114 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +NRD_CONSTANTS_START( RELAX_HistoryClampingConstants ) + RELAX_SHARED_CONSTANTS +NRD_CONSTANTS_END + +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +#if( defined RELAX_DIFFUSE && defined RELAX_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gTiles, t, 0 ) + NRD_INPUT( Texture2D, gNoisySpecularIllumination, t, 1 ) + NRD_INPUT( Texture2D, gNoisyDiffuseIllumination, t, 2 ) + NRD_INPUT( Texture2D, gSpecIllumination, t, 3 ) + NRD_INPUT( Texture2D, gDiffIllumination, t, 4 ) + NRD_INPUT( Texture2D, gSpecIlluminationResponsive, t, 5 ) + NRD_INPUT( Texture2D, gDiffIlluminationResponsive, t, 6 ) + NRD_INPUT( Texture2D, gHistoryLength, t, 7 ) + #ifdef RELAX_SH + NRD_INPUT( Texture2D, gSpecSH1, t, 8 ) + NRD_INPUT( Texture2D, gDiffSH1, t, 9 ) + NRD_INPUT( Texture2D, gSpecResponsiveSH1, t, 10 ) + NRD_INPUT( Texture2D, gDiffResponsiveSH1, t, 11 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutSpecularIllumination, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOutDiffuseIllumination, u, 1 ) + NRD_OUTPUT( RWTexture2D, gOutSpecularIlluminationResponsive, u, 2 ) + NRD_OUTPUT( RWTexture2D, gOutDiffuseIlluminationResponsive, u, 3 ) + NRD_OUTPUT( RWTexture2D, gOutHistoryLength, u, 4 ) + #ifdef RELAX_SH + NRD_OUTPUT( RWTexture2D, gOutSpecularSH1, u, 5 ) + NRD_OUTPUT( RWTexture2D, gOutDiffuseSH1, u, 6 ) + NRD_OUTPUT( RWTexture2D, gOutSpecularResponsiveSH1, u, 7 ) + NRD_OUTPUT( RWTexture2D, gOutDiffuseResponsiveSH1, u, 8 ) + #endif + NRD_OUTPUTS_END + +#elif( defined RELAX_DIFFUSE ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gTiles, t, 0 ) + NRD_INPUT( Texture2D, gNoisyDiffuseIllumination, t, 1 ) + NRD_INPUT( Texture2D, gDiffIllumination, t, 2 ) + NRD_INPUT( Texture2D, gDiffIlluminationResponsive, t, 3 ) + NRD_INPUT( Texture2D, gHistoryLength, t, 4 ) + #ifdef RELAX_SH + NRD_INPUT( Texture2D, gDiffSH1, t, 5 ) + NRD_INPUT( Texture2D, gDiffResponsiveSH1, t, 6 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutDiffuseIllumination, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOutDiffuseIlluminationResponsive, u, 1 ) + NRD_OUTPUT( RWTexture2D, gOutHistoryLength, u, 2 ) + #ifdef RELAX_SH + NRD_OUTPUT( RWTexture2D, gOutDiffuseSH1, u, 3 ) + NRD_OUTPUT( RWTexture2D, gOutDiffuseResponsiveSH1, u, 4 ) + #endif + NRD_OUTPUTS_END + +#elif( defined RELAX_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gTiles, t, 0 ) + NRD_INPUT( Texture2D, gNoisySpecularIllumination, t, 1 ) + NRD_INPUT( Texture2D, gSpecIllumination, t, 2 ) + NRD_INPUT( Texture2D, gSpecIlluminationResponsive, t, 3 ) + NRD_INPUT( Texture2D, gHistoryLength, t, 4 ) + #ifdef RELAX_SH + NRD_INPUT( Texture2D, gSpecSH1, t, 5 ) + NRD_INPUT( Texture2D, gSpecResponsiveSH1, t, 6 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutSpecularIllumination, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOutSpecularIlluminationResponsive, u, 1 ) + NRD_OUTPUT( RWTexture2D, gOutHistoryLength, u, 2 ) + #ifdef RELAX_SH + NRD_OUTPUT( RWTexture2D, gOutSpecularSH1, u, 3 ) + NRD_OUTPUT( RWTexture2D, gOutSpecularResponsiveSH1, u, 4 ) + #endif + NRD_OUTPUTS_END + +#endif + +// Macro magic +#define RELAX_HistoryClampingGroupX 8 +#define RELAX_HistoryClampingGroupY 8 + +#define NRD_USE_BORDER_2 + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X RELAX_HistoryClampingGroupX +#define GROUP_Y RELAX_HistoryClampingGroupY + diff --git a/Shaders/Resources/RELAX_HistoryFix.resources.hlsli b/Shaders/Resources/RELAX_HistoryFix.resources.hlsli new file mode 100644 index 0000000..70da9f2 --- /dev/null +++ b/Shaders/Resources/RELAX_HistoryFix.resources.hlsli @@ -0,0 +1,94 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +NRD_CONSTANTS_START( RELAX_HistoryFixConstants ) + RELAX_SHARED_CONSTANTS +NRD_CONSTANTS_END + +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +#if( defined RELAX_DIFFUSE && defined RELAX_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gTiles, t, 0 ) + NRD_INPUT( Texture2D, gSpecIllumination, t, 1 ) + NRD_INPUT( Texture2D, gDiffIllumination, t, 2 ) + NRD_INPUT( Texture2D, gHistoryLength, t, 3 ) + NRD_INPUT( Texture2D, gNormalRoughness, t, 4 ) + NRD_INPUT( Texture2D, gViewZ, t, 5 ) + #ifdef RELAX_SH + NRD_INPUT( Texture2D, gSpecSH1, t, 6 ) + NRD_INPUT( Texture2D, gDiffSH1, t, 7 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutSpecularIllumination, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOutDiffuseIllumination, u, 1 ) + #ifdef RELAX_SH + NRD_OUTPUT( RWTexture2D, gOutSpecularSH1, u, 2 ) + NRD_OUTPUT( RWTexture2D, gOutDiffuseSH1, u, 3 ) + #endif + NRD_OUTPUTS_END + +#elif( defined RELAX_DIFFUSE ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gTiles, t, 0 ) + NRD_INPUT( Texture2D, gDiffIllumination, t, 1 ) + NRD_INPUT( Texture2D, gHistoryLength, t, 2 ) + NRD_INPUT( Texture2D, gNormalRoughness, t, 3 ) + NRD_INPUT( Texture2D, gViewZ, t, 4 ) + #ifdef RELAX_SH + NRD_INPUT( Texture2D, gDiffSH1, t, 5 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutDiffuseIllumination, u, 0 ) + #ifdef RELAX_SH + NRD_OUTPUT( RWTexture2D, gOutDiffuseSH1, u, 1 ) + #endif + NRD_OUTPUTS_END + +#elif( defined RELAX_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gTiles, t, 0 ) + NRD_INPUT( Texture2D, gSpecIllumination, t, 1 ) + NRD_INPUT( Texture2D, gHistoryLength, t, 2 ) + NRD_INPUT( Texture2D, gNormalRoughness, t, 3 ) + NRD_INPUT( Texture2D, gViewZ, t, 4 ) + #ifdef RELAX_SH + NRD_INPUT( Texture2D, gSpecSH1, t, 5 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutSpecularIllumination, u, 0 ) + #ifdef RELAX_SH + NRD_OUTPUT( RWTexture2D, gOutSpecularSH1, u, 1 ) + #endif + NRD_OUTPUTS_END + +#endif + +// Macro magic +#define RELAX_HistoryFixGroupX 8 +#define RELAX_HistoryFixGroupY 8 + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X RELAX_HistoryFixGroupX +#define GROUP_Y RELAX_HistoryFixGroupY diff --git a/Shaders/Resources/RELAX_HitDistReconstruction.resources.hlsli b/Shaders/Resources/RELAX_HitDistReconstruction.resources.hlsli new file mode 100644 index 0000000..15569e3 --- /dev/null +++ b/Shaders/Resources/RELAX_HitDistReconstruction.resources.hlsli @@ -0,0 +1,74 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +NRD_CONSTANTS_START( RELAX_HitDistReconstructionConstants ) + RELAX_SHARED_CONSTANTS +NRD_CONSTANTS_END + +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +#if( defined RELAX_DIFFUSE && defined RELAX_SPECULAR ) + NRD_INPUTS_START + NRD_INPUT( Texture2D, gTiles, t, 0 ) + NRD_INPUT( Texture2D, gSpecIllumination, t, 1 ) + NRD_INPUT( Texture2D, gDiffIllumination, t, 2 ) + NRD_INPUT( Texture2D, gNormalRoughness, t, 3 ) + NRD_INPUT( Texture2D, gViewZ, t, 4 ) + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutSpecularIllumination, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOutDiffuseIllumination, u, 1 ) + NRD_OUTPUTS_END + +#elif( defined RELAX_DIFFUSE ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gTiles, t, 0 ) + NRD_INPUT( Texture2D, gDiffIllumination, t, 1 ) + NRD_INPUT( Texture2D, gNormalRoughness, t, 2 ) + NRD_INPUT( Texture2D, gViewZ, t, 3 ) + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutDiffuseIllumination, u, 0 ) + NRD_OUTPUTS_END + +#elif( defined RELAX_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT(Texture2D, gTiles, t, 0) + NRD_INPUT( Texture2D, gSpecIllumination, t, 1 ) + NRD_INPUT( Texture2D, gNormalRoughness, t, 2 ) + NRD_INPUT( Texture2D, gViewZ, t, 3 ) + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutSpecularIllumination, u, 0 ) + NRD_OUTPUTS_END + +#endif + +// Macro magic +#define RELAX_HitDistReconstructionGroupX 8 +#define RELAX_HitDistReconstructionGroupY 8 + +#ifdef RELAX_HITDIST_RECONSTRUCTION_5X5 + #define NRD_USE_BORDER_2 +#endif + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X RELAX_HitDistReconstructionGroupX +#define GROUP_Y RELAX_HitDistReconstructionGroupY diff --git a/Shaders/Resources/RELAX_PrePass.resources.hlsli b/Shaders/Resources/RELAX_PrePass.resources.hlsli new file mode 100644 index 0000000..d75c2c6 --- /dev/null +++ b/Shaders/Resources/RELAX_PrePass.resources.hlsli @@ -0,0 +1,92 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +NRD_CONSTANTS_START( RELAX_PrePassConstants ) + RELAX_SHARED_CONSTANTS + NRD_CONSTANT( float4, gRotator ) +NRD_CONSTANTS_END + +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +#if( defined RELAX_DIFFUSE && defined RELAX_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gTiles, t, 0 ) + NRD_INPUT( Texture2D, gSpecIllumination, t, 1 ) + NRD_INPUT( Texture2D, gDiffIllumination, t, 2 ) + NRD_INPUT( Texture2D, gNormalRoughness, t, 3 ) + NRD_INPUT( Texture2D, gViewZ, t, 4 ) + #ifdef RELAX_SH + NRD_INPUT( Texture2D, gSpecSH1, t, 5 ) + NRD_INPUT( Texture2D, gDiffSH1, t, 6 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutSpecularIllumination, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOutDiffuseIllumination, u, 1 ) + #ifdef RELAX_SH + NRD_OUTPUT( RWTexture2D, gOutSpecularSH1, u, 2 ) + NRD_OUTPUT( RWTexture2D, gOutDiffuseSH1, u, 3 ) + #endif + NRD_OUTPUTS_END + +#elif( defined RELAX_DIFFUSE ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gTiles, t, 0 ) + NRD_INPUT( Texture2D, gDiffIllumination, t, 1 ) + NRD_INPUT( Texture2D, gNormalRoughness, t, 2 ) + NRD_INPUT( Texture2D, gViewZ, t, 3 ) + #ifdef RELAX_SH + NRD_INPUT( Texture2D, gDiffSH1, t, 4 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutDiffuseIllumination, u, 0 ) + #ifdef RELAX_SH + NRD_OUTPUT( RWTexture2D, gOutDiffuseSH1, u, 1 ) + #endif + NRD_OUTPUTS_END + +#elif( defined RELAX_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gTiles, t, 0 ) + NRD_INPUT( Texture2D, gSpecIllumination, t, 1 ) + NRD_INPUT( Texture2D, gNormalRoughness, t, 2 ) + NRD_INPUT( Texture2D, gViewZ, t, 3 ) + #ifdef RELAX_SH + NRD_INPUT( Texture2D, gSpecSH1, t, 4 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutSpecularIllumination, u, 0 ) + #ifdef RELAX_SH + NRD_OUTPUT( RWTexture2D, gOutSpecularSH1, u, 1 ) + #endif + NRD_OUTPUTS_END + +#endif + +// Macro magic +#define RELAX_PrePassGroupX 16 +#define RELAX_PrePassGroupY 16 + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X RELAX_PrePassGroupX +#define GROUP_Y RELAX_PrePassGroupY diff --git a/Shaders/Resources/RELAX_SplitScreen.resources.hlsli b/Shaders/Resources/RELAX_SplitScreen.resources.hlsli new file mode 100644 index 0000000..fa13bca --- /dev/null +++ b/Shaders/Resources/RELAX_SplitScreen.resources.hlsli @@ -0,0 +1,65 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +NRD_CONSTANTS_START( RELAX_SplitScreenConstants ) + RELAX_SHARED_CONSTANTS +NRD_CONSTANTS_END + +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +#if( defined RELAX_DIFFUSE && defined RELAX_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_ViewZ, t, 0 ) + NRD_INPUT( Texture2D, gIn_Diff, t, 1 ) + NRD_INPUT( Texture2D, gIn_Spec, t, 2 ) + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Diff, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOut_Spec, u, 1 ) + NRD_OUTPUTS_END + +#elif( defined RELAX_DIFFUSE ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_ViewZ, t, 0 ) + NRD_INPUT( Texture2D, gIn_Diff, t, 1 ) + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Diff, u, 0 ) + NRD_OUTPUTS_END + +#else + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_ViewZ, t, 0 ) + NRD_INPUT( Texture2D, gIn_Spec, t, 1 ) + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Spec, u, 0 ) + NRD_OUTPUTS_END + +#endif + +// Macro magic +#define RELAX_SplitScreenGroupX 8 +#define RELAX_SplitScreenGroupY 8 + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X RELAX_SplitScreenGroupX +#define GROUP_Y RELAX_SplitScreenGroupY diff --git a/Shaders/Resources/RELAX_TemporalAccumulation.resources.hlsli b/Shaders/Resources/RELAX_TemporalAccumulation.resources.hlsli new file mode 100644 index 0000000..1fd3dd3 --- /dev/null +++ b/Shaders/Resources/RELAX_TemporalAccumulation.resources.hlsli @@ -0,0 +1,146 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +NRD_CONSTANTS_START( RELAX_TemporalAccumulationConstants ) + RELAX_SHARED_CONSTANTS +NRD_CONSTANTS_END + +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +#if( defined RELAX_DIFFUSE && defined RELAX_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gTiles, t, 0 ) + NRD_INPUT( Texture2D, gSpecIllumination, t, 1 ) + NRD_INPUT( Texture2D, gDiffIllumination, t, 2 ) + NRD_INPUT( Texture2D, gMv, t, 3 ) + NRD_INPUT( Texture2D, gNormalRoughness, t, 4 ) + NRD_INPUT( Texture2D, gViewZ, t, 5 ) + NRD_INPUT( Texture2D, gPrevSpecularIlluminationResponsive, t, 6 ) + NRD_INPUT( Texture2D, gPrevDiffuseIlluminationResponsive, t, 7 ) + NRD_INPUT( Texture2D, gPrevSpecularIllumination, t, 8 ) + NRD_INPUT( Texture2D, gPrevDiffuseIllumination, t, 9 ) + NRD_INPUT( Texture2D, gPrevNormalRoughness, t, 10 ) + NRD_INPUT( Texture2D, gPrevViewZ, t, 11 ) + NRD_INPUT( Texture2D, gPrevReflectionHitT, t, 12 ) + NRD_INPUT( Texture2D, gPrevHistoryLength, t, 13 ) + NRD_INPUT( Texture2D, gPrevMaterialID, t, 14 ) + NRD_INPUT( Texture2D, gSpecConfidence, t, 15 ) + NRD_INPUT( Texture2D, gDiffConfidence, t, 16 ) + NRD_INPUT( Texture2D, gDisocclusionThresholdMix, t, 17) + #ifdef RELAX_SH + NRD_INPUT( Texture2D, gSpecSH1, t, 18 ) + NRD_INPUT( Texture2D, gDiffSH1, t, 19 ) + NRD_INPUT( Texture2D, gPrevSpecularResponsiveSH1, t, 20 ) + NRD_INPUT( Texture2D, gPrevDiffuseResponsiveSH1, t, 21 ) + NRD_INPUT( Texture2D, gPrevSpecularSH1, t, 22 ) + NRD_INPUT( Texture2D, gPrevDiffuseSH1, t, 23 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutSpecularIllumination, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOutDiffuseIllumination, u, 1 ) + NRD_OUTPUT( RWTexture2D, gOutSpecularIlluminationResponsive, u, 2 ) + NRD_OUTPUT( RWTexture2D, gOutDiffuseIlluminationResponsive, u, 3 ) + NRD_OUTPUT( RWTexture2D, gOutReflectionHitT, u, 4 ) + NRD_OUTPUT( RWTexture2D, gOutHistoryLength, u, 5 ) + NRD_OUTPUT( RWTexture2D, gOutSpecularReprojectionConfidence, u, 6 ) + #ifdef RELAX_SH + NRD_OUTPUT( RWTexture2D, gOutSpecularSH1, u, 7 ) + NRD_OUTPUT( RWTexture2D, gOutDiffuseSH1, u, 8 ) + NRD_OUTPUT( RWTexture2D, gOutSpecularResponsiveSH1, u, 9 ) + NRD_OUTPUT( RWTexture2D, gOutDiffuseResponsiveSH1, u, 10 ) + #endif + NRD_OUTPUTS_END + +#elif( defined RELAX_DIFFUSE ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gTiles, t, 0 ) + NRD_INPUT( Texture2D, gDiffIllumination, t, 1 ) + NRD_INPUT( Texture2D, gMv, t, 2 ) + NRD_INPUT( Texture2D, gNormalRoughness, t, 3 ) + NRD_INPUT( Texture2D, gViewZ, t, 4 ) + NRD_INPUT( Texture2D, gPrevDiffuseIlluminationResponsive, t, 5 ) + NRD_INPUT( Texture2D, gPrevDiffuseIllumination, t, 6 ) + NRD_INPUT( Texture2D, gPrevNormalRoughness, t, 7 ) + NRD_INPUT( Texture2D, gPrevViewZ, t, 8 ) + NRD_INPUT( Texture2D, gPrevHistoryLength, t, 9 ) + NRD_INPUT( Texture2D, gPrevMaterialID, t, 10 ) + NRD_INPUT( Texture2D, gDiffConfidence, t, 11 ) + NRD_INPUT( Texture2D, gDisocclusionThresholdMix, t, 12) + #ifdef RELAX_SH + NRD_INPUT( Texture2D, gDiffSH1, t, 13 ) + NRD_INPUT( Texture2D, gPrevDiffuseResponsiveSH1, t, 14 ) + NRD_INPUT( Texture2D, gPrevDiffuseSH1, t, 15 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutDiffuseIllumination, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOutDiffuseIlluminationResponsive, u, 1 ) + NRD_OUTPUT( RWTexture2D, gOutHistoryLength, u, 2 ) + #ifdef RELAX_SH + NRD_OUTPUT( RWTexture2D, gOutDiffuseSH1, u, 3 ) + NRD_OUTPUT( RWTexture2D, gOutDiffuseResponsiveSH1, u, 4 ) + #endif + NRD_OUTPUTS_END + +#elif( defined RELAX_SPECULAR ) + + NRD_INPUTS_START + NRD_INPUT( Texture2D, gTiles, t, 0 ) + NRD_INPUT( Texture2D, gSpecIllumination, t, 1 ) + NRD_INPUT( Texture2D, gMv, t, 2 ) + NRD_INPUT( Texture2D, gNormalRoughness, t, 3 ) + NRD_INPUT( Texture2D, gViewZ, t, 4 ) + NRD_INPUT( Texture2D, gPrevSpecularIlluminationResponsive, t, 5 ) + NRD_INPUT( Texture2D, gPrevSpecularIllumination, t, 6 ) + NRD_INPUT( Texture2D, gPrevNormalRoughness, t, 7 ) + NRD_INPUT( Texture2D, gPrevViewZ, t, 8 ) + NRD_INPUT( Texture2D, gPrevReflectionHitT, t, 9 ) + NRD_INPUT( Texture2D, gPrevHistoryLength, t, 10 ) + NRD_INPUT( Texture2D, gPrevMaterialID, t, 11 ) + NRD_INPUT( Texture2D, gSpecConfidence, t, 12 ) + NRD_INPUT( Texture2D, gDisocclusionThresholdMix, t, 13) + #ifdef RELAX_SH + NRD_INPUT( Texture2D, gSpecSH1, t, 14 ) + NRD_INPUT( Texture2D, gPrevSpecularResponsiveSH1, t, 15 ) + NRD_INPUT( Texture2D, gPrevSpecularSH1, t, 16 ) + #endif + NRD_INPUTS_END + + NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOutSpecularIllumination, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOutSpecularIlluminationResponsive, u, 1 ) + NRD_OUTPUT( RWTexture2D, gOutReflectionHitT, u, 2 ) + NRD_OUTPUT( RWTexture2D, gOutHistoryLength, u, 3 ) + NRD_OUTPUT( RWTexture2D, gOutSpecularReprojectionConfidence, u, 4 ) + #ifdef RELAX_SH + NRD_OUTPUT( RWTexture2D, gOutSpecularSH1, u, 5 ) + NRD_OUTPUT( RWTexture2D, gOutSpecularResponsiveSH1, u, 6 ) + #endif + NRD_OUTPUTS_END + +#endif + +// Macro magic +#define RELAX_TemporalAccumulationGroupX 8 +#define RELAX_TemporalAccumulationGroupY 16 + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X RELAX_TemporalAccumulationGroupX +#define GROUP_Y RELAX_TemporalAccumulationGroupY diff --git a/Shaders/Resources/RELAX_Validation.resources.hlsli b/Shaders/Resources/RELAX_Validation.resources.hlsli index b6b046a..2ec23b6 100644 --- a/Shaders/Resources/RELAX_Validation.resources.hlsli +++ b/Shaders/Resources/RELAX_Validation.resources.hlsli @@ -8,27 +8,32 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -NRD_SAMPLER_START +NRD_CONSTANTS_START( RELAX_ValidationConstants ) + RELAX_SHARED_CONSTANTS +NRD_CONSTANTS_END + +NRD_SAMPLERS_START NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END -NRD_CONSTANTS_START - RELAX_SHARED_CB_DATA - NRD_CONSTANT( float4x4, gWorldToClipPrev ) - NRD_CONSTANT( float2, gJitter ) - NRD_CONSTANT( float, gMaxAccumulatedFrameNum ) -NRD_CONSTANTS_END +NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Normal_Roughness, t, 0 ) + NRD_INPUT( Texture2D, gIn_ViewZ, t, 1 ) + NRD_INPUT( Texture2D, gIn_Mv, t, 2 ) + NRD_INPUT( Texture2D, gIn_HistoryLength, t, 3 ) +NRD_INPUTS_END + +NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Validation, u, 0 ) +NRD_OUTPUTS_END -NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Normal_Roughness, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Mv, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_HistoryLength, t, 3 ) -NRD_INPUT_TEXTURE_END +// Macro magic +#define RELAX_ValidationGroupX 8 +#define RELAX_ValidationGroupY 16 -NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Validation, u, 0 ) -NRD_OUTPUT_TEXTURE_END +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X RELAX_ValidationGroupX +#define GROUP_Y RELAX_ValidationGroupY diff --git a/Shaders/Resources/SIGMA_Blur.resources.hlsli b/Shaders/Resources/SIGMA_Blur.resources.hlsli new file mode 100644 index 0000000..8479b18 --- /dev/null +++ b/Shaders/Resources/SIGMA_Blur.resources.hlsli @@ -0,0 +1,55 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +NRD_CONSTANTS_START( SIGMA_BlurConstants ) + SIGMA_SHARED_CONSTANTS + NRD_CONSTANT( float4, gRotator ) +NRD_CONSTANTS_END + +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Normal_Roughness, t, 0 ) + NRD_INPUT( Texture2D, gIn_Hit_ViewZ, t, 1 ) + NRD_INPUT( Texture2D, gIn_Tiles, t, 2 ) + #ifdef SIGMA_FIRST_PASS + NRD_INPUT( Texture2D, gIn_History, t, 3 ) + #ifdef SIGMA_TRANSLUCENT + NRD_INPUT( Texture2D, gIn_Shadow_Translucency, t, 4 ) + #endif + #else + NRD_INPUT( Texture2D, gIn_Shadow_Translucency, t, 3 ) + #endif +NRD_INPUTS_END + +NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Hit_ViewZ, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOut_Shadow_Translucency, u, 1 ) + #ifdef SIGMA_FIRST_PASS + NRD_OUTPUT( RWTexture2D, gOut_History, u, 2 ) + #endif +NRD_OUTPUTS_END + +// Macro magic +#define SIGMA_BlurGroupX 8 +#define SIGMA_BlurGroupY 16 + +#if( SIGMA_5X5_BLUR_RADIUS_ESTIMATION_KERNEL == 1 ) + #define NRD_USE_BORDER_2 +#endif + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X SIGMA_BlurGroupX +#define GROUP_Y SIGMA_BlurGroupY diff --git a/Shaders/Resources/SIGMA_ClassifyTiles.resources.hlsli b/Shaders/Resources/SIGMA_ClassifyTiles.resources.hlsli new file mode 100644 index 0000000..c3c2288 --- /dev/null +++ b/Shaders/Resources/SIGMA_ClassifyTiles.resources.hlsli @@ -0,0 +1,39 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +NRD_CONSTANTS_START( SIGMA_ClassifyTilesConstants ) + SIGMA_SHARED_CONSTANTS +NRD_CONSTANTS_END + +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Hit_ViewZ, t, 0 ) + #ifdef SIGMA_TRANSLUCENT + NRD_INPUT( Texture2D, gIn_Shadow_Translucency, t, 1 ) + #endif +NRD_INPUTS_END + +NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Tiles, u, 0 ) +NRD_OUTPUTS_END + +// Macro magic +#define SIGMA_ClassifyTilesGroupX 16 +#define SIGMA_ClassifyTilesGroupY 16 + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X SIGMA_ClassifyTilesGroupX +#define GROUP_Y SIGMA_ClassifyTilesGroupY diff --git a/Shaders/Resources/SIGMA_Shadow_Blur.resources.hlsli b/Shaders/Resources/SIGMA_Shadow_Blur.resources.hlsli deleted file mode 100644 index 27d0aae..0000000 --- a/Shaders/Resources/SIGMA_Shadow_Blur.resources.hlsli +++ /dev/null @@ -1,48 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -NRD_CONSTANTS_START - SIGMA_SHARED_CB_DATA - NRD_CONSTANT( float4x4, gWorldToView ) - NRD_CONSTANT( float4, gRotator ) -NRD_CONSTANTS_END - -NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Normal_Roughness, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Hit_ViewZ, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 2 ) - #ifdef SIGMA_FIRST_PASS - NRD_INPUT_TEXTURE( Texture2D, gIn_History, t, 3 ) - #ifdef SIGMA_TRANSLUCENT - NRD_INPUT_TEXTURE( Texture2D, gIn_Shadow_Translucency, t, 4 ) - #endif - #else - NRD_INPUT_TEXTURE( Texture2D, gIn_Shadow_Translucency, t, 3 ) - #endif -NRD_INPUT_TEXTURE_END - -NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Hit_ViewZ, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Shadow_Translucency, u, 1 ) - #ifdef SIGMA_FIRST_PASS - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_History, u, 2 ) - #endif -NRD_OUTPUT_TEXTURE_END - -#if( SIGMA_5X5_BLUR_RADIUS_ESTIMATION_KERNEL == 1 ) - #define NRD_USE_BORDER_2 -#endif diff --git a/Shaders/Resources/SIGMA_Shadow_ClassifyTiles.resources.hlsli b/Shaders/Resources/SIGMA_Shadow_ClassifyTiles.resources.hlsli deleted file mode 100644 index 4a6ee98..0000000 --- a/Shaders/Resources/SIGMA_Shadow_ClassifyTiles.resources.hlsli +++ /dev/null @@ -1,31 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -NRD_CONSTANTS_START - SIGMA_SHARED_CB_DATA -NRD_CONSTANTS_END - -NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Hit_ViewZ, t, 0 ) - #ifdef SIGMA_TRANSLUCENT - NRD_INPUT_TEXTURE( Texture2D, gIn_Shadow_Translucency, t, 1 ) - #endif -NRD_INPUT_TEXTURE_END - -NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Tiles, u, 0 ) -NRD_OUTPUT_TEXTURE_END diff --git a/Shaders/Resources/SIGMA_Shadow_SmoothTiles.resources.hlsli b/Shaders/Resources/SIGMA_Shadow_SmoothTiles.resources.hlsli deleted file mode 100644 index 2f1ba2f..0000000 --- a/Shaders/Resources/SIGMA_Shadow_SmoothTiles.resources.hlsli +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -NRD_CONSTANTS_START - SIGMA_SHARED_CB_DATA - NRD_CONSTANT( int2, gTilesSizeMinusOne ) -NRD_CONSTANTS_END - -NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 0 ) -NRD_INPUT_TEXTURE_END - -NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Tiles, u, 0 ) -NRD_OUTPUT_TEXTURE_END diff --git a/Shaders/Resources/SIGMA_Shadow_SplitScreen.resources.hlsli b/Shaders/Resources/SIGMA_Shadow_SplitScreen.resources.hlsli deleted file mode 100644 index 571724b..0000000 --- a/Shaders/Resources/SIGMA_Shadow_SplitScreen.resources.hlsli +++ /dev/null @@ -1,32 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -NRD_CONSTANTS_START - SIGMA_SHARED_CB_DATA - NRD_CONSTANT( float, gSplitScreen ) -NRD_CONSTANTS_END - -NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Hit_ViewZ, t, 0 ) - #ifdef SIGMA_TRANSLUCENT - NRD_INPUT_TEXTURE( Texture2D, gIn_Shadow_Translucency, t, 1 ) - #endif -NRD_INPUT_TEXTURE_END - -NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Shadow_Translucency, u, 0 ) -NRD_OUTPUT_TEXTURE_END diff --git a/Shaders/Resources/SIGMA_Shadow_TemporalStabilization.resources.hlsli b/Shaders/Resources/SIGMA_Shadow_TemporalStabilization.resources.hlsli deleted file mode 100644 index 6488e92..0000000 --- a/Shaders/Resources/SIGMA_Shadow_TemporalStabilization.resources.hlsli +++ /dev/null @@ -1,39 +0,0 @@ -/* -Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. - -NVIDIA CORPORATION and its licensors retain all intellectual property -and proprietary rights in and to this software, related documentation -and any modifications thereto. Any use, reproduction, disclosure or -distribution of this software and related documentation without an express -license agreement from NVIDIA CORPORATION is strictly prohibited. -*/ - -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -NRD_CONSTANTS_START - SIGMA_SHARED_CB_DATA - NRD_CONSTANT( float4x4, gWorldToClipPrev ) - NRD_CONSTANT( float4x4, gViewToWorld ) -NRD_CONSTANTS_END - -NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Mv, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Hit_ViewZ, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Shadow_Translucency, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_History, t, 3 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Tiles, t, 4 ) -NRD_INPUT_TEXTURE_END - -NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_Shadow_Translucency, u, 0 ) -NRD_OUTPUT_TEXTURE_END - -// Macro magic -#if( SIGMA_5X5_TEMPORAL_KERNEL == 1 ) - #define NRD_USE_BORDER_2 -#endif diff --git a/Shaders/Resources/SIGMA_SmoothTiles.resources.hlsli b/Shaders/Resources/SIGMA_SmoothTiles.resources.hlsli new file mode 100644 index 0000000..bb19561 --- /dev/null +++ b/Shaders/Resources/SIGMA_SmoothTiles.resources.hlsli @@ -0,0 +1,36 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +NRD_CONSTANTS_START( SIGMA_SmoothTilesConstants ) + SIGMA_SHARED_CONSTANTS +NRD_CONSTANTS_END + +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Tiles, t, 0 ) +NRD_INPUTS_END + +NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Tiles, u, 0 ) +NRD_OUTPUTS_END + +// Macro magic +#define SIGMA_SmoothTilesGroupX 16 +#define SIGMA_SmoothTilesGroupY 16 + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X SIGMA_SmoothTilesGroupX +#define GROUP_Y SIGMA_SmoothTilesGroupY diff --git a/Shaders/Resources/SIGMA_SplitScreen.resources.hlsli b/Shaders/Resources/SIGMA_SplitScreen.resources.hlsli new file mode 100644 index 0000000..c6485c8 --- /dev/null +++ b/Shaders/Resources/SIGMA_SplitScreen.resources.hlsli @@ -0,0 +1,39 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +NRD_CONSTANTS_START( SIGMA_SplitScreenConstants ) + SIGMA_SHARED_CONSTANTS +NRD_CONSTANTS_END + +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Hit_ViewZ, t, 0 ) + #ifdef SIGMA_TRANSLUCENT + NRD_INPUT( Texture2D, gIn_Shadow_Translucency, t, 1 ) + #endif +NRD_INPUTS_END + +NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Shadow_Translucency, u, 0 ) +NRD_OUTPUTS_END + +// Macro magic +#define SIGMA_SplitScreenGroupX 8 +#define SIGMA_SplitScreenGroupY 16 + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X SIGMA_SplitScreenGroupX +#define GROUP_Y SIGMA_SplitScreenGroupY diff --git a/Shaders/Resources/SIGMA_TemporalStabilization.resources.hlsli b/Shaders/Resources/SIGMA_TemporalStabilization.resources.hlsli new file mode 100644 index 0000000..51eba5b --- /dev/null +++ b/Shaders/Resources/SIGMA_TemporalStabilization.resources.hlsli @@ -0,0 +1,44 @@ +/* +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property +and proprietary rights in and to this software, related documentation +and any modifications thereto. Any use, reproduction, disclosure or +distribution of this software and related documentation without an express +license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +NRD_CONSTANTS_START( SIGMA_TemporalStabilizationConstants ) + SIGMA_SHARED_CONSTANTS +NRD_CONSTANTS_END + +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Mv, t, 0 ) + NRD_INPUT( Texture2D, gIn_Hit_ViewZ, t, 1 ) + NRD_INPUT( Texture2D, gIn_Shadow_Translucency, t, 2 ) + NRD_INPUT( Texture2D, gIn_History, t, 3 ) + NRD_INPUT( Texture2D, gIn_Tiles, t, 4 ) +NRD_INPUTS_END + +NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_Shadow_Translucency, u, 0 ) +NRD_OUTPUTS_END + +// Macro magic +#define SIGMA_TemporalStabilizationGroupX 8 +#define SIGMA_TemporalStabilizationGroupY 16 + +#if( SIGMA_5X5_TEMPORAL_KERNEL == 1 ) + #define NRD_USE_BORDER_2 +#endif + +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X SIGMA_TemporalStabilizationGroupX +#define GROUP_Y SIGMA_TemporalStabilizationGroupY diff --git a/Shaders/Resources/SpecularDeltaMv_Compute.resources.hlsli b/Shaders/Resources/SpecularDeltaMv_Compute.resources.hlsli index 3e69bf0..1a2e416 100644 --- a/Shaders/Resources/SpecularDeltaMv_Compute.resources.hlsli +++ b/Shaders/Resources/SpecularDeltaMv_Compute.resources.hlsli @@ -8,31 +8,38 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -NRD_CONSTANTS_START +NRD_CONSTANTS_START( SpecularDeltaMv_ComputeConstants ) NRD_CONSTANT( float4x4, gWorldToClipPrev ) - NRD_CONSTANT( float3, gMvScale ) - NRD_CONSTANT( float, gDebug ) - NRD_CONSTANT( uint2, gRectSize ) - NRD_CONSTANT( float2, gInvRectSize ) + NRD_CONSTANT( float4, gMvScale ) NRD_CONSTANT( uint2, gRectOrigin ) - NRD_CONSTANT( uint, gIsWorldSpaceMotionEnabled ) + NRD_CONSTANT( uint2, gRectSize ) + NRD_CONSTANT( float2, gRectSizeInv ) + NRD_CONSTANT( float, gDebug ) NRD_CONSTANTS_END -NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Mv, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_DeltaPrimaryPos, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_DeltaSecondaryPos, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_PrevDeltaSecondaryPos, t, 3 ) -NRD_INPUT_TEXTURE_END +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Mv, t, 0 ) + NRD_INPUT( Texture2D, gIn_DeltaPrimaryPos, t, 1 ) + NRD_INPUT( Texture2D, gIn_DeltaSecondaryPos, t, 2 ) + NRD_INPUT( Texture2D, gIn_PrevDeltaSecondaryPos, t, 3 ) +NRD_INPUTS_END + +NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_DeltaMv, u, 0 ) + NRD_OUTPUT( RWTexture2D, gOut_DeltaSecondaryPos, u, 1 ) +NRD_OUTPUTS_END + +// Macro magic +#define SpecularDeltaMv_ComputeGroupX 16 +#define SpecularDeltaMv_ComputeGroupY 16 -NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_DeltaMv, u, 0 ) - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_DeltaSecondaryPos, u, 1 ) -NRD_OUTPUT_TEXTURE_END +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X SpecularDeltaMv_ComputeGroupX +#define GROUP_Y SpecularDeltaMv_ComputeGroupY diff --git a/Shaders/Resources/SpecularReflectionMv_Compute.resources.hlsli b/Shaders/Resources/SpecularReflectionMv_Compute.resources.hlsli index 1b3fb37..393ac49 100644 --- a/Shaders/Resources/SpecularReflectionMv_Compute.resources.hlsli +++ b/Shaders/Resources/SpecularReflectionMv_Compute.resources.hlsli @@ -8,42 +8,49 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ -NRD_SAMPLER_START - NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) - NRD_SAMPLER( SamplerState, gNearestMirror, s, 1 ) - NRD_SAMPLER( SamplerState, gLinearClamp, s, 2 ) - NRD_SAMPLER( SamplerState, gLinearMirror, s, 3 ) -NRD_SAMPLER_END - -NRD_CONSTANTS_START +NRD_CONSTANTS_START( SpecularReflectionMv_ComputeConstants ) NRD_CONSTANT( float4x4, gViewToWorld ) NRD_CONSTANT( float4x4, gWorldToClip ) NRD_CONSTANT( float4x4, gWorldToClipPrev ) NRD_CONSTANT( float4x4, gWorldToViewPrev ) NRD_CONSTANT( float4, gFrustumPrev ) NRD_CONSTANT( float4, gFrustum ) - NRD_CONSTANT( float3, gViewVectorWorld ) - NRD_CONSTANT( float, gOrthoMode ) - NRD_CONSTANT( float3, gCameraDelta ) - NRD_CONSTANT( float, gUnproject ) - NRD_CONSTANT( float3, gMvScale ) - NRD_CONSTANT( float, gDebug ) + NRD_CONSTANT( float4, gViewVectorWorld ) // .w - unused + NRD_CONSTANT( float4, gCameraDelta ) // .w - unused + NRD_CONSTANT( float4, gMvScale ) NRD_CONSTANT( float2, gRectSize ) - NRD_CONSTANT( float2, gInvRectSize ) + NRD_CONSTANT( float2, gRectSizeInv ) NRD_CONSTANT( float2, gRectOffset ) NRD_CONSTANT( float2, gResolutionScale ) NRD_CONSTANT( uint2, gRectOrigin ) NRD_CONSTANT( float, gDenoisingRange ) - NRD_CONSTANT( uint, gIsWorldSpaceMotionEnabled ) + NRD_CONSTANT( float, gOrthoMode ) + NRD_CONSTANT( float, gUnproject ) + NRD_CONSTANT( float, gDebug ) NRD_CONSTANTS_END -NRD_INPUT_TEXTURE_START - NRD_INPUT_TEXTURE( Texture2D, gIn_Mv, t, 0 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_Normal_Roughness, t, 1 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_ViewZ, t, 2 ) - NRD_INPUT_TEXTURE( Texture2D, gIn_HitDist, t, 3 ) -NRD_INPUT_TEXTURE_END +NRD_SAMPLERS_START + NRD_SAMPLER( SamplerState, gNearestClamp, s, 0 ) + NRD_SAMPLER( SamplerState, gLinearClamp, s, 1 ) +NRD_SAMPLERS_END + +NRD_INPUTS_START + NRD_INPUT( Texture2D, gIn_Mv, t, 0 ) + NRD_INPUT( Texture2D, gIn_Normal_Roughness, t, 1 ) + NRD_INPUT( Texture2D, gIn_ViewZ, t, 2 ) + NRD_INPUT( Texture2D, gIn_HitDist, t, 3 ) +NRD_INPUTS_END + +NRD_OUTPUTS_START + NRD_OUTPUT( RWTexture2D, gOut_SpecularReflectionMv, u, 0 ) +NRD_OUTPUTS_END + +// Macro magic +#define SpecularReflectionMv_ComputeGroupX 16 +#define SpecularReflectionMv_ComputeGroupY 16 -NRD_OUTPUT_TEXTURE_START - NRD_OUTPUT_TEXTURE( RWTexture2D, gOut_SpecularReflectionMv, u, 0 ) -NRD_OUTPUT_TEXTURE_END +// Redirection +#undef GROUP_X +#undef GROUP_Y +#define GROUP_X SpecularReflectionMv_ComputeGroupX +#define GROUP_Y SpecularReflectionMv_ComputeGroupY diff --git a/Shaders/Source/Clear_f.cs.hlsl b/Shaders/Source/Clear_Float.cs.hlsl similarity index 94% rename from Shaders/Source/Clear_f.cs.hlsl rename to Shaders/Source/Clear_Float.cs.hlsl index 7c766c8..cf504e5 100644 --- a/Shaders/Source/Clear_f.cs.hlsl +++ b/Shaders/Source/Clear_Float.cs.hlsl @@ -11,7 +11,7 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "NRD.hlsli" #include "STL.hlsli" -#include "Clear_f.resources.hlsli" +#include "Clear_Float.resources.hlsli" #include "Common.hlsli" diff --git a/Shaders/Source/Clear_ui.cs.hlsl b/Shaders/Source/Clear_Uint.cs.hlsl similarity index 94% rename from Shaders/Source/Clear_ui.cs.hlsl rename to Shaders/Source/Clear_Uint.cs.hlsl index af6ddc4..92747d2 100644 --- a/Shaders/Source/Clear_ui.cs.hlsl +++ b/Shaders/Source/Clear_Uint.cs.hlsl @@ -11,7 +11,7 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "NRD.hlsli" #include "STL.hlsli" -#include "Clear_ui.resources.hlsli" +#include "Clear_Uint.resources.hlsli" #include "Common.hlsli" diff --git a/Shaders/Source/REBLUR_ClassifyTiles.cs.hlsl b/Shaders/Source/REBLUR_ClassifyTiles.cs.hlsl index 8634558..6bf381f 100644 --- a/Shaders/Source/REBLUR_ClassifyTiles.cs.hlsl +++ b/Shaders/Source/REBLUR_ClassifyTiles.cs.hlsl @@ -11,6 +11,7 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "NRD.hlsli" #include "STL.hlsli" +#include "REBLUR_Config.hlsli" #include "REBLUR_ClassifyTiles.resources.hlsli" groupshared uint s_isSky; diff --git a/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_Blur.cs.hlsl b/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_Blur.cs.hlsl index 9a251ab..cb721bc 100644 --- a/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_Blur.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_Blur.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_DIRECTIONAL_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_Blur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Blur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_Blur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_Blur.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_HistoryFix.cs.hlsl b/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_HistoryFix.cs.hlsl index d591157..c1564be 100644 --- a/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_HistoryFix.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_HistoryFix.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_DIRECTIONAL_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HistoryFix.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HistoryFix.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_PostBlur.cs.hlsl b/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_PostBlur.cs.hlsl index 613332d..38d994f 100644 --- a/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_PostBlur.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_PostBlur.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_DIRECTIONAL_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl index 6c7cf79..841d2f4 100644 --- a/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIRECTIONAL_OCCLUSION #define REBLUR_NO_TEMPORAL_STABILIZATION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_PrePass.cs.hlsl b/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_PrePass.cs.hlsl index 79e2c6a..0bbe6ac 100644 --- a/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_PrePass.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_PrePass.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_DIRECTIONAL_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PrePass.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PrePass.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PrePass.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PrePass.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_TemporalAccumulation.cs.hlsl b/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_TemporalAccumulation.cs.hlsl index 662a497..0eb3f6d 100644 --- a/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_TemporalAccumulation.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_DIRECTIONAL_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_TemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_TemporalStabilization.cs.hlsl index 5a600fd..81be0fa 100644 --- a/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_TemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseDirectionalOcclusion_TemporalStabilization.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_DIRECTIONAL_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalStabilization.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalStabilization.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalStabilization.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalStabilization.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseOcclusion_Blur.cs.hlsl b/Shaders/Source/REBLUR_DiffuseOcclusion_Blur.cs.hlsl index e12aca9..4e757dc 100644 --- a/Shaders/Source/REBLUR_DiffuseOcclusion_Blur.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseOcclusion_Blur.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_Blur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Blur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_Blur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_Blur.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseOcclusion_HistoryFix.cs.hlsl b/Shaders/Source/REBLUR_DiffuseOcclusion_HistoryFix.cs.hlsl index b1884ab..1a4e1d9 100644 --- a/Shaders/Source/REBLUR_DiffuseOcclusion_HistoryFix.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseOcclusion_HistoryFix.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HistoryFix.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HistoryFix.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseOcclusion_HitDistReconstruction.cs.hlsl b/Shaders/Source/REBLUR_DiffuseOcclusion_HitDistReconstruction.cs.hlsl index e9826a0..ad8d525 100644 --- a/Shaders/Source/REBLUR_DiffuseOcclusion_HitDistReconstruction.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseOcclusion_HitDistReconstruction.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseOcclusion_HitDistReconstruction_5x5.cs.hlsl b/Shaders/Source/REBLUR_DiffuseOcclusion_HitDistReconstruction_5x5.cs.hlsl index 45d9d65..2409d4e 100644 --- a/Shaders/Source/REBLUR_DiffuseOcclusion_HitDistReconstruction_5x5.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseOcclusion_HitDistReconstruction_5x5.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_OCCLUSION #define REBLUR_HITDIST_RECONSTRUCTION_5X5 -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_DiffuseOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl index 60ed870..df5d773 100644 --- a/Shaders/Source/REBLUR_DiffuseOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_OCCLUSION #define REBLUR_NO_TEMPORAL_STABILIZATION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseOcclusion_PrePass.cs.hlsl b/Shaders/Source/REBLUR_DiffuseOcclusion_PrePass.cs.hlsl index 637ca50..1272583 100644 --- a/Shaders/Source/REBLUR_DiffuseOcclusion_PrePass.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseOcclusion_PrePass.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PrePass.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PrePass.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PrePass.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PrePass.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseOcclusion_TemporalAccumulation.cs.hlsl b/Shaders/Source/REBLUR_DiffuseOcclusion_TemporalAccumulation.cs.hlsl index 76c0776..4020a39 100644 --- a/Shaders/Source/REBLUR_DiffuseOcclusion_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseOcclusion_TemporalAccumulation.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSh_Blur.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSh_Blur.cs.hlsl index cc32855..08c6d37 100644 --- a/Shaders/Source/REBLUR_DiffuseSh_Blur.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSh_Blur.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_Blur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Blur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_Blur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_Blur.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSh_CopyStabilizedHistory.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSh_Copy.cs.hlsl similarity index 74% rename from Shaders/Source/REBLUR_DiffuseSh_CopyStabilizedHistory.cs.hlsl rename to Shaders/Source/REBLUR_DiffuseSh_Copy.cs.hlsl index 2828fc8..500c464 100644 --- a/Shaders/Source/REBLUR_DiffuseSh_CopyStabilizedHistory.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSh_Copy.cs.hlsl @@ -14,8 +14,8 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_CopyStabilizedHistory.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Copy.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_CopyStabilizedHistory.hlsli" +#include "REBLUR_Copy.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSh_HistoryFix.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSh_HistoryFix.cs.hlsl index d73c2ea..88ffffb 100644 --- a/Shaders/Source/REBLUR_DiffuseSh_HistoryFix.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSh_HistoryFix.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HistoryFix.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HistoryFix.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSh_PostBlur.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSh_PostBlur.cs.hlsl index 718b56f..42996bc 100644 --- a/Shaders/Source/REBLUR_DiffuseSh_PostBlur.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSh_PostBlur.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSh_PostBlur_NoTemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSh_PostBlur_NoTemporalStabilization.cs.hlsl index e57bbee..7990b5b 100644 --- a/Shaders/Source/REBLUR_DiffuseSh_PostBlur_NoTemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSh_PostBlur_NoTemporalStabilization.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SH #define REBLUR_NO_TEMPORAL_STABILIZATION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSh_PrePass.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSh_PrePass.cs.hlsl index 5b22049..c642b8a 100644 --- a/Shaders/Source/REBLUR_DiffuseSh_PrePass.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSh_PrePass.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PrePass.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PrePass.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PrePass.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PrePass.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSh_SplitScreen.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSh_SplitScreen.cs.hlsl index 3823701..c11a9a0 100644 --- a/Shaders/Source/REBLUR_DiffuseSh_SplitScreen.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSh_SplitScreen.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_SplitScreen.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_SplitScreen.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_SplitScreen.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_SplitScreen.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSh_TemporalAccumulation.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSh_TemporalAccumulation.cs.hlsl index 4ff65a6..025edfb 100644 --- a/Shaders/Source/REBLUR_DiffuseSh_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSh_TemporalAccumulation.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSh_TemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSh_TemporalStabilization.cs.hlsl index eddec30..d530936 100644 --- a/Shaders/Source/REBLUR_DiffuseSh_TemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSh_TemporalStabilization.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalStabilization.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalStabilization.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalStabilization.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalStabilization.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_Blur.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_Blur.cs.hlsl index 5b48a2c..3f175d4 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_Blur.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_Blur.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_Blur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Blur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_Blur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_Blur.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_HistoryFix.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_HistoryFix.cs.hlsl index ab07968..259249e 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_HistoryFix.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_HistoryFix.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HistoryFix.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HistoryFix.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_HitDistReconstruction.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_HitDistReconstruction.cs.hlsl index 485fac0..3bf1e04 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_HitDistReconstruction.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_HitDistReconstruction.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_HitDistReconstruction_5x5.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_HitDistReconstruction_5x5.cs.hlsl index cc5d852..5bedecc 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_HitDistReconstruction_5x5.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_HitDistReconstruction_5x5.cs.hlsl @@ -16,9 +16,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_OCCLUSION #define REBLUR_HITDIST_RECONSTRUCTION_5X5 -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl index d49e98d..40f4d7a 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl @@ -16,9 +16,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_OCCLUSION #define REBLUR_NO_TEMPORAL_STABILIZATION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_PrePass.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_PrePass.cs.hlsl index b82e9a4..38dc769 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_PrePass.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_PrePass.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PrePass.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PrePass.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PrePass.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PrePass.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_TemporalAccumulation.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_TemporalAccumulation.cs.hlsl index 2571094..584a20d 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecularOcclusion_TemporalAccumulation.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecularSh_Blur.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecularSh_Blur.cs.hlsl index afd9667..fc95d0e 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecularSh_Blur.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecularSh_Blur.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_Blur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Blur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_Blur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_Blur.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecularSh_CopyStabilizedHistory.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecularSh_Copy.cs.hlsl similarity index 75% rename from Shaders/Source/REBLUR_DiffuseSpecularSh_CopyStabilizedHistory.cs.hlsl rename to Shaders/Source/REBLUR_DiffuseSpecularSh_Copy.cs.hlsl index 5ac814d..c1ef4de 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecularSh_CopyStabilizedHistory.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecularSh_Copy.cs.hlsl @@ -15,8 +15,8 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_CopyStabilizedHistory.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Copy.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_CopyStabilizedHistory.hlsli" +#include "REBLUR_Copy.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecularSh_HistoryFix.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecularSh_HistoryFix.cs.hlsl index 033022e..94f38d5 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecularSh_HistoryFix.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecularSh_HistoryFix.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HistoryFix.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HistoryFix.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecularSh_PostBlur.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecularSh_PostBlur.cs.hlsl index 50a6bc0..2dac4bc 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecularSh_PostBlur.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecularSh_PostBlur.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecularSh_PostBlur_NoTemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecularSh_PostBlur_NoTemporalStabilization.cs.hlsl index b68f231..630bb1a 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecularSh_PostBlur_NoTemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecularSh_PostBlur_NoTemporalStabilization.cs.hlsl @@ -16,9 +16,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SH #define REBLUR_NO_TEMPORAL_STABILIZATION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecularSh_PrePass.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecularSh_PrePass.cs.hlsl index 46fbd34..96e0ef0 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecularSh_PrePass.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecularSh_PrePass.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PrePass.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PrePass.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PrePass.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PrePass.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecularSh_SplitScreen.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecularSh_SplitScreen.cs.hlsl index 8a6c116..0ea8666 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecularSh_SplitScreen.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecularSh_SplitScreen.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_SplitScreen.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_SplitScreen.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_SplitScreen.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_SplitScreen.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecularSh_TemporalAccumulation.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecularSh_TemporalAccumulation.cs.hlsl index 82be2a3..5bfbdb9 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecularSh_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecularSh_TemporalAccumulation.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecularSh_TemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecularSh_TemporalStabilization.cs.hlsl index c51bf02..4a999e5 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecularSh_TemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecularSh_TemporalStabilization.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalStabilization.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalStabilization.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalStabilization.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalStabilization.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecular_Blur.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecular_Blur.cs.hlsl index 15a203f..4423579 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecular_Blur.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecular_Blur.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_Blur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Blur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_Blur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_Blur.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecular_CopyStabilizedHistory.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecular_Copy.cs.hlsl similarity index 74% rename from Shaders/Source/REBLUR_DiffuseSpecular_CopyStabilizedHistory.cs.hlsl rename to Shaders/Source/REBLUR_DiffuseSpecular_Copy.cs.hlsl index f273011..84b0c3f 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecular_CopyStabilizedHistory.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecular_Copy.cs.hlsl @@ -14,8 +14,8 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_CopyStabilizedHistory.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Copy.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_CopyStabilizedHistory.hlsli" +#include "REBLUR_Copy.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecular_HistoryFix.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecular_HistoryFix.cs.hlsl index 030481c..04c8e96 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecular_HistoryFix.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecular_HistoryFix.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HistoryFix.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HistoryFix.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecular_HitDistReconstruction.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecular_HitDistReconstruction.cs.hlsl index 737d7a9..67b150f 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecular_HitDistReconstruction.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecular_HitDistReconstruction.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecular_HitDistReconstruction_5x5.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecular_HitDistReconstruction_5x5.cs.hlsl index f7b4ae2..d7c1290 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecular_HitDistReconstruction_5x5.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecular_HitDistReconstruction_5x5.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_HITDIST_RECONSTRUCTION_5X5 -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecular_PostBlur.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecular_PostBlur.cs.hlsl index 7583321..a4f6f93 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecular_PostBlur.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecular_PostBlur.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecular_PostBlur_NoTemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecular_PostBlur_NoTemporalStabilization.cs.hlsl index 1b21ada..bc5efd8 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecular_PostBlur_NoTemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecular_PostBlur_NoTemporalStabilization.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_NO_TEMPORAL_STABILIZATION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecular_PrePass.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecular_PrePass.cs.hlsl index 5cacf67..bbae648 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecular_PrePass.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecular_PrePass.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PrePass.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PrePass.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PrePass.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PrePass.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecular_SplitScreen.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecular_SplitScreen.cs.hlsl index f896097..32c214a 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecular_SplitScreen.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecular_SplitScreen.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_SplitScreen.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_SplitScreen.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_SplitScreen.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_SplitScreen.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecular_TemporalAccumulation.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecular_TemporalAccumulation.cs.hlsl index 6b8a288..879e2da 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecular_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecular_TemporalAccumulation.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/REBLUR_DiffuseSpecular_TemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_DiffuseSpecular_TemporalStabilization.cs.hlsl index 9064ad5..53f7520 100644 --- a/Shaders/Source/REBLUR_DiffuseSpecular_TemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_DiffuseSpecular_TemporalStabilization.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalStabilization.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalStabilization.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalStabilization.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalStabilization.hlsli" diff --git a/Shaders/Source/REBLUR_Diffuse_Blur.cs.hlsl b/Shaders/Source/REBLUR_Diffuse_Blur.cs.hlsl index 776a75e..26b8938 100644 --- a/Shaders/Source/REBLUR_Diffuse_Blur.cs.hlsl +++ b/Shaders/Source/REBLUR_Diffuse_Blur.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_Blur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Blur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_Blur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_Blur.hlsli" diff --git a/Shaders/Source/REBLUR_Diffuse_CopyStabilizedHistory.cs.hlsl b/Shaders/Source/REBLUR_Diffuse_Copy.cs.hlsl similarity index 74% rename from Shaders/Source/REBLUR_Diffuse_CopyStabilizedHistory.cs.hlsl rename to Shaders/Source/REBLUR_Diffuse_Copy.cs.hlsl index 68bb9e9..2be44e5 100644 --- a/Shaders/Source/REBLUR_Diffuse_CopyStabilizedHistory.cs.hlsl +++ b/Shaders/Source/REBLUR_Diffuse_Copy.cs.hlsl @@ -13,8 +13,8 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_CopyStabilizedHistory.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Copy.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_CopyStabilizedHistory.hlsli" +#include "REBLUR_Copy.hlsli" diff --git a/Shaders/Source/REBLUR_Diffuse_HistoryFix.cs.hlsl b/Shaders/Source/REBLUR_Diffuse_HistoryFix.cs.hlsl index 360293e..e55c0db 100644 --- a/Shaders/Source/REBLUR_Diffuse_HistoryFix.cs.hlsl +++ b/Shaders/Source/REBLUR_Diffuse_HistoryFix.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HistoryFix.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HistoryFix.hlsli" diff --git a/Shaders/Source/REBLUR_Diffuse_HitDistReconstruction.cs.hlsl b/Shaders/Source/REBLUR_Diffuse_HitDistReconstruction.cs.hlsl index 0256157..0af42d3 100644 --- a/Shaders/Source/REBLUR_Diffuse_HitDistReconstruction.cs.hlsl +++ b/Shaders/Source/REBLUR_Diffuse_HitDistReconstruction.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/REBLUR_Diffuse_HitDistReconstruction_5x5.cs.hlsl b/Shaders/Source/REBLUR_Diffuse_HitDistReconstruction_5x5.cs.hlsl index 4125b59..57a1294 100644 --- a/Shaders/Source/REBLUR_Diffuse_HitDistReconstruction_5x5.cs.hlsl +++ b/Shaders/Source/REBLUR_Diffuse_HitDistReconstruction_5x5.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_HITDIST_RECONSTRUCTION_5X5 -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/REBLUR_Diffuse_PostBlur.cs.hlsl b/Shaders/Source/REBLUR_Diffuse_PostBlur.cs.hlsl index ea7469a..1e6ccb3 100644 --- a/Shaders/Source/REBLUR_Diffuse_PostBlur.cs.hlsl +++ b/Shaders/Source/REBLUR_Diffuse_PostBlur.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_Diffuse_PostBlur_NoTemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_Diffuse_PostBlur_NoTemporalStabilization.cs.hlsl index 490cc2e..9d3b95f 100644 --- a/Shaders/Source/REBLUR_Diffuse_PostBlur_NoTemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_Diffuse_PostBlur_NoTemporalStabilization.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_NO_TEMPORAL_STABILIZATION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_Diffuse_PrePass.cs.hlsl b/Shaders/Source/REBLUR_Diffuse_PrePass.cs.hlsl index 1fedf35..fdc6aaf 100644 --- a/Shaders/Source/REBLUR_Diffuse_PrePass.cs.hlsl +++ b/Shaders/Source/REBLUR_Diffuse_PrePass.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PrePass.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PrePass.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PrePass.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PrePass.hlsli" diff --git a/Shaders/Source/REBLUR_Diffuse_SplitScreen.cs.hlsl b/Shaders/Source/REBLUR_Diffuse_SplitScreen.cs.hlsl index 0789a17..65e067c 100644 --- a/Shaders/Source/REBLUR_Diffuse_SplitScreen.cs.hlsl +++ b/Shaders/Source/REBLUR_Diffuse_SplitScreen.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_SplitScreen.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_SplitScreen.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_SplitScreen.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_SplitScreen.hlsli" diff --git a/Shaders/Source/REBLUR_Diffuse_TemporalAccumulation.cs.hlsl b/Shaders/Source/REBLUR_Diffuse_TemporalAccumulation.cs.hlsl index e219f4c..98f4fa0 100644 --- a/Shaders/Source/REBLUR_Diffuse_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/REBLUR_Diffuse_TemporalAccumulation.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/REBLUR_Diffuse_TemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_Diffuse_TemporalStabilization.cs.hlsl index 6587fac..3023a3c 100644 --- a/Shaders/Source/REBLUR_Diffuse_TemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_Diffuse_TemporalStabilization.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalStabilization.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalStabilization.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalStabilization.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalStabilization.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_Blur.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_Blur.cs.hlsl index 49f2db8..7134ada 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_Blur.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_Blur.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_DIRECTIONAL_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_Blur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Blur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_Blur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_Blur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_HistoryFix.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_HistoryFix.cs.hlsl index c838eb6..1b205e5 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_HistoryFix.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_HistoryFix.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_DIRECTIONAL_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HistoryFix.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HistoryFix.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_PostBlur.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_PostBlur.cs.hlsl index 74290c2..86298ee 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_PostBlur.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_PostBlur.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_DIRECTIONAL_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl index 78e391a..b6fdaad 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl @@ -16,9 +16,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIRECTIONAL_OCCLUSION #define REBLUR_NO_TEMPORAL_STABILIZATION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_PrePass.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_PrePass.cs.hlsl index 366aa61..411784d 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_PrePass.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_PrePass.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_DIRECTIONAL_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PrePass.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PrePass.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PrePass.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PrePass.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_TemporalAccumulation.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_TemporalAccumulation.cs.hlsl index 1d0a6ac..5b08e8b 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_TemporalAccumulation.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_DIRECTIONAL_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_TemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_TemporalStabilization.cs.hlsl index 4c455a4..a8930fc 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_TemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseDirectionalOcclusion_TemporalStabilization.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_DIRECTIONAL_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalStabilization.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalStabilization.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalStabilization.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalStabilization.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_Blur.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_Blur.cs.hlsl index 704bab5..867d4ca 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_Blur.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_Blur.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_Blur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Blur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_Blur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_Blur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_HistoryFix.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_HistoryFix.cs.hlsl index cc8956b..6dd7189 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_HistoryFix.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_HistoryFix.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HistoryFix.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HistoryFix.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_HitDistReconstruction.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_HitDistReconstruction.cs.hlsl index 95a6ecb..7bffec9 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_HitDistReconstruction.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_HitDistReconstruction.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_HitDistReconstruction_5x5.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_HitDistReconstruction_5x5.cs.hlsl index 233cddd..a55b990 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_HitDistReconstruction_5x5.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_HitDistReconstruction_5x5.cs.hlsl @@ -16,9 +16,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_OCCLUSION #define REBLUR_HITDIST_RECONSTRUCTION_5X5 -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl index 03914b3..dafd38b 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl @@ -16,9 +16,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_OCCLUSION #define REBLUR_NO_TEMPORAL_STABILIZATION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_PrePass.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_PrePass.cs.hlsl index e159d66..76ded9f 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_PrePass.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_PrePass.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PrePass.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PrePass.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PrePass.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PrePass.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_TemporalAccumulation.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_TemporalAccumulation.cs.hlsl index d6a293b..c509bb5 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseOcclusion_TemporalAccumulation.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSh_Blur.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSh_Blur.cs.hlsl index d0d749e..e0cb57f 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSh_Blur.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSh_Blur.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_Blur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Blur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_Blur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_Blur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSh_HistoryFix.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSh_HistoryFix.cs.hlsl index ad5febc..d48add5 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSh_HistoryFix.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSh_HistoryFix.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HistoryFix.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HistoryFix.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSh_PostBlur.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSh_PostBlur.cs.hlsl index 8377734..806bf39 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSh_PostBlur.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSh_PostBlur.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSh_PostBlur_NoTemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSh_PostBlur_NoTemporalStabilization.cs.hlsl index d75c706..b2705c0 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSh_PostBlur_NoTemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSh_PostBlur_NoTemporalStabilization.cs.hlsl @@ -16,9 +16,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SH #define REBLUR_NO_TEMPORAL_STABILIZATION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSh_PrePass.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSh_PrePass.cs.hlsl index 9987926..84081f1 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSh_PrePass.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSh_PrePass.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PrePass.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PrePass.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PrePass.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PrePass.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSh_TemporalAccumulation.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSh_TemporalAccumulation.cs.hlsl index 89cfa37..a27edb4 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSh_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSh_TemporalAccumulation.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSh_TemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSh_TemporalStabilization.cs.hlsl index 064609d..d54453c 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSh_TemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSh_TemporalStabilization.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalStabilization.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalStabilization.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalStabilization.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalStabilization.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_Blur.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_Blur.cs.hlsl index 9416f8f..b3262ff 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_Blur.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_Blur.cs.hlsl @@ -16,9 +16,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_Blur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Blur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_Blur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_Blur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_HistoryFix.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_HistoryFix.cs.hlsl index 932f994..13d2adc 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_HistoryFix.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_HistoryFix.cs.hlsl @@ -16,9 +16,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HistoryFix.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HistoryFix.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_HitDistReconstruction.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_HitDistReconstruction.cs.hlsl index 01094d4..759b94e 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_HitDistReconstruction.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_HitDistReconstruction.cs.hlsl @@ -16,9 +16,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_HitDistReconstruction_5x5.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_HitDistReconstruction_5x5.cs.hlsl index c17b133..bcec1d1 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_HitDistReconstruction_5x5.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_HitDistReconstruction_5x5.cs.hlsl @@ -17,9 +17,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_OCCLUSION #define REBLUR_HITDIST_RECONSTRUCTION_5X5 -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl index b3b91a4..4cecfbb 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl @@ -17,9 +17,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_OCCLUSION #define REBLUR_NO_TEMPORAL_STABILIZATION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_PrePass.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_PrePass.cs.hlsl index 7370188..485b65f 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_PrePass.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_PrePass.cs.hlsl @@ -16,9 +16,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PrePass.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PrePass.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PrePass.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PrePass.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_TemporalAccumulation.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_TemporalAccumulation.cs.hlsl index 6b24446..de79f2a 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSpecularOcclusion_TemporalAccumulation.cs.hlsl @@ -16,9 +16,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_Blur.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_Blur.cs.hlsl index 3f22802..90739ae 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_Blur.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_Blur.cs.hlsl @@ -16,9 +16,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_Blur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Blur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_Blur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_Blur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_HistoryFix.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_HistoryFix.cs.hlsl index 8d6129c..76db0e1 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_HistoryFix.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_HistoryFix.cs.hlsl @@ -16,9 +16,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HistoryFix.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HistoryFix.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_PostBlur.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_PostBlur.cs.hlsl index b44538c..13e349c 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_PostBlur.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_PostBlur.cs.hlsl @@ -16,9 +16,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_PostBlur_NoTemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_PostBlur_NoTemporalStabilization.cs.hlsl index 077ec6e..28c43b2 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_PostBlur_NoTemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_PostBlur_NoTemporalStabilization.cs.hlsl @@ -17,9 +17,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SH #define REBLUR_NO_TEMPORAL_STABILIZATION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_PrePass.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_PrePass.cs.hlsl index 23dbe0b..8bc7371 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_PrePass.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_PrePass.cs.hlsl @@ -16,9 +16,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PrePass.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PrePass.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PrePass.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PrePass.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_TemporalAccumulation.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_TemporalAccumulation.cs.hlsl index 65ef5ef..6eecc33 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_TemporalAccumulation.cs.hlsl @@ -16,9 +16,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_TemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_TemporalStabilization.cs.hlsl index 431b9b4..2924f02 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_TemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSpecularSh_TemporalStabilization.cs.hlsl @@ -16,9 +16,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalStabilization.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalStabilization.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalStabilization.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalStabilization.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSpecular_Blur.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSpecular_Blur.cs.hlsl index d01786b..3b8d322 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSpecular_Blur.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSpecular_Blur.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_Blur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Blur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_Blur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_Blur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSpecular_HistoryFix.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSpecular_HistoryFix.cs.hlsl index fe62796..8a3842a 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSpecular_HistoryFix.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSpecular_HistoryFix.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HistoryFix.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HistoryFix.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSpecular_HitDistReconstruction.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSpecular_HitDistReconstruction.cs.hlsl index 155e345..e6b7c5b 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSpecular_HitDistReconstruction.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSpecular_HitDistReconstruction.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSpecular_HitDistReconstruction_5x5.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSpecular_HitDistReconstruction_5x5.cs.hlsl index d5b86dd..4c624b6 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSpecular_HitDistReconstruction_5x5.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSpecular_HitDistReconstruction_5x5.cs.hlsl @@ -16,9 +16,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_HITDIST_RECONSTRUCTION_5X5 -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSpecular_PostBlur.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSpecular_PostBlur.cs.hlsl index c80fd6c..e48c0dc 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSpecular_PostBlur.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSpecular_PostBlur.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSpecular_PostBlur_NoTemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSpecular_PostBlur_NoTemporalStabilization.cs.hlsl index 325a3ad..84139ce 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSpecular_PostBlur_NoTemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSpecular_PostBlur_NoTemporalStabilization.cs.hlsl @@ -16,9 +16,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_NO_TEMPORAL_STABILIZATION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSpecular_PrePass.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSpecular_PrePass.cs.hlsl index cef069a..903b7e7 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSpecular_PrePass.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSpecular_PrePass.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PrePass.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PrePass.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PrePass.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PrePass.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSpecular_TemporalAccumulation.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSpecular_TemporalAccumulation.cs.hlsl index 9ff2495..df68765 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSpecular_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSpecular_TemporalAccumulation.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_DiffuseSpecular_TemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_Perf_DiffuseSpecular_TemporalStabilization.cs.hlsl index 8c79ddb..e8f15fa 100644 --- a/Shaders/Source/REBLUR_Perf_DiffuseSpecular_TemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_DiffuseSpecular_TemporalStabilization.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalStabilization.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalStabilization.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalStabilization.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalStabilization.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_Diffuse_Blur.cs.hlsl b/Shaders/Source/REBLUR_Perf_Diffuse_Blur.cs.hlsl index 4f2d75a..02e4179 100644 --- a/Shaders/Source/REBLUR_Perf_Diffuse_Blur.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_Diffuse_Blur.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_PERFORMANCE_MODE #define REBLUR_DIFFUSE -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_Blur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Blur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_Blur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_Blur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_Diffuse_HistoryFix.cs.hlsl b/Shaders/Source/REBLUR_Perf_Diffuse_HistoryFix.cs.hlsl index 6cd5e4d..46ddc3d 100644 --- a/Shaders/Source/REBLUR_Perf_Diffuse_HistoryFix.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_Diffuse_HistoryFix.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_PERFORMANCE_MODE #define REBLUR_DIFFUSE -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HistoryFix.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HistoryFix.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_Diffuse_HitDistReconstruction.cs.hlsl b/Shaders/Source/REBLUR_Perf_Diffuse_HitDistReconstruction.cs.hlsl index ee3e1a8..978044d 100644 --- a/Shaders/Source/REBLUR_Perf_Diffuse_HitDistReconstruction.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_Diffuse_HitDistReconstruction.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_PERFORMANCE_MODE #define REBLUR_DIFFUSE -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_Diffuse_HitDistReconstruction_5x5.cs.hlsl b/Shaders/Source/REBLUR_Perf_Diffuse_HitDistReconstruction_5x5.cs.hlsl index e09ffc9..532ca0b 100644 --- a/Shaders/Source/REBLUR_Perf_Diffuse_HitDistReconstruction_5x5.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_Diffuse_HitDistReconstruction_5x5.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_HITDIST_RECONSTRUCTION_5X5 -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_Diffuse_PostBlur.cs.hlsl b/Shaders/Source/REBLUR_Perf_Diffuse_PostBlur.cs.hlsl index 7f305c0..022ca31 100644 --- a/Shaders/Source/REBLUR_Perf_Diffuse_PostBlur.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_Diffuse_PostBlur.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_PERFORMANCE_MODE #define REBLUR_DIFFUSE -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_Diffuse_PostBlur_NoTemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_Perf_Diffuse_PostBlur_NoTemporalStabilization.cs.hlsl index b9c1c90..23ebb0c 100644 --- a/Shaders/Source/REBLUR_Perf_Diffuse_PostBlur_NoTemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_Diffuse_PostBlur_NoTemporalStabilization.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_DIFFUSE #define REBLUR_NO_TEMPORAL_STABILIZATION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_Diffuse_PrePass.cs.hlsl b/Shaders/Source/REBLUR_Perf_Diffuse_PrePass.cs.hlsl index c1f6db8..e8681a0 100644 --- a/Shaders/Source/REBLUR_Perf_Diffuse_PrePass.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_Diffuse_PrePass.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_PERFORMANCE_MODE #define REBLUR_DIFFUSE -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PrePass.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PrePass.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PrePass.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PrePass.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_Diffuse_TemporalAccumulation.cs.hlsl b/Shaders/Source/REBLUR_Perf_Diffuse_TemporalAccumulation.cs.hlsl index 43b1348..b9f973e 100644 --- a/Shaders/Source/REBLUR_Perf_Diffuse_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_Diffuse_TemporalAccumulation.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_PERFORMANCE_MODE #define REBLUR_DIFFUSE -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_Diffuse_TemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_Perf_Diffuse_TemporalStabilization.cs.hlsl index bd8f1fa..2b6e513 100644 --- a/Shaders/Source/REBLUR_Perf_Diffuse_TemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_Diffuse_TemporalStabilization.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_PERFORMANCE_MODE #define REBLUR_DIFFUSE -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalStabilization.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalStabilization.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalStabilization.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalStabilization.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_SpecularOcclusion_Blur.cs.hlsl b/Shaders/Source/REBLUR_Perf_SpecularOcclusion_Blur.cs.hlsl index e1d459b..e2885d5 100644 --- a/Shaders/Source/REBLUR_Perf_SpecularOcclusion_Blur.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_SpecularOcclusion_Blur.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_Blur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Blur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_Blur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_Blur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_SpecularOcclusion_HistoryFix.cs.hlsl b/Shaders/Source/REBLUR_Perf_SpecularOcclusion_HistoryFix.cs.hlsl index cfb7f6f..db43041 100644 --- a/Shaders/Source/REBLUR_Perf_SpecularOcclusion_HistoryFix.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_SpecularOcclusion_HistoryFix.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HistoryFix.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HistoryFix.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_SpecularOcclusion_HitDistReconstruction.cs.hlsl b/Shaders/Source/REBLUR_Perf_SpecularOcclusion_HitDistReconstruction.cs.hlsl index 3624e21..ffb3fbd 100644 --- a/Shaders/Source/REBLUR_Perf_SpecularOcclusion_HitDistReconstruction.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_SpecularOcclusion_HitDistReconstruction.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_SpecularOcclusion_HitDistReconstruction_5x5.cs.hlsl b/Shaders/Source/REBLUR_Perf_SpecularOcclusion_HitDistReconstruction_5x5.cs.hlsl index 7163735..8c6f540 100644 --- a/Shaders/Source/REBLUR_Perf_SpecularOcclusion_HitDistReconstruction_5x5.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_SpecularOcclusion_HitDistReconstruction_5x5.cs.hlsl @@ -16,9 +16,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_OCCLUSION #define REBLUR_HITDIST_RECONSTRUCTION_5X5 -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_SpecularOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_Perf_SpecularOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl index fb3440e..d5dd397 100644 --- a/Shaders/Source/REBLUR_Perf_SpecularOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_SpecularOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl @@ -16,9 +16,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_OCCLUSION #define REBLUR_NO_TEMPORAL_STABILIZATION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_SpecularOcclusion_PrePass.cs.hlsl b/Shaders/Source/REBLUR_Perf_SpecularOcclusion_PrePass.cs.hlsl index 84c9c27..80c2577 100644 --- a/Shaders/Source/REBLUR_Perf_SpecularOcclusion_PrePass.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_SpecularOcclusion_PrePass.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PrePass.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PrePass.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PrePass.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PrePass.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_SpecularOcclusion_TemporalAccumulation.cs.hlsl b/Shaders/Source/REBLUR_Perf_SpecularOcclusion_TemporalAccumulation.cs.hlsl index 23756b3..b370ed9 100644 --- a/Shaders/Source/REBLUR_Perf_SpecularOcclusion_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_SpecularOcclusion_TemporalAccumulation.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_SpecularSh_Blur.cs.hlsl b/Shaders/Source/REBLUR_Perf_SpecularSh_Blur.cs.hlsl index 4e9f2d0..b5d04e6 100644 --- a/Shaders/Source/REBLUR_Perf_SpecularSh_Blur.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_SpecularSh_Blur.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_Blur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Blur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_Blur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_Blur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_SpecularSh_HistoryFix.cs.hlsl b/Shaders/Source/REBLUR_Perf_SpecularSh_HistoryFix.cs.hlsl index 999900c..c27dd6a 100644 --- a/Shaders/Source/REBLUR_Perf_SpecularSh_HistoryFix.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_SpecularSh_HistoryFix.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HistoryFix.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HistoryFix.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_SpecularSh_PostBlur.cs.hlsl b/Shaders/Source/REBLUR_Perf_SpecularSh_PostBlur.cs.hlsl index 5ddde9f..54d06a1 100644 --- a/Shaders/Source/REBLUR_Perf_SpecularSh_PostBlur.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_SpecularSh_PostBlur.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_SpecularSh_PostBlur_NoTemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_Perf_SpecularSh_PostBlur_NoTemporalStabilization.cs.hlsl index 9fe5794..ae3dabc 100644 --- a/Shaders/Source/REBLUR_Perf_SpecularSh_PostBlur_NoTemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_SpecularSh_PostBlur_NoTemporalStabilization.cs.hlsl @@ -16,9 +16,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SH #define REBLUR_NO_TEMPORAL_STABILIZATION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_SpecularSh_PrePass.cs.hlsl b/Shaders/Source/REBLUR_Perf_SpecularSh_PrePass.cs.hlsl index d89b7d2..00bdb9c 100644 --- a/Shaders/Source/REBLUR_Perf_SpecularSh_PrePass.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_SpecularSh_PrePass.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PrePass.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PrePass.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PrePass.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PrePass.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_SpecularSh_TemporalAccumulation.cs.hlsl b/Shaders/Source/REBLUR_Perf_SpecularSh_TemporalAccumulation.cs.hlsl index 03dd63a..fdb55b2 100644 --- a/Shaders/Source/REBLUR_Perf_SpecularSh_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_SpecularSh_TemporalAccumulation.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_SpecularSh_TemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_Perf_SpecularSh_TemporalStabilization.cs.hlsl index 9c88f32..d5b6bae 100644 --- a/Shaders/Source/REBLUR_Perf_SpecularSh_TemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_SpecularSh_TemporalStabilization.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalStabilization.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalStabilization.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalStabilization.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalStabilization.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_Specular_Blur.cs.hlsl b/Shaders/Source/REBLUR_Perf_Specular_Blur.cs.hlsl index 68c3683..6a8d545 100644 --- a/Shaders/Source/REBLUR_Perf_Specular_Blur.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_Specular_Blur.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_PERFORMANCE_MODE #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_Blur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Blur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_Blur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_Blur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_Specular_HistoryFix.cs.hlsl b/Shaders/Source/REBLUR_Perf_Specular_HistoryFix.cs.hlsl index 9c6bae6..88a5f75 100644 --- a/Shaders/Source/REBLUR_Perf_Specular_HistoryFix.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_Specular_HistoryFix.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_PERFORMANCE_MODE #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HistoryFix.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HistoryFix.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_Specular_HitDistReconstruction.cs.hlsl b/Shaders/Source/REBLUR_Perf_Specular_HitDistReconstruction.cs.hlsl index 7060aca..8aaf76b 100644 --- a/Shaders/Source/REBLUR_Perf_Specular_HitDistReconstruction.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_Specular_HitDistReconstruction.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_PERFORMANCE_MODE #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_Specular_HitDistReconstruction_5x5.cs.hlsl b/Shaders/Source/REBLUR_Perf_Specular_HitDistReconstruction_5x5.cs.hlsl index ac8cd3f..07556bf 100644 --- a/Shaders/Source/REBLUR_Perf_Specular_HitDistReconstruction_5x5.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_Specular_HitDistReconstruction_5x5.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_HITDIST_RECONSTRUCTION_5X5 -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_Specular_PostBlur.cs.hlsl b/Shaders/Source/REBLUR_Perf_Specular_PostBlur.cs.hlsl index 79a6cfe..b7ee9a5 100644 --- a/Shaders/Source/REBLUR_Perf_Specular_PostBlur.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_Specular_PostBlur.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_PERFORMANCE_MODE #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_Specular_PostBlur_NoTemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_Perf_Specular_PostBlur_NoTemporalStabilization.cs.hlsl index 5820e03..e74b95b 100644 --- a/Shaders/Source/REBLUR_Perf_Specular_PostBlur_NoTemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_Specular_PostBlur_NoTemporalStabilization.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_NO_TEMPORAL_STABILIZATION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_Specular_PrePass.cs.hlsl b/Shaders/Source/REBLUR_Perf_Specular_PrePass.cs.hlsl index 0ca42d6..fc1db9a 100644 --- a/Shaders/Source/REBLUR_Perf_Specular_PrePass.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_Specular_PrePass.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_PERFORMANCE_MODE #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PrePass.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PrePass.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PrePass.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PrePass.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_Specular_TemporalAccumulation.cs.hlsl b/Shaders/Source/REBLUR_Perf_Specular_TemporalAccumulation.cs.hlsl index f5af8f3..3811acb 100644 --- a/Shaders/Source/REBLUR_Perf_Specular_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_Specular_TemporalAccumulation.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_PERFORMANCE_MODE #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/REBLUR_Perf_Specular_TemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_Perf_Specular_TemporalStabilization.cs.hlsl index f546dae..e0297da 100644 --- a/Shaders/Source/REBLUR_Perf_Specular_TemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_Perf_Specular_TemporalStabilization.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_PERFORMANCE_MODE #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalStabilization.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalStabilization.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalStabilization.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalStabilization.hlsli" diff --git a/Shaders/Source/REBLUR_SpecularOcclusion_Blur.cs.hlsl b/Shaders/Source/REBLUR_SpecularOcclusion_Blur.cs.hlsl index 33854b5..510606f 100644 --- a/Shaders/Source/REBLUR_SpecularOcclusion_Blur.cs.hlsl +++ b/Shaders/Source/REBLUR_SpecularOcclusion_Blur.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_Blur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Blur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_Blur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_Blur.hlsli" diff --git a/Shaders/Source/REBLUR_SpecularOcclusion_HistoryFix.cs.hlsl b/Shaders/Source/REBLUR_SpecularOcclusion_HistoryFix.cs.hlsl index e2899f7..e5e983b 100644 --- a/Shaders/Source/REBLUR_SpecularOcclusion_HistoryFix.cs.hlsl +++ b/Shaders/Source/REBLUR_SpecularOcclusion_HistoryFix.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HistoryFix.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HistoryFix.hlsli" diff --git a/Shaders/Source/REBLUR_SpecularOcclusion_HitDistReconstruction.cs.hlsl b/Shaders/Source/REBLUR_SpecularOcclusion_HitDistReconstruction.cs.hlsl index 03aad44..f8af8d2 100644 --- a/Shaders/Source/REBLUR_SpecularOcclusion_HitDistReconstruction.cs.hlsl +++ b/Shaders/Source/REBLUR_SpecularOcclusion_HitDistReconstruction.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/REBLUR_SpecularOcclusion_HitDistReconstruction_5x5.cs.hlsl b/Shaders/Source/REBLUR_SpecularOcclusion_HitDistReconstruction_5x5.cs.hlsl index 5543acc..2f78a2b 100644 --- a/Shaders/Source/REBLUR_SpecularOcclusion_HitDistReconstruction_5x5.cs.hlsl +++ b/Shaders/Source/REBLUR_SpecularOcclusion_HitDistReconstruction_5x5.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_OCCLUSION #define REBLUR_HITDIST_RECONSTRUCTION_5X5 -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/REBLUR_SpecularOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_SpecularOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl index 2856121..ade6361 100644 --- a/Shaders/Source/REBLUR_SpecularOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_SpecularOcclusion_PostBlur_NoTemporalStabilization.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_OCCLUSION #define REBLUR_NO_TEMPORAL_STABILIZATION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_SpecularOcclusion_PrePass.cs.hlsl b/Shaders/Source/REBLUR_SpecularOcclusion_PrePass.cs.hlsl index 614c1fe..1f70da6 100644 --- a/Shaders/Source/REBLUR_SpecularOcclusion_PrePass.cs.hlsl +++ b/Shaders/Source/REBLUR_SpecularOcclusion_PrePass.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PrePass.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PrePass.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PrePass.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PrePass.hlsli" diff --git a/Shaders/Source/REBLUR_SpecularOcclusion_TemporalAccumulation.cs.hlsl b/Shaders/Source/REBLUR_SpecularOcclusion_TemporalAccumulation.cs.hlsl index 6bd6e03..ba1e844 100644 --- a/Shaders/Source/REBLUR_SpecularOcclusion_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/REBLUR_SpecularOcclusion_TemporalAccumulation.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_OCCLUSION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/REBLUR_SpecularSh_Blur.cs.hlsl b/Shaders/Source/REBLUR_SpecularSh_Blur.cs.hlsl index 5420134..5331408 100644 --- a/Shaders/Source/REBLUR_SpecularSh_Blur.cs.hlsl +++ b/Shaders/Source/REBLUR_SpecularSh_Blur.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_Blur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Blur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_Blur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_Blur.hlsli" diff --git a/Shaders/Source/REBLUR_SpecularSh_CopyStabilizedHistory.cs.hlsl b/Shaders/Source/REBLUR_SpecularSh_Copy.cs.hlsl similarity index 74% rename from Shaders/Source/REBLUR_SpecularSh_CopyStabilizedHistory.cs.hlsl rename to Shaders/Source/REBLUR_SpecularSh_Copy.cs.hlsl index 1fb278a..84c2e65 100644 --- a/Shaders/Source/REBLUR_SpecularSh_CopyStabilizedHistory.cs.hlsl +++ b/Shaders/Source/REBLUR_SpecularSh_Copy.cs.hlsl @@ -14,8 +14,8 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_CopyStabilizedHistory.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Copy.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_CopyStabilizedHistory.hlsli" +#include "REBLUR_Copy.hlsli" diff --git a/Shaders/Source/REBLUR_SpecularSh_HistoryFix.cs.hlsl b/Shaders/Source/REBLUR_SpecularSh_HistoryFix.cs.hlsl index 823db95..3099a83 100644 --- a/Shaders/Source/REBLUR_SpecularSh_HistoryFix.cs.hlsl +++ b/Shaders/Source/REBLUR_SpecularSh_HistoryFix.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HistoryFix.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HistoryFix.hlsli" diff --git a/Shaders/Source/REBLUR_SpecularSh_PostBlur.cs.hlsl b/Shaders/Source/REBLUR_SpecularSh_PostBlur.cs.hlsl index 799fbcb..c1314e1 100644 --- a/Shaders/Source/REBLUR_SpecularSh_PostBlur.cs.hlsl +++ b/Shaders/Source/REBLUR_SpecularSh_PostBlur.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_SpecularSh_PostBlur_NoTemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_SpecularSh_PostBlur_NoTemporalStabilization.cs.hlsl index 9795909..bfdf0d5 100644 --- a/Shaders/Source/REBLUR_SpecularSh_PostBlur_NoTemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_SpecularSh_PostBlur_NoTemporalStabilization.cs.hlsl @@ -15,9 +15,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SH #define REBLUR_NO_TEMPORAL_STABILIZATION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_SpecularSh_PrePass.cs.hlsl b/Shaders/Source/REBLUR_SpecularSh_PrePass.cs.hlsl index 680aa53..aadb051 100644 --- a/Shaders/Source/REBLUR_SpecularSh_PrePass.cs.hlsl +++ b/Shaders/Source/REBLUR_SpecularSh_PrePass.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PrePass.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PrePass.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PrePass.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PrePass.hlsli" diff --git a/Shaders/Source/REBLUR_SpecularSh_SplitScreen.cs.hlsl b/Shaders/Source/REBLUR_SpecularSh_SplitScreen.cs.hlsl index e1be454..9991fa7 100644 --- a/Shaders/Source/REBLUR_SpecularSh_SplitScreen.cs.hlsl +++ b/Shaders/Source/REBLUR_SpecularSh_SplitScreen.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_SplitScreen.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_SplitScreen.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_SplitScreen.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_SplitScreen.hlsli" diff --git a/Shaders/Source/REBLUR_SpecularSh_TemporalAccumulation.cs.hlsl b/Shaders/Source/REBLUR_SpecularSh_TemporalAccumulation.cs.hlsl index d41ba17..9c9c7ba 100644 --- a/Shaders/Source/REBLUR_SpecularSh_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/REBLUR_SpecularSh_TemporalAccumulation.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/REBLUR_SpecularSh_TemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_SpecularSh_TemporalStabilization.cs.hlsl index e36743a..f997c30 100644 --- a/Shaders/Source/REBLUR_SpecularSh_TemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_SpecularSh_TemporalStabilization.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_SH -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalStabilization.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalStabilization.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalStabilization.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalStabilization.hlsli" diff --git a/Shaders/Source/REBLUR_Specular_Blur.cs.hlsl b/Shaders/Source/REBLUR_Specular_Blur.cs.hlsl index 501ca48..1a219a3 100644 --- a/Shaders/Source/REBLUR_Specular_Blur.cs.hlsl +++ b/Shaders/Source/REBLUR_Specular_Blur.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_Blur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Blur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_Blur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_Blur.hlsli" diff --git a/Shaders/Source/REBLUR_Specular_CopyStabilizedHistory.cs.hlsl b/Shaders/Source/REBLUR_Specular_Copy.cs.hlsl similarity index 74% rename from Shaders/Source/REBLUR_Specular_CopyStabilizedHistory.cs.hlsl rename to Shaders/Source/REBLUR_Specular_Copy.cs.hlsl index 77233c0..feeb311 100644 --- a/Shaders/Source/REBLUR_Specular_CopyStabilizedHistory.cs.hlsl +++ b/Shaders/Source/REBLUR_Specular_Copy.cs.hlsl @@ -13,8 +13,8 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_CopyStabilizedHistory.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_Copy.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_CopyStabilizedHistory.hlsli" +#include "REBLUR_Copy.hlsli" diff --git a/Shaders/Source/REBLUR_Specular_HistoryFix.cs.hlsl b/Shaders/Source/REBLUR_Specular_HistoryFix.cs.hlsl index c1732fd..ca5e65b 100644 --- a/Shaders/Source/REBLUR_Specular_HistoryFix.cs.hlsl +++ b/Shaders/Source/REBLUR_Specular_HistoryFix.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HistoryFix.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HistoryFix.hlsli" diff --git a/Shaders/Source/REBLUR_Specular_HitDistReconstruction.cs.hlsl b/Shaders/Source/REBLUR_Specular_HitDistReconstruction.cs.hlsl index b13faf9..7af2aef 100644 --- a/Shaders/Source/REBLUR_Specular_HitDistReconstruction.cs.hlsl +++ b/Shaders/Source/REBLUR_Specular_HitDistReconstruction.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/REBLUR_Specular_HitDistReconstruction_5x5.cs.hlsl b/Shaders/Source/REBLUR_Specular_HitDistReconstruction_5x5.cs.hlsl index 646e5f0..3a3c0a2 100644 --- a/Shaders/Source/REBLUR_Specular_HitDistReconstruction_5x5.cs.hlsl +++ b/Shaders/Source/REBLUR_Specular_HitDistReconstruction_5x5.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_HITDIST_RECONSTRUCTION_5X5 -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/REBLUR_Specular_PostBlur.cs.hlsl b/Shaders/Source/REBLUR_Specular_PostBlur.cs.hlsl index b575bcc..405ccb2 100644 --- a/Shaders/Source/REBLUR_Specular_PostBlur.cs.hlsl +++ b/Shaders/Source/REBLUR_Specular_PostBlur.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_Specular_PostBlur_NoTemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_Specular_PostBlur_NoTemporalStabilization.cs.hlsl index 0117b69..b16e1b3 100644 --- a/Shaders/Source/REBLUR_Specular_PostBlur_NoTemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_Specular_PostBlur_NoTemporalStabilization.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR #define REBLUR_NO_TEMPORAL_STABILIZATION -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PostBlur.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PostBlur.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PostBlur.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PostBlur.hlsli" diff --git a/Shaders/Source/REBLUR_Specular_PrePass.cs.hlsl b/Shaders/Source/REBLUR_Specular_PrePass.cs.hlsl index e9855c9..5e38642 100644 --- a/Shaders/Source/REBLUR_Specular_PrePass.cs.hlsl +++ b/Shaders/Source/REBLUR_Specular_PrePass.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_PrePass.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_PrePass.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_PrePass.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_PrePass.hlsli" diff --git a/Shaders/Source/REBLUR_Specular_SplitScreen.cs.hlsl b/Shaders/Source/REBLUR_Specular_SplitScreen.cs.hlsl index 0a7c463..ecfb511 100644 --- a/Shaders/Source/REBLUR_Specular_SplitScreen.cs.hlsl +++ b/Shaders/Source/REBLUR_Specular_SplitScreen.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_SplitScreen.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_SplitScreen.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_SplitScreen.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_SplitScreen.hlsli" diff --git a/Shaders/Source/REBLUR_Specular_TemporalAccumulation.cs.hlsl b/Shaders/Source/REBLUR_Specular_TemporalAccumulation.cs.hlsl index 0f84611..4e91764 100644 --- a/Shaders/Source/REBLUR_Specular_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/REBLUR_Specular_TemporalAccumulation.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/REBLUR_Specular_TemporalStabilization.cs.hlsl b/Shaders/Source/REBLUR_Specular_TemporalStabilization.cs.hlsl index d92347c..8e0e689 100644 --- a/Shaders/Source/REBLUR_Specular_TemporalStabilization.cs.hlsl +++ b/Shaders/Source/REBLUR_Specular_TemporalStabilization.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define REBLUR_SPECULAR -#include "REBLUR/REBLUR_Config.hlsli" -#include "REBLUR_DiffuseSpecular_TemporalStabilization.resources.hlsli" +#include "REBLUR_Config.hlsli" +#include "REBLUR_TemporalStabilization.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" -#include "REBLUR/REBLUR_DiffuseSpecular_TemporalStabilization.hlsli" +#include "REBLUR_Common.hlsli" +#include "REBLUR_TemporalStabilization.hlsli" diff --git a/Shaders/Source/REBLUR_Validation.cs.hlsl b/Shaders/Source/REBLUR_Validation.cs.hlsl index f6ff439..8f35ddf 100644 --- a/Shaders/Source/REBLUR_Validation.cs.hlsl +++ b/Shaders/Source/REBLUR_Validation.cs.hlsl @@ -11,11 +11,11 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "NRD.hlsli" #include "STL.hlsli" -#include "REBLUR/REBLUR_Config.hlsli" +#include "REBLUR_Config.hlsli" #include "REBLUR_Validation.resources.hlsli" #include "Common.hlsli" -#include "REBLUR/REBLUR_Common.hlsli" +#include "REBLUR_Common.hlsli" #define VIEWPORT_SIZE 0.25 #define OFFSET 5 @@ -37,7 +37,7 @@ NRD_EXPORT void NRD_CS_MAIN( uint2 pixelPos : SV_DispatchThreadId ) return; } - float2 pixelUv = float2( pixelPos + 0.5 ) * gInvScreenSize; + float2 pixelUv = float2( pixelPos + 0.5 ) / gResourceSize; float2 viewportUv = frac( pixelUv / VIEWPORT_SIZE ); float2 viewportId = floor( pixelUv / VIEWPORT_SIZE ); @@ -47,7 +47,7 @@ NRD_EXPORT void NRD_CS_MAIN( uint2 pixelPos : SV_DispatchThreadId ) float4 normalAndRoughness = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness.SampleLevel( gNearestClamp, viewportUvScaled, 0 ) ); float viewZ = gIn_ViewZ.SampleLevel( gNearestClamp, viewportUvScaled, 0 ); - float3 mv = gIn_Mv.SampleLevel( gNearestClamp, viewportUvScaled, 0 ) * gMvScale; + float3 mv = gIn_Mv.SampleLevel( gNearestClamp, viewportUvScaled, 0 ) * gMvScale.xyz; float4 diff = gIn_Diff.SampleLevel( gNearestClamp, viewportUvScaled * float2( gDiffCheckerboard != 2 ? 0.5 : 1.0, 1.0 ), 0 ); float4 spec = gIn_Spec.SampleLevel( gNearestClamp, viewportUvScaled * float2( gSpecCheckerboard != 2 ? 0.5 : 1.0, 1.0 ), 0 ); @@ -58,7 +58,7 @@ NRD_EXPORT void NRD_CS_MAIN( uint2 pixelPos : SV_DispatchThreadId ) data1.xz *= REBLUR_MAX_ACCUM_FRAME_NUM; uint bits; - float2 data2 = UnpackData2( gIn_Data2[ uint2( viewportUvScaled * gScreenSize ) ], bits ); + float2 data2 = UnpackData2( gIn_Data2[ uint2( viewportUvScaled * gResourceSize ) ], bits ); float3 N = normalAndRoughness.xyz; float roughness = normalAndRoughness.w; @@ -69,7 +69,7 @@ NRD_EXPORT void NRD_CS_MAIN( uint2 pixelPos : SV_DispatchThreadId ) bool isInf = abs( viewZ ) > gDenoisingRange; bool checkerboard = STL::Sequence::CheckerBoard( pixelPos >> 2, 0 ); - uint4 textState = STL::Text::Init( pixelPos, viewportId * gScreenSize * VIEWPORT_SIZE + OFFSET, 1 ); + uint4 textState = STL::Text::Init( pixelPos, viewportId * gResourceSize * VIEWPORT_SIZE + OFFSET, 1 ); float4 result = gOut_Validation[ pixelPos ]; @@ -125,12 +125,12 @@ NRD_EXPORT void NRD_CS_MAIN( uint2 pixelPos : SV_DispatchThreadId ) float2 viewportUvPrevExpected = STL::Geometry::GetScreenUv( gWorldToClipPrev, X ); float2 viewportUvPrev = viewportUv + mv.xy; - if( gIsWorldSpaceMotionEnabled ) + if( gMvScale.w != 0.0 ) viewportUvPrev = STL::Geometry::GetScreenUv( gWorldToClipPrev, X + mv ); float2 uvDelta = ( viewportUvPrev - viewportUvPrevExpected ) * gRectSize; - result.xyz = IsInScreen( viewportUvPrev ) ? float3( abs( uvDelta ), 0 ) : float3( 0, 0, 1 ); + result.xyz = IsInScreenNearest( viewportUvPrev ) ? float3( abs( uvDelta ), 0 ) : float3( 0, 0, 1 ); result.w = 1.0; } // World units @@ -151,12 +151,12 @@ NRD_EXPORT void NRD_CS_MAIN( uint2 pixelPos : SV_DispatchThreadId ) STL::Text::Print_ch( 'E', textState ); STL::Text::Print_ch( 'R', textState ); - float2 dim = float2( 0.5 * gScreenSize.y * gInvScreenSize.x, 0.5 ); + float2 dim = float2( 0.5 * gResourceSize.y / gResourceSize.x, 0.5 ); float2 remappedUv = ( viewportUv - ( 1.0 - dim ) ) / dim; if( all( remappedUv > 0.0 ) ) { - float2 dimInPixels = gScreenSize * VIEWPORT_SIZE * dim; + float2 dimInPixels = gResourceSize * VIEWPORT_SIZE * dim; float2 uv = gJitter + 0.5; bool isValid = all( saturate( uv ) == uv ); int2 a = int2( saturate( uv ) * dimInPixels ); diff --git a/Shaders/Source/REFERENCE_TemporalAccumulation.cs.hlsl b/Shaders/Source/REFERENCE_TemporalAccumulation.cs.hlsl index 9628d82..13ec801 100644 --- a/Shaders/Source/REFERENCE_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/REFERENCE_TemporalAccumulation.cs.hlsl @@ -18,9 +18,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. [numthreads( GROUP_X, GROUP_Y, 1 )] NRD_EXPORT void NRD_CS_MAIN( uint2 pixelPos : SV_DispatchThreadId ) { - float2 pixelUv = float2( pixelPos + 0.5 ) * gInvRectSize; + float2 pixelUv = float2( pixelPos + 0.5 ) * gRectSizeInv; - float4 input = gIn_Input[ gRectOrigin + pixelPos ]; + float4 input = gIn_Input[ pixelPos ]; float4 history = gInOut_History[ pixelPos ]; float4 result = lerp( history, input, gAccumSpeed ); diff --git a/Shaders/Source/RELAX_ClassifyTiles.cs.hlsl b/Shaders/Source/RELAX_ClassifyTiles.cs.hlsl index 5b26498..6a8ef25 100644 --- a/Shaders/Source/RELAX_ClassifyTiles.cs.hlsl +++ b/Shaders/Source/RELAX_ClassifyTiles.cs.hlsl @@ -11,6 +11,7 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "NRD.hlsli" #include "STL.hlsli" +#include "RELAX_Config.hlsli" #include "RELAX_ClassifyTiles.resources.hlsli" groupshared uint s_isSky; diff --git a/Shaders/Source/RELAX_DiffuseSh_AntiFirefly.cs.hlsl b/Shaders/Source/RELAX_DiffuseSh_AntiFirefly.cs.hlsl index 3d5a34f..1f8e7d0 100644 --- a/Shaders/Source/RELAX_DiffuseSh_AntiFirefly.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSh_AntiFirefly.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_DIFFUSE #define RELAX_SH -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_AntiFirefly.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_AntiFirefly.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_AntiFirefly.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_AntiFirefly.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSh_Atrous.cs.hlsl b/Shaders/Source/RELAX_DiffuseSh_Atrous.cs.hlsl index 7eb43b4..c715618 100644 --- a/Shaders/Source/RELAX_DiffuseSh_Atrous.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSh_Atrous.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_DIFFUSE #define RELAX_SH -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_Atrous.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_Atrous.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_Atrous.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_Atrous.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSh_AtrousSmem.cs.hlsl b/Shaders/Source/RELAX_DiffuseSh_AtrousSmem.cs.hlsl index c09b971..a2c73c2 100644 --- a/Shaders/Source/RELAX_DiffuseSh_AtrousSmem.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSh_AtrousSmem.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_DIFFUSE #define RELAX_SH -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_AtrousSmem.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_AtrousSmem.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_AtrousSmem.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_AtrousSmem.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSh_Copy.cs.hlsl b/Shaders/Source/RELAX_DiffuseSh_Copy.cs.hlsl index 1d5c8d9..a0d664e 100644 --- a/Shaders/Source/RELAX_DiffuseSh_Copy.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSh_Copy.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_DIFFUSE -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_Copy.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_Copy.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_Copy.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_Copy.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSh_HistoryClamping.cs.hlsl b/Shaders/Source/RELAX_DiffuseSh_HistoryClamping.cs.hlsl index c0ee4bb..562076f 100644 --- a/Shaders/Source/RELAX_DiffuseSh_HistoryClamping.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSh_HistoryClamping.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_DIFFUSE #define RELAX_SH -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_HistoryClamping.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_HistoryClamping.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_HistoryClamping.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_HistoryClamping.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSh_HistoryFix.cs.hlsl b/Shaders/Source/RELAX_DiffuseSh_HistoryFix.cs.hlsl index 0b52f96..30d015c 100644 --- a/Shaders/Source/RELAX_DiffuseSh_HistoryFix.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSh_HistoryFix.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_DIFFUSE #define RELAX_SH -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_HistoryFix.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_HistoryFix.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSh_HitDistReconstruction.cs.hlsl b/Shaders/Source/RELAX_DiffuseSh_HitDistReconstruction.cs.hlsl index 1dc8881..7499c25 100644 --- a/Shaders/Source/RELAX_DiffuseSh_HitDistReconstruction.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSh_HitDistReconstruction.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_DIFFUSE -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSh_PrePass.cs.hlsl b/Shaders/Source/RELAX_DiffuseSh_PrePass.cs.hlsl index cffa4ec..8ff2bf3 100644 --- a/Shaders/Source/RELAX_DiffuseSh_PrePass.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSh_PrePass.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_DIFFUSE #define RELAX_SH -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_PrePass.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_PrePass.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_PrePass.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_PrePass.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSh_SplitScreen.cs.hlsl b/Shaders/Source/RELAX_DiffuseSh_SplitScreen.cs.hlsl index 9ae3020..09ad9e9 100644 --- a/Shaders/Source/RELAX_DiffuseSh_SplitScreen.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSh_SplitScreen.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_DIFFUSE -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_SplitScreen.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_SplitScreen.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_SplitScreen.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_SplitScreen.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSh_TemporalAccumulation.cs.hlsl b/Shaders/Source/RELAX_DiffuseSh_TemporalAccumulation.cs.hlsl index 2d84bf5..d42d661 100644 --- a/Shaders/Source/RELAX_DiffuseSh_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSh_TemporalAccumulation.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_DIFFUSE #define RELAX_SH -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSpecularSh_AntiFirefly.cs.hlsl b/Shaders/Source/RELAX_DiffuseSpecularSh_AntiFirefly.cs.hlsl index fa06b66..ab5fc0f 100644 --- a/Shaders/Source/RELAX_DiffuseSpecularSh_AntiFirefly.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSpecularSh_AntiFirefly.cs.hlsl @@ -11,9 +11,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "NRD.hlsli" #include "STL.hlsli" -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_AntiFirefly.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_AntiFirefly.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_AntiFirefly.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_AntiFirefly.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSpecularSh_Atrous.cs.hlsl b/Shaders/Source/RELAX_DiffuseSpecularSh_Atrous.cs.hlsl index 96037e2..50d60e7 100644 --- a/Shaders/Source/RELAX_DiffuseSpecularSh_Atrous.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSpecularSh_Atrous.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SH -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_Atrous.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_Atrous.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_Atrous.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_Atrous.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSpecularSh_AtrousSmem.cs.hlsl b/Shaders/Source/RELAX_DiffuseSpecularSh_AtrousSmem.cs.hlsl index c918aa4..f3281c3 100644 --- a/Shaders/Source/RELAX_DiffuseSpecularSh_AtrousSmem.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSpecularSh_AtrousSmem.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SH -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_AtrousSmem.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_AtrousSmem.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_AtrousSmem.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_AtrousSmem.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSpecularSh_Copy.cs.hlsl b/Shaders/Source/RELAX_DiffuseSpecularSh_Copy.cs.hlsl index f01f8e8..e675f60 100644 --- a/Shaders/Source/RELAX_DiffuseSpecularSh_Copy.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSpecularSh_Copy.cs.hlsl @@ -11,9 +11,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "NRD.hlsli" #include "STL.hlsli" -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_Copy.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_Copy.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_Copy.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_Copy.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSpecularSh_HistoryClamping.cs.hlsl b/Shaders/Source/RELAX_DiffuseSpecularSh_HistoryClamping.cs.hlsl index 2be3427..41ccd5f 100644 --- a/Shaders/Source/RELAX_DiffuseSpecularSh_HistoryClamping.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSpecularSh_HistoryClamping.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SH -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_HistoryClamping.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_HistoryClamping.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_HistoryClamping.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_HistoryClamping.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSpecularSh_HistoryFix.cs.hlsl b/Shaders/Source/RELAX_DiffuseSpecularSh_HistoryFix.cs.hlsl index 35635b4..cbff6e7 100644 --- a/Shaders/Source/RELAX_DiffuseSpecularSh_HistoryFix.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSpecularSh_HistoryFix.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SH -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_HistoryFix.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_HistoryFix.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSpecularSh_PrePass.cs.hlsl b/Shaders/Source/RELAX_DiffuseSpecularSh_PrePass.cs.hlsl index 0699048..60d28b1 100644 --- a/Shaders/Source/RELAX_DiffuseSpecularSh_PrePass.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSpecularSh_PrePass.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SH -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_PrePass.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_PrePass.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_PrePass.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_PrePass.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSpecularSh_SplitScreen.cs.hlsl b/Shaders/Source/RELAX_DiffuseSpecularSh_SplitScreen.cs.hlsl index 2fe628b..d9a41c6 100644 --- a/Shaders/Source/RELAX_DiffuseSpecularSh_SplitScreen.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSpecularSh_SplitScreen.cs.hlsl @@ -11,9 +11,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "NRD.hlsli" #include "STL.hlsli" -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_SplitScreen.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_SplitScreen.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_SplitScreen.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_SplitScreen.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSpecularSh_TemporalAccumulation.cs.hlsl b/Shaders/Source/RELAX_DiffuseSpecularSh_TemporalAccumulation.cs.hlsl index 9fb47b9..7a02aa5 100644 --- a/Shaders/Source/RELAX_DiffuseSpecularSh_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSpecularSh_TemporalAccumulation.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SH -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSpecular_AntiFirefly.cs.hlsl b/Shaders/Source/RELAX_DiffuseSpecular_AntiFirefly.cs.hlsl index fa06b66..ab5fc0f 100644 --- a/Shaders/Source/RELAX_DiffuseSpecular_AntiFirefly.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSpecular_AntiFirefly.cs.hlsl @@ -11,9 +11,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "NRD.hlsli" #include "STL.hlsli" -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_AntiFirefly.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_AntiFirefly.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_AntiFirefly.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_AntiFirefly.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSpecular_Atrous.cs.hlsl b/Shaders/Source/RELAX_DiffuseSpecular_Atrous.cs.hlsl index 906f04c..5312bd4 100644 --- a/Shaders/Source/RELAX_DiffuseSpecular_Atrous.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSpecular_Atrous.cs.hlsl @@ -11,9 +11,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "NRD.hlsli" #include "STL.hlsli" -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_Atrous.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_Atrous.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_Atrous.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_Atrous.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSpecular_AtrousSmem.cs.hlsl b/Shaders/Source/RELAX_DiffuseSpecular_AtrousSmem.cs.hlsl index 09bca68..a614e7f 100644 --- a/Shaders/Source/RELAX_DiffuseSpecular_AtrousSmem.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSpecular_AtrousSmem.cs.hlsl @@ -11,9 +11,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "NRD.hlsli" #include "STL.hlsli" -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_AtrousSmem.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_AtrousSmem.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_AtrousSmem.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_AtrousSmem.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSpecular_Copy.cs.hlsl b/Shaders/Source/RELAX_DiffuseSpecular_Copy.cs.hlsl index f01f8e8..e675f60 100644 --- a/Shaders/Source/RELAX_DiffuseSpecular_Copy.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSpecular_Copy.cs.hlsl @@ -11,9 +11,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "NRD.hlsli" #include "STL.hlsli" -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_Copy.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_Copy.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_Copy.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_Copy.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSpecular_HistoryClamping.cs.hlsl b/Shaders/Source/RELAX_DiffuseSpecular_HistoryClamping.cs.hlsl index 4bbaa4f..a9d40e0 100644 --- a/Shaders/Source/RELAX_DiffuseSpecular_HistoryClamping.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSpecular_HistoryClamping.cs.hlsl @@ -11,9 +11,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "NRD.hlsli" #include "STL.hlsli" -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_HistoryClamping.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_HistoryClamping.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_HistoryClamping.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_HistoryClamping.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSpecular_HistoryFix.cs.hlsl b/Shaders/Source/RELAX_DiffuseSpecular_HistoryFix.cs.hlsl index 7c75478..f6a9183 100644 --- a/Shaders/Source/RELAX_DiffuseSpecular_HistoryFix.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSpecular_HistoryFix.cs.hlsl @@ -11,9 +11,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "NRD.hlsli" #include "STL.hlsli" -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_HistoryFix.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_HistoryFix.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSpecular_HitDistReconstruction.cs.hlsl b/Shaders/Source/RELAX_DiffuseSpecular_HitDistReconstruction.cs.hlsl index 025d536..bb70117 100644 --- a/Shaders/Source/RELAX_DiffuseSpecular_HitDistReconstruction.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSpecular_HitDistReconstruction.cs.hlsl @@ -11,9 +11,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "NRD.hlsli" #include "STL.hlsli" -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSpecular_HitDistReconstruction_5x5.cs.hlsl b/Shaders/Source/RELAX_DiffuseSpecular_HitDistReconstruction_5x5.cs.hlsl index 6732c1b..8a18c99 100644 --- a/Shaders/Source/RELAX_DiffuseSpecular_HitDistReconstruction_5x5.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSpecular_HitDistReconstruction_5x5.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_HITDIST_RECONSTRUCTION_5X5 -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSpecular_PrePass.cs.hlsl b/Shaders/Source/RELAX_DiffuseSpecular_PrePass.cs.hlsl index ac40b30..76abefc 100644 --- a/Shaders/Source/RELAX_DiffuseSpecular_PrePass.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSpecular_PrePass.cs.hlsl @@ -11,9 +11,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "NRD.hlsli" #include "STL.hlsli" -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_PrePass.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_PrePass.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_PrePass.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_PrePass.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSpecular_SplitScreen.cs.hlsl b/Shaders/Source/RELAX_DiffuseSpecular_SplitScreen.cs.hlsl index 2fe628b..d9a41c6 100644 --- a/Shaders/Source/RELAX_DiffuseSpecular_SplitScreen.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSpecular_SplitScreen.cs.hlsl @@ -11,9 +11,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "NRD.hlsli" #include "STL.hlsli" -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_SplitScreen.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_SplitScreen.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_SplitScreen.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_SplitScreen.hlsli" diff --git a/Shaders/Source/RELAX_DiffuseSpecular_TemporalAccumulation.cs.hlsl b/Shaders/Source/RELAX_DiffuseSpecular_TemporalAccumulation.cs.hlsl index abf998c..256a2d8 100644 --- a/Shaders/Source/RELAX_DiffuseSpecular_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/RELAX_DiffuseSpecular_TemporalAccumulation.cs.hlsl @@ -11,9 +11,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "NRD.hlsli" #include "STL.hlsli" -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/RELAX_Diffuse_AntiFirefly.cs.hlsl b/Shaders/Source/RELAX_Diffuse_AntiFirefly.cs.hlsl index 61dd3cd..3c88918 100644 --- a/Shaders/Source/RELAX_Diffuse_AntiFirefly.cs.hlsl +++ b/Shaders/Source/RELAX_Diffuse_AntiFirefly.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_DIFFUSE -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_AntiFirefly.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_AntiFirefly.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_AntiFirefly.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_AntiFirefly.hlsli" diff --git a/Shaders/Source/RELAX_Diffuse_Atrous.cs.hlsl b/Shaders/Source/RELAX_Diffuse_Atrous.cs.hlsl index 0f94657..6bf4773 100644 --- a/Shaders/Source/RELAX_Diffuse_Atrous.cs.hlsl +++ b/Shaders/Source/RELAX_Diffuse_Atrous.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_DIFFUSE -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_Atrous.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_Atrous.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_Atrous.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_Atrous.hlsli" diff --git a/Shaders/Source/RELAX_Diffuse_AtrousSmem.cs.hlsl b/Shaders/Source/RELAX_Diffuse_AtrousSmem.cs.hlsl index 209a125..3219c2a 100644 --- a/Shaders/Source/RELAX_Diffuse_AtrousSmem.cs.hlsl +++ b/Shaders/Source/RELAX_Diffuse_AtrousSmem.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_DIFFUSE -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_AtrousSmem.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_AtrousSmem.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_AtrousSmem.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_AtrousSmem.hlsli" diff --git a/Shaders/Source/RELAX_Diffuse_Copy.cs.hlsl b/Shaders/Source/RELAX_Diffuse_Copy.cs.hlsl index 1d5c8d9..a0d664e 100644 --- a/Shaders/Source/RELAX_Diffuse_Copy.cs.hlsl +++ b/Shaders/Source/RELAX_Diffuse_Copy.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_DIFFUSE -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_Copy.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_Copy.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_Copy.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_Copy.hlsli" diff --git a/Shaders/Source/RELAX_Diffuse_HistoryClamping.cs.hlsl b/Shaders/Source/RELAX_Diffuse_HistoryClamping.cs.hlsl index 9e16ba8..87111f1 100644 --- a/Shaders/Source/RELAX_Diffuse_HistoryClamping.cs.hlsl +++ b/Shaders/Source/RELAX_Diffuse_HistoryClamping.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_DIFFUSE -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_HistoryClamping.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_HistoryClamping.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_HistoryClamping.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_HistoryClamping.hlsli" diff --git a/Shaders/Source/RELAX_Diffuse_HistoryFix.cs.hlsl b/Shaders/Source/RELAX_Diffuse_HistoryFix.cs.hlsl index 48819f1..085cc06 100644 --- a/Shaders/Source/RELAX_Diffuse_HistoryFix.cs.hlsl +++ b/Shaders/Source/RELAX_Diffuse_HistoryFix.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_DIFFUSE -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_HistoryFix.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_HistoryFix.hlsli" diff --git a/Shaders/Source/RELAX_Diffuse_HitDistReconstruction.cs.hlsl b/Shaders/Source/RELAX_Diffuse_HitDistReconstruction.cs.hlsl index 1dc8881..7499c25 100644 --- a/Shaders/Source/RELAX_Diffuse_HitDistReconstruction.cs.hlsl +++ b/Shaders/Source/RELAX_Diffuse_HitDistReconstruction.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_DIFFUSE -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/RELAX_Diffuse_HitDistReconstruction_5x5.cs.hlsl b/Shaders/Source/RELAX_Diffuse_HitDistReconstruction_5x5.cs.hlsl index ebc228b..0356179 100644 --- a/Shaders/Source/RELAX_Diffuse_HitDistReconstruction_5x5.cs.hlsl +++ b/Shaders/Source/RELAX_Diffuse_HitDistReconstruction_5x5.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_DIFFUSE #define RELAX_HITDIST_RECONSTRUCTION_5X5 -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/RELAX_Diffuse_PrePass.cs.hlsl b/Shaders/Source/RELAX_Diffuse_PrePass.cs.hlsl index 42aa9c5..b8a4bf5 100644 --- a/Shaders/Source/RELAX_Diffuse_PrePass.cs.hlsl +++ b/Shaders/Source/RELAX_Diffuse_PrePass.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_DIFFUSE -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_PrePass.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_PrePass.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_PrePass.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_PrePass.hlsli" diff --git a/Shaders/Source/RELAX_Diffuse_SplitScreen.cs.hlsl b/Shaders/Source/RELAX_Diffuse_SplitScreen.cs.hlsl index 9ae3020..09ad9e9 100644 --- a/Shaders/Source/RELAX_Diffuse_SplitScreen.cs.hlsl +++ b/Shaders/Source/RELAX_Diffuse_SplitScreen.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_DIFFUSE -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_SplitScreen.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_SplitScreen.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_SplitScreen.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_SplitScreen.hlsli" diff --git a/Shaders/Source/RELAX_Diffuse_TemporalAccumulation.cs.hlsl b/Shaders/Source/RELAX_Diffuse_TemporalAccumulation.cs.hlsl index e4a3088..04fb311 100644 --- a/Shaders/Source/RELAX_Diffuse_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/RELAX_Diffuse_TemporalAccumulation.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_DIFFUSE -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/RELAX_SpecularSh_AntiFirefly.cs.hlsl b/Shaders/Source/RELAX_SpecularSh_AntiFirefly.cs.hlsl index 36bfe54..73115e2 100644 --- a/Shaders/Source/RELAX_SpecularSh_AntiFirefly.cs.hlsl +++ b/Shaders/Source/RELAX_SpecularSh_AntiFirefly.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SPECULAR #define RELAX_SH -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_AntiFirefly.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_AntiFirefly.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_AntiFirefly.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_AntiFirefly.hlsli" diff --git a/Shaders/Source/RELAX_SpecularSh_Atrous.cs.hlsl b/Shaders/Source/RELAX_SpecularSh_Atrous.cs.hlsl index 3f9c306..62dbd75 100644 --- a/Shaders/Source/RELAX_SpecularSh_Atrous.cs.hlsl +++ b/Shaders/Source/RELAX_SpecularSh_Atrous.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SPECULAR #define RELAX_SH -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_Atrous.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_Atrous.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_Atrous.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_Atrous.hlsli" diff --git a/Shaders/Source/RELAX_SpecularSh_AtrousSmem.cs.hlsl b/Shaders/Source/RELAX_SpecularSh_AtrousSmem.cs.hlsl index 20550d1..6d75e05 100644 --- a/Shaders/Source/RELAX_SpecularSh_AtrousSmem.cs.hlsl +++ b/Shaders/Source/RELAX_SpecularSh_AtrousSmem.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SPECULAR #define RELAX_SH -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_AtrousSmem.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_AtrousSmem.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_AtrousSmem.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_AtrousSmem.hlsli" diff --git a/Shaders/Source/RELAX_SpecularSh_Copy.cs.hlsl b/Shaders/Source/RELAX_SpecularSh_Copy.cs.hlsl index a0c8f09..eb9370e 100644 --- a/Shaders/Source/RELAX_SpecularSh_Copy.cs.hlsl +++ b/Shaders/Source/RELAX_SpecularSh_Copy.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SPECULAR -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_Copy.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_Copy.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_Copy.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_Copy.hlsli" diff --git a/Shaders/Source/RELAX_SpecularSh_HistoryClamping.cs.hlsl b/Shaders/Source/RELAX_SpecularSh_HistoryClamping.cs.hlsl index 587b5b0..c932c9e 100644 --- a/Shaders/Source/RELAX_SpecularSh_HistoryClamping.cs.hlsl +++ b/Shaders/Source/RELAX_SpecularSh_HistoryClamping.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SPECULAR #define RELAX_SH -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_HistoryClamping.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_HistoryClamping.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_HistoryClamping.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_HistoryClamping.hlsli" diff --git a/Shaders/Source/RELAX_SpecularSh_HistoryFix.cs.hlsl b/Shaders/Source/RELAX_SpecularSh_HistoryFix.cs.hlsl index 7c0945d..e714037 100644 --- a/Shaders/Source/RELAX_SpecularSh_HistoryFix.cs.hlsl +++ b/Shaders/Source/RELAX_SpecularSh_HistoryFix.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SPECULAR #define RELAX_SH -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_HistoryFix.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_HistoryFix.hlsli" diff --git a/Shaders/Source/RELAX_SpecularSh_PrePass.cs.hlsl b/Shaders/Source/RELAX_SpecularSh_PrePass.cs.hlsl index a756f15..d4a57af 100644 --- a/Shaders/Source/RELAX_SpecularSh_PrePass.cs.hlsl +++ b/Shaders/Source/RELAX_SpecularSh_PrePass.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SPECULAR #define RELAX_SH -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_PrePass.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_PrePass.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_PrePass.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_PrePass.hlsli" diff --git a/Shaders/Source/RELAX_SpecularSh_SplitScreen.cs.hlsl b/Shaders/Source/RELAX_SpecularSh_SplitScreen.cs.hlsl index dbac178..91d1962 100644 --- a/Shaders/Source/RELAX_SpecularSh_SplitScreen.cs.hlsl +++ b/Shaders/Source/RELAX_SpecularSh_SplitScreen.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SPECULAR -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_SplitScreen.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_SplitScreen.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_SplitScreen.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_SplitScreen.hlsli" diff --git a/Shaders/Source/RELAX_SpecularSh_TemporalAccumulation.cs.hlsl b/Shaders/Source/RELAX_SpecularSh_TemporalAccumulation.cs.hlsl index 209664b..fc2c083 100644 --- a/Shaders/Source/RELAX_SpecularSh_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/RELAX_SpecularSh_TemporalAccumulation.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SPECULAR #define RELAX_SH -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/RELAX_Specular_AntiFirefly.cs.hlsl b/Shaders/Source/RELAX_Specular_AntiFirefly.cs.hlsl index 361ca60..768b40d 100644 --- a/Shaders/Source/RELAX_Specular_AntiFirefly.cs.hlsl +++ b/Shaders/Source/RELAX_Specular_AntiFirefly.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SPECULAR -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_AntiFirefly.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_AntiFirefly.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_AntiFirefly.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_AntiFirefly.hlsli" diff --git a/Shaders/Source/RELAX_Specular_Atrous.cs.hlsl b/Shaders/Source/RELAX_Specular_Atrous.cs.hlsl index 1eaa0a8..4833e49 100644 --- a/Shaders/Source/RELAX_Specular_Atrous.cs.hlsl +++ b/Shaders/Source/RELAX_Specular_Atrous.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SPECULAR -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_Atrous.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_Atrous.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_Atrous.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_Atrous.hlsli" diff --git a/Shaders/Source/RELAX_Specular_AtrousSmem.cs.hlsl b/Shaders/Source/RELAX_Specular_AtrousSmem.cs.hlsl index 01a6763..4546cea 100644 --- a/Shaders/Source/RELAX_Specular_AtrousSmem.cs.hlsl +++ b/Shaders/Source/RELAX_Specular_AtrousSmem.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SPECULAR -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_AtrousSmem.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_AtrousSmem.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_AtrousSmem.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_AtrousSmem.hlsli" diff --git a/Shaders/Source/RELAX_Specular_Copy.cs.hlsl b/Shaders/Source/RELAX_Specular_Copy.cs.hlsl index a0c8f09..eb9370e 100644 --- a/Shaders/Source/RELAX_Specular_Copy.cs.hlsl +++ b/Shaders/Source/RELAX_Specular_Copy.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SPECULAR -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_Copy.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_Copy.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_Copy.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_Copy.hlsli" diff --git a/Shaders/Source/RELAX_Specular_HistoryClamping.cs.hlsl b/Shaders/Source/RELAX_Specular_HistoryClamping.cs.hlsl index ecfa68c..9e1b1a2 100644 --- a/Shaders/Source/RELAX_Specular_HistoryClamping.cs.hlsl +++ b/Shaders/Source/RELAX_Specular_HistoryClamping.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SPECULAR -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_HistoryClamping.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_HistoryClamping.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_HistoryClamping.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_HistoryClamping.hlsli" diff --git a/Shaders/Source/RELAX_Specular_HistoryFix.cs.hlsl b/Shaders/Source/RELAX_Specular_HistoryFix.cs.hlsl index d8b111c..5777ba1 100644 --- a/Shaders/Source/RELAX_Specular_HistoryFix.cs.hlsl +++ b/Shaders/Source/RELAX_Specular_HistoryFix.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SPECULAR -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_HistoryFix.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_HistoryFix.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_HistoryFix.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_HistoryFix.hlsli" diff --git a/Shaders/Source/RELAX_Specular_HitDistReconstruction.cs.hlsl b/Shaders/Source/RELAX_Specular_HitDistReconstruction.cs.hlsl index 588cce1..ee5a735 100644 --- a/Shaders/Source/RELAX_Specular_HitDistReconstruction.cs.hlsl +++ b/Shaders/Source/RELAX_Specular_HitDistReconstruction.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SPECULAR -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/RELAX_Specular_HitDistReconstruction_5x5.cs.hlsl b/Shaders/Source/RELAX_Specular_HitDistReconstruction_5x5.cs.hlsl index 539b87b..22c01d4 100644 --- a/Shaders/Source/RELAX_Specular_HitDistReconstruction_5x5.cs.hlsl +++ b/Shaders/Source/RELAX_Specular_HitDistReconstruction_5x5.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SPECULAR #define RELAX_HITDIST_RECONSTRUCTION_5X5 -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_HitDistReconstruction.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_HitDistReconstruction.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_HitDistReconstruction.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_HitDistReconstruction.hlsli" diff --git a/Shaders/Source/RELAX_Specular_PrePass.cs.hlsl b/Shaders/Source/RELAX_Specular_PrePass.cs.hlsl index adf6a40..cc6aa29 100644 --- a/Shaders/Source/RELAX_Specular_PrePass.cs.hlsl +++ b/Shaders/Source/RELAX_Specular_PrePass.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SPECULAR -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_PrePass.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_PrePass.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_PrePass.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_PrePass.hlsli" diff --git a/Shaders/Source/RELAX_Specular_SplitScreen.cs.hlsl b/Shaders/Source/RELAX_Specular_SplitScreen.cs.hlsl index dbac178..91d1962 100644 --- a/Shaders/Source/RELAX_Specular_SplitScreen.cs.hlsl +++ b/Shaders/Source/RELAX_Specular_SplitScreen.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SPECULAR -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_SplitScreen.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_SplitScreen.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_SplitScreen.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_SplitScreen.hlsli" diff --git a/Shaders/Source/RELAX_Specular_TemporalAccumulation.cs.hlsl b/Shaders/Source/RELAX_Specular_TemporalAccumulation.cs.hlsl index 2dcd2b1..5edefb6 100644 --- a/Shaders/Source/RELAX_Specular_TemporalAccumulation.cs.hlsl +++ b/Shaders/Source/RELAX_Specular_TemporalAccumulation.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define RELAX_SPECULAR -#include "RELAX/RELAX_Config.hlsli" -#include "RELAX_DiffuseSpecular_TemporalAccumulation.resources.hlsli" +#include "RELAX_Config.hlsli" +#include "RELAX_TemporalAccumulation.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" -#include "RELAX/RELAX_DiffuseSpecular_TemporalAccumulation.hlsli" +#include "RELAX_Common.hlsli" +#include "RELAX_TemporalAccumulation.hlsli" diff --git a/Shaders/Source/RELAX_Validation.cs.hlsl b/Shaders/Source/RELAX_Validation.cs.hlsl index 16ba3eb..f012e59 100644 --- a/Shaders/Source/RELAX_Validation.cs.hlsl +++ b/Shaders/Source/RELAX_Validation.cs.hlsl @@ -11,11 +11,11 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "NRD.hlsli" #include "STL.hlsli" -#include "RELAX/RELAX_Config.hlsli" +#include "RELAX_Config.hlsli" #include "RELAX_Validation.resources.hlsli" #include "Common.hlsli" -#include "RELAX/RELAX_Common.hlsli" +#include "RELAX_Common.hlsli" #define VIEWPORT_SIZE 0.25 #define OFFSET 5 @@ -37,8 +37,7 @@ NRD_EXPORT void NRD_CS_MAIN( uint2 pixelPos : SV_DispatchThreadId ) return; } - float2 pixelUv = float2( pixelPos + 0.5 ) * gInvResourceSize; - float2 gResourceSize = 1.0 / gInvResourceSize; + float2 pixelUv = float2( pixelPos + 0.5 ) / gResourceSize; float2 viewportUv = frac( pixelUv / VIEWPORT_SIZE ); float2 viewportId = floor( pixelUv / VIEWPORT_SIZE ); @@ -49,7 +48,7 @@ NRD_EXPORT void NRD_CS_MAIN( uint2 pixelPos : SV_DispatchThreadId ) float historyLength = 255.0 * gIn_HistoryLength.SampleLevel( gNearestClamp, viewportUvScaled, 0 ) - 1.0; float4 normalAndRoughness = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness.SampleLevel( gNearestClamp, viewportUvScaled, 0 ) ); float viewZ = gIn_ViewZ.SampleLevel( gNearestClamp, viewportUvScaled, 0 ); - float3 mv = gIn_Mv.SampleLevel( gNearestClamp, viewportUvScaled, 0 ) * gMvScale; + float3 mv = gIn_Mv.SampleLevel( gNearestClamp, viewportUvScaled, 0 ) * gMvScale.xyz; float3 N = normalAndRoughness.xyz; float roughness = normalAndRoughness.w; @@ -115,12 +114,12 @@ NRD_EXPORT void NRD_CS_MAIN( uint2 pixelPos : SV_DispatchThreadId ) float2 viewportUvPrevExpected = STL::Geometry::GetScreenUv( gWorldToClipPrev, X ); float2 viewportUvPrev = viewportUv + mv.xy; - if( gIsWorldSpaceMotionEnabled ) + if( gMvScale.w != 0.0 ) viewportUvPrev = STL::Geometry::GetScreenUv( gWorldToClipPrev, X + mv ); float2 uvDelta = ( viewportUvPrev - viewportUvPrevExpected ) * gRectSize; - result.xyz = IsInScreen( viewportUvPrev ) ? float3( abs( uvDelta ), 0 ) : float3( 0, 0, 1 ); + result.xyz = IsInScreenNearest( viewportUvPrev ) ? float3( abs( uvDelta ), 0 ) : float3( 0, 0, 1 ); result.w = 1.0; } // World units @@ -141,7 +140,7 @@ NRD_EXPORT void NRD_CS_MAIN( uint2 pixelPos : SV_DispatchThreadId ) STL::Text::Print_ch( 'E', textState ); STL::Text::Print_ch( 'R', textState ); - float2 dim = float2( 0.5 * gResourceSize.y * gInvResourceSize.x, 0.5 ); + float2 dim = float2( 0.5 * gResourceSize.y / gResourceSize.x, 0.5 ); float2 remappedUv = ( viewportUv - ( 1.0 - dim ) ) / dim; if( all( remappedUv > 0.0 ) ) @@ -187,7 +186,7 @@ NRD_EXPORT void NRD_CS_MAIN( uint2 pixelPos : SV_DispatchThreadId ) STL::Text::Print_ch( 'E', textState ); STL::Text::Print_ch( 'S', textState ); - float f = 1.0 - saturate( historyLength / max( gMaxAccumulatedFrameNum, 1.0 ) ); + float f = 1.0 - saturate( historyLength / max( max( gDiffMaxAccumulatedFrameNum, gSpecMaxAccumulatedFrameNum ), 1.0 ) ); f = checkerboard && historyLength < 2.0 ? 0.75 : f; result.xyz = STL::Color::ColorizeZucconi( viewportUv.y > 0.95 ? 1.0 - viewportUv.x : f * float( !isInf ) ); diff --git a/Shaders/Source/SIGMA_ShadowTranslucency_Blur.cs.hlsl b/Shaders/Source/SIGMA_ShadowTranslucency_Blur.cs.hlsl index 9358e39..c96c83e 100644 --- a/Shaders/Source/SIGMA_ShadowTranslucency_Blur.cs.hlsl +++ b/Shaders/Source/SIGMA_ShadowTranslucency_Blur.cs.hlsl @@ -14,9 +14,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define SIGMA_TRANSLUCENT #define SIGMA_FIRST_PASS -#include "SIGMA/SIGMA_Config.hlsli" -#include "SIGMA_Shadow_Blur.resources.hlsli" +#include "SIGMA_Config.hlsli" +#include "SIGMA_Blur.resources.hlsli" #include "Common.hlsli" -#include "SIGMA/SIGMA_Common.hlsli" -#include "SIGMA/SIGMA_Shadow_Blur.hlsli" +#include "SIGMA_Common.hlsli" +#include "SIGMA_Blur.hlsli" diff --git a/Shaders/Source/SIGMA_ShadowTranslucency_ClassifyTiles.cs.hlsl b/Shaders/Source/SIGMA_ShadowTranslucency_ClassifyTiles.cs.hlsl index 28b86df..a7649be 100644 --- a/Shaders/Source/SIGMA_ShadowTranslucency_ClassifyTiles.cs.hlsl +++ b/Shaders/Source/SIGMA_ShadowTranslucency_ClassifyTiles.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define SIGMA_TRANSLUCENT -#include "SIGMA/SIGMA_Config.hlsli" -#include "SIGMA_Shadow_ClassifyTiles.resources.hlsli" +#include "SIGMA_Config.hlsli" +#include "SIGMA_ClassifyTiles.resources.hlsli" #include "Common.hlsli" -#include "SIGMA/SIGMA_Common.hlsli" -#include "SIGMA/SIGMA_Shadow_ClassifyTiles.hlsli" +#include "SIGMA_Common.hlsli" +#include "SIGMA_ClassifyTiles.hlsli" diff --git a/Shaders/Source/SIGMA_ShadowTranslucency_PostBlur.cs.hlsl b/Shaders/Source/SIGMA_ShadowTranslucency_PostBlur.cs.hlsl index 9ba0af3..920f529 100644 --- a/Shaders/Source/SIGMA_ShadowTranslucency_PostBlur.cs.hlsl +++ b/Shaders/Source/SIGMA_ShadowTranslucency_PostBlur.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define SIGMA_TRANSLUCENT -#include "SIGMA/SIGMA_Config.hlsli" -#include "SIGMA_Shadow_Blur.resources.hlsli" +#include "SIGMA_Config.hlsli" +#include "SIGMA_Blur.resources.hlsli" #include "Common.hlsli" -#include "SIGMA/SIGMA_Common.hlsli" -#include "SIGMA/SIGMA_Shadow_Blur.hlsli" +#include "SIGMA_Common.hlsli" +#include "SIGMA_Blur.hlsli" diff --git a/Shaders/Source/SIGMA_ShadowTranslucency_SplitScreen.cs.hlsl b/Shaders/Source/SIGMA_ShadowTranslucency_SplitScreen.cs.hlsl index fd9451f..1deb3f1 100644 --- a/Shaders/Source/SIGMA_ShadowTranslucency_SplitScreen.cs.hlsl +++ b/Shaders/Source/SIGMA_ShadowTranslucency_SplitScreen.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define SIGMA_TRANSLUCENT -#include "SIGMA/SIGMA_Config.hlsli" -#include "SIGMA_Shadow_SplitScreen.resources.hlsli" +#include "SIGMA_Config.hlsli" +#include "SIGMA_SplitScreen.resources.hlsli" #include "Common.hlsli" -#include "SIGMA/SIGMA_Common.hlsli" -#include "SIGMA/SIGMA_Shadow_SplitScreen.hlsli" +#include "SIGMA_Common.hlsli" +#include "SIGMA_SplitScreen.hlsli" diff --git a/Shaders/Source/SIGMA_ShadowTranslucency_TemporalStabilization.cs.hlsl b/Shaders/Source/SIGMA_ShadowTranslucency_TemporalStabilization.cs.hlsl index 9a9f901..d485c51 100644 --- a/Shaders/Source/SIGMA_ShadowTranslucency_TemporalStabilization.cs.hlsl +++ b/Shaders/Source/SIGMA_ShadowTranslucency_TemporalStabilization.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define SIGMA_TRANSLUCENT -#include "SIGMA/SIGMA_Config.hlsli" -#include "SIGMA_Shadow_TemporalStabilization.resources.hlsli" +#include "SIGMA_Config.hlsli" +#include "SIGMA_TemporalStabilization.resources.hlsli" #include "Common.hlsli" -#include "SIGMA/SIGMA_Common.hlsli" -#include "SIGMA/SIGMA_Shadow_TemporalStabilization.hlsli" +#include "SIGMA_Common.hlsli" +#include "SIGMA_TemporalStabilization.hlsli" diff --git a/Shaders/Source/SIGMA_Shadow_Blur.cs.hlsl b/Shaders/Source/SIGMA_Shadow_Blur.cs.hlsl index 19d7c62..9d7fbd8 100644 --- a/Shaders/Source/SIGMA_Shadow_Blur.cs.hlsl +++ b/Shaders/Source/SIGMA_Shadow_Blur.cs.hlsl @@ -13,9 +13,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #define SIGMA_FIRST_PASS -#include "SIGMA/SIGMA_Config.hlsli" -#include "SIGMA_Shadow_Blur.resources.hlsli" +#include "SIGMA_Config.hlsli" +#include "SIGMA_Blur.resources.hlsli" #include "Common.hlsli" -#include "SIGMA/SIGMA_Common.hlsli" -#include "SIGMA/SIGMA_Shadow_Blur.hlsli" +#include "SIGMA_Common.hlsli" +#include "SIGMA_Blur.hlsli" diff --git a/Shaders/Source/SIGMA_Shadow_ClassifyTiles.cs.hlsl b/Shaders/Source/SIGMA_Shadow_ClassifyTiles.cs.hlsl index e187711..2085597 100644 --- a/Shaders/Source/SIGMA_Shadow_ClassifyTiles.cs.hlsl +++ b/Shaders/Source/SIGMA_Shadow_ClassifyTiles.cs.hlsl @@ -11,9 +11,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "NRD.hlsli" #include "STL.hlsli" -#include "SIGMA/SIGMA_Config.hlsli" -#include "SIGMA_Shadow_ClassifyTiles.resources.hlsli" +#include "SIGMA_Config.hlsli" +#include "SIGMA_ClassifyTiles.resources.hlsli" #include "Common.hlsli" -#include "SIGMA/SIGMA_Common.hlsli" -#include "SIGMA/SIGMA_Shadow_ClassifyTiles.hlsli" +#include "SIGMA_Common.hlsli" +#include "SIGMA_ClassifyTiles.hlsli" diff --git a/Shaders/Source/SIGMA_Shadow_PostBlur.cs.hlsl b/Shaders/Source/SIGMA_Shadow_PostBlur.cs.hlsl index d75cb8a..8544c8e 100644 --- a/Shaders/Source/SIGMA_Shadow_PostBlur.cs.hlsl +++ b/Shaders/Source/SIGMA_Shadow_PostBlur.cs.hlsl @@ -11,9 +11,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "NRD.hlsli" #include "STL.hlsli" -#include "SIGMA/SIGMA_Config.hlsli" -#include "SIGMA_Shadow_Blur.resources.hlsli" +#include "SIGMA_Config.hlsli" +#include "SIGMA_Blur.resources.hlsli" #include "Common.hlsli" -#include "SIGMA/SIGMA_Common.hlsli" -#include "SIGMA/SIGMA_Shadow_Blur.hlsli" +#include "SIGMA_Common.hlsli" +#include "SIGMA_Blur.hlsli" diff --git a/Shaders/Source/SIGMA_Shadow_SmoothTiles.cs.hlsl b/Shaders/Source/SIGMA_Shadow_SmoothTiles.cs.hlsl index c4d082a..5a83476 100644 --- a/Shaders/Source/SIGMA_Shadow_SmoothTiles.cs.hlsl +++ b/Shaders/Source/SIGMA_Shadow_SmoothTiles.cs.hlsl @@ -11,11 +11,11 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "NRD.hlsli" #include "STL.hlsli" -#include "SIGMA/SIGMA_Config.hlsli" -#include "SIGMA_Shadow_SmoothTiles.resources.hlsli" +#include "SIGMA_Config.hlsli" +#include "SIGMA_SmoothTiles.resources.hlsli" #include "Common.hlsli" -#include "SIGMA/SIGMA_Common.hlsli" +#include "SIGMA_Common.hlsli" groupshared float s_Tile[ BUFFER_Y ][ BUFFER_X ]; diff --git a/Shaders/Source/SIGMA_Shadow_SplitScreen.cs.hlsl b/Shaders/Source/SIGMA_Shadow_SplitScreen.cs.hlsl index 6b33463..61790e3 100644 --- a/Shaders/Source/SIGMA_Shadow_SplitScreen.cs.hlsl +++ b/Shaders/Source/SIGMA_Shadow_SplitScreen.cs.hlsl @@ -11,9 +11,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "NRD.hlsli" #include "STL.hlsli" -#include "SIGMA/SIGMA_Config.hlsli" -#include "SIGMA_Shadow_SplitScreen.resources.hlsli" +#include "SIGMA_Config.hlsli" +#include "SIGMA_SplitScreen.resources.hlsli" #include "Common.hlsli" -#include "SIGMA/SIGMA_Common.hlsli" -#include "SIGMA/SIGMA_Shadow_SplitScreen.hlsli" +#include "SIGMA_Common.hlsli" +#include "SIGMA_SplitScreen.hlsli" diff --git a/Shaders/Source/SIGMA_Shadow_TemporalStabilization.cs.hlsl b/Shaders/Source/SIGMA_Shadow_TemporalStabilization.cs.hlsl index 0c6b91c..66db8da 100644 --- a/Shaders/Source/SIGMA_Shadow_TemporalStabilization.cs.hlsl +++ b/Shaders/Source/SIGMA_Shadow_TemporalStabilization.cs.hlsl @@ -11,9 +11,9 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "NRD.hlsli" #include "STL.hlsli" -#include "SIGMA/SIGMA_Config.hlsli" -#include "SIGMA_Shadow_TemporalStabilization.resources.hlsli" +#include "SIGMA_Config.hlsli" +#include "SIGMA_TemporalStabilization.resources.hlsli" #include "Common.hlsli" -#include "SIGMA/SIGMA_Common.hlsli" -#include "SIGMA/SIGMA_Shadow_TemporalStabilization.hlsli" +#include "SIGMA_Common.hlsli" +#include "SIGMA_TemporalStabilization.hlsli" diff --git a/Shaders/Source/SpecularDeltaMv_Compute.cs.hlsl b/Shaders/Source/SpecularDeltaMv_Compute.cs.hlsl index ce33089..fe29acd 100644 --- a/Shaders/Source/SpecularDeltaMv_Compute.cs.hlsl +++ b/Shaders/Source/SpecularDeltaMv_Compute.cs.hlsl @@ -27,7 +27,7 @@ float GetAngle(float3 a, float3 b) float3 LoadCandidate(float2 samplePos) { - return gIn_PrevDeltaSecondaryPos.SampleLevel(gLinearClamp, samplePos * gInvRectSize, 0.f).xyz; + return gIn_PrevDeltaSecondaryPos.SampleLevel(gLinearClamp, samplePos * gRectSizeInv, 0.f).xyz; } float LoadAngle(float2 samplePos, float3 primaryPos, float3 refDir) @@ -49,21 +49,19 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId) static const uint kMaxNewtonMethodIterations = 5; static const uint kMaxLineSearchIterations = 10; - const uint2 pixelPosUser = gRectOrigin + pixelPos; - - if (any(pixelPosUser >= gRectSize)) + if (any(pixelPos >= gRectSize)) return; - float3 primaryPos = gIn_DeltaPrimaryPos[pixelPosUser].xyz; - float3 secondaryPos = gIn_DeltaSecondaryPos[pixelPosUser].xyz; + float3 primaryPos = gIn_DeltaPrimaryPos[ pixelPos ].xyz; + float3 secondaryPos = gIn_DeltaSecondaryPos[ pixelPos ].xyz; - float3 mv = gIn_Mv[ pixelPosUser ] * gMvScale; - float2 pixelUv = float2(pixelPos + 0.5) * gInvRectSize; + float3 mv = gIn_Mv[ WithRectOrigin( pixelPos ) ] * gMvScale.xyz; + float2 pixelUv = float2(pixelPos + 0.5) * gRectSizeInv; float2 prevPixelUV = pixelUv + mv.xy; - if( gIsWorldSpaceMotionEnabled ) + if( gMvScale.w != 0.0 ) prevPixelUV = STL::Geometry::GetScreenUv( gWorldToClipPrev, primaryPos + mv ); - gOut_DeltaSecondaryPos[pixelPosUser] = secondaryPos; + gOut_DeltaSecondaryPos[ pixelPos ] = secondaryPos; float2 initialScreenMotion = prevPixelUV - pixelUv; @@ -80,7 +78,7 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId) { if (currAngle < kAngleEpsilon) { - gOut_DeltaMv[pixelPosUser] = prevSamplePos * gInvRectSize - pixelUv; + gOut_DeltaMv[ pixelPos ] = prevSamplePos * gRectSizeInv - pixelUv; return; } @@ -111,7 +109,7 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId) // Can't find a suitable position, fallback to primary surface mvec if (abs(tmp1) < 1e-15) { - gOut_DeltaMv[pixelPosUser] = initialScreenMotion; + gOut_DeltaMv[ pixelPos ] = initialScreenMotion; return; } @@ -142,10 +140,10 @@ NRD_EXPORT void NRD_CS_MAIN(uint2 pixelPos : SV_DispatchThreadId) if (currAngle < kAngleConvergenceEpsilon) { - gOut_DeltaMv[pixelPosUser] = prevSamplePos * gInvRectSize - pixelUv; + gOut_DeltaMv[ pixelPos ] = prevSamplePos * gRectSizeInv - pixelUv; return; } } - gOut_DeltaMv[pixelPosUser] = initialScreenMotion; + gOut_DeltaMv[ pixelPos ] = initialScreenMotion; } diff --git a/Shaders/Source/SpecularReflectionMv_Compute.cs.hlsl b/Shaders/Source/SpecularReflectionMv_Compute.cs.hlsl index 283f6a1..16b3c97 100644 --- a/Shaders/Source/SpecularReflectionMv_Compute.cs.hlsl +++ b/Shaders/Source/SpecularReflectionMv_Compute.cs.hlsl @@ -20,9 +20,8 @@ groupshared float4 s_Normal_Roughness[ BUFFER_Y ][ BUFFER_X ]; void Preload( uint2 sharedPos, int2 globalPos ) { globalPos = clamp( globalPos, 0, gRectSize - 1.0 ); - uint2 globalIdUser = gRectOrigin + globalPos; - s_Normal_Roughness[ sharedPos.y ][ sharedPos.x ] = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ globalIdUser ] ); + s_Normal_Roughness[ sharedPos.y ][ sharedPos.x ] = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ WithRectOrigin( globalPos ) ] ); } float3 GetViewVector( float3 X, bool isViewSpace = false ) @@ -33,13 +32,12 @@ float3 GetViewVector( float3 X, bool isViewSpace = false ) [numthreads( GROUP_X, GROUP_Y, 1 )] NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : SV_DispatchThreadId, uint threadIndex : SV_GroupIndex ) { - float2 pixelUv = float2( pixelPos + 0.5 ) * gInvRectSize; - uint2 pixelPosUser = gRectOrigin + pixelPos; + float2 pixelUv = float2( pixelPos + 0.5 ) * gRectSizeInv; PRELOAD_INTO_SMEM; // Early out - float viewZ = gIn_ViewZ[ pixelPosUser ]; + float viewZ = gIn_ViewZ[ WithRectOrigin( pixelPos ) ]; [branch] if( viewZ > gDenoisingRange ) @@ -58,23 +56,24 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : float NoV = abs( dot( N, V ) ); // Previous position and surface motion uv - float3 mv = gIn_Mv[ pixelPosUser ] * gMvScale; - if( gMvScale.z == 0.0 ) - mv.z = STL::Geometry::AffineTransform( gWorldToViewPrev, X ).z - viewZ; - + float3 mv = gIn_Mv[ WithRectOrigin( pixelPos ) ] * gMvScale.xyz; float3 Xprev = X; float2 smbPixelUv = pixelUv + mv.xy; - if( gIsWorldSpaceMotionEnabled ) + + if( gMvScale.w != 0.0 ) { Xprev += mv; smbPixelUv = STL::Geometry::GetScreenUv( gWorldToClipPrev, Xprev ); } else { + if( gMvScale.z == 0.0 ) + mv.z = STL::Geometry::AffineTransform( gWorldToViewPrev, X ).z - viewZ; + float viewZprev = viewZ + mv.z; float3 Xvprevlocal = STL::Geometry::ReconstructViewPosition( smbPixelUv, gFrustumPrev, viewZprev, gOrthoMode ); // TODO: use gOrthoModePrev - Xprev = STL::Geometry::RotateVectorInverse( gWorldToViewPrev, Xvprevlocal ) + gCameraDelta; + Xprev = STL::Geometry::RotateVectorInverse( gWorldToViewPrev, Xvprevlocal ) + gCameraDelta.xyz; } // Modified roughness @@ -99,24 +98,24 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : float roughnessModified = STL::Filtering::GetModifiedRoughnessFromNormalVariance( roughness, Navg ); // Parallax - float smbParallaxInPixels = ComputeParallaxInPixels( Xprev - gCameraDelta, gOrthoMode == 0.0 ? pixelUv : smbPixelUv, gWorldToClip, gRectSize ); + float smbParallaxInPixels = ComputeParallaxInPixels( Xprev - gCameraDelta.xyz, gOrthoMode == 0.0 ? pixelUv : smbPixelUv, gWorldToClip, gRectSize ); // Hit distance - float hitDistForTracking = gIn_HitDist[ pixelPosUser ]; // TODO: min hitDist logic from REBLUR / RELAX needed + float hitDistForTracking = gIn_HitDist[ pixelPos ]; // TODO: min hitDist logic from REBLUR / RELAX needed // Curvature float curvature; { // IMPORTANT: this code allows to get non-zero parallax on objects attached to the camera float2 uvForZeroParallax = gOrthoMode == 0.0 ? smbPixelUv : pixelUv; - float2 deltaUv = STL::Geometry::GetScreenUv( gWorldToClipPrev, Xprev - gCameraDelta ) - uvForZeroParallax; + float2 deltaUv = STL::Geometry::GetScreenUv( gWorldToClipPrev, Xprev - gCameraDelta.xyz ) - uvForZeroParallax; deltaUv *= gRectSize; float deltaUvLen = length( deltaUv ); deltaUv /= max( deltaUvLen, 1.0 / 256.0 ); - float2 motionUv = pixelUv + 0.99 * deltaUv * gInvRectSize; // stay in SMEM + float2 motionUv = pixelUv + 0.99 * deltaUv * gRectSizeInv; // stay in SMEM // Construct the other edge point "x" - float z = abs( gIn_ViewZ.SampleLevel( gLinearClamp, gRectOffset + motionUv * gResolutionScale, 0 ) ); + float z = abs( gIn_ViewZ.SampleLevel( gLinearClamp, WithRectOffset( motionUv * gResolutionScale ), 0 ) ); float3 x = STL::Geometry::ReconstructViewPosition( motionUv, gFrustum, z, gOrthoMode ); x = STL::Geometry::RotateVector( gViewToWorld, x ); @@ -131,16 +130,16 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : float3 n01 = s_Normal_Roughness[ pos.y + 1 ][ pos.x ].xyz; float3 n11 = s_Normal_Roughness[ pos.y + 1 ][ pos.x + 1 ].xyz; - float3 n = normalize( STL::Filtering::ApplyBilinearFilter( n00, n10, n01, n11, f ) ); + float3 n = _NRD_SafeNormalize( STL::Filtering::ApplyBilinearFilter( n00, n10, n01, n11, f ) ); // ( Optional ) High parallax - flattens surface on high motion ( test 132, e9 ) // IMPORTANT: a must for 8-bit and 10-bit normals ( tests b7, b10, b33 ) float deltaUvLenFixed = deltaUvLen * ( NRD_USE_HIGH_PARALLAX_CURVATURE_SILHOUETTE_FIX ? NoV : 1.0 ); // it fixes silhouettes, but leads to less flattening - float2 motionUvHigh = pixelUv + deltaUvLenFixed * deltaUv * gInvRectSize; - if( NRD_USE_HIGH_PARALLAX_CURVATURE && deltaUvLenFixed > 1.0 && IsInScreen( motionUvHigh ) ) + float2 motionUvHigh = pixelUv + deltaUvLenFixed * deltaUv * gRectSizeInv; + if( NRD_USE_HIGH_PARALLAX_CURVATURE && deltaUvLenFixed > 1.0 && IsInScreenNearest( motionUvHigh ) ) { // Construct the other edge point "xHigh" - float zHigh = abs( gIn_ViewZ.SampleLevel( gLinearClamp, gRectOffset + motionUvHigh * gResolutionScale, 0 ) ); + float zHigh = abs( gIn_ViewZ.SampleLevel( gLinearClamp, WithRectOffset( motionUvHigh * gResolutionScale ), 0 ) ); float3 xHigh = STL::Geometry::ReconstructViewPosition( motionUvHigh, gFrustum, zHigh, gOrthoMode ); xHigh = STL::Geometry::RotateVector( gViewToWorld, xHigh ); @@ -148,17 +147,17 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : #if( NRD_NORMAL_ENCODING == NRD_NORMAL_ENCODING_R10G10B10A2_UNORM ) f = STL::Filtering::GetBilinearFilter( motionUvHigh, gRectSize ); + f.origin = clamp( f.origin, 0, gRectSize - 2.0 ); pos = gRectOrigin + int2( f.origin ); - pos = clamp( pos, 0, int2( gRectSize ) - 2 ); n00 = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pos ] ).xyz; n10 = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pos + int2( 1, 0 ) ] ).xyz; n01 = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pos + int2( 0, 1 ) ] ).xyz; n11 = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness[ pos + int2( 1, 1 ) ] ).xyz; - float3 nHigh = normalize( STL::Filtering::ApplyBilinearFilter( n00, n10, n01, n11, f ) ); + float3 nHigh = _NRD_SafeNormalize( STL::Filtering::ApplyBilinearFilter( n00, n10, n01, n11, f ) ); #else - float3 nHigh = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness.SampleLevel( gLinearClamp, gRectOffset + motionUvHigh * gResolutionScale, 0 ) ).xyz; + float3 nHigh = NRD_FrontEnd_UnpackNormalAndRoughness( gIn_Normal_Roughness.SampleLevel( gLinearClamp, WithRectOffset( motionUvHigh * gResolutionScale ), 0 ) ).xyz; #endif // Replace if same surface @@ -183,7 +182,7 @@ NRD_EXPORT void NRD_CS_MAIN( int2 threadPos : SV_GroupThreadId, int2 pixelPos : float2 uv1 = STL::Geometry::GetScreenUv( gWorldToClipPrev, X - V * ApplyThinLensEquation( NoV, hitDistForTracking, curvature ) ); float2 uv2 = STL::Geometry::GetScreenUv( gWorldToClipPrev, X ); float a = length( ( uv1 - uv2 ) * gRectSize ); - curvature *= float( a < 3.0 * deltaUvLen + gInvRectSize.x ); // TODO:it's a hack, incompatible with concave mirrors ( tests 22b, 23b, 25b ) + curvature *= float( a < 3.0 * deltaUvLen + gRectSizeInv.x ); // TODO:it's a hack, incompatible with concave mirrors ( tests 22b, 23b, 25b ) } // Virtual motion diff --git a/Source/Denoisers/Reblur_Diffuse.hpp b/Source/Denoisers/Reblur_Diffuse.hpp index 24170e3..2150b40 100644 --- a/Source/Denoisers/Reblur_Diffuse.hpp +++ b/Source/Denoisers/Reblur_Diffuse.hpp @@ -17,11 +17,6 @@ void nrd::InstanceImpl::Add_ReblurDiffuse(DenoiserData& denoiserData) denoiserData.settings.reblur = ReblurSettings(); denoiserData.settingsSize = sizeof(denoiserData.settings.reblur); - uint16_t w = denoiserData.desc.renderWidth; - uint16_t h = denoiserData.desc.renderHeight; - uint16_t tilesW = DivideUp(w, 16); - uint16_t tilesH = DivideUp(h, 16); - enum class Permanent { PREV_VIEWZ = PERMANENT_POOL_START, @@ -31,11 +26,11 @@ void nrd::InstanceImpl::Add_ReblurDiffuse(DenoiserData& denoiserData) DIFF_FAST_HISTORY, }; - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_VIEWZ, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_NORMAL_ROUGHNESS, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_INTERNAL_DATA, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_FAST_HISTORY, w, h, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_VIEWZ, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_NORMAL_ROUGHNESS, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_INTERNAL_DATA, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_FAST_HISTORY, 1} ); enum class Transient { @@ -47,28 +42,23 @@ void nrd::InstanceImpl::Add_ReblurDiffuse(DenoiserData& denoiserData) TILES, }; - AddTextureToTransientPool( {Format::RG8_UNORM, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UINT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_FAST_HISTORY, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, tilesW, tilesH, 1} ); - - REBLUR_SET_SHARED_CONSTANTS; + AddTextureToTransientPool( {Format::RG8_UNORM, 1} ); + AddTextureToTransientPool( {Format::R8_UINT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_FAST_HISTORY, 1} ); + AddTextureToTransientPool( {Format::R8_UNORM, 16} ); - for (int i = 0; i < REBLUR_CLASSIFY_TILES_PERMUTATION_NUM; i++) + PushPass("Classify tiles"); { - PushPass("Classify tiles"); - { - // Inputs - PushInput( AsUint(ResourceType::IN_VIEWZ) ); + // Inputs + PushInput( AsUint(ResourceType::IN_VIEWZ) ); - // Outputs - PushOutput( AsUint(Transient::TILES) ); + // Outputs + PushOutput( AsUint(Transient::TILES) ); - // Shaders - AddDispatch( REBLUR_ClassifyTiles, REBLUR_CLASSIFY_TILES_CONSTANT_NUM, REBLUR_CLASSIFY_TILES_NUM_THREADS, 1 ); - } + // Shaders + AddDispatch( REBLUR_ClassifyTiles, REBLUR_ClassifyTiles, 1 ); } for (int i = 0; i < REBLUR_HITDIST_RECONSTRUCTION_PERMUTATION_NUM; i++) @@ -90,13 +80,13 @@ void nrd::InstanceImpl::Add_ReblurDiffuse(DenoiserData& denoiserData) // Shaders if (is5x5) { - AddDispatch( REBLUR_Diffuse_HitDistReconstruction_5x5, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_Diffuse_HitDistReconstruction_5x5, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_Diffuse_HitDistReconstruction_5x5, REBLUR_HitDistReconstruction, 1 ); + AddDispatch( REBLUR_Perf_Diffuse_HitDistReconstruction_5x5, REBLUR_HitDistReconstruction, 1 ); } else { - AddDispatch( REBLUR_Diffuse_HitDistReconstruction, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_Diffuse_HitDistReconstruction, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_Diffuse_HitDistReconstruction, REBLUR_HitDistReconstruction, 1 ); + AddDispatch( REBLUR_Perf_Diffuse_HitDistReconstruction, REBLUR_HitDistReconstruction, 1 ); } } } @@ -117,8 +107,8 @@ void nrd::InstanceImpl::Add_ReblurDiffuse(DenoiserData& denoiserData) PushOutput( DIFF_TEMP1 ); // Shaders - AddDispatch( REBLUR_Diffuse_PrePass, REBLUR_PREPASS_CONSTANT_NUM, REBLUR_PREPASS_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_Diffuse_PrePass, REBLUR_PREPASS_CONSTANT_NUM, REBLUR_PREPASS_NUM_THREADS, 1 ); + AddDispatch( REBLUR_Diffuse_PrePass, REBLUR_PrePass, 1 ); + AddDispatch( REBLUR_Perf_Diffuse_PrePass, REBLUR_PrePass, 1 ); } } @@ -152,52 +142,46 @@ void nrd::InstanceImpl::Add_ReblurDiffuse(DenoiserData& denoiserData) PushOutput( AsUint(Transient::DATA2) ); // Shaders - AddDispatch( REBLUR_Diffuse_TemporalAccumulation, REBLUR_TEMPORAL_ACCUMULATION_CONSTANT_NUM, REBLUR_TEMPORAL_ACCUMULATION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_Diffuse_TemporalAccumulation, REBLUR_TEMPORAL_ACCUMULATION_CONSTANT_NUM, REBLUR_TEMPORAL_ACCUMULATION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_Diffuse_TemporalAccumulation, REBLUR_TemporalAccumulation, 1 ); + AddDispatch( REBLUR_Perf_Diffuse_TemporalAccumulation, REBLUR_TemporalAccumulation, 1 ); } } - for (int i = 0; i < REBLUR_HISTORY_FIX_PERMUTATION_NUM; i++) + PushPass("History fix"); { - PushPass("History fix"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(Transient::DATA1) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( DIFF_TEMP2 ); - PushInput( AsUint(Transient::DIFF_FAST_HISTORY) ); - - // Outputs - PushOutput( DIFF_TEMP1 ); - PushOutput( AsUint(Permanent::DIFF_FAST_HISTORY) ); - - // Shaders - AddDispatch( REBLUR_Diffuse_HistoryFix, REBLUR_HISTORY_FIX_CONSTANT_NUM, REBLUR_HISTORY_FIX_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_Diffuse_HistoryFix, REBLUR_HISTORY_FIX_CONSTANT_NUM, REBLUR_HISTORY_FIX_NUM_THREADS, 1 ); - } + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(Transient::DATA1) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( DIFF_TEMP2 ); + PushInput( AsUint(Transient::DIFF_FAST_HISTORY) ); + + // Outputs + PushOutput( DIFF_TEMP1 ); + PushOutput( AsUint(Permanent::DIFF_FAST_HISTORY) ); + + // Shaders + AddDispatch( REBLUR_Diffuse_HistoryFix, REBLUR_HistoryFix, 1 ); + AddDispatch( REBLUR_Perf_Diffuse_HistoryFix, REBLUR_HistoryFix, 1 ); } - for (int i = 0; i < REBLUR_BLUR_PERMUTATION_NUM; i++) + PushPass("Blur"); { - PushPass("Blur"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(Transient::DATA1) ); - PushInput( DIFF_TEMP1 ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - - // Outputs - PushOutput( DIFF_TEMP2 ); - PushOutput( AsUint(Permanent::PREV_VIEWZ) ); - - // Shaders - AddDispatch( REBLUR_Diffuse_Blur, REBLUR_BLUR_CONSTANT_NUM, REBLUR_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_Diffuse_Blur, REBLUR_BLUR_CONSTANT_NUM, REBLUR_BLUR_NUM_THREADS, 1 ); - } + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(Transient::DATA1) ); + PushInput( DIFF_TEMP1 ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + + // Outputs + PushOutput( DIFF_TEMP2 ); + PushOutput( AsUint(Permanent::PREV_VIEWZ) ); + + // Shaders + AddDispatch( REBLUR_Diffuse_Blur, REBLUR_Blur, 1 ); + AddDispatch( REBLUR_Perf_Diffuse_Blur, REBLUR_Blur, 1 ); } for (int i = 0; i < REBLUR_POST_BLUR_PERMUTATION_NUM; i++) @@ -227,31 +211,28 @@ void nrd::InstanceImpl::Add_ReblurDiffuse(DenoiserData& denoiserData) // Shaders if (isTemporalStabilization) { - AddDispatch( REBLUR_Diffuse_PostBlur, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_Diffuse_PostBlur, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); + AddDispatch( REBLUR_Diffuse_PostBlur, REBLUR_PostBlur, 1 ); + AddDispatch( REBLUR_Perf_Diffuse_PostBlur, REBLUR_PostBlur, 1 ); } else { - AddDispatch( REBLUR_Diffuse_PostBlur_NoTemporalStabilization, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_Diffuse_PostBlur_NoTemporalStabilization, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); + AddDispatch( REBLUR_Diffuse_PostBlur_NoTemporalStabilization, REBLUR_PostBlur, 1 ); + AddDispatch( REBLUR_Perf_Diffuse_PostBlur_NoTemporalStabilization, REBLUR_PostBlur, 1 ); } } } - for (int i = 0; i < REBLUR_COPY_STABILIZED_HISTORY_PERMUTATION_NUM; i++) + PushPass("Copy"); { - PushPass("Copy stabilized history"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); - // Outputs - PushOutput( DIFF_TEMP2 ); + // Outputs + PushOutput( DIFF_TEMP2 ); - // Shaders - AddDispatch( REBLUR_Diffuse_CopyStabilizedHistory, REBLUR_COPY_STABILIZED_HISTORY_CONSTANT_NUM, REBLUR_COPY_STABILIZED_HISTORY_NUM_THREADS, USE_MAX_DIMS ); - } + // Shaders + AddDispatch( REBLUR_Diffuse_Copy, REBLUR_Copy, USE_MAX_DIMS ); } for (int i = 0; i < REBLUR_TEMPORAL_STABILIZATION_PERMUTATION_NUM; i++) @@ -273,25 +254,22 @@ void nrd::InstanceImpl::Add_ReblurDiffuse(DenoiserData& denoiserData) PushOutput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); // Shaders - AddDispatch( REBLUR_Diffuse_TemporalStabilization, REBLUR_TEMPORAL_STABILIZATION_CONSTANT_NUM, REBLUR_TEMPORAL_STABILIZATION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_Diffuse_TemporalStabilization, REBLUR_TEMPORAL_STABILIZATION_CONSTANT_NUM, REBLUR_TEMPORAL_STABILIZATION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_Diffuse_TemporalStabilization, REBLUR_TemporalStabilization, 1 ); + AddDispatch( REBLUR_Perf_Diffuse_TemporalStabilization, REBLUR_TemporalStabilization, 1 ); } } - for (int i = 0; i < REBLUR_SPLIT_SCREEN_PERMUTATION_NUM; i++) + PushPass("Split screen"); { - PushPass("Split screen"); - { - // Inputs - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(ResourceType::IN_DIFF_RADIANCE_HITDIST) ); + // Inputs + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( AsUint(ResourceType::IN_DIFF_RADIANCE_HITDIST) ); - // Outputs - PushOutput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); + // Outputs + PushOutput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); - // Shaders - AddDispatch( REBLUR_Diffuse_SplitScreen, REBLUR_SPLIT_SCREEN_CONSTANT_NUM, REBLUR_SPLIT_SCREEN_NUM_THREADS, 1 ); - } + // Shaders + AddDispatch( REBLUR_Diffuse_SplitScreen, REBLUR_SplitScreen, 1 ); } REBLUR_ADD_VALIDATION_DISPATCH( Transient::DATA2, ResourceType::IN_DIFF_RADIANCE_HITDIST, ResourceType::IN_DIFF_RADIANCE_HITDIST ); diff --git a/Source/Denoisers/Reblur_DiffuseDirectionalOcclusion.hpp b/Source/Denoisers/Reblur_DiffuseDirectionalOcclusion.hpp index 3d7adc6..c4eb0d6 100644 --- a/Source/Denoisers/Reblur_DiffuseDirectionalOcclusion.hpp +++ b/Source/Denoisers/Reblur_DiffuseDirectionalOcclusion.hpp @@ -17,11 +17,6 @@ void nrd::InstanceImpl::Add_ReblurDiffuseDirectionalOcclusion(DenoiserData& deno denoiserData.settings.reblur = ReblurSettings(); denoiserData.settingsSize = sizeof(denoiserData.settings.reblur); - uint16_t w = denoiserData.desc.renderWidth; - uint16_t h = denoiserData.desc.renderHeight; - uint16_t tilesW = DivideUp(w, 16); - uint16_t tilesH = DivideUp(h, 16); - // IMPORTANT: uses SNORM / UNORM 16-bit textures to maximize bits utilization and uniformity enum class Permanent @@ -33,11 +28,11 @@ void nrd::InstanceImpl::Add_ReblurDiffuseDirectionalOcclusion(DenoiserData& deno DIFF_FAST_HISTORY, }; - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_VIEWZ, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_NORMAL_ROUGHNESS, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_INTERNAL_DATA, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_DIRECTIONAL_OCCLUSION, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_DIRECTIONAL_OCCLUSION_FAST_HISTORY, w, h, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_VIEWZ, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_NORMAL_ROUGHNESS, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_INTERNAL_DATA, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_DIRECTIONAL_OCCLUSION, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_DIRECTIONAL_OCCLUSION_FAST_HISTORY, 1} ); enum class Transient { @@ -49,28 +44,23 @@ void nrd::InstanceImpl::Add_ReblurDiffuseDirectionalOcclusion(DenoiserData& deno TILES, }; - AddTextureToTransientPool( {Format::RG8_UNORM, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UINT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_DIRECTIONAL_OCCLUSION, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_DIRECTIONAL_OCCLUSION, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_DIRECTIONAL_OCCLUSION_FAST_HISTORY, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, tilesW, tilesH, 1} ); - - REBLUR_SET_SHARED_CONSTANTS; + AddTextureToTransientPool( {Format::RG8_UNORM, 1} ); + AddTextureToTransientPool( {Format::R8_UINT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_DIRECTIONAL_OCCLUSION, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_DIRECTIONAL_OCCLUSION, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_DIRECTIONAL_OCCLUSION_FAST_HISTORY, 1} ); + AddTextureToTransientPool( {Format::R8_UNORM, 16} ); - for (int i = 0; i < REBLUR_CLASSIFY_TILES_PERMUTATION_NUM; i++) + PushPass("Classify tiles"); { - PushPass("Classify tiles"); - { - // Inputs - PushInput( AsUint(ResourceType::IN_VIEWZ) ); + // Inputs + PushInput( AsUint(ResourceType::IN_VIEWZ) ); - // Outputs - PushOutput( AsUint(Transient::TILES) ); + // Outputs + PushOutput( AsUint(Transient::TILES) ); - // Shaders - AddDispatch( REBLUR_ClassifyTiles, REBLUR_CLASSIFY_TILES_CONSTANT_NUM, REBLUR_CLASSIFY_TILES_NUM_THREADS, 1 ); - } + // Shaders + AddDispatch( REBLUR_ClassifyTiles, REBLUR_ClassifyTiles, 1 ); } for (int i = 0; i < REBLUR_HITDIST_RECONSTRUCTION_PERMUTATION_NUM; i++) @@ -92,13 +82,13 @@ void nrd::InstanceImpl::Add_ReblurDiffuseDirectionalOcclusion(DenoiserData& deno // Shaders if (is5x5) { - AddDispatch( REBLUR_Diffuse_HitDistReconstruction_5x5, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_Diffuse_HitDistReconstruction_5x5, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_Diffuse_HitDistReconstruction_5x5, REBLUR_HitDistReconstruction, 1 ); + AddDispatch( REBLUR_Perf_Diffuse_HitDistReconstruction_5x5, REBLUR_HitDistReconstruction, 1 ); } else { - AddDispatch( REBLUR_Diffuse_HitDistReconstruction, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_Diffuse_HitDistReconstruction, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_Diffuse_HitDistReconstruction, REBLUR_HitDistReconstruction, 1 ); + AddDispatch( REBLUR_Perf_Diffuse_HitDistReconstruction, REBLUR_HitDistReconstruction, 1 ); } } } @@ -119,8 +109,8 @@ void nrd::InstanceImpl::Add_ReblurDiffuseDirectionalOcclusion(DenoiserData& deno PushOutput( DIFF_TEMP1 ); // Shaders - AddDispatch( REBLUR_DiffuseDirectionalOcclusion_PrePass, REBLUR_PREPASS_CONSTANT_NUM, REBLUR_PREPASS_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseDirectionalOcclusion_PrePass, REBLUR_PREPASS_CONSTANT_NUM, REBLUR_PREPASS_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseDirectionalOcclusion_PrePass, REBLUR_PrePass, 1 ); + AddDispatch( REBLUR_Perf_DiffuseDirectionalOcclusion_PrePass, REBLUR_PrePass, 1 ); } } @@ -154,52 +144,46 @@ void nrd::InstanceImpl::Add_ReblurDiffuseDirectionalOcclusion(DenoiserData& deno PushOutput( AsUint(Transient::DATA2) ); // Shaders - AddDispatch( REBLUR_DiffuseDirectionalOcclusion_TemporalAccumulation, REBLUR_TEMPORAL_ACCUMULATION_CONSTANT_NUM, REBLUR_TEMPORAL_ACCUMULATION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseDirectionalOcclusion_TemporalAccumulation, REBLUR_TEMPORAL_ACCUMULATION_CONSTANT_NUM, REBLUR_TEMPORAL_ACCUMULATION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseDirectionalOcclusion_TemporalAccumulation, REBLUR_TemporalAccumulation, 1 ); + AddDispatch( REBLUR_Perf_DiffuseDirectionalOcclusion_TemporalAccumulation, REBLUR_TemporalAccumulation, 1 ); } } - for (int i = 0; i < REBLUR_HISTORY_FIX_PERMUTATION_NUM; i++) + PushPass("History fix"); { - PushPass("History fix"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(Transient::DATA1) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( DIFF_TEMP2 ); - PushInput( AsUint(Transient::DIFF_FAST_HISTORY) ); - - // Outputs - PushOutput( DIFF_TEMP1 ); - PushOutput( AsUint(Permanent::DIFF_FAST_HISTORY) ); - - // Shaders - AddDispatch( REBLUR_DiffuseDirectionalOcclusion_HistoryFix, REBLUR_HISTORY_FIX_CONSTANT_NUM, REBLUR_HISTORY_FIX_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseDirectionalOcclusion_HistoryFix, REBLUR_HISTORY_FIX_CONSTANT_NUM, REBLUR_HISTORY_FIX_NUM_THREADS, 1 ); - } + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(Transient::DATA1) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( DIFF_TEMP2 ); + PushInput( AsUint(Transient::DIFF_FAST_HISTORY) ); + + // Outputs + PushOutput( DIFF_TEMP1 ); + PushOutput( AsUint(Permanent::DIFF_FAST_HISTORY) ); + + // Shaders + AddDispatch( REBLUR_DiffuseDirectionalOcclusion_HistoryFix, REBLUR_HistoryFix, 1 ); + AddDispatch( REBLUR_Perf_DiffuseDirectionalOcclusion_HistoryFix, REBLUR_HistoryFix, 1 ); } - for (int i = 0; i < REBLUR_BLUR_PERMUTATION_NUM; i++) + PushPass("Blur"); { - PushPass("Blur"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(Transient::DATA1) ); - PushInput( DIFF_TEMP1 ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - - // Outputs - PushOutput( DIFF_TEMP2 ); - PushOutput( AsUint(Permanent::PREV_VIEWZ) ); - - // Shaders - AddDispatch( REBLUR_DiffuseDirectionalOcclusion_Blur, REBLUR_BLUR_CONSTANT_NUM, REBLUR_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseDirectionalOcclusion_Blur, REBLUR_BLUR_CONSTANT_NUM, REBLUR_BLUR_NUM_THREADS, 1 ); - } + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(Transient::DATA1) ); + PushInput( DIFF_TEMP1 ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + + // Outputs + PushOutput( DIFF_TEMP2 ); + PushOutput( AsUint(Permanent::PREV_VIEWZ) ); + + // Shaders + AddDispatch( REBLUR_DiffuseDirectionalOcclusion_Blur, REBLUR_Blur, 1 ); + AddDispatch( REBLUR_Perf_DiffuseDirectionalOcclusion_Blur, REBLUR_Blur, 1 ); } for (int i = 0; i < REBLUR_POST_BLUR_PERMUTATION_NUM; i++) @@ -229,31 +213,28 @@ void nrd::InstanceImpl::Add_ReblurDiffuseDirectionalOcclusion(DenoiserData& deno // Shaders if (isTemporalStabilization) { - AddDispatch( REBLUR_DiffuseDirectionalOcclusion_PostBlur, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseDirectionalOcclusion_PostBlur, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseDirectionalOcclusion_PostBlur, REBLUR_PostBlur, 1 ); + AddDispatch( REBLUR_Perf_DiffuseDirectionalOcclusion_PostBlur, REBLUR_PostBlur, 1 ); } else { - AddDispatch( REBLUR_DiffuseDirectionalOcclusion_PostBlur_NoTemporalStabilization, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseDirectionalOcclusion_PostBlur_NoTemporalStabilization, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseDirectionalOcclusion_PostBlur_NoTemporalStabilization, REBLUR_PostBlur, 1 ); + AddDispatch( REBLUR_Perf_DiffuseDirectionalOcclusion_PostBlur_NoTemporalStabilization, REBLUR_PostBlur, 1 ); } } } - for (int i = 0; i < REBLUR_COPY_STABILIZED_HISTORY_PERMUTATION_NUM; i++) + PushPass("Copy"); { - PushPass("Copy stabilized history"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::OUT_DIFF_DIRECTION_HITDIST) ); + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::OUT_DIFF_DIRECTION_HITDIST) ); - // Outputs - PushOutput( DIFF_TEMP2 ); + // Outputs + PushOutput( DIFF_TEMP2 ); - // Shaders - AddDispatch( REBLUR_Diffuse_CopyStabilizedHistory, REBLUR_COPY_STABILIZED_HISTORY_CONSTANT_NUM, REBLUR_COPY_STABILIZED_HISTORY_NUM_THREADS, USE_MAX_DIMS ); - } + // Shaders + AddDispatch( REBLUR_Diffuse_Copy, REBLUR_Copy, USE_MAX_DIMS ); } for (int i = 0; i < REBLUR_TEMPORAL_STABILIZATION_PERMUTATION_NUM; i++) @@ -275,25 +256,22 @@ void nrd::InstanceImpl::Add_ReblurDiffuseDirectionalOcclusion(DenoiserData& deno PushOutput( AsUint(ResourceType::OUT_DIFF_DIRECTION_HITDIST) ); // Shaders - AddDispatch( REBLUR_DiffuseDirectionalOcclusion_TemporalStabilization, REBLUR_TEMPORAL_STABILIZATION_CONSTANT_NUM, REBLUR_TEMPORAL_STABILIZATION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseDirectionalOcclusion_TemporalStabilization, REBLUR_TEMPORAL_STABILIZATION_CONSTANT_NUM, REBLUR_TEMPORAL_STABILIZATION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseDirectionalOcclusion_TemporalStabilization, REBLUR_TemporalStabilization, 1 ); + AddDispatch( REBLUR_Perf_DiffuseDirectionalOcclusion_TemporalStabilization, REBLUR_TemporalStabilization, 1 ); } } - for (int i = 0; i < REBLUR_SPLIT_SCREEN_PERMUTATION_NUM; i++) + PushPass("Split screen"); { - PushPass("Split screen"); - { - // Inputs - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(ResourceType::IN_DIFF_DIRECTION_HITDIST) ); + // Inputs + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( AsUint(ResourceType::IN_DIFF_DIRECTION_HITDIST) ); - // Outputs - PushOutput( AsUint(ResourceType::OUT_DIFF_DIRECTION_HITDIST) ); + // Outputs + PushOutput( AsUint(ResourceType::OUT_DIFF_DIRECTION_HITDIST) ); - // Shaders - AddDispatch( REBLUR_Diffuse_SplitScreen, REBLUR_SPLIT_SCREEN_CONSTANT_NUM, REBLUR_SPLIT_SCREEN_NUM_THREADS, 1 ); - } + // Shaders + AddDispatch( REBLUR_Diffuse_SplitScreen, REBLUR_SplitScreen, 1 ); } REBLUR_ADD_VALIDATION_DISPATCH( Transient::DATA2, ResourceType::IN_DIFF_DIRECTION_HITDIST, ResourceType::IN_DIFF_DIRECTION_HITDIST ); diff --git a/Source/Denoisers/Reblur_DiffuseOcclusion.hpp b/Source/Denoisers/Reblur_DiffuseOcclusion.hpp index 6cf806e..e3d5fde 100644 --- a/Source/Denoisers/Reblur_DiffuseOcclusion.hpp +++ b/Source/Denoisers/Reblur_DiffuseOcclusion.hpp @@ -17,11 +17,6 @@ void nrd::InstanceImpl::Add_ReblurDiffuseOcclusion(DenoiserData& denoiserData) denoiserData.settings.reblur = ReblurSettings(); denoiserData.settingsSize = sizeof(denoiserData.settings.reblur); - uint16_t w = denoiserData.desc.renderWidth; - uint16_t h = denoiserData.desc.renderHeight; - uint16_t tilesW = DivideUp(w, 16); - uint16_t tilesH = DivideUp(h, 16); - enum class Permanent { PREV_VIEWZ = PERMANENT_POOL_START, @@ -30,10 +25,10 @@ void nrd::InstanceImpl::Add_ReblurDiffuseOcclusion(DenoiserData& denoiserData) DIFF_FAST_HISTORY, }; - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_VIEWZ, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_NORMAL_ROUGHNESS, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_INTERNAL_DATA, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_OCCLUSION_FAST_HISTORY, w, h, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_VIEWZ, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_NORMAL_ROUGHNESS, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_INTERNAL_DATA, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_OCCLUSION_FAST_HISTORY, 1} ); enum class Transient { @@ -44,27 +39,22 @@ void nrd::InstanceImpl::Add_ReblurDiffuseOcclusion(DenoiserData& denoiserData) TILES, }; - AddTextureToTransientPool( {Format::RG8_UNORM, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_OCCLUSION, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_OCCLUSION, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_OCCLUSION_FAST_HISTORY, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, tilesW, tilesH, 1} ); - - REBLUR_SET_SHARED_CONSTANTS; + AddTextureToTransientPool( {Format::RG8_UNORM, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_OCCLUSION, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_OCCLUSION, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_OCCLUSION_FAST_HISTORY, 1} ); + AddTextureToTransientPool( {Format::R8_UNORM, 16} ); - for (int i = 0; i < REBLUR_CLASSIFY_TILES_PERMUTATION_NUM; i++) + PushPass("Classify tiles"); { - PushPass("Classify tiles"); - { - // Inputs - PushInput( AsUint(ResourceType::IN_VIEWZ) ); + // Inputs + PushInput( AsUint(ResourceType::IN_VIEWZ) ); - // Outputs - PushOutput( AsUint(Transient::TILES) ); + // Outputs + PushOutput( AsUint(Transient::TILES) ); - // Shaders - AddDispatch( REBLUR_ClassifyTiles, REBLUR_CLASSIFY_TILES_CONSTANT_NUM, REBLUR_CLASSIFY_TILES_NUM_THREADS, 1 ); - } + // Shaders + AddDispatch( REBLUR_ClassifyTiles, REBLUR_ClassifyTiles, 1 ); } for (int i = 0; i < REBLUR_OCCLUSION_HITDIST_RECONSTRUCTION_PERMUTATION_NUM; i++) @@ -85,13 +75,13 @@ void nrd::InstanceImpl::Add_ReblurDiffuseOcclusion(DenoiserData& denoiserData) // Shaders if (is5x5) { - AddDispatch( REBLUR_DiffuseOcclusion_HitDistReconstruction_5x5, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseOcclusion_HitDistReconstruction_5x5, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseOcclusion_HitDistReconstruction_5x5, REBLUR_HitDistReconstruction, 1 ); + AddDispatch( REBLUR_Perf_DiffuseOcclusion_HitDistReconstruction_5x5, REBLUR_HitDistReconstruction, 1 ); } else { - AddDispatch( REBLUR_DiffuseOcclusion_HitDistReconstruction, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseOcclusion_HitDistReconstruction, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseOcclusion_HitDistReconstruction, REBLUR_HitDistReconstruction, 1 ); + AddDispatch( REBLUR_Perf_DiffuseOcclusion_HitDistReconstruction, REBLUR_HitDistReconstruction, 1 ); } } } @@ -124,90 +114,78 @@ void nrd::InstanceImpl::Add_ReblurDiffuseOcclusion(DenoiserData& denoiserData) PushOutput( AsUint(Transient::DATA1) ); // Shaders - AddDispatch( REBLUR_DiffuseOcclusion_TemporalAccumulation, REBLUR_TEMPORAL_ACCUMULATION_CONSTANT_NUM, REBLUR_TEMPORAL_ACCUMULATION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseOcclusion_TemporalAccumulation, REBLUR_TEMPORAL_ACCUMULATION_CONSTANT_NUM, REBLUR_TEMPORAL_ACCUMULATION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseOcclusion_TemporalAccumulation, REBLUR_TemporalAccumulation, 1 ); + AddDispatch( REBLUR_Perf_DiffuseOcclusion_TemporalAccumulation, REBLUR_TemporalAccumulation, 1 ); } } - for (int i = 0; i < REBLUR_OCCLUSION_HISTORY_FIX_PERMUTATION_NUM; i++) + PushPass("History fix"); { - PushPass("History fix"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(Transient::DATA1) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( DIFF_TEMP2 ); - PushInput( AsUint(Transient::DIFF_FAST_HISTORY) ); - - // Outputs - PushOutput( DIFF_TEMP1 ); - PushOutput( AsUint(Permanent::DIFF_FAST_HISTORY) ); - - // Shaders - AddDispatch( REBLUR_DiffuseOcclusion_HistoryFix, REBLUR_HISTORY_FIX_CONSTANT_NUM, REBLUR_HISTORY_FIX_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseOcclusion_HistoryFix, REBLUR_HISTORY_FIX_CONSTANT_NUM, REBLUR_HISTORY_FIX_NUM_THREADS, 1 ); - } + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(Transient::DATA1) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( DIFF_TEMP2 ); + PushInput( AsUint(Transient::DIFF_FAST_HISTORY) ); + + // Outputs + PushOutput( DIFF_TEMP1 ); + PushOutput( AsUint(Permanent::DIFF_FAST_HISTORY) ); + + // Shaders + AddDispatch( REBLUR_DiffuseOcclusion_HistoryFix, REBLUR_HistoryFix, 1 ); + AddDispatch( REBLUR_Perf_DiffuseOcclusion_HistoryFix, REBLUR_HistoryFix, 1 ); } - for (int i = 0; i < REBLUR_OCCLUSION_BLUR_PERMUTATION_NUM; i++) + PushPass("Blur"); { - PushPass("Blur"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(Transient::DATA1) ); - PushInput( DIFF_TEMP1 ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - - // Outputs - PushOutput( DIFF_TEMP2 ); - PushOutput( AsUint(Permanent::PREV_VIEWZ) ); - - // Shaders - AddDispatch( REBLUR_DiffuseOcclusion_Blur, REBLUR_BLUR_CONSTANT_NUM, REBLUR_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseOcclusion_Blur, REBLUR_BLUR_CONSTANT_NUM, REBLUR_BLUR_NUM_THREADS, 1 ); - } + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(Transient::DATA1) ); + PushInput( DIFF_TEMP1 ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + + // Outputs + PushOutput( DIFF_TEMP2 ); + PushOutput( AsUint(Permanent::PREV_VIEWZ) ); + + // Shaders + AddDispatch( REBLUR_DiffuseOcclusion_Blur, REBLUR_Blur, 1 ); + AddDispatch( REBLUR_Perf_DiffuseOcclusion_Blur, REBLUR_Blur, 1 ); } - for (int i = 0; i < REBLUR_OCCLUSION_POST_BLUR_PERMUTATION_NUM; i++) + PushPass("Post-blur"); { - PushPass("Post-blur"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(Transient::DATA1) ); - PushInput( DIFF_TEMP2 ); - PushInput( AsUint(Permanent::PREV_VIEWZ) ); - - // Outputs - PushOutput( AsUint(Permanent::PREV_NORMAL_ROUGHNESS) ); - PushOutput( AsUint(ResourceType::OUT_DIFF_HITDIST) ); - PushOutput( AsUint(Permanent::PREV_INTERNAL_DATA) ); - - // Shaders - AddDispatch( REBLUR_DiffuseOcclusion_PostBlur_NoTemporalStabilization, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseOcclusion_PostBlur_NoTemporalStabilization, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); - } + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(Transient::DATA1) ); + PushInput( DIFF_TEMP2 ); + PushInput( AsUint(Permanent::PREV_VIEWZ) ); + + // Outputs + PushOutput( AsUint(Permanent::PREV_NORMAL_ROUGHNESS) ); + PushOutput( AsUint(ResourceType::OUT_DIFF_HITDIST) ); + PushOutput( AsUint(Permanent::PREV_INTERNAL_DATA) ); + + // Shaders + AddDispatch( REBLUR_DiffuseOcclusion_PostBlur_NoTemporalStabilization, REBLUR_PostBlur, 1 ); + AddDispatch( REBLUR_Perf_DiffuseOcclusion_PostBlur_NoTemporalStabilization, REBLUR_PostBlur, 1 ); } - for (int i = 0; i < REBLUR_OCCLUSION_SPLIT_SCREEN_PERMUTATION_NUM; i++) + PushPass("Split screen"); { - PushPass("Split screen"); - { - // Inputs - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(ResourceType::IN_DIFF_HITDIST) ); + // Inputs + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( AsUint(ResourceType::IN_DIFF_HITDIST) ); - // Outputs - PushOutput( AsUint(ResourceType::OUT_DIFF_HITDIST) ); + // Outputs + PushOutput( AsUint(ResourceType::OUT_DIFF_HITDIST) ); - // Shaders - AddDispatch( REBLUR_Diffuse_SplitScreen, REBLUR_SPLIT_SCREEN_CONSTANT_NUM, REBLUR_SPLIT_SCREEN_NUM_THREADS, 1 ); - } + // Shaders + AddDispatch( REBLUR_Diffuse_SplitScreen, REBLUR_SplitScreen, 1 ); } REBLUR_ADD_VALIDATION_DISPATCH( Transient::DATA1, ResourceType::IN_DIFF_HITDIST, ResourceType::IN_DIFF_HITDIST ); diff --git a/Source/Denoisers/Reblur_DiffuseSh.hpp b/Source/Denoisers/Reblur_DiffuseSh.hpp index 59d90fc..e28dbd3 100644 --- a/Source/Denoisers/Reblur_DiffuseSh.hpp +++ b/Source/Denoisers/Reblur_DiffuseSh.hpp @@ -19,11 +19,6 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSh(DenoiserData& denoiserData) denoiserData.settings.reblur = ReblurSettings(); denoiserData.settingsSize = sizeof(denoiserData.settings.reblur); - uint16_t w = denoiserData.desc.renderWidth; - uint16_t h = denoiserData.desc.renderHeight; - uint16_t tilesW = DivideUp(w, 16); - uint16_t tilesH = DivideUp(h, 16); - enum class Permanent { PREV_VIEWZ = PERMANENT_POOL_START, @@ -34,12 +29,12 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSh(DenoiserData& denoiserData) DIFF_SH_HISTORY, }; - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_VIEWZ, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_NORMAL_ROUGHNESS, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_INTERNAL_DATA, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_FAST_HISTORY, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT, w, h, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_VIEWZ, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_NORMAL_ROUGHNESS, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_INTERNAL_DATA, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_FAST_HISTORY, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT, 1} ); enum class Transient { @@ -53,30 +48,25 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSh(DenoiserData& denoiserData) TILES, }; - AddTextureToTransientPool( {Format::RG8_UNORM, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UINT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_FAST_HISTORY, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, tilesW, tilesH, 1} ); - - REBLUR_SET_SHARED_CONSTANTS; + AddTextureToTransientPool( {Format::RG8_UNORM, 1} ); + AddTextureToTransientPool( {Format::R8_UINT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_FAST_HISTORY, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT, 1} ); + AddTextureToTransientPool( {Format::R8_UNORM, 16} ); - for (int i = 0; i < REBLUR_CLASSIFY_TILES_PERMUTATION_NUM; i++) + PushPass("Classify tiles"); { - PushPass("Classify tiles"); - { - // Inputs - PushInput( AsUint(ResourceType::IN_VIEWZ) ); + // Inputs + PushInput( AsUint(ResourceType::IN_VIEWZ) ); - // Outputs - PushOutput( AsUint(Transient::TILES) ); + // Outputs + PushOutput( AsUint(Transient::TILES) ); - // Shaders - AddDispatch( REBLUR_ClassifyTiles, REBLUR_CLASSIFY_TILES_CONSTANT_NUM, REBLUR_CLASSIFY_TILES_NUM_THREADS, 1 ); - } + // Shaders + AddDispatch( REBLUR_ClassifyTiles, REBLUR_ClassifyTiles, 1 ); } for (int i = 0; i < REBLUR_HITDIST_RECONSTRUCTION_PERMUTATION_NUM; i++) @@ -98,13 +88,13 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSh(DenoiserData& denoiserData) // Shaders if (is5x5) { - AddDispatch( REBLUR_Diffuse_HitDistReconstruction_5x5, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_Diffuse_HitDistReconstruction_5x5, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_Diffuse_HitDistReconstruction_5x5, REBLUR_HitDistReconstruction, 1 ); + AddDispatch( REBLUR_Perf_Diffuse_HitDistReconstruction_5x5, REBLUR_HitDistReconstruction, 1 ); } else { - AddDispatch( REBLUR_Diffuse_HitDistReconstruction, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_Diffuse_HitDistReconstruction, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_Diffuse_HitDistReconstruction, REBLUR_HitDistReconstruction, 1 ); + AddDispatch( REBLUR_Perf_Diffuse_HitDistReconstruction, REBLUR_HitDistReconstruction, 1 ); } } } @@ -127,8 +117,8 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSh(DenoiserData& denoiserData) PushOutput( DIFF_SH_TEMP1 ); // Shaders - AddDispatch( REBLUR_DiffuseSh_PrePass, REBLUR_PREPASS_CONSTANT_NUM, REBLUR_PREPASS_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSh_PrePass, REBLUR_PREPASS_CONSTANT_NUM, REBLUR_PREPASS_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseSh_PrePass, REBLUR_PrePass, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSh_PrePass, REBLUR_PrePass, 1 ); } } @@ -165,56 +155,50 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSh(DenoiserData& denoiserData) PushOutput( DIFF_SH_TEMP2 ); // Shaders - AddDispatch( REBLUR_DiffuseSh_TemporalAccumulation, REBLUR_TEMPORAL_ACCUMULATION_CONSTANT_NUM, REBLUR_TEMPORAL_ACCUMULATION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSh_TemporalAccumulation, REBLUR_TEMPORAL_ACCUMULATION_CONSTANT_NUM, REBLUR_TEMPORAL_ACCUMULATION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseSh_TemporalAccumulation, REBLUR_TemporalAccumulation, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSh_TemporalAccumulation, REBLUR_TemporalAccumulation, 1 ); } } - for (int i = 0; i < REBLUR_HISTORY_FIX_PERMUTATION_NUM; i++) + PushPass("History fix"); { - PushPass("History fix"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(Transient::DATA1) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( DIFF_TEMP2 ); - PushInput( AsUint(Transient::DIFF_FAST_HISTORY) ); - PushInput( DIFF_SH_TEMP2 ); - - // Outputs - PushOutput( DIFF_TEMP1 ); - PushOutput( AsUint(Permanent::DIFF_FAST_HISTORY) ); - PushOutput( DIFF_SH_TEMP1 ); - - // Shaders - AddDispatch( REBLUR_DiffuseSh_HistoryFix, REBLUR_HISTORY_FIX_CONSTANT_NUM, REBLUR_HISTORY_FIX_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSh_HistoryFix, REBLUR_HISTORY_FIX_CONSTANT_NUM, REBLUR_HISTORY_FIX_NUM_THREADS, 1 ); - } + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(Transient::DATA1) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( DIFF_TEMP2 ); + PushInput( AsUint(Transient::DIFF_FAST_HISTORY) ); + PushInput( DIFF_SH_TEMP2 ); + + // Outputs + PushOutput( DIFF_TEMP1 ); + PushOutput( AsUint(Permanent::DIFF_FAST_HISTORY) ); + PushOutput( DIFF_SH_TEMP1 ); + + // Shaders + AddDispatch( REBLUR_DiffuseSh_HistoryFix, REBLUR_HistoryFix, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSh_HistoryFix, REBLUR_HistoryFix, 1 ); } - for (int i = 0; i < REBLUR_BLUR_PERMUTATION_NUM; i++) + PushPass("Blur"); { - PushPass("Blur"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(Transient::DATA1) ); - PushInput( DIFF_TEMP1 ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( DIFF_SH_TEMP1 ); - - // Outputs - PushOutput( DIFF_TEMP2 ); - PushOutput( AsUint(Permanent::PREV_VIEWZ) ); - PushOutput( DIFF_SH_TEMP2 ); - - // Shaders - AddDispatch( REBLUR_DiffuseSh_Blur, REBLUR_BLUR_CONSTANT_NUM, REBLUR_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSh_Blur, REBLUR_BLUR_CONSTANT_NUM, REBLUR_BLUR_NUM_THREADS, 1 ); - } + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(Transient::DATA1) ); + PushInput( DIFF_TEMP1 ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( DIFF_SH_TEMP1 ); + + // Outputs + PushOutput( DIFF_TEMP2 ); + PushOutput( AsUint(Permanent::PREV_VIEWZ) ); + PushOutput( DIFF_SH_TEMP2 ); + + // Shaders + AddDispatch( REBLUR_DiffuseSh_Blur, REBLUR_Blur, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSh_Blur, REBLUR_Blur, 1 ); } for (int i = 0; i < REBLUR_POST_BLUR_PERMUTATION_NUM; i++) @@ -249,33 +233,30 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSh(DenoiserData& denoiserData) // Shaders if (isTemporalStabilization) { - AddDispatch( REBLUR_DiffuseSh_PostBlur, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSh_PostBlur, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseSh_PostBlur, REBLUR_PostBlur, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSh_PostBlur, REBLUR_PostBlur, 1 ); } else { - AddDispatch( REBLUR_DiffuseSh_PostBlur_NoTemporalStabilization, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSh_PostBlur_NoTemporalStabilization, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseSh_PostBlur_NoTemporalStabilization, REBLUR_PostBlur, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSh_PostBlur_NoTemporalStabilization, REBLUR_PostBlur, 1 ); } } } - for (int i = 0; i < REBLUR_COPY_STABILIZED_HISTORY_PERMUTATION_NUM; i++) + PushPass("Copy"); { - PushPass("Copy stabilized history"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::OUT_DIFF_SH0) ); - PushInput( AsUint(ResourceType::OUT_DIFF_SH1) ); + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::OUT_DIFF_SH0) ); + PushInput( AsUint(ResourceType::OUT_DIFF_SH1) ); - // Outputs - PushOutput( DIFF_TEMP2 ); - PushOutput( DIFF_SH_TEMP2 ); + // Outputs + PushOutput( DIFF_TEMP2 ); + PushOutput( DIFF_SH_TEMP2 ); - // Shaders - AddDispatch( REBLUR_DiffuseSh_CopyStabilizedHistory, REBLUR_COPY_STABILIZED_HISTORY_CONSTANT_NUM, REBLUR_COPY_STABILIZED_HISTORY_NUM_THREADS, USE_MAX_DIMS ); - } + // Shaders + AddDispatch( REBLUR_DiffuseSh_Copy, REBLUR_Copy, USE_MAX_DIMS ); } for (int i = 0; i < REBLUR_TEMPORAL_STABILIZATION_PERMUTATION_NUM; i++) @@ -300,27 +281,24 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSh(DenoiserData& denoiserData) PushOutput( AsUint(ResourceType::OUT_DIFF_SH1) ); // Shaders - AddDispatch( REBLUR_DiffuseSh_TemporalStabilization, REBLUR_TEMPORAL_STABILIZATION_CONSTANT_NUM, REBLUR_TEMPORAL_STABILIZATION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSh_TemporalStabilization, REBLUR_TEMPORAL_STABILIZATION_CONSTANT_NUM, REBLUR_TEMPORAL_STABILIZATION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseSh_TemporalStabilization, REBLUR_TemporalStabilization, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSh_TemporalStabilization, REBLUR_TemporalStabilization, 1 ); } } - for (int i = 0; i < REBLUR_SPLIT_SCREEN_PERMUTATION_NUM; i++) + PushPass("Split screen"); { - PushPass("Split screen"); - { - // Inputs - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(ResourceType::IN_DIFF_SH0) ); - PushInput( AsUint(ResourceType::IN_DIFF_SH1) ); + // Inputs + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( AsUint(ResourceType::IN_DIFF_SH0) ); + PushInput( AsUint(ResourceType::IN_DIFF_SH1) ); - // Outputs - PushOutput( AsUint(ResourceType::OUT_DIFF_SH0) ); - PushOutput( AsUint(ResourceType::OUT_DIFF_SH1) ); + // Outputs + PushOutput( AsUint(ResourceType::OUT_DIFF_SH0) ); + PushOutput( AsUint(ResourceType::OUT_DIFF_SH1) ); - // Shaders - AddDispatch( REBLUR_DiffuseSh_SplitScreen, REBLUR_SPLIT_SCREEN_CONSTANT_NUM, REBLUR_SPLIT_SCREEN_NUM_THREADS, 1 ); - } + // Shaders + AddDispatch( REBLUR_DiffuseSh_SplitScreen, REBLUR_SplitScreen, 1 ); } REBLUR_ADD_VALIDATION_DISPATCH( Transient::DATA2, ResourceType::IN_DIFF_SH0, ResourceType::IN_DIFF_SH0 ); diff --git a/Source/Denoisers/Reblur_DiffuseSpecular.hpp b/Source/Denoisers/Reblur_DiffuseSpecular.hpp index 936cd7b..f441a93 100644 --- a/Source/Denoisers/Reblur_DiffuseSpecular.hpp +++ b/Source/Denoisers/Reblur_DiffuseSpecular.hpp @@ -19,11 +19,6 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSpecular(DenoiserData& denoiserData) denoiserData.settings.reblur = ReblurSettings(); denoiserData.settingsSize = sizeof(denoiserData.settings.reblur); - uint16_t w = denoiserData.desc.renderWidth; - uint16_t h = denoiserData.desc.renderHeight; - uint16_t tilesW = DivideUp(w, 16); - uint16_t tilesH = DivideUp(h, 16); - enum class Permanent { PREV_VIEWZ = PERMANENT_POOL_START, @@ -37,15 +32,15 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSpecular(DenoiserData& denoiserData) SPEC_HITDIST_FOR_TRACKING_PONG, }; - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_VIEWZ, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_NORMAL_ROUGHNESS, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_INTERNAL_DATA, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_FAST_HISTORY, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_FAST_HISTORY, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, w, h, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_VIEWZ, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_NORMAL_ROUGHNESS, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_INTERNAL_DATA, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_FAST_HISTORY, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_FAST_HISTORY, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, 1} ); enum class Transient { @@ -61,32 +56,27 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSpecular(DenoiserData& denoiserData) TILES, }; - AddTextureToTransientPool( {Format::RGBA8_UNORM, w, h, 1} ); - AddTextureToTransientPool( {Format::R32_UINT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_FAST_HISTORY, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_FAST_HISTORY, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, tilesW, tilesH, 1} ); - - REBLUR_SET_SHARED_CONSTANTS; - - for (int i = 0; i < REBLUR_CLASSIFY_TILES_PERMUTATION_NUM; i++) + AddTextureToTransientPool( {Format::RGBA8_UNORM, 1} ); + AddTextureToTransientPool( {Format::R32_UINT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_FAST_HISTORY, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_FAST_HISTORY, 1} ); + AddTextureToTransientPool( {Format::R8_UNORM, 16} ); + + PushPass("Classify tiles"); { - PushPass("Classify tiles"); - { - // Inputs - PushInput( AsUint(ResourceType::IN_VIEWZ) ); + // Inputs + PushInput( AsUint(ResourceType::IN_VIEWZ) ); - // Outputs - PushOutput( AsUint(Transient::TILES) ); + // Outputs + PushOutput( AsUint(Transient::TILES) ); - // Shaders - AddDispatch( REBLUR_ClassifyTiles, REBLUR_CLASSIFY_TILES_CONSTANT_NUM, REBLUR_CLASSIFY_TILES_NUM_THREADS, 1 ); - } + // Shaders + AddDispatch( REBLUR_ClassifyTiles, REBLUR_ClassifyTiles, 1 ); } for (int i = 0; i < REBLUR_HITDIST_RECONSTRUCTION_PERMUTATION_NUM; i++) @@ -110,13 +100,13 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSpecular(DenoiserData& denoiserData) // Shaders if (is5x5) { - AddDispatch( REBLUR_DiffuseSpecular_HitDistReconstruction_5x5, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSpecular_HitDistReconstruction_5x5, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseSpecular_HitDistReconstruction_5x5, REBLUR_HitDistReconstruction, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSpecular_HitDistReconstruction_5x5, REBLUR_HitDistReconstruction, 1 ); } else { - AddDispatch( REBLUR_DiffuseSpecular_HitDistReconstruction, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSpecular_HitDistReconstruction, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseSpecular_HitDistReconstruction, REBLUR_HitDistReconstruction, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSpecular_HitDistReconstruction, REBLUR_HitDistReconstruction, 1 ); } } } @@ -140,8 +130,8 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSpecular(DenoiserData& denoiserData) PushOutput( AsUint(Transient::SPEC_HITDIST_FOR_TRACKING) ); // Shaders - AddDispatch( REBLUR_DiffuseSpecular_PrePass, REBLUR_PREPASS_CONSTANT_NUM, REBLUR_PREPASS_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSpecular_PrePass, REBLUR_PREPASS_CONSTANT_NUM, REBLUR_PREPASS_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseSpecular_PrePass, REBLUR_PrePass, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSpecular_PrePass, REBLUR_PrePass, 1 ); } } @@ -171,7 +161,7 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSpecular(DenoiserData& denoiserData) PushInput( isTemporalStabilization ? AsUint(Permanent::SPEC_HISTORY) : AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); PushInput( AsUint(Permanent::DIFF_FAST_HISTORY) ); PushInput( AsUint(Permanent::SPEC_FAST_HISTORY) ); - PushInput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING), 0, 1, AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG) ); + PushInput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING), AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG) ); PushInput( AsUint(Transient::SPEC_HITDIST_FOR_TRACKING) ); // Outputs @@ -179,63 +169,57 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSpecular(DenoiserData& denoiserData) PushOutput( SPEC_TEMP2 ); PushOutput( AsUint(Transient::DIFF_FAST_HISTORY) ); PushOutput( AsUint(Transient::SPEC_FAST_HISTORY) ); - PushOutput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG), 0, 1, AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING) ); + PushOutput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG), AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING) ); PushOutput( AsUint(Transient::DATA1) ); PushOutput( AsUint(Transient::DATA2) ); // Shaders - AddDispatch( REBLUR_DiffuseSpecular_TemporalAccumulation, REBLUR_TEMPORAL_ACCUMULATION_CONSTANT_NUM, REBLUR_TEMPORAL_ACCUMULATION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSpecular_TemporalAccumulation, REBLUR_TEMPORAL_ACCUMULATION_CONSTANT_NUM, REBLUR_TEMPORAL_ACCUMULATION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseSpecular_TemporalAccumulation, REBLUR_TemporalAccumulation, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSpecular_TemporalAccumulation, REBLUR_TemporalAccumulation, 1 ); } } - for (int i = 0; i < REBLUR_HISTORY_FIX_PERMUTATION_NUM; i++) + PushPass("History fix"); { - PushPass("History fix"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(Transient::DATA1) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( DIFF_TEMP2 ); - PushInput( SPEC_TEMP2 ); - PushInput( AsUint(Transient::DIFF_FAST_HISTORY) ); - PushInput( AsUint(Transient::SPEC_FAST_HISTORY) ); - - // Outputs - PushOutput( DIFF_TEMP1 ); - PushOutput( SPEC_TEMP1 ); - PushOutput( AsUint(Permanent::DIFF_FAST_HISTORY) ); - PushOutput( AsUint(Permanent::SPEC_FAST_HISTORY) ); - - // Shaders - AddDispatch( REBLUR_DiffuseSpecular_HistoryFix, REBLUR_HISTORY_FIX_CONSTANT_NUM, REBLUR_HISTORY_FIX_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSpecular_HistoryFix, REBLUR_HISTORY_FIX_CONSTANT_NUM, REBLUR_HISTORY_FIX_NUM_THREADS, 1 ); - } + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(Transient::DATA1) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( DIFF_TEMP2 ); + PushInput( SPEC_TEMP2 ); + PushInput( AsUint(Transient::DIFF_FAST_HISTORY) ); + PushInput( AsUint(Transient::SPEC_FAST_HISTORY) ); + + // Outputs + PushOutput( DIFF_TEMP1 ); + PushOutput( SPEC_TEMP1 ); + PushOutput( AsUint(Permanent::DIFF_FAST_HISTORY) ); + PushOutput( AsUint(Permanent::SPEC_FAST_HISTORY) ); + + // Shaders + AddDispatch( REBLUR_DiffuseSpecular_HistoryFix, REBLUR_HistoryFix, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSpecular_HistoryFix, REBLUR_HistoryFix, 1 ); } - for (int i = 0; i < REBLUR_BLUR_PERMUTATION_NUM; i++) + PushPass("Blur"); { - PushPass("Blur"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(Transient::DATA1) ); - PushInput( DIFF_TEMP1 ); - PushInput( SPEC_TEMP1 ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - - // Outputs - PushOutput( DIFF_TEMP2 ); - PushOutput( SPEC_TEMP2 ); - PushOutput( AsUint(Permanent::PREV_VIEWZ) ); - - // Shaders - AddDispatch( REBLUR_DiffuseSpecular_Blur, REBLUR_BLUR_CONSTANT_NUM, REBLUR_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSpecular_Blur, REBLUR_BLUR_CONSTANT_NUM, REBLUR_BLUR_NUM_THREADS, 1 ); - } + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(Transient::DATA1) ); + PushInput( DIFF_TEMP1 ); + PushInput( SPEC_TEMP1 ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + + // Outputs + PushOutput( DIFF_TEMP2 ); + PushOutput( SPEC_TEMP2 ); + PushOutput( AsUint(Permanent::PREV_VIEWZ) ); + + // Shaders + AddDispatch( REBLUR_DiffuseSpecular_Blur, REBLUR_Blur, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSpecular_Blur, REBLUR_Blur, 1 ); } for (int i = 0; i < REBLUR_POST_BLUR_PERMUTATION_NUM; i++) @@ -270,33 +254,30 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSpecular(DenoiserData& denoiserData) // Shaders if (isTemporalStabilization) { - AddDispatch( REBLUR_DiffuseSpecular_PostBlur, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSpecular_PostBlur, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseSpecular_PostBlur, REBLUR_PostBlur, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSpecular_PostBlur, REBLUR_PostBlur, 1 ); } else { - AddDispatch( REBLUR_DiffuseSpecular_PostBlur_NoTemporalStabilization, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSpecular_PostBlur_NoTemporalStabilization, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseSpecular_PostBlur_NoTemporalStabilization, REBLUR_PostBlur, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSpecular_PostBlur_NoTemporalStabilization, REBLUR_PostBlur, 1 ); } } } - for (int i = 0; i < REBLUR_COPY_STABILIZED_HISTORY_PERMUTATION_NUM; i++) + PushPass("Copy"); { - PushPass("Copy stabilized history"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); - PushInput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); + PushInput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); - // Outputs - PushOutput( DIFF_TEMP2 ); - PushOutput( SPEC_TEMP2 ); + // Outputs + PushOutput( DIFF_TEMP2 ); + PushOutput( SPEC_TEMP2 ); - // Shaders - AddDispatch( REBLUR_DiffuseSpecular_CopyStabilizedHistory, REBLUR_COPY_STABILIZED_HISTORY_CONSTANT_NUM, REBLUR_COPY_STABILIZED_HISTORY_NUM_THREADS, USE_MAX_DIMS ); - } + // Shaders + AddDispatch( REBLUR_DiffuseSpecular_Copy, REBLUR_Copy, USE_MAX_DIMS ); } for (int i = 0; i < REBLUR_TEMPORAL_STABILIZATION_PERMUTATION_NUM; i++) @@ -316,7 +297,7 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSpecular(DenoiserData& denoiserData) PushInput( AsUint(Permanent::SPEC_HISTORY) ); PushInput( DIFF_TEMP2 ); PushInput( SPEC_TEMP2 ); - PushInput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG), 0, 1, AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING) ); + PushInput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG), AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING) ); // Outputs PushOutput( AsUint(ResourceType::IN_MV) ); @@ -325,27 +306,24 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSpecular(DenoiserData& denoiserData) PushOutput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); // Shaders - AddDispatch( REBLUR_DiffuseSpecular_TemporalStabilization, REBLUR_TEMPORAL_STABILIZATION_CONSTANT_NUM, REBLUR_TEMPORAL_STABILIZATION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSpecular_TemporalStabilization, REBLUR_TEMPORAL_STABILIZATION_CONSTANT_NUM, REBLUR_TEMPORAL_STABILIZATION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseSpecular_TemporalStabilization, REBLUR_TemporalStabilization, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSpecular_TemporalStabilization, REBLUR_TemporalStabilization, 1 ); } } - for (int i = 0; i < REBLUR_SPLIT_SCREEN_PERMUTATION_NUM; i++) + PushPass("Split screen"); { - PushPass("Split screen"); - { - // Inputs - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(ResourceType::IN_DIFF_RADIANCE_HITDIST) ); - PushInput( AsUint(ResourceType::IN_SPEC_RADIANCE_HITDIST) ); + // Inputs + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( AsUint(ResourceType::IN_DIFF_RADIANCE_HITDIST) ); + PushInput( AsUint(ResourceType::IN_SPEC_RADIANCE_HITDIST) ); - // Outputs - PushOutput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); - PushOutput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); + // Outputs + PushOutput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); + PushOutput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); - // Shaders - AddDispatch( REBLUR_DiffuseSpecular_SplitScreen, REBLUR_SPLIT_SCREEN_CONSTANT_NUM, REBLUR_SPLIT_SCREEN_NUM_THREADS, 1 ); - } + // Shaders + AddDispatch( REBLUR_DiffuseSpecular_SplitScreen, REBLUR_SplitScreen, 1 ); } REBLUR_ADD_VALIDATION_DISPATCH( Transient::DATA2, ResourceType::IN_DIFF_RADIANCE_HITDIST, ResourceType::IN_SPEC_RADIANCE_HITDIST ); diff --git a/Source/Denoisers/Reblur_DiffuseSpecularOcclusion.hpp b/Source/Denoisers/Reblur_DiffuseSpecularOcclusion.hpp index 282a4e3..5838db7 100644 --- a/Source/Denoisers/Reblur_DiffuseSpecularOcclusion.hpp +++ b/Source/Denoisers/Reblur_DiffuseSpecularOcclusion.hpp @@ -19,11 +19,6 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSpecularOcclusion(DenoiserData& denoise denoiserData.settings.reblur = ReblurSettings(); denoiserData.settingsSize = sizeof(denoiserData.settings.reblur); - uint16_t w = denoiserData.desc.renderWidth; - uint16_t h = denoiserData.desc.renderHeight; - uint16_t tilesW = DivideUp(w, 16); - uint16_t tilesH = DivideUp(h, 16); - enum class Permanent { PREV_VIEWZ = PERMANENT_POOL_START, @@ -35,13 +30,13 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSpecularOcclusion(DenoiserData& denoise SPEC_HITDIST_FOR_TRACKING_PONG, }; - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_VIEWZ, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_NORMAL_ROUGHNESS, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_INTERNAL_DATA, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_OCCLUSION_FAST_HISTORY, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_OCCLUSION_FAST_HISTORY, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, w, h, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_VIEWZ, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_NORMAL_ROUGHNESS, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_INTERNAL_DATA, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_OCCLUSION_FAST_HISTORY, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_OCCLUSION_FAST_HISTORY, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, 1} ); enum class Transient { @@ -55,30 +50,25 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSpecularOcclusion(DenoiserData& denoise TILES, }; - AddTextureToTransientPool( {Format::RGBA8_UNORM, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_OCCLUSION, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_OCCLUSION, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_OCCLUSION_FAST_HISTORY, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_OCCLUSION, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_OCCLUSION, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_OCCLUSION_FAST_HISTORY, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, tilesW, tilesH, 1} ); - - REBLUR_SET_SHARED_CONSTANTS; + AddTextureToTransientPool( {Format::RGBA8_UNORM, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_OCCLUSION, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_OCCLUSION, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_OCCLUSION_FAST_HISTORY, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_OCCLUSION, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_OCCLUSION, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_OCCLUSION_FAST_HISTORY, 1} ); + AddTextureToTransientPool( {Format::R8_UNORM, 16} ); - for (int i = 0; i < REBLUR_CLASSIFY_TILES_PERMUTATION_NUM; i++) + PushPass("Classify tiles"); { - PushPass("Classify tiles"); - { - // Inputs - PushInput( AsUint(ResourceType::IN_VIEWZ) ); + // Inputs + PushInput( AsUint(ResourceType::IN_VIEWZ) ); - // Outputs - PushOutput( AsUint(Transient::TILES) ); + // Outputs + PushOutput( AsUint(Transient::TILES) ); - // Shaders - AddDispatch( REBLUR_ClassifyTiles, REBLUR_CLASSIFY_TILES_CONSTANT_NUM, REBLUR_CLASSIFY_TILES_NUM_THREADS, 1 ); - } + // Shaders + AddDispatch( REBLUR_ClassifyTiles, REBLUR_ClassifyTiles, 1 ); } for (int i = 0; i < REBLUR_OCCLUSION_HITDIST_RECONSTRUCTION_PERMUTATION_NUM; i++) @@ -101,13 +91,13 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSpecularOcclusion(DenoiserData& denoise // Shaders if (is5x5) { - AddDispatch( REBLUR_DiffuseSpecularOcclusion_HitDistReconstruction_5x5, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSpecularOcclusion_HitDistReconstruction_5x5, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseSpecularOcclusion_HitDistReconstruction_5x5, REBLUR_HitDistReconstruction, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSpecularOcclusion_HitDistReconstruction_5x5, REBLUR_HitDistReconstruction, 1 ); } else { - AddDispatch( REBLUR_DiffuseSpecularOcclusion_HitDistReconstruction, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSpecularOcclusion_HitDistReconstruction, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseSpecularOcclusion_HitDistReconstruction, REBLUR_HitDistReconstruction, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSpecularOcclusion_HitDistReconstruction, REBLUR_HitDistReconstruction, 1 ); } } } @@ -137,111 +127,99 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSpecularOcclusion(DenoiserData& denoise PushInput( AsUint(ResourceType::OUT_SPEC_HITDIST) ); PushInput( AsUint(Permanent::DIFF_FAST_HISTORY) ); PushInput( AsUint(Permanent::SPEC_FAST_HISTORY) ); - PushInput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING), 0, 1, AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG) ); + PushInput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING), AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG) ); // Outputs PushOutput( DIFF_TEMP2 ); PushOutput( SPEC_TEMP2 ); PushOutput( AsUint(Transient::DIFF_FAST_HISTORY) ); PushOutput( AsUint(Transient::SPEC_FAST_HISTORY) ); - PushOutput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG), 0, 1, AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING) ); + PushOutput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG), AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING) ); PushOutput( AsUint(Transient::DATA1) ); // Shaders - AddDispatch( REBLUR_DiffuseSpecularOcclusion_TemporalAccumulation, REBLUR_TEMPORAL_ACCUMULATION_CONSTANT_NUM, REBLUR_TEMPORAL_ACCUMULATION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSpecularOcclusion_TemporalAccumulation, REBLUR_TEMPORAL_ACCUMULATION_CONSTANT_NUM, REBLUR_TEMPORAL_ACCUMULATION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseSpecularOcclusion_TemporalAccumulation, REBLUR_TemporalAccumulation, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSpecularOcclusion_TemporalAccumulation, REBLUR_TemporalAccumulation, 1 ); } } - for (int i = 0; i < REBLUR_OCCLUSION_HISTORY_FIX_PERMUTATION_NUM; i++) + PushPass("History fix"); { - PushPass("History fix"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(Transient::DATA1) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( DIFF_TEMP2 ); - PushInput( SPEC_TEMP2 ); - PushInput( AsUint(Transient::DIFF_FAST_HISTORY) ); - PushInput( AsUint(Transient::SPEC_FAST_HISTORY) ); - - // Outputs - PushOutput( DIFF_TEMP1 ); - PushOutput( SPEC_TEMP1 ); - PushOutput( AsUint(Permanent::DIFF_FAST_HISTORY) ); - PushOutput( AsUint(Permanent::SPEC_FAST_HISTORY) ); - - // Shaders - AddDispatch( REBLUR_DiffuseSpecularOcclusion_HistoryFix, REBLUR_HISTORY_FIX_CONSTANT_NUM, REBLUR_HISTORY_FIX_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSpecularOcclusion_HistoryFix, REBLUR_HISTORY_FIX_CONSTANT_NUM, REBLUR_HISTORY_FIX_NUM_THREADS, 1 ); - } + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(Transient::DATA1) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( DIFF_TEMP2 ); + PushInput( SPEC_TEMP2 ); + PushInput( AsUint(Transient::DIFF_FAST_HISTORY) ); + PushInput( AsUint(Transient::SPEC_FAST_HISTORY) ); + + // Outputs + PushOutput( DIFF_TEMP1 ); + PushOutput( SPEC_TEMP1 ); + PushOutput( AsUint(Permanent::DIFF_FAST_HISTORY) ); + PushOutput( AsUint(Permanent::SPEC_FAST_HISTORY) ); + + // Shaders + AddDispatch( REBLUR_DiffuseSpecularOcclusion_HistoryFix, REBLUR_HistoryFix, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSpecularOcclusion_HistoryFix, REBLUR_HistoryFix, 1 ); } - for (int i = 0; i < REBLUR_OCCLUSION_BLUR_PERMUTATION_NUM; i++) + PushPass("Blur"); { - PushPass("Blur"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(Transient::DATA1) ); - PushInput( DIFF_TEMP1 ); - PushInput( SPEC_TEMP1 ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - - // Outputs - PushOutput( DIFF_TEMP2 ); - PushOutput( SPEC_TEMP2 ); - PushOutput( AsUint(Permanent::PREV_VIEWZ) ); - - // Shaders - AddDispatch( REBLUR_DiffuseSpecularOcclusion_Blur, REBLUR_BLUR_CONSTANT_NUM, REBLUR_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSpecularOcclusion_Blur, REBLUR_BLUR_CONSTANT_NUM, REBLUR_BLUR_NUM_THREADS, 1 ); - } + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(Transient::DATA1) ); + PushInput( DIFF_TEMP1 ); + PushInput( SPEC_TEMP1 ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + + // Outputs + PushOutput( DIFF_TEMP2 ); + PushOutput( SPEC_TEMP2 ); + PushOutput( AsUint(Permanent::PREV_VIEWZ) ); + + // Shaders + AddDispatch( REBLUR_DiffuseSpecularOcclusion_Blur, REBLUR_Blur, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSpecularOcclusion_Blur, REBLUR_Blur, 1 ); } - for (int i = 0; i < REBLUR_OCCLUSION_POST_BLUR_PERMUTATION_NUM; i++) + PushPass("Post-blur"); { - PushPass("Post-blur"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(Transient::DATA1) ); - PushInput( DIFF_TEMP2 ); - PushInput( SPEC_TEMP2 ); - PushInput( AsUint(Permanent::PREV_VIEWZ) ); - - // Outputs - PushOutput( AsUint(Permanent::PREV_NORMAL_ROUGHNESS) ); - PushOutput( AsUint(ResourceType::OUT_DIFF_HITDIST) ); - PushOutput( AsUint(ResourceType::OUT_SPEC_HITDIST) ); - PushOutput( AsUint(Permanent::PREV_INTERNAL_DATA) ); - - // Shaders - AddDispatch( REBLUR_DiffuseSpecularOcclusion_PostBlur_NoTemporalStabilization, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSpecularOcclusion_PostBlur_NoTemporalStabilization, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); - } + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(Transient::DATA1) ); + PushInput( DIFF_TEMP2 ); + PushInput( SPEC_TEMP2 ); + PushInput( AsUint(Permanent::PREV_VIEWZ) ); + + // Outputs + PushOutput( AsUint(Permanent::PREV_NORMAL_ROUGHNESS) ); + PushOutput( AsUint(ResourceType::OUT_DIFF_HITDIST) ); + PushOutput( AsUint(ResourceType::OUT_SPEC_HITDIST) ); + PushOutput( AsUint(Permanent::PREV_INTERNAL_DATA) ); + + // Shaders + AddDispatch( REBLUR_DiffuseSpecularOcclusion_PostBlur_NoTemporalStabilization, REBLUR_PostBlur, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSpecularOcclusion_PostBlur_NoTemporalStabilization, REBLUR_PostBlur, 1 ); } - for (int i = 0; i < REBLUR_OCCLUSION_SPLIT_SCREEN_PERMUTATION_NUM; i++) + PushPass("Split screen"); { - PushPass("Split screen"); - { - // Inputs - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(ResourceType::IN_DIFF_HITDIST) ); - PushInput( AsUint(ResourceType::IN_SPEC_HITDIST) ); + // Inputs + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( AsUint(ResourceType::IN_DIFF_HITDIST) ); + PushInput( AsUint(ResourceType::IN_SPEC_HITDIST) ); - // Outputs - PushOutput( AsUint(ResourceType::OUT_DIFF_HITDIST) ); - PushOutput( AsUint(ResourceType::OUT_SPEC_HITDIST) ); + // Outputs + PushOutput( AsUint(ResourceType::OUT_DIFF_HITDIST) ); + PushOutput( AsUint(ResourceType::OUT_SPEC_HITDIST) ); - // Shaders - AddDispatch( REBLUR_DiffuseSpecular_SplitScreen, REBLUR_SPLIT_SCREEN_CONSTANT_NUM, REBLUR_SPLIT_SCREEN_NUM_THREADS, 1 ); - } + // Shaders + AddDispatch( REBLUR_DiffuseSpecular_SplitScreen, REBLUR_SplitScreen, 1 ); } REBLUR_ADD_VALIDATION_DISPATCH( Transient::DATA1, ResourceType::IN_DIFF_HITDIST, ResourceType::IN_SPEC_HITDIST ); diff --git a/Source/Denoisers/Reblur_DiffuseSpecularSh.hpp b/Source/Denoisers/Reblur_DiffuseSpecularSh.hpp index 1f56014..99360f5 100644 --- a/Source/Denoisers/Reblur_DiffuseSpecularSh.hpp +++ b/Source/Denoisers/Reblur_DiffuseSpecularSh.hpp @@ -23,11 +23,6 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSpecularSh(DenoiserData& denoiserData) denoiserData.settings.reblur = ReblurSettings(); denoiserData.settingsSize = sizeof(denoiserData.settings.reblur); - uint16_t w = denoiserData.desc.renderWidth; - uint16_t h = denoiserData.desc.renderHeight; - uint16_t tilesW = DivideUp(w, 16); - uint16_t tilesH = DivideUp(h, 16); - enum class Permanent { PREV_VIEWZ = PERMANENT_POOL_START, @@ -43,17 +38,17 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSpecularSh(DenoiserData& denoiserData) SPEC_HITDIST_FOR_TRACKING_PONG, }; - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_VIEWZ, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_NORMAL_ROUGHNESS, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_INTERNAL_DATA, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_FAST_HISTORY, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_FAST_HISTORY, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, w, h, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_VIEWZ, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_NORMAL_ROUGHNESS, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_INTERNAL_DATA, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_FAST_HISTORY, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_FAST_HISTORY, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, 1} ); enum class Transient { @@ -73,36 +68,31 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSpecularSh(DenoiserData& denoiserData) TILES, }; - AddTextureToTransientPool( {Format::RGBA8_UNORM, w, h, 1} ); - AddTextureToTransientPool( {Format::R32_UINT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_FAST_HISTORY, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_FAST_HISTORY, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, tilesW, tilesH, 1} ); - - REBLUR_SET_SHARED_CONSTANTS; - - for (int i = 0; i < REBLUR_CLASSIFY_TILES_PERMUTATION_NUM; i++) + AddTextureToTransientPool( {Format::RGBA8_UNORM, 1} ); + AddTextureToTransientPool( {Format::R32_UINT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_FAST_HISTORY, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_FAST_HISTORY, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT, 1} ); + AddTextureToTransientPool( {Format::R8_UNORM, 16} ); + + PushPass("Classify tiles"); { - PushPass("Classify tiles"); - { - // Inputs - PushInput( AsUint(ResourceType::IN_VIEWZ) ); + // Inputs + PushInput( AsUint(ResourceType::IN_VIEWZ) ); - // Outputs - PushOutput( AsUint(Transient::TILES) ); + // Outputs + PushOutput( AsUint(Transient::TILES) ); - // Shaders - AddDispatch( REBLUR_ClassifyTiles, REBLUR_CLASSIFY_TILES_CONSTANT_NUM, REBLUR_CLASSIFY_TILES_NUM_THREADS, 1 ); - } + // Shaders + AddDispatch( REBLUR_ClassifyTiles, REBLUR_ClassifyTiles, 1 ); } for (int i = 0; i < REBLUR_HITDIST_RECONSTRUCTION_PERMUTATION_NUM; i++) @@ -126,13 +116,13 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSpecularSh(DenoiserData& denoiserData) // Shaders if (is5x5) { - AddDispatch( REBLUR_DiffuseSpecular_HitDistReconstruction_5x5, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSpecular_HitDistReconstruction_5x5, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseSpecular_HitDistReconstruction_5x5, REBLUR_HitDistReconstruction, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSpecular_HitDistReconstruction_5x5, REBLUR_HitDistReconstruction, 1 ); } else { - AddDispatch( REBLUR_DiffuseSpecular_HitDistReconstruction, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSpecular_HitDistReconstruction, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseSpecular_HitDistReconstruction, REBLUR_HitDistReconstruction, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSpecular_HitDistReconstruction, REBLUR_HitDistReconstruction, 1 ); } } } @@ -160,8 +150,8 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSpecularSh(DenoiserData& denoiserData) PushOutput( SPEC_SH_TEMP1 ); // Shaders - AddDispatch( REBLUR_DiffuseSpecularSh_PrePass, REBLUR_PREPASS_CONSTANT_NUM, REBLUR_PREPASS_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSpecularSh_PrePass, REBLUR_PREPASS_CONSTANT_NUM, REBLUR_PREPASS_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseSpecularSh_PrePass, REBLUR_PrePass, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSpecularSh_PrePass, REBLUR_PrePass, 1 ); } } @@ -191,7 +181,7 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSpecularSh(DenoiserData& denoiserData) PushInput( isTemporalStabilization ? AsUint(Permanent::SPEC_HISTORY) : AsUint(ResourceType::OUT_SPEC_SH0) ); PushInput( AsUint(Permanent::DIFF_FAST_HISTORY) ); PushInput( AsUint(Permanent::SPEC_FAST_HISTORY) ); - PushInput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING), 0, 1, AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG) ); + PushInput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING), AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG) ); PushInput( AsUint(Transient::SPEC_HITDIST_FOR_TRACKING) ); PushInput( isAfterPrepass ? DIFF_SH_TEMP1 : AsUint(ResourceType::IN_DIFF_SH1) ); PushInput( isAfterPrepass ? SPEC_SH_TEMP1 : AsUint(ResourceType::IN_SPEC_SH1) ); @@ -203,73 +193,67 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSpecularSh(DenoiserData& denoiserData) PushOutput( SPEC_TEMP2 ); PushOutput( AsUint(Transient::DIFF_FAST_HISTORY) ); PushOutput( AsUint(Transient::SPEC_FAST_HISTORY) ); - PushOutput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG), 0, 1, AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING) ); + PushOutput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG), AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING) ); PushOutput( AsUint(Transient::DATA1) ); PushOutput( AsUint(Transient::DATA2) ); PushOutput( DIFF_SH_TEMP2 ); PushOutput( SPEC_SH_TEMP2 ); // Shaders - AddDispatch( REBLUR_DiffuseSpecularSh_TemporalAccumulation, REBLUR_TEMPORAL_ACCUMULATION_CONSTANT_NUM, REBLUR_TEMPORAL_ACCUMULATION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSpecularSh_TemporalAccumulation, REBLUR_TEMPORAL_ACCUMULATION_CONSTANT_NUM, REBLUR_TEMPORAL_ACCUMULATION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseSpecularSh_TemporalAccumulation, REBLUR_TemporalAccumulation, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSpecularSh_TemporalAccumulation, REBLUR_TemporalAccumulation, 1 ); } } - for (int i = 0; i < REBLUR_HISTORY_FIX_PERMUTATION_NUM; i++) + PushPass("History fix"); { - PushPass("History fix"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(Transient::DATA1) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( DIFF_TEMP2 ); - PushInput( SPEC_TEMP2 ); - PushInput( AsUint(Transient::DIFF_FAST_HISTORY) ); - PushInput( AsUint(Transient::SPEC_FAST_HISTORY) ); - PushInput( DIFF_SH_TEMP2 ); - PushInput( SPEC_SH_TEMP2 ); - - // Outputs - PushOutput( DIFF_TEMP1 ); - PushOutput( SPEC_TEMP1 ); - PushOutput( AsUint(Permanent::DIFF_FAST_HISTORY) ); - PushOutput( AsUint(Permanent::SPEC_FAST_HISTORY) ); - PushOutput( DIFF_SH_TEMP1 ); - PushOutput( SPEC_SH_TEMP1 ); - - // Shaders - AddDispatch( REBLUR_DiffuseSpecularSh_HistoryFix, REBLUR_HISTORY_FIX_CONSTANT_NUM, REBLUR_HISTORY_FIX_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSpecularSh_HistoryFix, REBLUR_HISTORY_FIX_CONSTANT_NUM, REBLUR_HISTORY_FIX_NUM_THREADS, 1 ); - } + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(Transient::DATA1) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( DIFF_TEMP2 ); + PushInput( SPEC_TEMP2 ); + PushInput( AsUint(Transient::DIFF_FAST_HISTORY) ); + PushInput( AsUint(Transient::SPEC_FAST_HISTORY) ); + PushInput( DIFF_SH_TEMP2 ); + PushInput( SPEC_SH_TEMP2 ); + + // Outputs + PushOutput( DIFF_TEMP1 ); + PushOutput( SPEC_TEMP1 ); + PushOutput( AsUint(Permanent::DIFF_FAST_HISTORY) ); + PushOutput( AsUint(Permanent::SPEC_FAST_HISTORY) ); + PushOutput( DIFF_SH_TEMP1 ); + PushOutput( SPEC_SH_TEMP1 ); + + // Shaders + AddDispatch( REBLUR_DiffuseSpecularSh_HistoryFix, REBLUR_HistoryFix, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSpecularSh_HistoryFix, REBLUR_HistoryFix, 1 ); } - for (int i = 0; i < REBLUR_BLUR_PERMUTATION_NUM; i++) + PushPass("Blur"); { - PushPass("Blur"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(Transient::DATA1) ); - PushInput( DIFF_TEMP1 ); - PushInput( SPEC_TEMP1 ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( DIFF_SH_TEMP1 ); - PushInput( SPEC_SH_TEMP1 ); - - // Outputs - PushOutput( DIFF_TEMP2 ); - PushOutput( SPEC_TEMP2 ); - PushOutput( AsUint(Permanent::PREV_VIEWZ) ); - PushOutput( DIFF_SH_TEMP2 ); - PushOutput( SPEC_SH_TEMP2 ); - - // Shaders - AddDispatch( REBLUR_DiffuseSpecularSh_Blur, REBLUR_BLUR_CONSTANT_NUM, REBLUR_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSpecularSh_Blur, REBLUR_BLUR_CONSTANT_NUM, REBLUR_BLUR_NUM_THREADS, 1 ); - } + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(Transient::DATA1) ); + PushInput( DIFF_TEMP1 ); + PushInput( SPEC_TEMP1 ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( DIFF_SH_TEMP1 ); + PushInput( SPEC_SH_TEMP1 ); + + // Outputs + PushOutput( DIFF_TEMP2 ); + PushOutput( SPEC_TEMP2 ); + PushOutput( AsUint(Permanent::PREV_VIEWZ) ); + PushOutput( DIFF_SH_TEMP2 ); + PushOutput( SPEC_SH_TEMP2 ); + + // Shaders + AddDispatch( REBLUR_DiffuseSpecularSh_Blur, REBLUR_Blur, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSpecularSh_Blur, REBLUR_Blur, 1 ); } for (int i = 0; i < REBLUR_POST_BLUR_PERMUTATION_NUM; i++) @@ -310,37 +294,34 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSpecularSh(DenoiserData& denoiserData) // Shaders if (isTemporalStabilization) { - AddDispatch( REBLUR_DiffuseSpecularSh_PostBlur, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSpecularSh_PostBlur, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseSpecularSh_PostBlur, REBLUR_PostBlur, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSpecularSh_PostBlur, REBLUR_PostBlur, 1 ); } else { - AddDispatch( REBLUR_DiffuseSpecularSh_PostBlur_NoTemporalStabilization, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSpecularSh_PostBlur_NoTemporalStabilization, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseSpecularSh_PostBlur_NoTemporalStabilization, REBLUR_PostBlur, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSpecularSh_PostBlur_NoTemporalStabilization, REBLUR_PostBlur, 1 ); } } } - for (int i = 0; i < REBLUR_COPY_STABILIZED_HISTORY_PERMUTATION_NUM; i++) + PushPass("Copy"); { - PushPass("Copy stabilized history"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::OUT_DIFF_SH0) ); - PushInput( AsUint(ResourceType::OUT_SPEC_SH0) ); - PushInput( AsUint(ResourceType::OUT_DIFF_SH1) ); - PushInput( AsUint(ResourceType::OUT_SPEC_SH1) ); - - // Outputs - PushOutput( DIFF_TEMP2 ); - PushOutput( SPEC_TEMP2 ); - PushOutput( DIFF_SH_TEMP2 ); - PushOutput( SPEC_SH_TEMP2 ); - - // Shaders - AddDispatch( REBLUR_DiffuseSpecularSh_CopyStabilizedHistory, REBLUR_COPY_STABILIZED_HISTORY_CONSTANT_NUM, REBLUR_COPY_STABILIZED_HISTORY_NUM_THREADS, USE_MAX_DIMS ); - } + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::OUT_DIFF_SH0) ); + PushInput( AsUint(ResourceType::OUT_SPEC_SH0) ); + PushInput( AsUint(ResourceType::OUT_DIFF_SH1) ); + PushInput( AsUint(ResourceType::OUT_SPEC_SH1) ); + + // Outputs + PushOutput( DIFF_TEMP2 ); + PushOutput( SPEC_TEMP2 ); + PushOutput( DIFF_SH_TEMP2 ); + PushOutput( SPEC_SH_TEMP2 ); + + // Shaders + AddDispatch( REBLUR_DiffuseSpecularSh_Copy, REBLUR_Copy, USE_MAX_DIMS ); } for (int i = 0; i < REBLUR_TEMPORAL_STABILIZATION_PERMUTATION_NUM; i++) @@ -360,7 +341,7 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSpecularSh(DenoiserData& denoiserData) PushInput( AsUint(Permanent::SPEC_HISTORY) ); PushInput( DIFF_TEMP2 ); PushInput( SPEC_TEMP2 ); - PushInput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG), 0, 1, AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING) ); + PushInput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG), AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING) ); PushInput( AsUint(Permanent::DIFF_SH_HISTORY) ); PushInput( AsUint(Permanent::SPEC_SH_HISTORY) ); PushInput( DIFF_SH_TEMP2 ); @@ -375,31 +356,28 @@ void nrd::InstanceImpl::Add_ReblurDiffuseSpecularSh(DenoiserData& denoiserData) PushOutput( AsUint(ResourceType::OUT_SPEC_SH1) ); // Shaders - AddDispatch( REBLUR_DiffuseSpecularSh_TemporalStabilization, REBLUR_TEMPORAL_STABILIZATION_CONSTANT_NUM, REBLUR_TEMPORAL_STABILIZATION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_DiffuseSpecularSh_TemporalStabilization, REBLUR_TEMPORAL_STABILIZATION_CONSTANT_NUM, REBLUR_TEMPORAL_STABILIZATION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_DiffuseSpecularSh_TemporalStabilization, REBLUR_TemporalStabilization, 1 ); + AddDispatch( REBLUR_Perf_DiffuseSpecularSh_TemporalStabilization, REBLUR_TemporalStabilization, 1 ); } } - for (int i = 0; i < REBLUR_SPLIT_SCREEN_PERMUTATION_NUM; i++) + PushPass("Split screen"); { - PushPass("Split screen"); - { - // Inputs - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(ResourceType::IN_DIFF_SH0) ); - PushInput( AsUint(ResourceType::IN_SPEC_SH0) ); - PushInput( AsUint(ResourceType::IN_DIFF_SH1) ); - PushInput( AsUint(ResourceType::IN_SPEC_SH1) ); - - // Outputs - PushOutput( AsUint(ResourceType::OUT_DIFF_SH0) ); - PushOutput( AsUint(ResourceType::OUT_SPEC_SH0) ); - PushOutput( AsUint(ResourceType::OUT_DIFF_SH1) ); - PushOutput( AsUint(ResourceType::OUT_SPEC_SH1) ); - - // Shaders - AddDispatch( REBLUR_DiffuseSpecularSh_SplitScreen, REBLUR_SPLIT_SCREEN_CONSTANT_NUM, REBLUR_SPLIT_SCREEN_NUM_THREADS, 1 ); - } + // Inputs + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( AsUint(ResourceType::IN_DIFF_SH0) ); + PushInput( AsUint(ResourceType::IN_SPEC_SH0) ); + PushInput( AsUint(ResourceType::IN_DIFF_SH1) ); + PushInput( AsUint(ResourceType::IN_SPEC_SH1) ); + + // Outputs + PushOutput( AsUint(ResourceType::OUT_DIFF_SH0) ); + PushOutput( AsUint(ResourceType::OUT_SPEC_SH0) ); + PushOutput( AsUint(ResourceType::OUT_DIFF_SH1) ); + PushOutput( AsUint(ResourceType::OUT_SPEC_SH1) ); + + // Shaders + AddDispatch( REBLUR_DiffuseSpecularSh_SplitScreen, REBLUR_SplitScreen, 1 ); } REBLUR_ADD_VALIDATION_DISPATCH( Transient::DATA2, ResourceType::IN_DIFF_SH0, ResourceType::IN_SPEC_SH0 ); diff --git a/Source/Denoisers/Reblur_Specular.hpp b/Source/Denoisers/Reblur_Specular.hpp index d6b10f4..1f82d85 100644 --- a/Source/Denoisers/Reblur_Specular.hpp +++ b/Source/Denoisers/Reblur_Specular.hpp @@ -17,11 +17,6 @@ void nrd::InstanceImpl::Add_ReblurSpecular(DenoiserData& denoiserData) denoiserData.settings.reblur = ReblurSettings(); denoiserData.settingsSize = sizeof(denoiserData.settings.reblur); - uint16_t w = denoiserData.desc.renderWidth; - uint16_t h = denoiserData.desc.renderHeight; - uint16_t tilesW = DivideUp(w, 16); - uint16_t tilesH = DivideUp(h, 16); - enum class Permanent { PREV_VIEWZ = PERMANENT_POOL_START, @@ -33,13 +28,13 @@ void nrd::InstanceImpl::Add_ReblurSpecular(DenoiserData& denoiserData) SPEC_HITDIST_FOR_TRACKING_PONG, }; - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_VIEWZ, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_NORMAL_ROUGHNESS, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_INTERNAL_DATA, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_FAST_HISTORY, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, w, h, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_VIEWZ, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_NORMAL_ROUGHNESS, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_INTERNAL_DATA, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_FAST_HISTORY, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, 1} ); enum class Transient { @@ -52,29 +47,24 @@ void nrd::InstanceImpl::Add_ReblurSpecular(DenoiserData& denoiserData) TILES, }; - AddTextureToTransientPool( {Format::RG8_UNORM, w, h, 1} ); - AddTextureToTransientPool( {Format::R32_UINT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_FAST_HISTORY, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, tilesW, tilesH, 1} ); - - REBLUR_SET_SHARED_CONSTANTS; + AddTextureToTransientPool( {Format::RG8_UNORM, 1} ); + AddTextureToTransientPool( {Format::R32_UINT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_FAST_HISTORY, 1} ); + AddTextureToTransientPool( {Format::R8_UNORM, 16} ); - for (int i = 0; i < REBLUR_CLASSIFY_TILES_PERMUTATION_NUM; i++) + PushPass("Classify tiles"); { - PushPass("Classify tiles"); - { - // Inputs - PushInput( AsUint(ResourceType::IN_VIEWZ) ); + // Inputs + PushInput( AsUint(ResourceType::IN_VIEWZ) ); - // Outputs - PushOutput( AsUint(Transient::TILES) ); + // Outputs + PushOutput( AsUint(Transient::TILES) ); - // Shaders - AddDispatch( REBLUR_ClassifyTiles, REBLUR_CLASSIFY_TILES_CONSTANT_NUM, REBLUR_CLASSIFY_TILES_NUM_THREADS, 1 ); - } + // Shaders + AddDispatch( REBLUR_ClassifyTiles, REBLUR_ClassifyTiles, 1 ); } for (int i = 0; i < REBLUR_HITDIST_RECONSTRUCTION_PERMUTATION_NUM; i++) @@ -96,13 +86,13 @@ void nrd::InstanceImpl::Add_ReblurSpecular(DenoiserData& denoiserData) // Shaders if (is5x5) { - AddDispatch( REBLUR_Specular_HitDistReconstruction_5x5, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_Specular_HitDistReconstruction_5x5, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_Specular_HitDistReconstruction_5x5, REBLUR_HitDistReconstruction, 1 ); + AddDispatch( REBLUR_Perf_Specular_HitDistReconstruction_5x5, REBLUR_HitDistReconstruction, 1 ); } else { - AddDispatch( REBLUR_Specular_HitDistReconstruction, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_Specular_HitDistReconstruction, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_Specular_HitDistReconstruction, REBLUR_HitDistReconstruction, 1 ); + AddDispatch( REBLUR_Perf_Specular_HitDistReconstruction, REBLUR_HitDistReconstruction, 1 ); } } } @@ -124,8 +114,8 @@ void nrd::InstanceImpl::Add_ReblurSpecular(DenoiserData& denoiserData) PushOutput( AsUint(Transient::SPEC_HITDIST_FOR_TRACKING) ); // Shaders - AddDispatch( REBLUR_Specular_PrePass, REBLUR_PREPASS_CONSTANT_NUM, REBLUR_PREPASS_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_Specular_PrePass, REBLUR_PREPASS_CONSTANT_NUM, REBLUR_PREPASS_NUM_THREADS, 1 ); + AddDispatch( REBLUR_Specular_PrePass, REBLUR_PrePass, 1 ); + AddDispatch( REBLUR_Perf_Specular_PrePass, REBLUR_PrePass, 1 ); } } @@ -151,62 +141,56 @@ void nrd::InstanceImpl::Add_ReblurSpecular(DenoiserData& denoiserData) PushInput( isAfterPrepass ? SPEC_TEMP1 : AsUint(ResourceType::IN_SPEC_RADIANCE_HITDIST) ); PushInput( isTemporalStabilization ? AsUint(Permanent::SPEC_HISTORY) : AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); PushInput( AsUint(Permanent::SPEC_FAST_HISTORY) ); - PushInput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING), 0, 1, AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG) ); + PushInput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING), AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG) ); PushInput( AsUint(Transient::SPEC_HITDIST_FOR_TRACKING) ); // Outputs PushOutput( SPEC_TEMP2 ); PushOutput( AsUint(Transient::SPEC_FAST_HISTORY) ); - PushOutput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG), 0, 1, AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING) ); + PushOutput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG), AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING) ); PushOutput( AsUint(Transient::DATA1) ); PushOutput( AsUint(Transient::DATA2) ); // Shaders - AddDispatch( REBLUR_Specular_TemporalAccumulation, REBLUR_TEMPORAL_ACCUMULATION_CONSTANT_NUM, REBLUR_TEMPORAL_ACCUMULATION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_Specular_TemporalAccumulation, REBLUR_TEMPORAL_ACCUMULATION_CONSTANT_NUM, REBLUR_TEMPORAL_ACCUMULATION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_Specular_TemporalAccumulation, REBLUR_TemporalAccumulation, 1 ); + AddDispatch( REBLUR_Perf_Specular_TemporalAccumulation, REBLUR_TemporalAccumulation, 1 ); } } - for (int i = 0; i < REBLUR_HISTORY_FIX_PERMUTATION_NUM; i++) + PushPass("History fix"); { - PushPass("History fix"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(Transient::DATA1) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( SPEC_TEMP2 ); - PushInput( AsUint(Transient::SPEC_FAST_HISTORY) ); - - // Outputs - PushOutput( SPEC_TEMP1 ); - PushOutput( AsUint(Permanent::SPEC_FAST_HISTORY) ); - - AddDispatch( REBLUR_Specular_HistoryFix, REBLUR_HISTORY_FIX_CONSTANT_NUM, REBLUR_HISTORY_FIX_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_Specular_HistoryFix, REBLUR_HISTORY_FIX_CONSTANT_NUM, REBLUR_HISTORY_FIX_NUM_THREADS, 1 ); - } + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(Transient::DATA1) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( SPEC_TEMP2 ); + PushInput( AsUint(Transient::SPEC_FAST_HISTORY) ); + + // Outputs + PushOutput( SPEC_TEMP1 ); + PushOutput( AsUint(Permanent::SPEC_FAST_HISTORY) ); + + AddDispatch( REBLUR_Specular_HistoryFix, REBLUR_HistoryFix, 1 ); + AddDispatch( REBLUR_Perf_Specular_HistoryFix, REBLUR_HistoryFix, 1 ); } - for (int i = 0; i < REBLUR_BLUR_PERMUTATION_NUM; i++) + PushPass("Blur"); { - PushPass("Blur"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(Transient::DATA1) ); - PushInput( SPEC_TEMP1 ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - - // Outputs - PushOutput( SPEC_TEMP2 ); - PushOutput( AsUint(Permanent::PREV_VIEWZ) ); - - // Shaders - AddDispatch( REBLUR_Specular_Blur, REBLUR_BLUR_CONSTANT_NUM, REBLUR_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_Specular_Blur, REBLUR_BLUR_CONSTANT_NUM, REBLUR_BLUR_NUM_THREADS, 1 ); - } + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(Transient::DATA1) ); + PushInput( SPEC_TEMP1 ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + + // Outputs + PushOutput( SPEC_TEMP2 ); + PushOutput( AsUint(Permanent::PREV_VIEWZ) ); + + // Shaders + AddDispatch( REBLUR_Specular_Blur, REBLUR_Blur, 1 ); + AddDispatch( REBLUR_Perf_Specular_Blur, REBLUR_Blur, 1 ); } for (int i = 0; i < REBLUR_POST_BLUR_PERMUTATION_NUM; i++) @@ -236,31 +220,28 @@ void nrd::InstanceImpl::Add_ReblurSpecular(DenoiserData& denoiserData) // Shaders if (isTemporalStabilization) { - AddDispatch( REBLUR_Specular_PostBlur, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_Specular_PostBlur, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); + AddDispatch( REBLUR_Specular_PostBlur, REBLUR_PostBlur, 1 ); + AddDispatch( REBLUR_Perf_Specular_PostBlur, REBLUR_PostBlur, 1 ); } else { - AddDispatch( REBLUR_Specular_PostBlur_NoTemporalStabilization, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_Specular_PostBlur_NoTemporalStabilization, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); + AddDispatch( REBLUR_Specular_PostBlur_NoTemporalStabilization, REBLUR_PostBlur, 1 ); + AddDispatch( REBLUR_Perf_Specular_PostBlur_NoTemporalStabilization, REBLUR_PostBlur, 1 ); } } } - for (int i = 0; i < REBLUR_COPY_STABILIZED_HISTORY_PERMUTATION_NUM; i++) + PushPass("Copy"); { - PushPass("Copy stabilized history"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); - // Outputs - PushOutput( SPEC_TEMP2 ); + // Outputs + PushOutput( SPEC_TEMP2 ); - // Shaders - AddDispatch( REBLUR_Specular_CopyStabilizedHistory, REBLUR_COPY_STABILIZED_HISTORY_CONSTANT_NUM, REBLUR_COPY_STABILIZED_HISTORY_NUM_THREADS, USE_MAX_DIMS ); - } + // Shaders + AddDispatch( REBLUR_Specular_Copy, REBLUR_Copy, USE_MAX_DIMS ); } for (int i = 0; i < REBLUR_TEMPORAL_STABILIZATION_PERMUTATION_NUM; i++) @@ -278,7 +259,7 @@ void nrd::InstanceImpl::Add_ReblurSpecular(DenoiserData& denoiserData) PushInput( AsUint(Transient::DATA2) ); PushInput( AsUint(Permanent::SPEC_HISTORY) ); PushInput( SPEC_TEMP2 ); - PushInput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG), 0, 1, AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING) ); + PushInput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG), AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING) ); // Outputs PushOutput( AsUint(ResourceType::IN_MV) ); @@ -286,25 +267,22 @@ void nrd::InstanceImpl::Add_ReblurSpecular(DenoiserData& denoiserData) PushOutput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); // Shaders - AddDispatch( REBLUR_Specular_TemporalStabilization, REBLUR_TEMPORAL_STABILIZATION_CONSTANT_NUM, REBLUR_TEMPORAL_STABILIZATION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_Specular_TemporalStabilization, REBLUR_TEMPORAL_STABILIZATION_CONSTANT_NUM, REBLUR_TEMPORAL_STABILIZATION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_Specular_TemporalStabilization, REBLUR_TemporalStabilization, 1 ); + AddDispatch( REBLUR_Perf_Specular_TemporalStabilization, REBLUR_TemporalStabilization, 1 ); } } - for (int i = 0; i < REBLUR_SPLIT_SCREEN_PERMUTATION_NUM; i++) + PushPass("Split screen"); { - PushPass("Split screen"); - { - // Inputs - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(ResourceType::IN_SPEC_RADIANCE_HITDIST) ); + // Inputs + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( AsUint(ResourceType::IN_SPEC_RADIANCE_HITDIST) ); - // Outputs - PushOutput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); + // Outputs + PushOutput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); - // Shaders - AddDispatch( REBLUR_Specular_SplitScreen, REBLUR_SPLIT_SCREEN_CONSTANT_NUM, REBLUR_SPLIT_SCREEN_NUM_THREADS, 1 ); - } + // Shaders + AddDispatch( REBLUR_Specular_SplitScreen, REBLUR_SplitScreen, 1 ); } REBLUR_ADD_VALIDATION_DISPATCH( Transient::DATA2, ResourceType::IN_SPEC_RADIANCE_HITDIST, ResourceType::IN_SPEC_RADIANCE_HITDIST ); diff --git a/Source/Denoisers/Reblur_SpecularOcclusion.hpp b/Source/Denoisers/Reblur_SpecularOcclusion.hpp index 6e9caa5..9b7d83a 100644 --- a/Source/Denoisers/Reblur_SpecularOcclusion.hpp +++ b/Source/Denoisers/Reblur_SpecularOcclusion.hpp @@ -17,11 +17,6 @@ void nrd::InstanceImpl::Add_ReblurSpecularOcclusion(DenoiserData& denoiserData) denoiserData.settings.reblur = ReblurSettings(); denoiserData.settingsSize = sizeof(denoiserData.settings.reblur); - uint16_t w = denoiserData.desc.renderWidth; - uint16_t h = denoiserData.desc.renderHeight; - uint16_t tilesW = DivideUp(w, 16); - uint16_t tilesH = DivideUp(h, 16); - enum class Permanent { PREV_VIEWZ = PERMANENT_POOL_START, @@ -32,12 +27,12 @@ void nrd::InstanceImpl::Add_ReblurSpecularOcclusion(DenoiserData& denoiserData) SPEC_HITDIST_FOR_TRACKING_PONG, }; - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_VIEWZ, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_NORMAL_ROUGHNESS, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_INTERNAL_DATA, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_OCCLUSION_FAST_HISTORY, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, w, h, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_VIEWZ, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_NORMAL_ROUGHNESS, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_INTERNAL_DATA, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_OCCLUSION_FAST_HISTORY, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, 1} ); enum class Transient { @@ -48,27 +43,22 @@ void nrd::InstanceImpl::Add_ReblurSpecularOcclusion(DenoiserData& denoiserData) TILES, }; - AddTextureToTransientPool( {Format::RG8_UNORM, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_OCCLUSION, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_OCCLUSION, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_OCCLUSION_FAST_HISTORY, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, tilesW, tilesH, 1} ); - - REBLUR_SET_SHARED_CONSTANTS; + AddTextureToTransientPool( {Format::RG8_UNORM, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_OCCLUSION, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_OCCLUSION, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_OCCLUSION_FAST_HISTORY, 1} ); + AddTextureToTransientPool( {Format::R8_UNORM, 16} ); - for (int i = 0; i < REBLUR_CLASSIFY_TILES_PERMUTATION_NUM; i++) + PushPass("Classify tiles"); { - PushPass("Classify tiles"); - { - // Inputs - PushInput( AsUint(ResourceType::IN_VIEWZ) ); + // Inputs + PushInput( AsUint(ResourceType::IN_VIEWZ) ); - // Outputs - PushOutput( AsUint(Transient::TILES) ); + // Outputs + PushOutput( AsUint(Transient::TILES) ); - // Shaders - AddDispatch( REBLUR_ClassifyTiles, REBLUR_CLASSIFY_TILES_CONSTANT_NUM, REBLUR_CLASSIFY_TILES_NUM_THREADS, 1 ); - } + // Shaders + AddDispatch( REBLUR_ClassifyTiles, REBLUR_ClassifyTiles, 1 ); } for (int i = 0; i < REBLUR_OCCLUSION_HITDIST_RECONSTRUCTION_PERMUTATION_NUM; i++) @@ -89,13 +79,13 @@ void nrd::InstanceImpl::Add_ReblurSpecularOcclusion(DenoiserData& denoiserData) // Shaders if (is5x5) { - AddDispatch( REBLUR_SpecularOcclusion_HitDistReconstruction_5x5, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_SpecularOcclusion_HitDistReconstruction_5x5, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_SpecularOcclusion_HitDistReconstruction_5x5, REBLUR_HitDistReconstruction, 1 ); + AddDispatch( REBLUR_Perf_SpecularOcclusion_HitDistReconstruction_5x5, REBLUR_HitDistReconstruction, 1 ); } else { - AddDispatch( REBLUR_SpecularOcclusion_HitDistReconstruction, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_SpecularOcclusion_HitDistReconstruction, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_SpecularOcclusion_HitDistReconstruction, REBLUR_HitDistReconstruction, 1 ); + AddDispatch( REBLUR_Perf_SpecularOcclusion_HitDistReconstruction, REBLUR_HitDistReconstruction, 1 ); } } } @@ -121,99 +111,87 @@ void nrd::InstanceImpl::Add_ReblurSpecularOcclusion(DenoiserData& denoiserData) PushInput( isAfterReconstruction ? SPEC_TEMP1 : AsUint(ResourceType::IN_SPEC_HITDIST) ); PushInput( AsUint(ResourceType::OUT_SPEC_HITDIST) ); PushInput( AsUint(Permanent::SPEC_FAST_HISTORY) ); - PushInput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING), 0, 1, AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG) ); + PushInput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING), AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG) ); // Outputs PushOutput( SPEC_TEMP2 ); PushOutput( AsUint(Transient::SPEC_FAST_HISTORY) ); - PushOutput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG), 0, 1, AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING) ); + PushOutput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG), AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING) ); PushOutput( AsUint(Transient::DATA1) ); // Shaders - AddDispatch( REBLUR_SpecularOcclusion_TemporalAccumulation, REBLUR_TEMPORAL_ACCUMULATION_CONSTANT_NUM, REBLUR_TEMPORAL_ACCUMULATION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_SpecularOcclusion_TemporalAccumulation, REBLUR_TEMPORAL_ACCUMULATION_CONSTANT_NUM, REBLUR_TEMPORAL_ACCUMULATION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_SpecularOcclusion_TemporalAccumulation, REBLUR_TemporalAccumulation, 1 ); + AddDispatch( REBLUR_Perf_SpecularOcclusion_TemporalAccumulation, REBLUR_TemporalAccumulation, 1 ); } } - for (int i = 0; i < REBLUR_OCCLUSION_HISTORY_FIX_PERMUTATION_NUM; i++) + PushPass("History fix"); { - PushPass("History fix"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(Transient::DATA1) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( SPEC_TEMP2 ); - PushInput( AsUint(Transient::SPEC_FAST_HISTORY) ); - - // Outputs - PushOutput( SPEC_TEMP1 ); - PushOutput( AsUint(Permanent::SPEC_FAST_HISTORY) ); - - // Shaders - AddDispatch( REBLUR_SpecularOcclusion_HistoryFix, REBLUR_HISTORY_FIX_CONSTANT_NUM, REBLUR_HISTORY_FIX_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_SpecularOcclusion_HistoryFix, REBLUR_HISTORY_FIX_CONSTANT_NUM, REBLUR_HISTORY_FIX_NUM_THREADS, 1 ); - } + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(Transient::DATA1) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( SPEC_TEMP2 ); + PushInput( AsUint(Transient::SPEC_FAST_HISTORY) ); + + // Outputs + PushOutput( SPEC_TEMP1 ); + PushOutput( AsUint(Permanent::SPEC_FAST_HISTORY) ); + + // Shaders + AddDispatch( REBLUR_SpecularOcclusion_HistoryFix, REBLUR_HistoryFix, 1 ); + AddDispatch( REBLUR_Perf_SpecularOcclusion_HistoryFix, REBLUR_HistoryFix, 1 ); } - for (int i = 0; i < REBLUR_OCCLUSION_BLUR_PERMUTATION_NUM; i++) + PushPass("Blur"); { - PushPass("Blur"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(Transient::DATA1) ); - PushInput( SPEC_TEMP1 ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - - // Outputs - PushOutput( SPEC_TEMP2 ); - PushOutput( AsUint(Permanent::PREV_VIEWZ) ); - - // Shaders - AddDispatch( REBLUR_SpecularOcclusion_Blur, REBLUR_BLUR_CONSTANT_NUM, REBLUR_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_SpecularOcclusion_Blur, REBLUR_BLUR_CONSTANT_NUM, REBLUR_BLUR_NUM_THREADS, 1 ); - } + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(Transient::DATA1) ); + PushInput( SPEC_TEMP1 ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + + // Outputs + PushOutput( SPEC_TEMP2 ); + PushOutput( AsUint(Permanent::PREV_VIEWZ) ); + + // Shaders + AddDispatch( REBLUR_SpecularOcclusion_Blur, REBLUR_Blur, 1 ); + AddDispatch( REBLUR_Perf_SpecularOcclusion_Blur, REBLUR_Blur, 1 ); } - for (int i = 0; i < REBLUR_OCCLUSION_POST_BLUR_PERMUTATION_NUM; i++) + PushPass("Post-blur"); { - PushPass("Post-blur"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(Transient::DATA1) ); - PushInput( SPEC_TEMP2 ); - PushInput( AsUint(Permanent::PREV_VIEWZ) ); - - // Outputs - PushOutput( AsUint(Permanent::PREV_NORMAL_ROUGHNESS) ); - PushOutput( AsUint(ResourceType::OUT_SPEC_HITDIST) ); - PushOutput( AsUint(Permanent::PREV_INTERNAL_DATA) ); - - // Shaders - AddDispatch( REBLUR_SpecularOcclusion_PostBlur_NoTemporalStabilization, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_SpecularOcclusion_PostBlur_NoTemporalStabilization, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); - } + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(Transient::DATA1) ); + PushInput( SPEC_TEMP2 ); + PushInput( AsUint(Permanent::PREV_VIEWZ) ); + + // Outputs + PushOutput( AsUint(Permanent::PREV_NORMAL_ROUGHNESS) ); + PushOutput( AsUint(ResourceType::OUT_SPEC_HITDIST) ); + PushOutput( AsUint(Permanent::PREV_INTERNAL_DATA) ); + + // Shaders + AddDispatch( REBLUR_SpecularOcclusion_PostBlur_NoTemporalStabilization, REBLUR_PostBlur, 1 ); + AddDispatch( REBLUR_Perf_SpecularOcclusion_PostBlur_NoTemporalStabilization, REBLUR_PostBlur, 1 ); } - for (int i = 0; i < REBLUR_OCCLUSION_SPLIT_SCREEN_PERMUTATION_NUM; i++) + PushPass("Split screen"); { - PushPass("Split screen"); - { - // Inputs - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(ResourceType::IN_SPEC_HITDIST) ); + // Inputs + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( AsUint(ResourceType::IN_SPEC_HITDIST) ); - // Outputs - PushOutput( AsUint(ResourceType::OUT_SPEC_HITDIST) ); + // Outputs + PushOutput( AsUint(ResourceType::OUT_SPEC_HITDIST) ); - // Shaders - AddDispatch( REBLUR_Specular_SplitScreen, REBLUR_SPLIT_SCREEN_CONSTANT_NUM, REBLUR_SPLIT_SCREEN_NUM_THREADS, 1 ); - } + // Shaders + AddDispatch( REBLUR_Specular_SplitScreen, REBLUR_SplitScreen, 1 ); } REBLUR_ADD_VALIDATION_DISPATCH( Transient::DATA1, ResourceType::IN_SPEC_HITDIST, ResourceType::IN_SPEC_HITDIST ); diff --git a/Source/Denoisers/Reblur_SpecularSh.hpp b/Source/Denoisers/Reblur_SpecularSh.hpp index 5c5c9fd..ad4271a 100644 --- a/Source/Denoisers/Reblur_SpecularSh.hpp +++ b/Source/Denoisers/Reblur_SpecularSh.hpp @@ -19,11 +19,6 @@ void nrd::InstanceImpl::Add_ReblurSpecularSh(DenoiserData& denoiserData) denoiserData.settings.reblur = ReblurSettings(); denoiserData.settingsSize = sizeof(denoiserData.settings.reblur); - uint16_t w = denoiserData.desc.renderWidth; - uint16_t h = denoiserData.desc.renderHeight; - uint16_t tilesW = DivideUp(w, 16); - uint16_t tilesH = DivideUp(h, 16); - enum class Permanent { PREV_VIEWZ = PERMANENT_POOL_START, @@ -36,14 +31,14 @@ void nrd::InstanceImpl::Add_ReblurSpecularSh(DenoiserData& denoiserData) SPEC_HITDIST_FOR_TRACKING_PONG, }; - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_VIEWZ, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_NORMAL_ROUGHNESS, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_INTERNAL_DATA, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_FAST_HISTORY, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, w, h, 1} ); - AddTextureToPermanentPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, w, h, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_VIEWZ, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_NORMAL_ROUGHNESS, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_PREV_INTERNAL_DATA, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_FAST_HISTORY, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, 1} ); + AddTextureToPermanentPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, 1} ); enum class Transient { @@ -58,31 +53,26 @@ void nrd::InstanceImpl::Add_ReblurSpecularSh(DenoiserData& denoiserData) TILES, }; - AddTextureToTransientPool( {Format::RG8_UNORM, w, h, 1} ); - AddTextureToTransientPool( {Format::R32_UINT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT_FAST_HISTORY, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToTransientPool( {REBLUR_FORMAT, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, tilesW, tilesH, 1} ); - - REBLUR_SET_SHARED_CONSTANTS; - - for (int i = 0; i < REBLUR_CLASSIFY_TILES_PERMUTATION_NUM; i++) + AddTextureToTransientPool( {Format::RG8_UNORM, 1} ); + AddTextureToTransientPool( {Format::R32_UINT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_HITDIST_FOR_TRACKING, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT_FAST_HISTORY, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT, 1} ); + AddTextureToTransientPool( {REBLUR_FORMAT, 1} ); + AddTextureToTransientPool( {Format::R8_UNORM, 16} ); + + PushPass("Classify tiles"); { - PushPass("Classify tiles"); - { - // Inputs - PushInput( AsUint(ResourceType::IN_VIEWZ) ); + // Inputs + PushInput( AsUint(ResourceType::IN_VIEWZ) ); - // Outputs - PushOutput( AsUint(Transient::TILES) ); + // Outputs + PushOutput( AsUint(Transient::TILES) ); - // Shaders - AddDispatch( REBLUR_ClassifyTiles, REBLUR_CLASSIFY_TILES_CONSTANT_NUM, REBLUR_CLASSIFY_TILES_NUM_THREADS, 1 ); - } + // Shaders + AddDispatch( REBLUR_ClassifyTiles, REBLUR_ClassifyTiles, 1 ); } for (int i = 0; i < REBLUR_HITDIST_RECONSTRUCTION_PERMUTATION_NUM; i++) @@ -104,13 +94,13 @@ void nrd::InstanceImpl::Add_ReblurSpecularSh(DenoiserData& denoiserData) // Shaders if (is5x5) { - AddDispatch( REBLUR_Specular_HitDistReconstruction_5x5, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_Specular_HitDistReconstruction_5x5, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_Specular_HitDistReconstruction_5x5, REBLUR_HitDistReconstruction, 1 ); + AddDispatch( REBLUR_Perf_Specular_HitDistReconstruction_5x5, REBLUR_HitDistReconstruction, 1 ); } else { - AddDispatch( REBLUR_Specular_HitDistReconstruction, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_Specular_HitDistReconstruction, REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM, REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_Specular_HitDistReconstruction, REBLUR_HitDistReconstruction, 1 ); + AddDispatch( REBLUR_Perf_Specular_HitDistReconstruction, REBLUR_HitDistReconstruction, 1 ); } } } @@ -134,8 +124,8 @@ void nrd::InstanceImpl::Add_ReblurSpecularSh(DenoiserData& denoiserData) PushOutput( SPEC_SH_TEMP1 ); // Shaders - AddDispatch( REBLUR_SpecularSh_PrePass, REBLUR_PREPASS_CONSTANT_NUM, REBLUR_PREPASS_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_SpecularSh_PrePass, REBLUR_PREPASS_CONSTANT_NUM, REBLUR_PREPASS_NUM_THREADS, 1 ); + AddDispatch( REBLUR_SpecularSh_PrePass, REBLUR_PrePass, 1 ); + AddDispatch( REBLUR_Perf_SpecularSh_PrePass, REBLUR_PrePass, 1 ); } } @@ -161,7 +151,7 @@ void nrd::InstanceImpl::Add_ReblurSpecularSh(DenoiserData& denoiserData) PushInput( isAfterPrepass ? SPEC_TEMP1 : AsUint(ResourceType::IN_SPEC_SH0) ); PushInput( isTemporalStabilization ? AsUint(Permanent::SPEC_HISTORY) : AsUint(ResourceType::OUT_SPEC_SH0) ); PushInput( AsUint(Permanent::SPEC_FAST_HISTORY) ); - PushInput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING), 0, 1, AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG) ); + PushInput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING), AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG) ); PushInput( AsUint(Transient::SPEC_HITDIST_FOR_TRACKING) ); PushInput( isAfterPrepass ? SPEC_SH_TEMP1 : AsUint(ResourceType::IN_SPEC_SH1) ); PushInput( isTemporalStabilization ? AsUint(Permanent::SPEC_SH_HISTORY) : AsUint(ResourceType::OUT_SPEC_SH1) ); @@ -169,61 +159,55 @@ void nrd::InstanceImpl::Add_ReblurSpecularSh(DenoiserData& denoiserData) // Outputs PushOutput( SPEC_TEMP2 ); PushOutput( AsUint(Transient::SPEC_FAST_HISTORY) ); - PushOutput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG), 0, 1, AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING) ); + PushOutput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG), AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING) ); PushOutput( AsUint(Transient::DATA1) ); PushOutput( AsUint(Transient::DATA2) ); PushOutput( SPEC_SH_TEMP2 ); // Shaders - AddDispatch( REBLUR_SpecularSh_TemporalAccumulation, REBLUR_TEMPORAL_ACCUMULATION_CONSTANT_NUM, REBLUR_TEMPORAL_ACCUMULATION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_SpecularSh_TemporalAccumulation, REBLUR_TEMPORAL_ACCUMULATION_CONSTANT_NUM, REBLUR_TEMPORAL_ACCUMULATION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_SpecularSh_TemporalAccumulation, REBLUR_TemporalAccumulation, 1 ); + AddDispatch( REBLUR_Perf_SpecularSh_TemporalAccumulation, REBLUR_TemporalAccumulation, 1 ); } } - for (int i = 0; i < REBLUR_HISTORY_FIX_PERMUTATION_NUM; i++) + PushPass("History fix"); { - PushPass("History fix"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(Transient::DATA1) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( SPEC_TEMP2 ); - PushInput( AsUint(Transient::SPEC_FAST_HISTORY) ); - PushInput( SPEC_SH_TEMP2 ); - - // Outputs - PushOutput( SPEC_TEMP1 ); - PushOutput( AsUint(Permanent::SPEC_FAST_HISTORY) ); - PushOutput( SPEC_SH_TEMP1 ); - - AddDispatch( REBLUR_SpecularSh_HistoryFix, REBLUR_HISTORY_FIX_CONSTANT_NUM, REBLUR_HISTORY_FIX_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_SpecularSh_HistoryFix, REBLUR_HISTORY_FIX_CONSTANT_NUM, REBLUR_HISTORY_FIX_NUM_THREADS, 1 ); - } + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(Transient::DATA1) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( SPEC_TEMP2 ); + PushInput( AsUint(Transient::SPEC_FAST_HISTORY) ); + PushInput( SPEC_SH_TEMP2 ); + + // Outputs + PushOutput( SPEC_TEMP1 ); + PushOutput( AsUint(Permanent::SPEC_FAST_HISTORY) ); + PushOutput( SPEC_SH_TEMP1 ); + + AddDispatch( REBLUR_SpecularSh_HistoryFix, REBLUR_HistoryFix, 1 ); + AddDispatch( REBLUR_Perf_SpecularSh_HistoryFix, REBLUR_HistoryFix, 1 ); } - for (int i = 0; i < REBLUR_BLUR_PERMUTATION_NUM; i++) + PushPass("Blur"); { - PushPass("Blur"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(Transient::DATA1) ); - PushInput( SPEC_TEMP1 ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( SPEC_SH_TEMP1 ); - - // Outputs - PushOutput( SPEC_TEMP2 ); - PushOutput( AsUint(Permanent::PREV_VIEWZ) ); - PushOutput( SPEC_SH_TEMP2 ); - - // Shaders - AddDispatch( REBLUR_SpecularSh_Blur, REBLUR_BLUR_CONSTANT_NUM, REBLUR_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_SpecularSh_Blur, REBLUR_BLUR_CONSTANT_NUM, REBLUR_BLUR_NUM_THREADS, 1 ); - } + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(Transient::DATA1) ); + PushInput( SPEC_TEMP1 ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( SPEC_SH_TEMP1 ); + + // Outputs + PushOutput( SPEC_TEMP2 ); + PushOutput( AsUint(Permanent::PREV_VIEWZ) ); + PushOutput( SPEC_SH_TEMP2 ); + + // Shaders + AddDispatch( REBLUR_SpecularSh_Blur, REBLUR_Blur, 1 ); + AddDispatch( REBLUR_Perf_SpecularSh_Blur, REBLUR_Blur, 1 ); } for (int i = 0; i < REBLUR_POST_BLUR_PERMUTATION_NUM; i++) @@ -258,33 +242,30 @@ void nrd::InstanceImpl::Add_ReblurSpecularSh(DenoiserData& denoiserData) // Shaders if (isTemporalStabilization) { - AddDispatch( REBLUR_SpecularSh_PostBlur, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_SpecularSh_PostBlur, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); + AddDispatch( REBLUR_SpecularSh_PostBlur, REBLUR_PostBlur, 1 ); + AddDispatch( REBLUR_Perf_SpecularSh_PostBlur, REBLUR_PostBlur, 1 ); } else { - AddDispatch( REBLUR_SpecularSh_PostBlur_NoTemporalStabilization, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_SpecularSh_PostBlur_NoTemporalStabilization, REBLUR_POST_BLUR_CONSTANT_NUM, REBLUR_POST_BLUR_NUM_THREADS, 1 ); + AddDispatch( REBLUR_SpecularSh_PostBlur_NoTemporalStabilization, REBLUR_PostBlur, 1 ); + AddDispatch( REBLUR_Perf_SpecularSh_PostBlur_NoTemporalStabilization, REBLUR_PostBlur, 1 ); } } } - for (int i = 0; i < REBLUR_COPY_STABILIZED_HISTORY_PERMUTATION_NUM; i++) + PushPass("Copy"); { - PushPass("Copy stabilized history"); - { - // Inputs - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::OUT_SPEC_SH0) ); - PushInput( AsUint(ResourceType::OUT_SPEC_SH1) ); + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::OUT_SPEC_SH0) ); + PushInput( AsUint(ResourceType::OUT_SPEC_SH1) ); - // Outputs - PushOutput( SPEC_TEMP2 ); - PushOutput( SPEC_SH_TEMP2 ); + // Outputs + PushOutput( SPEC_TEMP2 ); + PushOutput( SPEC_SH_TEMP2 ); - // Shaders - AddDispatch( REBLUR_SpecularSh_CopyStabilizedHistory, REBLUR_COPY_STABILIZED_HISTORY_CONSTANT_NUM, REBLUR_COPY_STABILIZED_HISTORY_NUM_THREADS, USE_MAX_DIMS ); - } + // Shaders + AddDispatch( REBLUR_SpecularSh_Copy, REBLUR_Copy, USE_MAX_DIMS ); } for (int i = 0; i < REBLUR_TEMPORAL_STABILIZATION_PERMUTATION_NUM; i++) @@ -302,7 +283,7 @@ void nrd::InstanceImpl::Add_ReblurSpecularSh(DenoiserData& denoiserData) PushInput( AsUint(Transient::DATA2) ); PushInput( AsUint(Permanent::SPEC_HISTORY) ); PushInput( SPEC_TEMP2 ); - PushInput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG), 0, 1, AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING) ); + PushInput( AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PONG), AsUint(Permanent::SPEC_HITDIST_FOR_TRACKING_PING) ); PushInput( AsUint(Permanent::SPEC_SH_HISTORY) ); PushInput( SPEC_SH_TEMP2 ); @@ -313,27 +294,24 @@ void nrd::InstanceImpl::Add_ReblurSpecularSh(DenoiserData& denoiserData) PushOutput( AsUint(ResourceType::OUT_SPEC_SH1) ); // Shaders - AddDispatch( REBLUR_SpecularSh_TemporalStabilization, REBLUR_TEMPORAL_STABILIZATION_CONSTANT_NUM, REBLUR_TEMPORAL_STABILIZATION_NUM_THREADS, 1 ); - AddDispatch( REBLUR_Perf_SpecularSh_TemporalStabilization, REBLUR_TEMPORAL_STABILIZATION_CONSTANT_NUM, REBLUR_TEMPORAL_STABILIZATION_NUM_THREADS, 1 ); + AddDispatch( REBLUR_SpecularSh_TemporalStabilization, REBLUR_TemporalStabilization, 1 ); + AddDispatch( REBLUR_Perf_SpecularSh_TemporalStabilization, REBLUR_TemporalStabilization, 1 ); } } - for (int i = 0; i < REBLUR_SPLIT_SCREEN_PERMUTATION_NUM; i++) + PushPass("Split screen"); { - PushPass("Split screen"); - { - // Inputs - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(ResourceType::IN_SPEC_SH0) ); - PushInput( AsUint(ResourceType::IN_SPEC_SH1) ); + // Inputs + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( AsUint(ResourceType::IN_SPEC_SH0) ); + PushInput( AsUint(ResourceType::IN_SPEC_SH1) ); - // Outputs - PushOutput( AsUint(ResourceType::OUT_SPEC_SH0) ); - PushOutput( AsUint(ResourceType::OUT_SPEC_SH1) ); + // Outputs + PushOutput( AsUint(ResourceType::OUT_SPEC_SH0) ); + PushOutput( AsUint(ResourceType::OUT_SPEC_SH1) ); - // Shaders - AddDispatch( REBLUR_SpecularSh_SplitScreen, REBLUR_SPLIT_SCREEN_CONSTANT_NUM, REBLUR_SPLIT_SCREEN_NUM_THREADS, 1 ); - } + // Shaders + AddDispatch( REBLUR_SpecularSh_SplitScreen, REBLUR_SplitScreen, 1 ); } REBLUR_ADD_VALIDATION_DISPATCH( Transient::DATA2, ResourceType::IN_SPEC_SH0, ResourceType::IN_SPEC_SH0 ); diff --git a/Source/Denoisers/Reference.hpp b/Source/Denoisers/Reference.hpp index 3a48a2c..1369a0d 100644 --- a/Source/Denoisers/Reference.hpp +++ b/Source/Denoisers/Reference.hpp @@ -8,41 +8,39 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ +#include "../Shaders/Resources/REFERENCE_TemporalAccumulation.resources.hlsli" +#include "../Shaders/Resources/REFERENCE_SplitScreen.resources.hlsli" + void nrd::InstanceImpl::Add_Reference(DenoiserData& denoiserData) { #define DENOISER_NAME Reference denoiserData.settings.reference = ReferenceSettings(); denoiserData.settingsSize = sizeof(denoiserData.settings.reference); - - uint16_t w = denoiserData.desc.renderWidth; - uint16_t h = denoiserData.desc.renderHeight; enum class Permanent { HISTORY = PERMANENT_POOL_START, }; - AddTextureToPermanentPool( {Format::RGBA32_SFLOAT, w, h, 1} ); - - SetSharedConstants(0, 0, 0, 0); + AddTextureToPermanentPool( {Format::RGBA32_SFLOAT, 1} ); PushPass("Temporal accumulation"); { - PushInput( AsUint(ResourceType::IN_RADIANCE) ); + PushInput( AsUint(ResourceType::IN_SIGNAL) ); PushOutput( AsUint(Permanent::HISTORY) ); - AddDispatch( REFERENCE_TemporalAccumulation, SumConstants(0, 0, 2, 3), NumThreads(16, 16), 1 ); + AddDispatch( REFERENCE_TemporalAccumulation, REFERENCE_TemporalAccumulation, 1 ); } - PushPass("Split screen"); + PushPass("Copy"); { PushInput( AsUint(Permanent::HISTORY) ); - PushOutput( AsUint(ResourceType::OUT_RADIANCE) ); + PushOutput( AsUint(ResourceType::OUT_SIGNAL) ); - AddDispatch( REFERENCE_SplitScreen, SumConstants(0, 0, 0, 0), NumThreads(16, 16), 1 ); + AddDispatch( REFERENCE_SplitScreen, REFERENCE_SplitScreen, 1 ); // TODO: rename to Copy } #undef DENOISER_NAME @@ -61,20 +59,20 @@ void nrd::InstanceImpl::Update_Reference(const DenoiserData& denoiserData) if (m_WorldToClip != m_WorldToClipPrev || m_CommonSettings.accumulationMode != AccumulationMode::CONTINUE) m_AccumulatedFrameNum = 0; else - m_AccumulatedFrameNum = ml::Min(m_AccumulatedFrameNum + 1, settings.maxAccumulatedFrameNum); + m_AccumulatedFrameNum = Min(m_AccumulatedFrameNum + 1, settings.maxAccumulatedFrameNum); NRD_DECLARE_DIMS; - // ACCUMULATE - Constant* data = PushDispatch(denoiserData, AsUint(Dispatch::ACCUMULATE)); - AddUint2(data, m_CommonSettings.inputSubrectOrigin[0], m_CommonSettings.inputSubrectOrigin[1]); - AddFloat2(data, 1.0f / float(rectW), 1.0f / float(rectH)); - AddFloat(data, m_CommonSettings.splitScreen); - AddFloat(data, 1.0f / (1.0f + float(m_AccumulatedFrameNum))); - AddFloat(data, m_CommonSettings.debug); - ValidateConstants(data); - - // COPY - data = PushDispatch(denoiserData, AsUint(Dispatch::COPY)); - ValidateConstants(data); + { // ACCUMULATE + REFERENCE_TemporalAccumulationConstants* consts = (REFERENCE_TemporalAccumulationConstants*)PushDispatch(denoiserData, AsUint(Dispatch::ACCUMULATE)); + consts->gRectOrigin = uint2(m_CommonSettings.rectOrigin[0], m_CommonSettings.rectOrigin[1]); + consts->gRectSizeInv = float2(1.0f / float(rectW), 1.0f / float(rectH)); + consts->gSplitScreen = m_CommonSettings.splitScreen; + consts->gAccumSpeed = 1.0f / (1.0f + float(m_AccumulatedFrameNum)); + consts->gDebug = m_CommonSettings.debug; + } + + { // COPY + PushDispatch(denoiserData, AsUint(Dispatch::COPY)); + } } diff --git a/Source/Denoisers/Relax_Diffuse.hpp b/Source/Denoisers/Relax_Diffuse.hpp index c3c185a..4aab824 100644 --- a/Source/Denoisers/Relax_Diffuse.hpp +++ b/Source/Denoisers/Relax_Diffuse.hpp @@ -12,13 +12,8 @@ void nrd::InstanceImpl::Add_RelaxDiffuse(DenoiserData& denoiserData) { #define DENOISER_NAME RELAX_Diffuse - denoiserData.settings.diffuseRelax = RelaxDiffuseSettings(); - denoiserData.settingsSize = sizeof(denoiserData.settings.diffuseRelax); - - uint16_t w = denoiserData.desc.renderWidth; - uint16_t h = denoiserData.desc.renderHeight; - uint16_t tilesW = DivideUp(w, 16); - uint16_t tilesH = DivideUp(h, 16); + denoiserData.settings.relax = RelaxSettings(); + denoiserData.settingsSize = sizeof(denoiserData.settings.relax); enum class Permanent { @@ -30,13 +25,13 @@ void nrd::InstanceImpl::Add_RelaxDiffuse(DenoiserData& denoiserData) VIEWZ_PREV }; - AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::R8_UNORM, w, h, 1} ); - AddTextureToPermanentPool( {Format::RGBA8_UNORM, w, h, 1} ); - AddTextureToPermanentPool( {Format::R8_UNORM, w, h, 1} ); - AddTextureToPermanentPool( {Format::R32_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::R32_SFLOAT, w, h, 1} ); + AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::R8_UNORM, 1} ); + AddTextureToPermanentPool( {Format::RGBA8_UNORM, 1} ); + AddTextureToPermanentPool( {Format::R8_UNORM, 1} ); + AddTextureToPermanentPool( {Format::R32_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::R32_SFLOAT, 1} ); enum class Transient { @@ -46,83 +41,74 @@ void nrd::InstanceImpl::Add_RelaxDiffuse(DenoiserData& denoiserData) HISTORY_LENGTH }; - AddTextureToTransientPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, tilesW, tilesH, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, w, h, 1} ); - - RELAX_SET_SHARED_CONSTANTS; - - const uint32_t halfMaxPassNum = (RELAX_MAX_ATROUS_PASS_NUM - 2 + 1) / 2; + AddTextureToTransientPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::R8_UNORM, 16} ); + AddTextureToTransientPool( {Format::R8_UNORM, 1} ); PushPass("Classify tiles"); { + // Inputs PushInput( AsUint(ResourceType::IN_VIEWZ) ); + + // Outputs PushOutput( AsUint(Transient::TILES) ); - AddDispatch(RELAX_ClassifyTiles, SumConstants(0, 0, 0, 1, false), NumThreads(16, 16), 1); + // Shaders + AddDispatch( RELAX_ClassifyTiles, RELAX_ClassifyTiles, 1 ); } - PushPass("Hit distance reconstruction"); // 3x3 + for (int i = 0; i < RELAX_HITDIST_RECONSTRUCTION_PERMUTATION_NUM; i++) { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_DIFF_RADIANCE_HITDIST) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); + bool is5x5 = ( ( ( i >> 0 ) & 0x1 ) != 0 ); - PushOutput( AsUint(Transient::DIFF_ILLUM_PING) ); - - AddDispatch( RELAX_Diffuse_HitDistReconstruction, SumConstants(0, 0, 0, 0), NumThreads(8, 8), 1 ); - } - - PushPass("Hit distance reconstruction"); // 5x5 - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_DIFF_RADIANCE_HITDIST) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushPass("Hit distance reconstruction"); + { + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_DIFF_RADIANCE_HITDIST) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushOutput( AsUint(Transient::DIFF_ILLUM_PING) ); + // Outputs + PushOutput( AsUint(Transient::DIFF_ILLUM_PING) ); - AddDispatch( RELAX_Diffuse_HitDistReconstruction_5x5, SumConstants(0, 0, 0, 0), NumThreads(8, 8), 1 ); + // Shaders + if (is5x5) + AddDispatch( RELAX_Diffuse_HitDistReconstruction_5x5, RELAX_HitDistReconstruction, 1 ); + else + AddDispatch( RELAX_Diffuse_HitDistReconstruction, RELAX_HitDistReconstruction, 1 ); + } } - PushPass("Pre-pass"); // After hit distance reconstruction + for (int i = 0; i < RELAX_PREPASS_PERMUTATION_NUM; i++) { - // Does preblur (if enabled) and checkerboard reconstruction (if enabled) - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PING) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - - PushOutput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); - - AddDispatch( RELAX_Diffuse_PrePass, SumConstants(0, 1, 0, 5), NumThreads(16, 16), 1 ); - } + bool isAfterReconstruction = ( ( ( i >> 0 ) & 0x1 ) != 0 ); - PushPass("Pre-pass"); // Without hit distance reconstruction - { - // Does preblur (if enabled) and checkerboard reconstruction (if enabled) - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_DIFF_RADIANCE_HITDIST) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushPass("Pre-pass"); + { + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( isAfterReconstruction ? AsUint(Transient::DIFF_ILLUM_PING) : AsUint(ResourceType::IN_DIFF_RADIANCE_HITDIST) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushOutput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); + // Outputs + PushOutput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); - AddDispatch( RELAX_Diffuse_PrePass, SumConstants(0, 1, 0, 5), NumThreads(16, 16), 1 ); + // Shaders + AddDispatch( RELAX_Diffuse_PrePass, RELAX_PrePass, 1 ); + } } - for (int i = 0; i < 4; i++) + for (int i = 0; i < RELAX_TEMPORAL_ACCUMULATION_PERMUTATION_NUM; i++) { - // The following passes are defined here: - // TEMPORAL_ACCUMULATION, - // TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS, - // TEMPORAL_ACCUMULATION_WITH_THRESHOLD_MIX, - // TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS_WITH_THRESHOLD_MIX + bool hasDisocclusionThresholdMix = ( ( ( i >> 1 ) & 0x1 ) != 0 ); + bool hasConfidenceInputs = ( ( ( i >> 0 ) & 0x1 ) != 0 ); PushPass("Temporal accumulation"); { + // Inputs PushInput( AsUint(Transient::TILES) ); PushInput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); PushInput( AsUint(ResourceType::IN_MV) ); @@ -134,419 +120,146 @@ void nrd::InstanceImpl::Add_RelaxDiffuse(DenoiserData& denoiserData) PushInput( AsUint(Permanent::VIEWZ_PREV) ); PushInput( AsUint(Permanent::HISTORY_LENGTH_PREV) ); PushInput( AsUint(Permanent::MATERIAL_ID_PREV) ); - // Confidence inputs: - if (i == 0) - { - PushInput( AsUint(ResourceType::IN_VIEWZ) ); // Bogus input that will not be fetched anyway - PushInput( AsUint(Permanent::HISTORY_LENGTH_PREV) ); // Bogus input that will not be fetched anyway - } - if (i == 1) - { - PushInput( AsUint(ResourceType::IN_DIFF_CONFIDENCE) ); - PushInput( AsUint(Permanent::HISTORY_LENGTH_PREV) ); // Bogus input that will not be fetched anyway - } - if (i == 2) - { - PushInput( AsUint(ResourceType::IN_VIEWZ) ); // Bogus input that will not be fetched anyway - PushInput( AsUint(ResourceType::IN_DISOCCLUSION_THRESHOLD_MIX) ); - } - if (i == 3) - { - PushInput( AsUint(ResourceType::IN_DIFF_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_DISOCCLUSION_THRESHOLD_MIX) ); - } + PushInput( hasConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : RELAX_DUMMY ); + PushInput( hasDisocclusionThresholdMix ? AsUint(ResourceType::IN_DISOCCLUSION_THRESHOLD_MIX) : RELAX_DUMMY ); + // Outputs PushOutput( AsUint(Transient::DIFF_ILLUM_PING) ); PushOutput( AsUint(Transient::DIFF_ILLUM_PONG) ); PushOutput( AsUint(Transient::HISTORY_LENGTH) ); - AddDispatch( RELAX_Diffuse_TemporalAccumulation, SumConstants(0, 0, 0, 8), NumThreads(8, 8), 1 ); + // Shaders + AddDispatch( RELAX_Diffuse_TemporalAccumulation, RELAX_TemporalAccumulation, 1 ); } } PushPass("History fix"); { + // Inputs PushInput( AsUint(Transient::TILES) ); PushInput( AsUint(Transient::DIFF_ILLUM_PING) ); PushInput( AsUint(Transient::HISTORY_LENGTH) ); PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); PushInput( AsUint(ResourceType::IN_VIEWZ) ); + // Outputs PushOutput( AsUint(Transient::DIFF_ILLUM_PONG) ); - AddDispatch( RELAX_Diffuse_HistoryFix, SumConstants(0, 0, 0, 4), NumThreads(8, 8), 1 ); + // Shaders + AddDispatch( RELAX_Diffuse_HistoryFix, RELAX_HistoryFix, 1 ); } PushPass("History clamping"); { + // Inputs PushInput( AsUint(Transient::TILES) ); PushInput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); PushInput( AsUint(Transient::DIFF_ILLUM_PING) ); PushInput( AsUint(Transient::DIFF_ILLUM_PONG) ); PushInput( AsUint(Transient::HISTORY_LENGTH) ); + // Outputs PushOutput( AsUint(Permanent::DIFF_ILLUM_PREV) ); PushOutput( AsUint(Permanent::DIFF_ILLUM_RESPONSIVE_PREV) ); PushOutput( AsUint(Permanent::HISTORY_LENGTH_PREV) ); - AddDispatch( RELAX_Diffuse_HistoryClamping, SumConstants(0, 0, 0, 7), NumThreads(8, 8), 1 ); + // Shaders + AddDispatch( RELAX_Diffuse_HistoryClamping, RELAX_HistoryClamping, 1 ); } PushPass("Copy"); { + // Inputs PushInput( AsUint(Permanent::DIFF_ILLUM_PREV) ); + + // Outputs PushOutput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); - AddDispatch( RELAX_Diffuse_Copy, SumConstants(0, 0, 0, 0), NumThreads(8, 8), 1 ); + // Shaders + AddDispatch( RELAX_Diffuse_Copy, RELAX_Copy, 1 ); } PushPass("Anti-firefly"); { + // Inputs PushInput( AsUint(Transient::TILES) ); PushInput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); PushInput( AsUint(ResourceType::IN_VIEWZ) ); + // Outputs PushOutput( AsUint(Permanent::DIFF_ILLUM_PREV) ); - AddDispatch( RELAX_Diffuse_AntiFirefly, SumConstants(0, 0, 0, 0), NumThreads(16, 16), 1 ); + // Shaders + AddDispatch( RELAX_Diffuse_AntiFirefly, RELAX_AntiFirefly, 1 ); } - for (int i = 0; i < 2; i++) + for (int i = 0; i < RELAX_ATROUS_PERMUTATION_NUM; i++) { - bool withConfidenceInputs = (i == 1); + bool hasConfidenceInputs = ( ( ( i >> 0 ) & 0x1 ) != 0 ); - // A-trous (first) - PushPass("A-trous (SMEM)"); + for (int j = 0; j < RELAX_ATROUS_BINDING_VARIANT_NUM; j++) { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Permanent::DIFF_ILLUM_PREV) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - - PushOutput( AsUint(Transient::DIFF_ILLUM_PING) ); - PushOutput( AsUint(Permanent::NORMAL_ROUGHNESS_PREV) ); - PushOutput( AsUint(Permanent::MATERIAL_ID_PREV) ); - PushOutput( AsUint(Permanent::VIEWZ_PREV) ); - - AddDispatch( RELAX_Diffuse_AtrousSmem, SumConstants(0, 0, 1, 10), NumThreads(8, 8), 1 ); - } - - // A-trous (odd) - PushPass("A-trous"); - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PING) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - - PushOutput( AsUint(Transient::DIFF_ILLUM_PONG) ); - - AddDispatchRepeated( RELAX_Diffuse_Atrous, SumConstants(0, 0, 0, 9), NumThreads(16, 16), 1, halfMaxPassNum ); - } - - // A-trous (even) - PushPass("A-trous"); - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PONG) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); + bool isSmem = j == 0; + bool isEven = j % 2 == 0; + bool isLast = j > 2; - PushOutput( AsUint(Transient::DIFF_ILLUM_PING) ); - - AddDispatchRepeated( RELAX_Diffuse_Atrous, SumConstants(0, 0, 0, 9), NumThreads(16, 16), 1, halfMaxPassNum ); - } - - // A-trous (odd, last) - PushPass("A-trous"); - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PING) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - - PushOutput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); - - AddDispatch( RELAX_Diffuse_Atrous, SumConstants(0, 0, 0, 9), NumThreads(16, 16), 1 ); - } - - // A-trous (even, last) - PushPass("A-trous"); - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PONG) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - - PushOutput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); + if (isSmem) + PushPass("A-trous (SMEM)"); + else + PushPass("A-trous"); - AddDispatch( RELAX_Diffuse_Atrous, SumConstants(0, 0, 0, 9), NumThreads(16, 16), 1 ); + { + // Inputs + PushInput( AsUint(Transient::TILES) ); + + if (isSmem) + PushInput( AsUint(Permanent::DIFF_ILLUM_PREV) ); + else + PushInput( isEven ? AsUint(Transient::DIFF_ILLUM_PONG) : AsUint(Transient::DIFF_ILLUM_PING) ); + + PushInput( AsUint(Transient::HISTORY_LENGTH) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( hasConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); + + // Outputs + if (isLast) + PushOutput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); + else + PushOutput( isEven ? AsUint(Transient::DIFF_ILLUM_PING) : AsUint(Transient::DIFF_ILLUM_PONG) ); + + if (isSmem) + { + PushOutput( AsUint(Permanent::NORMAL_ROUGHNESS_PREV) ); + PushOutput( AsUint(Permanent::MATERIAL_ID_PREV) ); + PushOutput( AsUint(Permanent::VIEWZ_PREV) ); + } + + // Shaders + uint32_t repeatNum = isLast ? 1 : (RELAX_MAX_ATROUS_PASS_NUM - 2 + 1) / 2; + if (isSmem) + AddDispatch( RELAX_Diffuse_AtrousSmem, RELAX_AtrousSmem, 1 ); + else + AddDispatchRepeated( RELAX_Diffuse_Atrous, RELAX_Atrous, 1, repeatNum ); + } } } PushPass("Split screen"); { + // Inputs PushInput( AsUint(ResourceType::IN_VIEWZ) ); PushInput( AsUint(ResourceType::IN_DIFF_RADIANCE_HITDIST) ); + // Outputs PushOutput( AsUint( ResourceType::OUT_DIFF_RADIANCE_HITDIST ) ); - AddDispatch( RELAX_Diffuse_SplitScreen, SumConstants(0, 0, 0, 2), NumThreads(16, 16), 1 ); + // Shaders + AddDispatch( RELAX_Diffuse_SplitScreen, RELAX_SplitScreen, 1 ); } RELAX_ADD_VALIDATION_DISPATCH; #undef DENOISER_NAME } - -void nrd::InstanceImpl::Update_RelaxDiffuse(const DenoiserData& denoiserData) -{ - enum class Dispatch - { - CLASSIFY_TILES, - HITDIST_RECONSTRUCTION_3x3, - HITDIST_RECONSTRUCTION_5x5, - PREPASS_AFTER_HITDIST_RECONSTRUCTION, - PREPASS, - TEMPORAL_ACCUMULATION, - TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS, - TEMPORAL_ACCUMULATION_WITH_THRESHOLD_MIX, - TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS_WITH_THRESHOLD_MIX, - HISTORY_FIX, - HISTORY_CLAMPING, - COPY, - FIREFLY, - ATROUS_SMEM, - ATROUS_ODD, - ATROUS_EVEN, - ATROUS_ODD_LAST, - ATROUS_EVEN_LAST, - ATROUS_SMEM_WITH_CONFIDENCE_INPUTS, - ATROUS_ODD_WITH_CONFIDENCE_INPUTS, - ATROUS_EVEN_WITH_CONFIDENCE_INPUTS, - ATROUS_ODD_LAST_WITH_CONFIDENCE_INPUTS, - ATROUS_EVEN_LAST_WITH_CONFIDENCE_INPUTS, - SPLIT_SCREEN, - VALIDATION, - }; - - const RelaxDiffuseSettings& settings = denoiserData.settings.diffuseRelax; - - NRD_DECLARE_DIMS; - - float maxLuminanceRelativeDifference = -ml::Log(ml::Saturate(settings.minLuminanceWeight)); - - float disocclusionThreshold = m_CommonSettings.disocclusionThreshold + (1.0f + m_JitterDelta) / float(rectH); - float disocclusionThresholdOrtho = disocclusionThreshold; - float disocclusionThresholdAlternate = m_CommonSettings.disocclusionThresholdAlternate + (1.0f + m_JitterDelta) / float(rectH); - float disocclusionThresholdAlternateOrtho = disocclusionThresholdAlternate; - float depthThresholdOrtho = settings.depthThreshold; - - float tanHalfFov = 1.0f / m_ViewToClip.a00; - float aspect = m_ViewToClip.a00 / m_ViewToClip.a11; - ml::float3 frustumRight = m_WorldToView.GetRow0().To3d() * tanHalfFov; - ml::float3 frustumUp = m_WorldToView.GetRow1().To3d() * tanHalfFov * aspect; - ml::float3 frustumForward = RELAX_GetFrustumForward(m_ViewToWorld, m_Frustum); - - float prevTanHalfFov = 1.0f / m_ViewToClipPrev.a00; - float prevAspect = m_ViewToClipPrev.a00 / m_ViewToClipPrev.a11; - ml::float3 prevFrustumRight = m_WorldToViewPrev.GetRow0().To3d() * prevTanHalfFov; - ml::float3 prevFrustumUp = m_WorldToViewPrev.GetRow1().To3d() * prevTanHalfFov * prevAspect; - ml::float3 prevFrustumForward = RELAX_GetFrustumForward(m_ViewToWorldPrev, m_FrustumPrev); - bool isCameraStatic = RELAX_IsCameraStatic(ml::float3(m_CameraDelta.x, m_CameraDelta.y, m_CameraDelta.z), frustumRight, frustumUp, frustumForward, prevFrustumRight, prevFrustumUp, prevFrustumForward); - - bool enableHitDistanceReconstruction = settings.hitDistanceReconstructionMode != HitDistanceReconstructionMode::OFF && settings.checkerboardMode == CheckerboardMode::OFF; - - // Checkerboard logic - uint32_t diffuseCheckerboard = 2; - - switch (settings.checkerboardMode) - { - case CheckerboardMode::BLACK: - diffuseCheckerboard = 0; - break; - case CheckerboardMode::WHITE: - diffuseCheckerboard = 1; - break; - default: - break; - } - - // SPLIT_SCREEN (passthrough) - if (m_CommonSettings.splitScreen >= 1.0f) - { - Constant* data = PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE); - AddFloat(data, m_CommonSettings.splitScreen); - AddUint(data, diffuseCheckerboard); - ValidateConstants(data); - - return; - } - - // CLASSIFY_TILES - Constant* data = PushDispatch(denoiserData, AsUint(Dispatch::CLASSIFY_TILES)); - AddFloat(data, m_CommonSettings.denoisingRange); - ValidateConstants(data); - - // HITDIST_RECONSTRUCTION - if (enableHitDistanceReconstruction) - { - bool is3x3 = settings.hitDistanceReconstructionMode == HitDistanceReconstructionMode::AREA_3X3; - data = PushDispatch(denoiserData, is3x3 ? AsUint(Dispatch::HITDIST_RECONSTRUCTION_3x3) : AsUint(Dispatch::HITDIST_RECONSTRUCTION_5x5)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE); - ValidateConstants(data); - } - - // PREPASS - data = PushDispatch(denoiserData, AsUint(enableHitDistanceReconstruction ? Dispatch::PREPASS_AFTER_HITDIST_RECONSTRUCTION : Dispatch::PREPASS)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE); - AddFloat4(data, m_Rotator_PrePass); - AddUint(data, diffuseCheckerboard); - AddFloat(data, settings.prepassBlurRadius); - AddFloat(data, 1.0f); - AddFloat(data, m_IsOrtho == 0 ? settings.depthThreshold : depthThresholdOrtho); - AddFloat(data, settings.diffuseLobeAngleFraction); - - ValidateConstants(data); - - // TEMPORAL_ACCUMULATION - if (!m_CommonSettings.isDisocclusionThresholdMixAvailable) - { - data = PushDispatch( - denoiserData, - AsUint(m_CommonSettings.isHistoryConfidenceAvailable ? - Dispatch::TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS : - Dispatch::TEMPORAL_ACCUMULATION)); - } - else - { - data = PushDispatch( - denoiserData, - AsUint(m_CommonSettings.isHistoryConfidenceAvailable ? - Dispatch::TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS_WITH_THRESHOLD_MIX : - Dispatch::TEMPORAL_ACCUMULATION_WITH_THRESHOLD_MIX)); - } - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE); - AddFloat(data, (float)settings.diffuseMaxAccumulatedFrameNum); - AddFloat(data, (float)settings.diffuseMaxFastAccumulatedFrameNum); - AddUint(data, diffuseCheckerboard); - AddFloat(data, m_IsOrtho == 0 ? disocclusionThreshold : disocclusionThresholdOrtho); - AddFloat(data, m_IsOrtho == 0 ? disocclusionThresholdAlternate : disocclusionThresholdAlternateOrtho); - AddUint(data, settings.enableReprojectionTestSkippingWithoutMotion && isCameraStatic); - AddUint(data, m_CommonSettings.isHistoryConfidenceAvailable ? 1 : 0); - AddUint(data, m_CommonSettings.isDisocclusionThresholdMixAvailable ? 1 : 0); - ValidateConstants(data); - - // HISTORY_FIX - data = PushDispatch(denoiserData, AsUint(Dispatch::HISTORY_FIX)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE); - AddFloat(data, m_IsOrtho == 0 ? settings.depthThreshold : depthThresholdOrtho); - AddFloat(data, settings.historyFixEdgeStoppingNormalPower); - AddFloat(data, settings.historyFixStrideBetweenSamples); - AddFloat(data, float(settings.historyFixFrameNum)); - ValidateConstants(data); - - - // HISTORY_CLAMPING - data = PushDispatch(denoiserData, AsUint(Dispatch::HISTORY_CLAMPING)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE); - AddFloat(data, settings.historyClampingColorBoxSigmaScale); - AddFloat(data, float(settings.historyFixFrameNum)); - AddUint(data, settings.diffuseMaxFastAccumulatedFrameNum < settings.diffuseMaxAccumulatedFrameNum ? 1 : 0); - AddFloat(data, float(settings.antilagSettings.accelerationAmount)); - AddFloat(data, float(settings.antilagSettings.temporalSigmaScale)); - AddFloat(data, float(settings.antilagSettings.spatialSigmaScale)); - AddFloat(data, float(settings.antilagSettings.resetAmount)); - ValidateConstants(data); - - if (settings.enableAntiFirefly) - { - // COPY - data = PushDispatch(denoiserData, AsUint(Dispatch::COPY)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE); - ValidateConstants(data); - - // FIREFLY - data = PushDispatch(denoiserData, AsUint(Dispatch::FIREFLY)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE); - ValidateConstants(data); - } - - // A-TROUS - uint32_t iterationNum = ml::Clamp(settings.atrousIterationNum, 2u, RELAX_MAX_ATROUS_PASS_NUM); - for (uint32_t i = 0; i < iterationNum; i++) - { - Dispatch dispatch; - if (!m_CommonSettings.isHistoryConfidenceAvailable) - { - if (i == 0) - dispatch = Dispatch::ATROUS_SMEM; - else if (i == iterationNum - 1) - dispatch = (i % 2 == 0) ? Dispatch::ATROUS_EVEN_LAST : Dispatch::ATROUS_ODD_LAST; - else - dispatch = (i % 2 == 0) ? Dispatch::ATROUS_EVEN : Dispatch::ATROUS_ODD; - } - else - { - if (i == 0) - dispatch = Dispatch::ATROUS_SMEM_WITH_CONFIDENCE_INPUTS; - else if (i == iterationNum - 1) - dispatch = (i % 2 == 0) ? Dispatch::ATROUS_EVEN_LAST_WITH_CONFIDENCE_INPUTS : Dispatch::ATROUS_ODD_LAST_WITH_CONFIDENCE_INPUTS; - else - dispatch = (i % 2 == 0) ? Dispatch::ATROUS_EVEN_WITH_CONFIDENCE_INPUTS : Dispatch::ATROUS_ODD_WITH_CONFIDENCE_INPUTS; - } - - data = PushDispatch(denoiserData, AsUint(dispatch)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE); - - if (i == 0) - { - AddUint2(data, screenW, screenH); // For Atrous_shmem - AddUint(data, settings.spatialVarianceEstimationHistoryThreshold); - } - - AddFloat(data, settings.diffusePhiLuminance); - AddFloat(data, maxLuminanceRelativeDifference); - AddFloat(data, m_IsOrtho == 0 ? settings.depthThreshold : depthThresholdOrtho); - AddFloat(data, settings.diffuseLobeAngleFraction); - AddUint(data, 1 << i); - AddUint(data, m_CommonSettings.isHistoryConfidenceAvailable ? 1 : 0); - AddFloat(data, settings.confidenceDrivenRelaxationMultiplier); - AddFloat(data, settings.confidenceDrivenLuminanceEdgeStoppingRelaxation); - AddFloat(data, settings.confidenceDrivenNormalEdgeStoppingRelaxation); - ValidateConstants(data); - } - - // SPLIT_SCREEN - if (m_CommonSettings.splitScreen > 0.0f) - { - data = PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE); - AddFloat(data, m_CommonSettings.splitScreen); - AddUint(data, diffuseCheckerboard); - ValidateConstants(data); - } - - // VALIDATION - if (m_CommonSettings.enableValidation) - { - data = PushDispatch(denoiserData, AsUint(Dispatch::VALIDATION)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - AddFloat4x4(data, m_WorldToClipPrev); - AddFloat2(data, m_CommonSettings.cameraJitter[0], m_CommonSettings.cameraJitter[1]); - AddFloat(data, (float)settings.diffuseMaxAccumulatedFrameNum); - ValidateConstants(data); - } -} diff --git a/Source/Denoisers/Relax_DiffuseSh.hpp b/Source/Denoisers/Relax_DiffuseSh.hpp index 2507d24..0f3f5c9 100644 --- a/Source/Denoisers/Relax_DiffuseSh.hpp +++ b/Source/Denoisers/Relax_DiffuseSh.hpp @@ -12,13 +12,8 @@ void nrd::InstanceImpl::Add_RelaxDiffuseSh(DenoiserData& denoiserData) { #define DENOISER_NAME RELAX_Diffuse - denoiserData.settings.diffuseRelax = RelaxDiffuseSettings(); - denoiserData.settingsSize = sizeof(denoiserData.settings.diffuseRelax); - - uint16_t w = denoiserData.desc.renderWidth; - uint16_t h = denoiserData.desc.renderHeight; - uint16_t tilesW = DivideUp(w, 16); - uint16_t tilesH = DivideUp(h, 16); + denoiserData.settings.relax = RelaxSettings(); + denoiserData.settingsSize = sizeof(denoiserData.settings.relax); enum class Permanent { @@ -32,14 +27,14 @@ void nrd::InstanceImpl::Add_RelaxDiffuseSh(DenoiserData& denoiserData) VIEWZ_PREV }; - AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::R8_UNORM, w, h, 1} ); - AddTextureToPermanentPool( {Format::RGBA8_UNORM, w, h, 1} ); - AddTextureToPermanentPool( {Format::R8_UNORM, w, h, 1} ); - AddTextureToPermanentPool( {Format::R32_SFLOAT, w, h, 1} ); + AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::R8_UNORM, 1} ); + AddTextureToPermanentPool( {Format::RGBA8_UNORM, 1} ); + AddTextureToPermanentPool( {Format::R8_UNORM, 1} ); + AddTextureToPermanentPool( {Format::R32_SFLOAT, 1} ); enum class Transient { @@ -51,89 +46,78 @@ void nrd::InstanceImpl::Add_RelaxDiffuseSh(DenoiserData& denoiserData) HISTORY_LENGTH }; - AddTextureToTransientPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, tilesW, tilesH, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, w, h, 1} ); - - RELAX_SET_SHARED_CONSTANTS; - - const uint32_t halfMaxPassNum = (RELAX_MAX_ATROUS_PASS_NUM - 2 + 1) / 2; + AddTextureToTransientPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::R8_UNORM, 16} ); + AddTextureToTransientPool( {Format::R8_UNORM, 1} ); PushPass("Classify tiles"); { + // Inputs PushInput(AsUint(ResourceType::IN_VIEWZ)); + + // Outputs PushOutput(AsUint(Transient::TILES)); - AddDispatch(RELAX_ClassifyTiles, SumConstants(0, 0, 0, 1, false), NumThreads(16, 16), 1); + // Shaders + AddDispatch( RELAX_ClassifyTiles, RELAX_ClassifyTiles, 1 ); } - PushPass("Hit distance reconstruction 3x3"); // 3x3 + for (int i = 0; i < RELAX_HITDIST_RECONSTRUCTION_PERMUTATION_NUM; i++) { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_DIFF_SH0) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - - PushOutput( AsUint(Transient::DIFF_ILLUM_PING) ); - - AddDispatch( RELAX_Diffuse_HitDistReconstruction, SumConstants(0, 0, 0, 0), NumThreads(8, 8), 1 ); - } + bool is5x5 = ( ( ( i >> 0 ) & 0x1 ) != 0 ); - PushPass("Hit distance reconstruction 5x5"); // 5x5 - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_DIFF_SH0) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushPass("Hit distance reconstruction"); + { + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_DIFF_SH0) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushOutput( AsUint(Transient::DIFF_ILLUM_PING) ); + // Outputs + PushOutput( AsUint(Transient::DIFF_ILLUM_PING) ); - AddDispatch( RELAX_Diffuse_HitDistReconstruction_5x5, SumConstants(0, 0, 0, 0), NumThreads(8, 8), 1 ); + // Shaders + if (is5x5) + AddDispatch( RELAX_Diffuse_HitDistReconstruction_5x5, RELAX_HitDistReconstruction, 1 ); + else + AddDispatch( RELAX_Diffuse_HitDistReconstruction, RELAX_HitDistReconstruction, 1 ); + } } - PushPass("Pre-pass"); // After hit distance reconstruction + for (int i = 0; i < RELAX_PREPASS_PERMUTATION_NUM; i++) { - // Does preblur (if enabled) and checkerboard reconstruction (if enabled) - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PING) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(ResourceType::IN_DIFF_SH1) ); + bool isAfterReconstruction = ( ( ( i >> 0 ) & 0x1 ) != 0 ); - PushOutput( AsUint(ResourceType::OUT_DIFF_SH0) ); - PushOutput( AsUint(ResourceType::OUT_DIFF_SH1) ); - - AddDispatch( RELAX_DiffuseSh_PrePass, SumConstants(0, 1, 0, 5), NumThreads(16, 16), 1 ); - } - - PushPass("Pre-pass"); // Without hit distance reconstruction - { - // Does preblur (if enabled) and checkerboard reconstruction (if enabled) - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_DIFF_SH0) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(ResourceType::IN_DIFF_SH1) ); + PushPass("Pre-pass"); + { + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( isAfterReconstruction ? AsUint(Transient::DIFF_ILLUM_PING) : AsUint(ResourceType::IN_DIFF_SH0) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( AsUint(ResourceType::IN_DIFF_SH1) ); - PushOutput( AsUint(ResourceType::OUT_DIFF_SH0) ); - PushOutput( AsUint(ResourceType::OUT_DIFF_SH1) ); + // Outputs + PushOutput( AsUint(ResourceType::OUT_DIFF_SH0) ); + PushOutput( AsUint(ResourceType::OUT_DIFF_SH1) ); - AddDispatch( RELAX_DiffuseSh_PrePass, SumConstants(0, 1, 0, 5), NumThreads(16, 16), 1 ); + // Shaders + AddDispatch( RELAX_DiffuseSh_PrePass, RELAX_PrePass, 1 ); + } } - for (int i = 0; i < 4; i++) + for (int i = 0; i < RELAX_TEMPORAL_ACCUMULATION_PERMUTATION_NUM; i++) { - // The following passes are defined here: - // TEMPORAL_ACCUMULATION, - // TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS, - // TEMPORAL_ACCUMULATION_WITH_THRESHOLD_MIX, - // TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS_WITH_THRESHOLD_MIX + bool hasDisocclusionThresholdMix = ( ( ( i >> 1 ) & 0x1 ) != 0 ); + bool hasConfidenceInputs = ( ( ( i >> 0 ) & 0x1 ) != 0 ); PushPass("Temporal accumulation"); { + // Inputs PushInput( AsUint(Transient::TILES) ); PushInput( AsUint(ResourceType::OUT_DIFF_SH0) ); PushInput( AsUint(ResourceType::IN_MV) ); @@ -145,43 +129,27 @@ void nrd::InstanceImpl::Add_RelaxDiffuseSh(DenoiserData& denoiserData) PushInput( AsUint(Permanent::VIEWZ_PREV) ); PushInput( AsUint(Permanent::HISTORY_LENGTH_PREV) ); PushInput( AsUint(Permanent::MATERIAL_ID_PREV) ); - // Confidence inputs: - if (i == 0) - { - PushInput( AsUint(ResourceType::IN_VIEWZ) ); // Bogus input that will not be fetched anyway - PushInput( AsUint(Permanent::HISTORY_LENGTH_PREV) ); // Bogus input that will not be fetched anyway - } - if (i == 1) - { - PushInput( AsUint(ResourceType::IN_DIFF_CONFIDENCE) ); - PushInput( AsUint(Permanent::HISTORY_LENGTH_PREV) ); // Bogus input that will not be fetched anyway - } - if (i == 2) - { - PushInput( AsUint(ResourceType::IN_VIEWZ) ); // Bogus input that will not be fetched anyway - PushInput( AsUint(ResourceType::IN_DISOCCLUSION_THRESHOLD_MIX) ); - } - if (i == 3) - { - PushInput( AsUint(ResourceType::IN_DIFF_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_DISOCCLUSION_THRESHOLD_MIX) ); - } + PushInput( hasConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : RELAX_DUMMY ); + PushInput( hasDisocclusionThresholdMix ? AsUint(ResourceType::IN_DISOCCLUSION_THRESHOLD_MIX) : RELAX_DUMMY ); PushInput( AsUint(ResourceType::OUT_DIFF_SH1) ); PushInput( AsUint(Permanent::DIFF_ILLUM_RESPONSIVE_PREV_SH1) ); PushInput( AsUint(Permanent::DIFF_ILLUM_PREV_SH1) ); + // Outputs PushOutput( AsUint(Transient::DIFF_ILLUM_PING) ); PushOutput( AsUint(Transient::DIFF_ILLUM_PONG) ); PushOutput( AsUint(Transient::HISTORY_LENGTH) ); PushOutput( AsUint(Transient::DIFF_ILLUM_PING_SH1) ); PushOutput( AsUint(Transient::DIFF_ILLUM_PONG_SH1) ); - AddDispatch( RELAX_DiffuseSh_TemporalAccumulation, SumConstants(0, 0, 0, 8), NumThreads(8, 8), 1 ); + // Shaders + AddDispatch( RELAX_DiffuseSh_TemporalAccumulation, RELAX_TemporalAccumulation, 1 ); } } PushPass("History fix"); { + // Inputs PushInput( AsUint(Transient::TILES) ); PushInput( AsUint(Transient::DIFF_ILLUM_PING) ); PushInput( AsUint(Transient::HISTORY_LENGTH) ); @@ -189,14 +157,17 @@ void nrd::InstanceImpl::Add_RelaxDiffuseSh(DenoiserData& denoiserData) PushInput( AsUint(ResourceType::IN_VIEWZ) ); PushInput( AsUint(Transient::DIFF_ILLUM_PING_SH1) ); + // Outputs PushOutput( AsUint(Transient::DIFF_ILLUM_PONG) ); PushOutput( AsUint(Transient::DIFF_ILLUM_PONG_SH1) ); - AddDispatch( RELAX_DiffuseSh_HistoryFix, SumConstants(0, 0, 0, 4), NumThreads(8, 8), 1 ); + // Shaders + AddDispatch( RELAX_DiffuseSh_HistoryFix, RELAX_HistoryFix, 1 ); } PushPass("History clamping"); { + // Inputs PushInput( AsUint(Transient::TILES) ); PushInput( AsUint(ResourceType::OUT_DIFF_SH0) ); PushInput( AsUint(Transient::DIFF_ILLUM_PING) ); @@ -205,383 +176,120 @@ void nrd::InstanceImpl::Add_RelaxDiffuseSh(DenoiserData& denoiserData) PushInput( AsUint(Transient::DIFF_ILLUM_PING_SH1) ); PushInput( AsUint(Transient::DIFF_ILLUM_PONG_SH1) ); + // Outputs PushOutput( AsUint(Permanent::DIFF_ILLUM_PREV) ); PushOutput( AsUint(Permanent::DIFF_ILLUM_RESPONSIVE_PREV) ); PushOutput( AsUint(Permanent::HISTORY_LENGTH_PREV) ); PushOutput( AsUint(Permanent::DIFF_ILLUM_PREV_SH1) ); PushOutput( AsUint(Permanent::DIFF_ILLUM_RESPONSIVE_PREV_SH1) ); - AddDispatch( RELAX_DiffuseSh_HistoryClamping, SumConstants(0, 0, 0, 7), NumThreads(8, 8), 1 ); + // Shaders + AddDispatch( RELAX_DiffuseSh_HistoryClamping, RELAX_HistoryClamping, 1 ); } PushPass("Copy"); { + // Inputs PushInput( AsUint(Permanent::DIFF_ILLUM_PREV) ); + + // Outputs PushOutput( AsUint(ResourceType::OUT_DIFF_SH0) ); - AddDispatch( RELAX_DiffuseSh_Copy, SumConstants(0, 0, 0, 0), NumThreads(8, 8), 1 ); + // Shaders + AddDispatch( RELAX_DiffuseSh_Copy, RELAX_Copy, 1 ); } PushPass("Anti-firefly"); { + // Inputs PushInput( AsUint(Transient::TILES) ); PushInput( AsUint(ResourceType::OUT_DIFF_SH0) ); PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); PushInput( AsUint(ResourceType::IN_VIEWZ) ); + // Outputs PushOutput( AsUint(Permanent::DIFF_ILLUM_PREV) ); - AddDispatch( RELAX_DiffuseSh_AntiFirefly, SumConstants(0, 0, 0, 0), NumThreads(16, 16), 1 ); + // Shaders + AddDispatch( RELAX_DiffuseSh_AntiFirefly, RELAX_AntiFirefly, 1 ); } - for (int i = 0; i < 2; i++) + for (int i = 0; i < RELAX_ATROUS_PERMUTATION_NUM; i++) { - bool withConfidenceInputs = (i == 1); + bool hasConfidenceInputs = ( ( ( i >> 0 ) & 0x1 ) != 0 ); - // A-trous (first) - PushPass("A-trous (SMEM)"); + for (int j = 0; j < RELAX_ATROUS_BINDING_VARIANT_NUM; j++) { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Permanent::DIFF_ILLUM_PREV) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(Permanent::DIFF_ILLUM_PREV_SH1) ); - - PushOutput( AsUint(Transient::DIFF_ILLUM_PING) ); - PushOutput( AsUint(Permanent::NORMAL_ROUGHNESS_PREV) ); - PushOutput( AsUint(Permanent::MATERIAL_ID_PREV) ); - PushOutput( AsUint(Permanent::VIEWZ_PREV) ); - PushOutput( AsUint(Transient::DIFF_ILLUM_PING_SH1) ); - - AddDispatch( RELAX_DiffuseSh_AtrousSmem, SumConstants(0, 0, 1, 10), NumThreads(8, 8), 1 ); - } - - // A-trous (odd) - PushPass("A-trous"); - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PING) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PING_SH1) ); - - PushOutput( AsUint(Transient::DIFF_ILLUM_PONG) ); - PushOutput( AsUint(Transient::DIFF_ILLUM_PONG_SH1) ); - - AddDispatchRepeated( RELAX_DiffuseSh_Atrous, SumConstants(0, 0, 0, 10), NumThreads(16, 16), 1, halfMaxPassNum ); - } - - // A-trous (even) - PushPass("A-trous"); - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PONG) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PONG_SH1) ); - - PushOutput( AsUint(Transient::DIFF_ILLUM_PING) ); - PushOutput( AsUint(Transient::DIFF_ILLUM_PING_SH1) ); + bool isSmem = j == 0; + bool isEven = j % 2 == 0; + bool isLast = j > 2; - AddDispatchRepeated(RELAX_DiffuseSh_Atrous, SumConstants(0, 0, 0, 10), NumThreads(16, 16), 1, halfMaxPassNum ); - } - - // A-trous (odd, last) - PushPass("A-trous"); - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PING) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PING_SH1) ); - - PushOutput( AsUint(ResourceType::OUT_DIFF_SH0) ); - PushOutput( AsUint(ResourceType::OUT_DIFF_SH1) ); - - AddDispatch(RELAX_DiffuseSh_Atrous, SumConstants(0, 0, 0, 10), NumThreads(16, 16), 1 ); - } - - // A-trous (even, last) - PushPass("A-trous"); - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PONG) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PONG_SH1) ); - - PushOutput( AsUint(ResourceType::OUT_DIFF_SH0) ); - PushOutput( AsUint(ResourceType::OUT_DIFF_SH1) ); + if (isSmem) + PushPass("A-trous (SMEM)"); + else + PushPass("A-trous"); - AddDispatch(RELAX_DiffuseSh_Atrous, SumConstants(0, 0, 0, 10), NumThreads(16, 16), 1 ); + { + // Inputs + PushInput( AsUint(Transient::TILES) ); + + if (isSmem) + PushInput( AsUint(Permanent::DIFF_ILLUM_PREV) ); + else + PushInput( isEven ? AsUint(Transient::DIFF_ILLUM_PONG) : AsUint(Transient::DIFF_ILLUM_PING) ); + + PushInput( AsUint(Transient::HISTORY_LENGTH) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( hasConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); + + if (isSmem) + PushInput( AsUint(Permanent::DIFF_ILLUM_PREV_SH1) ); + else + PushInput( isEven ? AsUint(Transient::DIFF_ILLUM_PONG_SH1) : AsUint(Transient::DIFF_ILLUM_PING_SH1) ); + + // Outputs + if (isLast) + PushOutput( AsUint(ResourceType::OUT_DIFF_SH0) ); + else + PushOutput( isEven ? AsUint(Transient::DIFF_ILLUM_PING) : AsUint(Transient::DIFF_ILLUM_PONG) ); + + if (isSmem) + { + PushOutput( AsUint(Permanent::NORMAL_ROUGHNESS_PREV) ); + PushOutput( AsUint(Permanent::MATERIAL_ID_PREV) ); + PushOutput( AsUint(Permanent::VIEWZ_PREV) ); + } + + if (isLast) + PushOutput( AsUint(ResourceType::OUT_DIFF_SH1) ); + else + PushOutput( isEven ? AsUint(Transient::DIFF_ILLUM_PING_SH1) : AsUint(Transient::DIFF_ILLUM_PONG_SH1) ); + + // Shaders + uint32_t repeatNum = isLast ? 1 : (RELAX_MAX_ATROUS_PASS_NUM - 2 + 1) / 2; + if (isSmem) + AddDispatch( RELAX_DiffuseSh_AtrousSmem, RELAX_AtrousSmem, 1 ); + else + AddDispatchRepeated( RELAX_DiffuseSh_Atrous, RELAX_Atrous, 1, repeatNum ); + } } } PushPass("Split screen"); { + // Inputs PushInput( AsUint(ResourceType::IN_VIEWZ) ); PushInput( AsUint(ResourceType::IN_DIFF_RADIANCE_HITDIST) ); + // Outputs PushOutput( AsUint( ResourceType::OUT_DIFF_RADIANCE_HITDIST ) ); - AddDispatch( RELAX_Diffuse_SplitScreen, SumConstants(0, 0, 0, 2), NumThreads(16, 16), 1 ); + // Shaders + AddDispatch( RELAX_Diffuse_SplitScreen, RELAX_SplitScreen, 1 ); } RELAX_ADD_VALIDATION_DISPATCH; #undef DENOISER_NAME } - -void nrd::InstanceImpl::Update_RelaxDiffuseSh(const DenoiserData& denoiserData) -{ - enum class Dispatch - { - CLASSIFY_TILES, - HITDIST_RECONSTRUCTION_3x3, - HITDIST_RECONSTRUCTION_5x5, - PREPASS_AFTER_HITDIST_RECONSTRUCTION, - PREPASS, - TEMPORAL_ACCUMULATION, - TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS, - TEMPORAL_ACCUMULATION_WITH_THRESHOLD_MIX, - TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS_WITH_THRESHOLD_MIX, - HISTORY_FIX, - HISTORY_CLAMPING, - COPY, - FIREFLY, - ATROUS_SMEM, - ATROUS_ODD, - ATROUS_EVEN, - ATROUS_ODD_LAST, - ATROUS_EVEN_LAST, - ATROUS_SMEM_WITH_CONFIDENCE_INPUTS, - ATROUS_ODD_WITH_CONFIDENCE_INPUTS, - ATROUS_EVEN_WITH_CONFIDENCE_INPUTS, - ATROUS_ODD_LAST_WITH_CONFIDENCE_INPUTS, - ATROUS_EVEN_LAST_WITH_CONFIDENCE_INPUTS, - SPLIT_SCREEN, - VALIDATION, - }; - - const RelaxDiffuseSettings& settings = denoiserData.settings.diffuseRelax; - - NRD_DECLARE_DIMS; - - float maxLuminanceRelativeDifference = -ml::Log(ml::Saturate(settings.minLuminanceWeight)); - - float disocclusionThreshold = m_CommonSettings.disocclusionThreshold + (1.0f + m_JitterDelta) / float(rectH); - float disocclusionThresholdOrtho = disocclusionThreshold; - float disocclusionThresholdAlternate = m_CommonSettings.disocclusionThresholdAlternate + (1.0f + m_JitterDelta) / float(rectH); - float disocclusionThresholdAlternateOrtho = disocclusionThresholdAlternate; - float depthThresholdOrtho = settings.depthThreshold; - - float tanHalfFov = 1.0f / m_ViewToClip.a00; - float aspect = m_ViewToClip.a00 / m_ViewToClip.a11; - ml::float3 frustumRight = m_WorldToView.GetRow0().To3d() * tanHalfFov; - ml::float3 frustumUp = m_WorldToView.GetRow1().To3d() * tanHalfFov * aspect; - ml::float3 frustumForward = RELAX_GetFrustumForward(m_ViewToWorld, m_Frustum); - - float prevTanHalfFov = 1.0f / m_ViewToClipPrev.a00; - float prevAspect = m_ViewToClipPrev.a00 / m_ViewToClipPrev.a11; - ml::float3 prevFrustumRight = m_WorldToViewPrev.GetRow0().To3d() * prevTanHalfFov; - ml::float3 prevFrustumUp = m_WorldToViewPrev.GetRow1().To3d() * prevTanHalfFov * prevAspect; - ml::float3 prevFrustumForward = RELAX_GetFrustumForward(m_ViewToWorldPrev, m_FrustumPrev); - bool isCameraStatic = RELAX_IsCameraStatic(ml::float3(m_CameraDelta.x, m_CameraDelta.y, m_CameraDelta.z), frustumRight, frustumUp, frustumForward, prevFrustumRight, prevFrustumUp, prevFrustumForward); - - bool enableHitDistanceReconstruction = settings.hitDistanceReconstructionMode != HitDistanceReconstructionMode::OFF && settings.checkerboardMode == CheckerboardMode::OFF; - - // Checkerboard logic - uint32_t diffuseCheckerboard = 2; - - switch (settings.checkerboardMode) - { - case CheckerboardMode::BLACK: - diffuseCheckerboard = 0; - break; - case CheckerboardMode::WHITE: - diffuseCheckerboard = 1; - break; - default: - break; - } - - // SPLIT_SCREEN (passthrough) - if (m_CommonSettings.splitScreen >= 1.0f) - { - Constant* data = PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE); - AddFloat(data, m_CommonSettings.splitScreen); - AddUint(data, diffuseCheckerboard); - ValidateConstants(data); - - return; - } - - // CLASSIFY_TILES - Constant* data = PushDispatch(denoiserData, AsUint(Dispatch::CLASSIFY_TILES)); - AddFloat(data, m_CommonSettings.denoisingRange); - ValidateConstants(data); - - // HITDIST_RECONSTRUCTION - if (enableHitDistanceReconstruction) - { - bool is3x3 = settings.hitDistanceReconstructionMode == HitDistanceReconstructionMode::AREA_3X3; - data = PushDispatch(denoiserData, is3x3 ? AsUint(Dispatch::HITDIST_RECONSTRUCTION_3x3) : AsUint(Dispatch::HITDIST_RECONSTRUCTION_5x5)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE); - ValidateConstants(data); - } - - // PREPASS - data = PushDispatch(denoiserData, AsUint(enableHitDistanceReconstruction ? Dispatch::PREPASS_AFTER_HITDIST_RECONSTRUCTION : Dispatch::PREPASS)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE); - AddFloat4(data, m_Rotator_PrePass); - AddUint(data, diffuseCheckerboard); - AddFloat(data, settings.prepassBlurRadius); - AddFloat(data, 1.0f); - AddFloat(data, m_IsOrtho == 0 ? settings.depthThreshold : depthThresholdOrtho); - AddFloat(data, settings.diffuseLobeAngleFraction); - - ValidateConstants(data); - - // TEMPORAL_ACCUMULATION - if (!m_CommonSettings.isDisocclusionThresholdMixAvailable) - { - data = PushDispatch( - denoiserData, - AsUint(m_CommonSettings.isHistoryConfidenceAvailable ? - Dispatch::TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS : - Dispatch::TEMPORAL_ACCUMULATION)); - } - else - { - data = PushDispatch( - denoiserData, - AsUint(m_CommonSettings.isHistoryConfidenceAvailable ? - Dispatch::TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS_WITH_THRESHOLD_MIX : - Dispatch::TEMPORAL_ACCUMULATION_WITH_THRESHOLD_MIX)); - } - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE); - AddFloat(data, (float)settings.diffuseMaxAccumulatedFrameNum); - AddFloat(data, (float)settings.diffuseMaxFastAccumulatedFrameNum); - AddUint(data, diffuseCheckerboard); - AddFloat(data, m_IsOrtho == 0 ? disocclusionThreshold : disocclusionThresholdOrtho); - AddFloat(data, m_IsOrtho == 0 ? disocclusionThresholdAlternate : disocclusionThresholdAlternateOrtho); - AddUint(data, settings.enableReprojectionTestSkippingWithoutMotion && isCameraStatic); - AddUint(data, m_CommonSettings.isHistoryConfidenceAvailable ? 1 : 0); - AddUint(data, m_CommonSettings.isDisocclusionThresholdMixAvailable ? 1 : 0); - ValidateConstants(data); - - // HISTORY_FIX - data = PushDispatch(denoiserData, AsUint(Dispatch::HISTORY_FIX)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE); - AddFloat(data, m_IsOrtho == 0 ? settings.depthThreshold : depthThresholdOrtho); - AddFloat(data, settings.historyFixEdgeStoppingNormalPower); - AddFloat(data, settings.historyFixStrideBetweenSamples); - AddFloat(data, float(settings.historyFixFrameNum)); - ValidateConstants(data); - - // HISTORY_CLAMPING - data = PushDispatch(denoiserData, AsUint(Dispatch::HISTORY_CLAMPING)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE); - AddFloat(data, settings.historyClampingColorBoxSigmaScale); - AddFloat(data, float(settings.historyFixFrameNum)); - AddUint(data, settings.diffuseMaxFastAccumulatedFrameNum < settings.diffuseMaxAccumulatedFrameNum ? 1 : 0); - AddFloat(data, float(settings.antilagSettings.accelerationAmount)); - AddFloat(data, float(settings.antilagSettings.temporalSigmaScale)); - AddFloat(data, float(settings.antilagSettings.spatialSigmaScale)); - AddFloat(data, float(settings.antilagSettings.resetAmount)); - ValidateConstants(data); - - if (settings.enableAntiFirefly) - { - // COPY - data = PushDispatch(denoiserData, AsUint(Dispatch::COPY)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE); - ValidateConstants(data); - - // FIREFLY - data = PushDispatch(denoiserData, AsUint(Dispatch::FIREFLY)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE); - ValidateConstants(data); - } - - // A-TROUS - uint32_t iterationNum = ml::Clamp(settings.atrousIterationNum, 2u, RELAX_MAX_ATROUS_PASS_NUM); - for (uint32_t i = 0; i < iterationNum; i++) - { - Dispatch dispatch; - if (!m_CommonSettings.isHistoryConfidenceAvailable) - { - if (i == 0) - dispatch = Dispatch::ATROUS_SMEM; - else if (i == iterationNum - 1) - dispatch = (i % 2 == 0) ? Dispatch::ATROUS_EVEN_LAST : Dispatch::ATROUS_ODD_LAST; - else - dispatch = (i % 2 == 0) ? Dispatch::ATROUS_EVEN : Dispatch::ATROUS_ODD; - } - else - { - if (i == 0) - dispatch = Dispatch::ATROUS_SMEM_WITH_CONFIDENCE_INPUTS; - else if (i == iterationNum - 1) - dispatch = (i % 2 == 0) ? Dispatch::ATROUS_EVEN_LAST_WITH_CONFIDENCE_INPUTS : Dispatch::ATROUS_ODD_LAST_WITH_CONFIDENCE_INPUTS; - else - dispatch = (i % 2 == 0) ? Dispatch::ATROUS_EVEN_WITH_CONFIDENCE_INPUTS : Dispatch::ATROUS_ODD_WITH_CONFIDENCE_INPUTS; - } - - data = PushDispatch(denoiserData, AsUint(dispatch)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE); - - if (i == 0) - { - AddUint2(data, screenW, screenH); // For Atrous_shmem - AddUint(data, settings.spatialVarianceEstimationHistoryThreshold); - } - - AddFloat(data, settings.diffusePhiLuminance); - AddFloat(data, maxLuminanceRelativeDifference); - AddFloat(data, m_IsOrtho == 0 ? settings.depthThreshold : depthThresholdOrtho); - AddFloat(data, settings.diffuseLobeAngleFraction); - AddUint(data, 1 << i); - AddUint(data, m_CommonSettings.isHistoryConfidenceAvailable ? 1 : 0); - AddFloat(data, settings.confidenceDrivenRelaxationMultiplier); - AddFloat(data, settings.confidenceDrivenLuminanceEdgeStoppingRelaxation); - AddFloat(data, settings.confidenceDrivenNormalEdgeStoppingRelaxation); - if (i != 0) - { - AddUint(data, (i == iterationNum - 1) ? 1 : 0); - } - ValidateConstants(data); - } - - // SPLIT_SCREEN - if (m_CommonSettings.splitScreen > 0.0f) - { - data = PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE); - AddFloat(data, m_CommonSettings.splitScreen); - AddUint(data, diffuseCheckerboard); - ValidateConstants(data); - } - - // VALIDATION - if (m_CommonSettings.enableValidation) - { - data = PushDispatch(denoiserData, AsUint(Dispatch::VALIDATION)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - AddFloat4x4(data, m_WorldToClipPrev); - AddFloat2(data, m_CommonSettings.cameraJitter[0], m_CommonSettings.cameraJitter[1]); - AddFloat(data, (float)settings.diffuseMaxAccumulatedFrameNum); - ValidateConstants(data); - } -} diff --git a/Source/Denoisers/Relax_DiffuseSpecular.hpp b/Source/Denoisers/Relax_DiffuseSpecular.hpp index 877f8ee..437faad 100644 --- a/Source/Denoisers/Relax_DiffuseSpecular.hpp +++ b/Source/Denoisers/Relax_DiffuseSpecular.hpp @@ -12,13 +12,8 @@ void nrd::InstanceImpl::Add_RelaxDiffuseSpecular(DenoiserData& denoiserData) { #define DENOISER_NAME RELAX_DiffuseSpecular - denoiserData.settings.diffuseSpecularRelax = RelaxDiffuseSpecularSettings(); - denoiserData.settingsSize = sizeof(denoiserData.settings.diffuseSpecularRelax); - - uint16_t w = denoiserData.desc.renderWidth; - uint16_t h = denoiserData.desc.renderHeight; - uint16_t tilesW = DivideUp(w, 16); - uint16_t tilesH = DivideUp(h, 16); + denoiserData.settings.relax = RelaxSettings(); + denoiserData.settingsSize = sizeof(denoiserData.settings.relax); enum class Permanent { @@ -34,16 +29,16 @@ void nrd::InstanceImpl::Add_RelaxDiffuseSpecular(DenoiserData& denoiserData) VIEWZ_PREV, }; - AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::R16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::R16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::R8_UNORM, w, h, 1} ); - AddTextureToPermanentPool( {Format::RGBA8_UNORM, w, h, 1} ); - AddTextureToPermanentPool( {Format::R8_UNORM, w, h, 1} ); - AddTextureToPermanentPool( {Format::R32_SFLOAT, w, h, 1} ); + AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::R16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::R16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::R8_UNORM, 1} ); + AddTextureToPermanentPool( {Format::RGBA8_UNORM, 1} ); + AddTextureToPermanentPool( {Format::R8_UNORM, 1} ); + AddTextureToPermanentPool( {Format::R32_SFLOAT, 1} ); enum class Transient { @@ -56,94 +51,81 @@ void nrd::InstanceImpl::Add_RelaxDiffuseSpecular(DenoiserData& denoiserData) HISTORY_LENGTH }; - AddTextureToTransientPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, tilesW, tilesH, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, w, h, 1} ); - - RELAX_SET_SHARED_CONSTANTS; - - const uint32_t halfMaxPassNum = (RELAX_MAX_ATROUS_PASS_NUM - 2 + 1) / 2; + AddTextureToTransientPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::R8_UNORM, 1} ); + AddTextureToTransientPool( {Format::R8_UNORM, 16} ); + AddTextureToTransientPool( {Format::R8_UNORM, 1} ); PushPass("Classify tiles"); { - PushInput(AsUint(ResourceType::IN_VIEWZ)); - PushOutput(AsUint(Transient::TILES)); - - AddDispatch(RELAX_ClassifyTiles, SumConstants(0, 0, 0, 1, false), NumThreads(16, 16), 1); - } - - PushPass("Hit distance reconstruction"); // 3x3 - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_SPEC_RADIANCE_HITDIST) ); - PushInput( AsUint(ResourceType::IN_DIFF_RADIANCE_HITDIST) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + // Inputs PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushOutput( AsUint(Transient::SPEC_ILLUM_PING) ); - PushOutput( AsUint(Transient::DIFF_ILLUM_PING) ); + // Outputs + PushOutput( AsUint(Transient::TILES) ); - AddDispatch( RELAX_DiffuseSpecular_HitDistReconstruction, SumConstants(0, 0, 0, 0), NumThreads(8, 8), 1 ); + // Shaders + AddDispatch( RELAX_ClassifyTiles, RELAX_ClassifyTiles, 1 ); } - PushPass("Hit distance reconstruction"); // 5x5 + for (int i = 0; i < RELAX_HITDIST_RECONSTRUCTION_PERMUTATION_NUM; i++) { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_SPEC_RADIANCE_HITDIST) ); - PushInput( AsUint(ResourceType::IN_DIFF_RADIANCE_HITDIST) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - - PushOutput(AsUint(Transient::SPEC_ILLUM_PING)); - PushOutput(AsUint(Transient::DIFF_ILLUM_PING)); + bool is5x5 = ( ( ( i >> 0 ) & 0x1 ) != 0 ); - AddDispatch( RELAX_DiffuseSpecular_HitDistReconstruction_5x5, SumConstants(0, 0, 0, 0), NumThreads(8, 8), 1 ); - } - - PushPass("Pre-pass"); // After hit distance reconstruction - { - // Does preblur (if enabled) and checkerboard reconstruction (if enabled) - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PING) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PING) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushPass("Hit distance reconstruction"); + { + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_SPEC_RADIANCE_HITDIST) ); + PushInput( AsUint(ResourceType::IN_DIFF_RADIANCE_HITDIST) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushOutput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); - PushOutput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); + // Outputs + PushOutput( AsUint(Transient::SPEC_ILLUM_PING) ); + PushOutput( AsUint(Transient::DIFF_ILLUM_PING) ); - AddDispatch( RELAX_DiffuseSpecular_PrePass, SumConstants(0, 1, 0, 10), NumThreads(16, 16), 1 ); + // Shaders + if (is5x5) + AddDispatch( RELAX_DiffuseSpecular_HitDistReconstruction_5x5, RELAX_HitDistReconstruction, 1 ); + else + AddDispatch( RELAX_DiffuseSpecular_HitDistReconstruction, RELAX_HitDistReconstruction, 1 ); + } } - PushPass("Pre-pass"); // Without hit distance reconstruction + for (int i = 0; i < RELAX_PREPASS_PERMUTATION_NUM; i++) { - // Does preblur (if enabled) and checkerboard reconstruction (if enabled) - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_SPEC_RADIANCE_HITDIST) ); - PushInput( AsUint(ResourceType::IN_DIFF_RADIANCE_HITDIST) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); + bool isAfterReconstruction = ( ( ( i >> 0 ) & 0x1 ) != 0 ); - PushOutput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); - PushOutput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); + PushPass("Pre-pass"); + { + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( isAfterReconstruction ? AsUint(Transient::SPEC_ILLUM_PING) : AsUint(ResourceType::IN_SPEC_RADIANCE_HITDIST) ); + PushInput( isAfterReconstruction ? AsUint(Transient::DIFF_ILLUM_PING) : AsUint(ResourceType::IN_DIFF_RADIANCE_HITDIST) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); - AddDispatch( RELAX_DiffuseSpecular_PrePass, SumConstants(0, 1, 0, 10), NumThreads(16, 16), 1 ); + // Outputs + PushOutput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); + PushOutput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); + + // Shaders + AddDispatch( RELAX_DiffuseSpecular_PrePass, RELAX_PrePass, 1 ); + } } - for (int i = 0; i < 4; i++) + for (int i = 0; i < RELAX_TEMPORAL_ACCUMULATION_PERMUTATION_NUM; i++) { - // The following passes are defined here: - // TEMPORAL_ACCUMULATION, - // TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS, - // TEMPORAL_ACCUMULATION_WITH_THRESHOLD_MIX, - // TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS_WITH_THRESHOLD_MIX + bool hasDisocclusionThresholdMix = ( ( ( i >> 1 ) & 0x1 ) != 0 ); + bool hasConfidenceInputs = ( ( ( i >> 0 ) & 0x1 ) != 0 ); PushPass("Temporal accumulation"); { + // Inputs PushInput( AsUint(Transient::TILES) ); PushInput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); PushInput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); @@ -156,50 +138,30 @@ void nrd::InstanceImpl::Add_RelaxDiffuseSpecular(DenoiserData& denoiserData) PushInput( AsUint(Permanent::DIFF_ILLUM_PREV) ); PushInput( AsUint(Permanent::NORMAL_ROUGHNESS_PREV) ); PushInput( AsUint(Permanent::VIEWZ_PREV) ); - PushInput( AsUint(Permanent::REFLECTION_HIT_T_PREV), 0, 1, AsUint(Permanent::REFLECTION_HIT_T_CURR) ); + PushInput( AsUint(Permanent::REFLECTION_HIT_T_PREV), AsUint(Permanent::REFLECTION_HIT_T_CURR) ); PushInput( AsUint(Permanent::HISTORY_LENGTH_PREV) ); PushInput( AsUint(Permanent::MATERIAL_ID_PREV) ); + PushInput( hasConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : RELAX_DUMMY ); + PushInput( hasConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : RELAX_DUMMY ); + PushInput( hasDisocclusionThresholdMix ? AsUint(ResourceType::IN_DISOCCLUSION_THRESHOLD_MIX) : RELAX_DUMMY ); - // Confidence inputs: - if (i == 0) - { - PushInput( AsUint(ResourceType::IN_VIEWZ) ); // Bogus input that will not be fetched anyway - PushInput( AsUint(ResourceType::IN_VIEWZ) ); // Bogus input that will not be fetched anyway - PushInput( AsUint(Permanent::HISTORY_LENGTH_PREV) ); // Bogus input that will not be fetched anyway - } - if (i == 1) - { - PushInput( AsUint(ResourceType::IN_SPEC_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_DIFF_CONFIDENCE) ); - PushInput( AsUint(Permanent::HISTORY_LENGTH_PREV) ); // Bogus input that will not be fetched anyway - } - if (i == 2) - { - PushInput( AsUint(ResourceType::IN_VIEWZ) ); // Bogus input that will not be fetched anyway - PushInput( AsUint(ResourceType::IN_VIEWZ) ); // Bogus input that will not be fetched anyway - PushInput( AsUint(ResourceType::IN_DISOCCLUSION_THRESHOLD_MIX) ); - } - if (i == 3) - { - PushInput( AsUint(ResourceType::IN_SPEC_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_DIFF_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_DISOCCLUSION_THRESHOLD_MIX) ); - } - + // Outputs PushOutput( AsUint(Transient::SPEC_ILLUM_PING) ); PushOutput( AsUint(Transient::DIFF_ILLUM_PING) ); PushOutput( AsUint(Transient::SPEC_ILLUM_PONG) ); PushOutput( AsUint(Transient::DIFF_ILLUM_PONG) ); - PushOutput( AsUint(Permanent::REFLECTION_HIT_T_CURR), 0, 1, AsUint(Permanent::REFLECTION_HIT_T_PREV) ); + PushOutput( AsUint(Permanent::REFLECTION_HIT_T_CURR), AsUint(Permanent::REFLECTION_HIT_T_PREV) ); PushOutput( AsUint(Transient::HISTORY_LENGTH) ); PushOutput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); - AddDispatch(RELAX_DiffuseSpecular_TemporalAccumulation, SumConstants(0, 0, 0, 13), NumThreads(8, 8), 1); + // Shaders + AddDispatch( RELAX_DiffuseSpecular_TemporalAccumulation, RELAX_TemporalAccumulation, 1 ); } } PushPass("History fix"); { + // Inputs PushInput( AsUint(Transient::TILES) ); PushInput( AsUint(Transient::SPEC_ILLUM_PING) ); // Normal history PushInput( AsUint(Transient::DIFF_ILLUM_PING) ); @@ -207,14 +169,17 @@ void nrd::InstanceImpl::Add_RelaxDiffuseSpecular(DenoiserData& denoiserData) PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); PushInput( AsUint(ResourceType::IN_VIEWZ) ); + // Outputs PushOutput( AsUint(Transient::SPEC_ILLUM_PONG) ); // Responsive history PushOutput( AsUint(Transient::DIFF_ILLUM_PONG) ); - AddDispatch( RELAX_DiffuseSpecular_HistoryFix, SumConstants(0, 0, 0, 8), NumThreads(8, 8), 1 ); + // Shaders + AddDispatch( RELAX_DiffuseSpecular_HistoryFix, RELAX_HistoryFix, 1 ); } PushPass("History clamping"); { + // Inputs PushInput( AsUint(Transient::TILES) ); PushInput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); // Noisy input with preblur applied PushInput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); @@ -224,424 +189,130 @@ void nrd::InstanceImpl::Add_RelaxDiffuseSpecular(DenoiserData& denoiserData) PushInput( AsUint(Transient::DIFF_ILLUM_PONG) ); PushInput( AsUint(Transient::HISTORY_LENGTH) ); + // Outputs PushOutput( AsUint(Permanent::SPEC_ILLUM_PREV) ); PushOutput( AsUint(Permanent::DIFF_ILLUM_PREV) ); PushOutput( AsUint(Permanent::SPEC_ILLUM_RESPONSIVE_PREV) ); PushOutput( AsUint(Permanent::DIFF_ILLUM_RESPONSIVE_PREV) ); PushOutput( AsUint(Permanent::HISTORY_LENGTH_PREV) ); - AddDispatch( RELAX_DiffuseSpecular_HistoryClamping, SumConstants(0, 0, 0, 8), NumThreads(8, 8), 1 ); + // Shaders + AddDispatch( RELAX_DiffuseSpecular_HistoryClamping, RELAX_HistoryClamping, 1 ); } PushPass("Copy"); { + // Inputs PushInput( AsUint(Permanent::SPEC_ILLUM_PREV) ); PushInput( AsUint(Permanent::DIFF_ILLUM_PREV) ); + + // Outputs PushOutput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); PushOutput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); - AddDispatch( RELAX_DiffuseSpecular_Copy, SumConstants(0, 0, 0, 0), NumThreads(8, 8), 1 ); + // Shaders + AddDispatch( RELAX_DiffuseSpecular_Copy, RELAX_Copy, 1 ); } PushPass("Anti-firefly"); { + // Inputs PushInput( AsUint(Transient::TILES) ); PushInput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); PushInput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); PushInput( AsUint(ResourceType::IN_VIEWZ) ); + // Outputs PushOutput( AsUint(Permanent::SPEC_ILLUM_PREV) ); PushOutput( AsUint(Permanent::DIFF_ILLUM_PREV) ); - AddDispatch( RELAX_DiffuseSpecular_AntiFirefly, SumConstants(0, 0, 0, 0), NumThreads(16, 16), 1 ); + // Shaders + AddDispatch( RELAX_DiffuseSpecular_AntiFirefly, RELAX_AntiFirefly, 1 ); } - for (int i = 0; i < 2; i++) + for (int i = 0; i < RELAX_ATROUS_PERMUTATION_NUM; i++) { - bool withConfidenceInputs = (i == 1); - - // A-trous (first) - PushPass("A-trous (SMEM)"); - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Permanent::SPEC_ILLUM_PREV) ); - PushInput( AsUint(Permanent::DIFF_ILLUM_PREV) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - - PushOutput( AsUint(Transient::SPEC_ILLUM_PING) ); - PushOutput( AsUint(Transient::DIFF_ILLUM_PING) ); - PushOutput( AsUint(Permanent::NORMAL_ROUGHNESS_PREV) ); - PushOutput( AsUint(Permanent::MATERIAL_ID_PREV) ); - PushOutput( AsUint(Permanent::VIEWZ_PREV) ); - - AddDispatch( RELAX_DiffuseSpecular_AtrousSmem, SumConstants(0, 0, 1, 19), NumThreads(8, 8), 1 ); - } + bool hasConfidenceInputs = ( ( ( i >> 0 ) & 0x1 ) != 0 ); - // A-trous (odd) - PushPass("A-trous"); + for (int j = 0; j < RELAX_ATROUS_BINDING_VARIANT_NUM; j++) { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PING) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PING) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - - PushOutput( AsUint(Transient::SPEC_ILLUM_PONG) ); - PushOutput( AsUint(Transient::DIFF_ILLUM_PONG) ); + bool isSmem = j == 0; + bool isEven = j % 2 == 0; + bool isLast = j > 2; - AddDispatchRepeated( RELAX_DiffuseSpecular_Atrous, SumConstants(0, 0, 0, 18), NumThreads(16, 16), 1, halfMaxPassNum ); - } - - // A-trous (even) - PushPass("A-trous"); - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PONG) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PONG) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - - PushOutput( AsUint(Transient::SPEC_ILLUM_PING) ); - PushOutput( AsUint(Transient::DIFF_ILLUM_PING) ); - - AddDispatchRepeated( RELAX_DiffuseSpecular_Atrous, SumConstants(0, 0, 0, 18), NumThreads(16, 16), 1, halfMaxPassNum ); - } - - // A-trous (odd, last) - PushPass("A-trous"); - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PING) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PING) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - - PushOutput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); - PushOutput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); - - AddDispatch( RELAX_DiffuseSpecular_Atrous, SumConstants(0, 0, 0, 18), NumThreads(16, 16), 1 ); - } - - // A-trous (even, last) - PushPass("A-trous"); - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PONG) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PONG) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - - PushOutput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); - PushOutput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); + if (isSmem) + PushPass("A-trous (SMEM)"); + else + PushPass("A-trous"); - AddDispatch( RELAX_DiffuseSpecular_Atrous, SumConstants(0, 0, 0, 18), NumThreads(16, 16), 1 ); + { + // Inputs + PushInput( AsUint(Transient::TILES) ); + + if (isSmem) + { + PushInput( AsUint(Permanent::SPEC_ILLUM_PREV) ); + PushInput( AsUint(Permanent::DIFF_ILLUM_PREV) ); + } + else + { + PushInput( isEven ? AsUint(Transient::SPEC_ILLUM_PONG) : AsUint(Transient::SPEC_ILLUM_PING) ); + PushInput( isEven ? AsUint(Transient::DIFF_ILLUM_PONG) : AsUint(Transient::DIFF_ILLUM_PING) ); + } + + PushInput( AsUint(Transient::HISTORY_LENGTH) ); + PushInput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( hasConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); + PushInput( hasConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); + + // Outputs + if (isLast) + { + PushOutput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); + PushOutput( AsUint(ResourceType::OUT_DIFF_RADIANCE_HITDIST) ); + } + else + { + PushOutput( isEven ? AsUint(Transient::SPEC_ILLUM_PING) : AsUint(Transient::SPEC_ILLUM_PONG) ); + PushOutput( isEven ? AsUint(Transient::DIFF_ILLUM_PING) : AsUint(Transient::DIFF_ILLUM_PONG) ); + } + + if (isSmem) + { + PushOutput( AsUint(Permanent::NORMAL_ROUGHNESS_PREV) ); + PushOutput( AsUint(Permanent::MATERIAL_ID_PREV) ); + PushOutput( AsUint(Permanent::VIEWZ_PREV) ); + } + + // Shaders + uint32_t repeatNum = isLast ? 1 : (RELAX_MAX_ATROUS_PASS_NUM - 2 + 1) / 2; + if (isSmem) + AddDispatch( RELAX_DiffuseSpecular_AtrousSmem, RELAX_AtrousSmem, 1 ); + else + AddDispatchRepeated( RELAX_DiffuseSpecular_Atrous, RELAX_Atrous, 1, repeatNum ); + } } } PushPass("Split screen"); { + // Inputs PushInput( AsUint(ResourceType::IN_VIEWZ) ); PushInput( AsUint(ResourceType::IN_SPEC_RADIANCE_HITDIST) ); PushInput( AsUint(ResourceType::IN_DIFF_RADIANCE_HITDIST) ); + // Outputs PushOutput( AsUint( ResourceType::OUT_SPEC_RADIANCE_HITDIST ) ); PushOutput( AsUint( ResourceType::OUT_DIFF_RADIANCE_HITDIST ) ); - AddDispatch( RELAX_DiffuseSpecular_SplitScreen, SumConstants(0, 0, 0, 3), NumThreads(16, 16), 1 ); + // Shaders + AddDispatch( RELAX_DiffuseSpecular_SplitScreen, RELAX_SplitScreen, 1 ); } RELAX_ADD_VALIDATION_DISPATCH; #undef DENOISER_NAME } - -void nrd::InstanceImpl::Update_RelaxDiffuseSpecular(const DenoiserData& denoiserData) -{ - enum class Dispatch - { - CLASSIFY_TILES, - HITDIST_RECONSTRUCTION_3x3, - HITDIST_RECONSTRUCTION_5x5, - PREPASS_AFTER_HITDIST_RECONSTRUCTION, - PREPASS, - TEMPORAL_ACCUMULATION, - TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS, - TEMPORAL_ACCUMULATION_WITH_THRESHOLD_MIX, - TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS_WITH_THRESHOLD_MIX, - HISTORY_FIX, - HISTORY_CLAMPING, - COPY, - FIREFLY, - ATROUS_SMEM, - ATROUS_ODD, - ATROUS_EVEN, - ATROUS_ODD_LAST, - ATROUS_EVEN_LAST, - ATROUS_SMEM_WITH_CONFIDENCE_INPUTS, - ATROUS_ODD_WITH_CONFIDENCE_INPUTS, - ATROUS_EVEN_WITH_CONFIDENCE_INPUTS, - ATROUS_ODD_LAST_WITH_CONFIDENCE_INPUTS, - ATROUS_EVEN_LAST_WITH_CONFIDENCE_INPUTS, - SPLIT_SCREEN, - VALIDATION, - }; - - const RelaxDiffuseSpecularSettings& settings = denoiserData.settings.diffuseSpecularRelax; - - NRD_DECLARE_DIMS; - - float maxDiffuseLuminanceRelativeDifference = -ml::Log( ml::Saturate(settings.diffuseMinLuminanceWeight) ); - float maxSpecularLuminanceRelativeDifference = -ml::Log( ml::Saturate(settings.specularMinLuminanceWeight) ); - - float disocclusionThreshold = m_CommonSettings.disocclusionThreshold + (1.0f + m_JitterDelta) / float(rectH); - float disocclusionThresholdOrtho = disocclusionThreshold; - float disocclusionThresholdAlternate = m_CommonSettings.disocclusionThresholdAlternate + (1.0f + m_JitterDelta) / float(rectH); - float disocclusionThresholdAlternateOrtho = disocclusionThresholdAlternate; - float depthThresholdOrtho = settings.depthThreshold; - - float tanHalfFov = 1.0f / m_ViewToClip.a00; - float aspect = m_ViewToClip.a00 / m_ViewToClip.a11; - ml::float3 frustumRight = m_WorldToView.GetRow0().To3d() * tanHalfFov; - ml::float3 frustumUp = m_WorldToView.GetRow1().To3d() * tanHalfFov * aspect; - ml::float3 frustumForward = RELAX_GetFrustumForward(m_ViewToWorld, m_Frustum); - - float prevTanHalfFov = 1.0f / m_ViewToClipPrev.a00; - float prevAspect = m_ViewToClipPrev.a00 / m_ViewToClipPrev.a11; - ml::float3 prevFrustumRight = m_WorldToViewPrev.GetRow0().To3d() * prevTanHalfFov; - ml::float3 prevFrustumUp = m_WorldToViewPrev.GetRow1().To3d() * prevTanHalfFov * prevAspect; - ml::float3 prevFrustumForward = RELAX_GetFrustumForward(m_ViewToWorldPrev, m_FrustumPrev); - bool isCameraStatic = RELAX_IsCameraStatic(ml::float3(m_CameraDelta.x, m_CameraDelta.y, m_CameraDelta.z), frustumRight, frustumUp, frustumForward, prevFrustumRight, prevFrustumUp, prevFrustumForward); - - bool enableHitDistanceReconstruction = settings.hitDistanceReconstructionMode != HitDistanceReconstructionMode::OFF && settings.checkerboardMode == CheckerboardMode::OFF; - - // Checkerboard logic - uint32_t specularCheckerboard = 2; - uint32_t diffuseCheckerboard = 2; - - switch (settings.checkerboardMode) - { - case CheckerboardMode::BLACK: - diffuseCheckerboard = 0; - specularCheckerboard = 1; - break; - case CheckerboardMode::WHITE: - diffuseCheckerboard = 1; - specularCheckerboard = 0; - break; - default: - break; - } - - // SPLIT_SCREEN (passthrough) - if (m_CommonSettings.splitScreen >= 1.0f) - { - Constant* data = PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - AddFloat(data, m_CommonSettings.splitScreen); - AddUint(data, diffuseCheckerboard); - AddUint(data, specularCheckerboard); - ValidateConstants(data); - - return; - } - - // CLASSIFY_TILES - Constant* data = PushDispatch(denoiserData, AsUint(Dispatch::CLASSIFY_TILES)); - AddFloat(data, m_CommonSettings.denoisingRange); - ValidateConstants(data); - - // HITDIST_RECONSTRUCTION - if (enableHitDistanceReconstruction) - { - bool is3x3 = settings.hitDistanceReconstructionMode == HitDistanceReconstructionMode::AREA_3X3; - data = PushDispatch(denoiserData, is3x3 ? AsUint(Dispatch::HITDIST_RECONSTRUCTION_3x3) : AsUint(Dispatch::HITDIST_RECONSTRUCTION_5x5)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - ValidateConstants(data); - } - - // PREPASS - data = PushDispatch(denoiserData, AsUint(enableHitDistanceReconstruction ? Dispatch::PREPASS_AFTER_HITDIST_RECONSTRUCTION : Dispatch::PREPASS)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - AddFloat4(data, m_Rotator_PrePass); - AddUint(data, diffuseCheckerboard); - AddUint(data, specularCheckerboard); - AddFloat(data, settings.diffusePrepassBlurRadius); - AddFloat(data, settings.specularPrepassBlurRadius); - AddFloat(data, 1.0f); - AddFloat(data, m_IsOrtho == 0 ? settings.depthThreshold : depthThresholdOrtho); - AddFloat(data, settings.diffuseLobeAngleFraction); - AddFloat(data, settings.specularLobeAngleFraction); - AddFloat(data, settings.specularLobeAngleSlack); - AddFloat(data, settings.roughnessFraction); - ValidateConstants(data); - - // TEMPORAL_ACCUMULATION - if (!m_CommonSettings.isDisocclusionThresholdMixAvailable) - { - data = PushDispatch( - denoiserData, - AsUint(m_CommonSettings.isHistoryConfidenceAvailable ? - Dispatch::TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS : - Dispatch::TEMPORAL_ACCUMULATION)); - } - else - { - data = PushDispatch( - denoiserData, - AsUint(m_CommonSettings.isHistoryConfidenceAvailable ? - Dispatch::TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS_WITH_THRESHOLD_MIX : - Dispatch::TEMPORAL_ACCUMULATION_WITH_THRESHOLD_MIX)); - } - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - AddFloat(data, (float)settings.specularMaxAccumulatedFrameNum); - AddFloat(data, (float)settings.specularMaxFastAccumulatedFrameNum); - AddFloat(data, (float)settings.diffuseMaxAccumulatedFrameNum); - AddFloat(data, (float)settings.diffuseMaxFastAccumulatedFrameNum); - AddUint(data, diffuseCheckerboard); - AddUint(data, specularCheckerboard); - AddFloat(data, m_IsOrtho == 0 ? disocclusionThreshold : disocclusionThresholdOrtho); - AddFloat(data, m_IsOrtho == 0 ? disocclusionThresholdAlternate : disocclusionThresholdAlternateOrtho); - AddFloat(data, settings.roughnessFraction); - AddFloat(data, settings.specularVarianceBoost); - AddUint(data, settings.enableReprojectionTestSkippingWithoutMotion && isCameraStatic); - AddUint(data, m_CommonSettings.isHistoryConfidenceAvailable ? 1 : 0); - AddUint(data, m_CommonSettings.isDisocclusionThresholdMixAvailable ? 1 : 0); - ValidateConstants(data); - - // HISTORY_FIX - data = PushDispatch(denoiserData, AsUint(Dispatch::HISTORY_FIX)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - AddFloat(data, m_IsOrtho == 0 ? settings.depthThreshold : depthThresholdOrtho); - AddFloat(data, settings.historyFixEdgeStoppingNormalPower); - AddFloat(data, settings.historyFixStrideBetweenSamples); - AddFloat(data, float(settings.historyFixFrameNum)); - AddFloat(data, settings.specularLobeAngleFraction); - AddFloat(data, ml::DegToRad(settings.specularLobeAngleSlack)); - AddFloat(data, settings.roughnessEdgeStoppingRelaxation); - AddFloat(data, settings.normalEdgeStoppingRelaxation); - ValidateConstants(data); - - // HISTORY_CLAMPING - data = PushDispatch(denoiserData, AsUint(Dispatch::HISTORY_CLAMPING)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - AddFloat(data, settings.historyClampingColorBoxSigmaScale); - AddFloat(data, float(settings.historyFixFrameNum)); - AddUint(data, settings.specularMaxFastAccumulatedFrameNum < settings.specularMaxAccumulatedFrameNum ? 1 : 0); - AddUint(data, settings.diffuseMaxFastAccumulatedFrameNum < settings.diffuseMaxAccumulatedFrameNum ? 1 : 0); - AddFloat(data, float(settings.antilagSettings.accelerationAmount)); - AddFloat(data, float(settings.antilagSettings.temporalSigmaScale)); - AddFloat(data, float(settings.antilagSettings.spatialSigmaScale)); - AddFloat(data, float(settings.antilagSettings.resetAmount)); - ValidateConstants(data); - - if (settings.enableAntiFirefly) - { - // COPY - data = PushDispatch(denoiserData, AsUint(Dispatch::COPY)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - ValidateConstants(data); - - // FIREFLY - data = PushDispatch(denoiserData, AsUint(Dispatch::FIREFLY)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - ValidateConstants(data); - } - - // A-TROUS - uint32_t iterationNum = ml::Clamp(settings.atrousIterationNum, 2u, RELAX_MAX_ATROUS_PASS_NUM); - for (uint32_t i = 0; i < iterationNum; i++) - { - Dispatch dispatch; - if (!m_CommonSettings.isHistoryConfidenceAvailable) - { - if (i == 0) - dispatch = Dispatch::ATROUS_SMEM; - else if (i == iterationNum - 1) - dispatch = (i % 2 == 0) ? Dispatch::ATROUS_EVEN_LAST : Dispatch::ATROUS_ODD_LAST; - else - dispatch = (i % 2 == 0) ? Dispatch::ATROUS_EVEN : Dispatch::ATROUS_ODD; - } - else - { - if (i == 0) - dispatch = Dispatch::ATROUS_SMEM_WITH_CONFIDENCE_INPUTS; - else if (i == iterationNum - 1) - dispatch = (i % 2 == 0) ? Dispatch::ATROUS_EVEN_LAST_WITH_CONFIDENCE_INPUTS : Dispatch::ATROUS_ODD_LAST_WITH_CONFIDENCE_INPUTS; - else - dispatch = (i % 2 == 0) ? Dispatch::ATROUS_EVEN_WITH_CONFIDENCE_INPUTS : Dispatch::ATROUS_ODD_WITH_CONFIDENCE_INPUTS; - } - - data = PushDispatch(denoiserData, AsUint(dispatch)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - - if (i == 0) - { - AddUint2(data, screenW, screenH); // For Atrous_shmem - AddUint(data, settings.spatialVarianceEstimationHistoryThreshold); - } - - AddFloat(data, settings.specularPhiLuminance); - AddFloat(data, settings.diffusePhiLuminance); - AddFloat(data, maxDiffuseLuminanceRelativeDifference); - AddFloat(data, maxSpecularLuminanceRelativeDifference); - AddFloat(data, m_IsOrtho == 0 ? settings.depthThreshold : depthThresholdOrtho); - AddFloat(data, settings.diffuseLobeAngleFraction); - AddFloat(data, settings.roughnessFraction); - AddFloat(data, settings.specularLobeAngleFraction); - AddFloat(data, ml::DegToRad(settings.specularLobeAngleSlack)); - AddUint(data, 1 << i); - AddUint(data, settings.enableRoughnessEdgeStopping); - AddFloat(data, settings.roughnessEdgeStoppingRelaxation); - AddFloat(data, settings.normalEdgeStoppingRelaxation); - AddFloat(data, settings.luminanceEdgeStoppingRelaxation); - AddUint(data, m_CommonSettings.isHistoryConfidenceAvailable ? 1 : 0); - AddFloat(data, settings.confidenceDrivenRelaxationMultiplier); - AddFloat(data, settings.confidenceDrivenLuminanceEdgeStoppingRelaxation); - AddFloat(data, settings.confidenceDrivenNormalEdgeStoppingRelaxation); - ValidateConstants(data); - } - - // SPLIT_SCREEN - if (m_CommonSettings.splitScreen > 0.0f) - { - data = PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - AddFloat(data, m_CommonSettings.splitScreen); - AddUint(data, diffuseCheckerboard); - AddUint(data, specularCheckerboard); - ValidateConstants(data); - } - - // VALIDATION - if (m_CommonSettings.enableValidation) - { - data = PushDispatch(denoiserData, AsUint(Dispatch::VALIDATION)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - AddFloat4x4(data, m_WorldToClipPrev); - AddFloat2(data, m_CommonSettings.cameraJitter[0], m_CommonSettings.cameraJitter[1]); - AddFloat(data, (float)ml::Max(settings.diffuseMaxAccumulatedFrameNum, settings.specularMaxAccumulatedFrameNum)); - ValidateConstants(data); - } -} diff --git a/Source/Denoisers/Relax_DiffuseSpecularSh.hpp b/Source/Denoisers/Relax_DiffuseSpecularSh.hpp index 936190a..e7e8188 100644 --- a/Source/Denoisers/Relax_DiffuseSpecularSh.hpp +++ b/Source/Denoisers/Relax_DiffuseSpecularSh.hpp @@ -12,13 +12,8 @@ void nrd::InstanceImpl::Add_RelaxDiffuseSpecularSh(DenoiserData& denoiserData) { #define DENOISER_NAME RELAX_DiffuseSpecular - denoiserData.settings.diffuseSpecularRelax = RelaxDiffuseSpecularSettings(); - denoiserData.settingsSize = sizeof(denoiserData.settings.diffuseSpecularRelax); - - uint16_t w = denoiserData.desc.renderWidth; - uint16_t h = denoiserData.desc.renderHeight; - uint16_t tilesW = DivideUp(w, 16); - uint16_t tilesH = DivideUp(h, 16); + denoiserData.settings.relax = RelaxSettings(); + denoiserData.settingsSize = sizeof(denoiserData.settings.relax); enum class Permanent { @@ -38,20 +33,20 @@ void nrd::InstanceImpl::Add_RelaxDiffuseSpecularSh(DenoiserData& denoiserData) VIEWZ_PREV, }; - AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::R16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::R16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::R8_UNORM, w, h, 1} ); - AddTextureToPermanentPool( {Format::RGBA8_UNORM, w, h, 1} ); - AddTextureToPermanentPool( {Format::R8_UNORM, w, h, 1} ); - AddTextureToPermanentPool( {Format::R32_SFLOAT, w, h, 1} ); + AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::R16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::R16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::R8_UNORM, 1} ); + AddTextureToPermanentPool( {Format::RGBA8_UNORM, 1} ); + AddTextureToPermanentPool( {Format::R8_UNORM, 1} ); + AddTextureToPermanentPool( {Format::R32_SFLOAT, 1} ); enum class Transient { @@ -68,106 +63,89 @@ void nrd::InstanceImpl::Add_RelaxDiffuseSpecularSh(DenoiserData& denoiserData) HISTORY_LENGTH }; - AddTextureToTransientPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, tilesW, tilesH, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, w, h, 1} ); - - RELAX_SET_SHARED_CONSTANTS; - - const uint32_t halfMaxPassNum = (RELAX_MAX_ATROUS_PASS_NUM - 2 + 1) / 2; + AddTextureToTransientPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::R8_UNORM, 1} ); + AddTextureToTransientPool( {Format::R8_UNORM, 16} ); + AddTextureToTransientPool( {Format::R8_UNORM, 1} ); PushPass("Classify tiles"); { - PushInput(AsUint(ResourceType::IN_VIEWZ)); - PushOutput(AsUint(Transient::TILES)); - - AddDispatch(RELAX_ClassifyTiles, SumConstants(0, 0, 0, 1, false), NumThreads(16, 16), 1); - } - - PushPass("Hit distance reconstruction 3x3"); // 3x3 - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_SPEC_SH0) ); - PushInput( AsUint(ResourceType::IN_DIFF_SH0) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + // Inputs PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushOutput( AsUint(Transient::SPEC_ILLUM_PING) ); - PushOutput( AsUint(Transient::DIFF_ILLUM_PING) ); + // Outputs + PushOutput( AsUint(Transient::TILES) ); - AddDispatch( RELAX_DiffuseSpecular_HitDistReconstruction, SumConstants(0, 0, 0, 0), NumThreads(8, 8), 1 ); + // Shaders + AddDispatch( RELAX_ClassifyTiles, RELAX_ClassifyTiles, 1 ); } - PushPass("Hit distance reconstruction 5x5"); // 5x5 + for (int i = 0; i < RELAX_HITDIST_RECONSTRUCTION_PERMUTATION_NUM; i++) { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_SPEC_SH0) ); - PushInput( AsUint(ResourceType::IN_DIFF_SH0) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - - PushOutput(AsUint(Transient::SPEC_ILLUM_PING)); - PushOutput(AsUint(Transient::DIFF_ILLUM_PING)); - - AddDispatch( RELAX_DiffuseSpecular_HitDistReconstruction_5x5, SumConstants(0, 0, 0, 0), NumThreads(8, 8), 1 ); - } + bool is5x5 = ( ( ( i >> 0 ) & 0x1 ) != 0 ); - PushPass("Pre-pass"); // After hit distance reconstruction - { - // Does preblur (if enabled) and checkerboard reconstruction (if enabled) - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PING) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PING) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(ResourceType::IN_SPEC_SH1) ); - PushInput( AsUint(ResourceType::IN_DIFF_SH1) ); + PushPass("Hit distance reconstruction"); + { + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_SPEC_SH0) ); + PushInput( AsUint(ResourceType::IN_DIFF_SH0) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushOutput( AsUint(ResourceType::OUT_SPEC_SH0) ); - PushOutput( AsUint(ResourceType::OUT_DIFF_SH0) ); - PushOutput( AsUint(ResourceType::OUT_SPEC_SH1) ); - PushOutput( AsUint(ResourceType::OUT_DIFF_SH1) ); + // Outputs + PushOutput( AsUint(Transient::SPEC_ILLUM_PING) ); + PushOutput( AsUint(Transient::DIFF_ILLUM_PING) ); - AddDispatch( RELAX_DiffuseSpecularSh_PrePass, SumConstants(0, 1, 0, 10), NumThreads(16, 16), 1 ); + // Shaders + if (is5x5) + AddDispatch( RELAX_DiffuseSpecular_HitDistReconstruction_5x5, RELAX_HitDistReconstruction, 1 ); + else + AddDispatch( RELAX_DiffuseSpecular_HitDistReconstruction, RELAX_HitDistReconstruction, 1 ); + } } - PushPass("Pre-pass"); // Without hit distance reconstruction + for (int i = 0; i < RELAX_PREPASS_PERMUTATION_NUM; i++) { - // Does preblur (if enabled) and checkerboard reconstruction - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_SPEC_SH0) ); - PushInput( AsUint(ResourceType::IN_DIFF_SH0) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(ResourceType::IN_SPEC_SH1) ); - PushInput( AsUint(ResourceType::IN_DIFF_SH1) ); + bool isAfterReconstruction = ( ( ( i >> 0 ) & 0x1 ) != 0 ); - PushOutput( AsUint(ResourceType::OUT_SPEC_SH0) ); - PushOutput( AsUint(ResourceType::OUT_DIFF_SH0) ); - PushOutput( AsUint(ResourceType::OUT_SPEC_SH1) ); - PushOutput( AsUint(ResourceType::OUT_DIFF_SH1) ); + PushPass("Pre-pass"); + { + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( isAfterReconstruction ? AsUint(Transient::SPEC_ILLUM_PING) : AsUint(ResourceType::IN_SPEC_SH0) ); + PushInput( isAfterReconstruction ? AsUint(Transient::DIFF_ILLUM_PING) : AsUint(ResourceType::IN_DIFF_SH0) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( AsUint(ResourceType::IN_SPEC_SH1) ); + PushInput( AsUint(ResourceType::IN_DIFF_SH1) ); - AddDispatch( RELAX_DiffuseSpecularSh_PrePass, SumConstants(0, 1, 0, 10), NumThreads(16, 16), 1 ); + // Outputs + PushOutput( AsUint(ResourceType::OUT_SPEC_SH0) ); + PushOutput( AsUint(ResourceType::OUT_DIFF_SH0) ); + PushOutput( AsUint(ResourceType::OUT_SPEC_SH1) ); + PushOutput( AsUint(ResourceType::OUT_DIFF_SH1) ); + + // Shaders + AddDispatch( RELAX_DiffuseSpecularSh_PrePass, RELAX_PrePass, 1 ); + } } - for (int i = 0; i < 4; i++) + for (int i = 0; i < RELAX_TEMPORAL_ACCUMULATION_PERMUTATION_NUM; i++) { - // The following passes are defined here: - // TEMPORAL_ACCUMULATION, - // TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS, - // TEMPORAL_ACCUMULATION_WITH_THRESHOLD_MIX, - // TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS_WITH_THRESHOLD_MIX + bool hasDisocclusionThresholdMix = ( ( ( i >> 1 ) & 0x1 ) != 0 ); + bool hasConfidenceInputs = ( ( ( i >> 0 ) & 0x1 ) != 0 ); PushPass("Temporal accumulation"); { + // Inputs PushInput( AsUint(Transient::TILES) ); PushInput( AsUint(ResourceType::OUT_SPEC_SH0) ); PushInput( AsUint(ResourceType::OUT_DIFF_SH0) ); @@ -180,35 +158,12 @@ void nrd::InstanceImpl::Add_RelaxDiffuseSpecularSh(DenoiserData& denoiserData) PushInput( AsUint(Permanent::DIFF_ILLUM_PREV) ); PushInput( AsUint(Permanent::NORMAL_ROUGHNESS_PREV) ); PushInput( AsUint(Permanent::VIEWZ_PREV) ); - PushInput( AsUint(Permanent::REFLECTION_HIT_T_PREV), 0, 1, AsUint(Permanent::REFLECTION_HIT_T_CURR) ); + PushInput( AsUint(Permanent::REFLECTION_HIT_T_PREV), AsUint(Permanent::REFLECTION_HIT_T_CURR) ); PushInput( AsUint(Permanent::HISTORY_LENGTH_PREV) ); PushInput( AsUint(Permanent::MATERIAL_ID_PREV) ); - - // Confidence inputs: - if (i == 0) - { - PushInput( AsUint(ResourceType::IN_VIEWZ) ); // Bogus input that will not be fetched anyway - PushInput( AsUint(ResourceType::IN_VIEWZ) ); // Bogus input that will not be fetched anyway - PushInput( AsUint(Permanent::HISTORY_LENGTH_PREV) ); // Bogus input that will not be fetched anyway - } - if (i == 1) - { - PushInput( AsUint(ResourceType::IN_SPEC_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_DIFF_CONFIDENCE) ); - PushInput( AsUint(Permanent::HISTORY_LENGTH_PREV) ); // Bogus input that will not be fetched anyway - } - if (i == 2) - { - PushInput( AsUint(ResourceType::IN_VIEWZ) ); // Bogus input that will not be fetched anyway - PushInput( AsUint(ResourceType::IN_VIEWZ) ); // Bogus input that will not be fetched anyway - PushInput( AsUint(ResourceType::IN_DISOCCLUSION_THRESHOLD_MIX) ); - } - if (i == 3) - { - PushInput( AsUint(ResourceType::IN_SPEC_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_DIFF_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_DISOCCLUSION_THRESHOLD_MIX) ); - } + PushInput( hasConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : RELAX_DUMMY ); + PushInput( hasConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : RELAX_DUMMY ); + PushInput( hasDisocclusionThresholdMix ? AsUint(ResourceType::IN_DISOCCLUSION_THRESHOLD_MIX) : RELAX_DUMMY ); PushInput( AsUint(ResourceType::OUT_SPEC_SH1) ); PushInput( AsUint(ResourceType::OUT_DIFF_SH1) ); PushInput( AsUint(Permanent::SPEC_ILLUM_RESPONSIVE_PREV_SH1) ); @@ -216,11 +171,12 @@ void nrd::InstanceImpl::Add_RelaxDiffuseSpecularSh(DenoiserData& denoiserData) PushInput( AsUint(Permanent::SPEC_ILLUM_PREV_SH1) ); PushInput( AsUint(Permanent::DIFF_ILLUM_PREV_SH1) ); + // Outputs PushOutput( AsUint(Transient::SPEC_ILLUM_PING) ); PushOutput( AsUint(Transient::DIFF_ILLUM_PING) ); PushOutput( AsUint(Transient::SPEC_ILLUM_PONG) ); PushOutput( AsUint(Transient::DIFF_ILLUM_PONG) ); - PushOutput( AsUint(Permanent::REFLECTION_HIT_T_CURR), 0, 1, AsUint(Permanent::REFLECTION_HIT_T_PREV) ); + PushOutput( AsUint(Permanent::REFLECTION_HIT_T_CURR), AsUint(Permanent::REFLECTION_HIT_T_PREV) ); PushOutput( AsUint(Transient::HISTORY_LENGTH) ); PushOutput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); PushOutput( AsUint(Transient::SPEC_ILLUM_PING_SH1) ); @@ -228,12 +184,14 @@ void nrd::InstanceImpl::Add_RelaxDiffuseSpecularSh(DenoiserData& denoiserData) PushOutput( AsUint(Transient::SPEC_ILLUM_PONG_SH1) ); PushOutput( AsUint(Transient::DIFF_ILLUM_PONG_SH1) ); - AddDispatch(RELAX_DiffuseSpecularSh_TemporalAccumulation, SumConstants(0, 0, 0, 13), NumThreads(8, 8), 1); + // Shaders + AddDispatch(RELAX_DiffuseSpecularSh_TemporalAccumulation, RELAX_TemporalAccumulation, 1); } } PushPass("History fix"); { + // Inputs PushInput( AsUint(Transient::TILES) ); PushInput( AsUint(Transient::SPEC_ILLUM_PING) ); // Normal history PushInput( AsUint(Transient::DIFF_ILLUM_PING) ); @@ -243,16 +201,19 @@ void nrd::InstanceImpl::Add_RelaxDiffuseSpecularSh(DenoiserData& denoiserData) PushInput( AsUint(Transient::SPEC_ILLUM_PING_SH1) ); PushInput( AsUint(Transient::DIFF_ILLUM_PING_SH1) ); + // Outputs PushOutput( AsUint(Transient::SPEC_ILLUM_PONG) ); // Responsive history PushOutput( AsUint(Transient::DIFF_ILLUM_PONG) ); PushOutput( AsUint(Transient::SPEC_ILLUM_PONG_SH1) ); PushOutput( AsUint(Transient::DIFF_ILLUM_PONG_SH1) ); - AddDispatch( RELAX_DiffuseSpecularSh_HistoryFix, SumConstants(0, 0, 0, 8), NumThreads(8, 8), 1 ); + // Shaders + AddDispatch( RELAX_DiffuseSpecularSh_HistoryFix, RELAX_HistoryFix, 1 ); } PushPass("History clamping"); { + // Inputs PushInput( AsUint(Transient::TILES) ); PushInput( AsUint(ResourceType::OUT_SPEC_SH0) ); // Noisy input with preblur applied PushInput( AsUint(ResourceType::OUT_DIFF_SH0) ); @@ -266,6 +227,7 @@ void nrd::InstanceImpl::Add_RelaxDiffuseSpecularSh(DenoiserData& denoiserData) PushInput( AsUint(Transient::SPEC_ILLUM_PONG_SH1) ); PushInput( AsUint(Transient::DIFF_ILLUM_PONG_SH1) ); + // Outputs PushOutput( AsUint(Permanent::SPEC_ILLUM_PREV) ); PushOutput( AsUint(Permanent::DIFF_ILLUM_PREV) ); PushOutput( AsUint(Permanent::SPEC_ILLUM_RESPONSIVE_PREV) ); @@ -276,443 +238,145 @@ void nrd::InstanceImpl::Add_RelaxDiffuseSpecularSh(DenoiserData& denoiserData) PushOutput( AsUint(Permanent::SPEC_ILLUM_RESPONSIVE_PREV_SH1) ); PushOutput( AsUint(Permanent::DIFF_ILLUM_RESPONSIVE_PREV_SH1) ); - AddDispatch( RELAX_DiffuseSpecularSh_HistoryClamping, SumConstants(0, 0, 0, 8), NumThreads(8, 8), 1 ); + // Shaders + AddDispatch( RELAX_DiffuseSpecularSh_HistoryClamping, RELAX_HistoryClamping, 1 ); } PushPass("Copy"); { + // Inputs PushInput( AsUint(Permanent::SPEC_ILLUM_PREV) ); PushInput( AsUint(Permanent::DIFF_ILLUM_PREV) ); + + // Outputs PushOutput( AsUint(ResourceType::OUT_SPEC_SH0) ); PushOutput( AsUint(ResourceType::OUT_DIFF_SH0) ); - AddDispatch( RELAX_DiffuseSpecularSh_Copy, SumConstants(0, 0, 0, 0), NumThreads(8, 8), 1 ); + // Shaders + AddDispatch( RELAX_DiffuseSpecularSh_Copy, RELAX_Copy, 1 ); } PushPass("Anti-firefly"); { + // Inputs PushInput( AsUint(Transient::TILES) ); PushInput( AsUint(ResourceType::OUT_SPEC_SH0) ); PushInput( AsUint(ResourceType::OUT_DIFF_SH0) ); PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); PushInput( AsUint(ResourceType::IN_VIEWZ) ); + // Outputs PushOutput( AsUint(Permanent::SPEC_ILLUM_PREV) ); PushOutput( AsUint(Permanent::DIFF_ILLUM_PREV) ); - AddDispatch( RELAX_DiffuseSpecularSh_AntiFirefly, SumConstants(0, 0, 0, 0), NumThreads(16, 16), 1 ); + // Shaders + AddDispatch( RELAX_DiffuseSpecularSh_AntiFirefly, RELAX_AntiFirefly, 1 ); } - for (int i = 0; i < 2; i++) + for (int i = 0; i < RELAX_ATROUS_PERMUTATION_NUM; i++) { - bool withConfidenceInputs = (i == 1); - - // A-trous (first) - PushPass("A-trous (SMEM)"); - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Permanent::SPEC_ILLUM_PREV) ); - PushInput( AsUint(Permanent::DIFF_ILLUM_PREV) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(Permanent::SPEC_ILLUM_PREV_SH1) ); - PushInput( AsUint(Permanent::DIFF_ILLUM_PREV_SH1) ); + bool hasConfidenceInputs = ( ( ( i >> 0 ) & 0x1 ) != 0 ); - PushOutput( AsUint(Transient::SPEC_ILLUM_PING) ); - PushOutput( AsUint(Transient::DIFF_ILLUM_PING) ); - PushOutput( AsUint(Permanent::NORMAL_ROUGHNESS_PREV) ); - PushOutput( AsUint(Permanent::MATERIAL_ID_PREV) ); - PushOutput( AsUint(Permanent::VIEWZ_PREV) ); - PushOutput( AsUint(Transient::SPEC_ILLUM_PING_SH1) ); - PushOutput( AsUint(Transient::DIFF_ILLUM_PING_SH1) ); - - AddDispatch( RELAX_DiffuseSpecularSh_AtrousSmem, SumConstants(0, 0, 1, 19), NumThreads(8, 8), 1 ); - } - - // A-trous (odd) - PushPass("A-trous"); + for (int j = 0; j < RELAX_ATROUS_BINDING_VARIANT_NUM; j++) { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PING) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PING) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PING_SH1) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PING_SH1) ); + bool isSmem = j == 0; + bool isEven = j % 2 == 0; + bool isLast = j > 2; - PushOutput( AsUint(Transient::SPEC_ILLUM_PONG) ); - PushOutput( AsUint(Transient::DIFF_ILLUM_PONG) ); - PushOutput( AsUint(Transient::SPEC_ILLUM_PONG_SH1) ); - PushOutput( AsUint(Transient::DIFF_ILLUM_PONG_SH1) ); - - AddDispatchRepeated( RELAX_DiffuseSpecularSh_Atrous, SumConstants(0, 0, 0, 19), NumThreads(16, 16), 1, halfMaxPassNum ); - } - - // A-trous (even) - PushPass("A-trous"); - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PONG) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PONG) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PONG_SH1) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PONG_SH1) ); - - PushOutput( AsUint(Transient::SPEC_ILLUM_PING) ); - PushOutput( AsUint(Transient::DIFF_ILLUM_PING) ); - PushOutput( AsUint(Transient::SPEC_ILLUM_PING_SH1) ); - PushOutput( AsUint(Transient::DIFF_ILLUM_PING_SH1) ); - - AddDispatchRepeated( RELAX_DiffuseSpecularSh_Atrous, SumConstants(0, 0, 0, 19), NumThreads(16, 16), 1, halfMaxPassNum ); - } - - // A-trous (odd, last) - PushPass("A-trous"); - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PING) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PING) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PING_SH1) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PING_SH1) ); - - PushOutput( AsUint(ResourceType::OUT_SPEC_SH0) ); - PushOutput( AsUint(ResourceType::OUT_DIFF_SH0) ); - PushOutput( AsUint(ResourceType::OUT_SPEC_SH1) ); - PushOutput( AsUint(ResourceType::OUT_DIFF_SH1) ); - - AddDispatch( RELAX_DiffuseSpecularSh_Atrous, SumConstants(0, 0, 0, 19), NumThreads(16, 16), 1 ); - } - - // A-trous (even, last) - PushPass("A-trous"); - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PONG) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PONG) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PONG_SH1) ); - PushInput( AsUint(Transient::DIFF_ILLUM_PONG_SH1) ); - - PushOutput( AsUint(ResourceType::OUT_SPEC_SH0) ); - PushOutput( AsUint(ResourceType::OUT_DIFF_SH0) ); - PushOutput( AsUint(ResourceType::OUT_SPEC_SH1) ); - PushOutput( AsUint(ResourceType::OUT_DIFF_SH1) ); + if (isSmem) + PushPass("A-trous (SMEM)"); + else + PushPass("A-trous"); - AddDispatch( RELAX_DiffuseSpecularSh_Atrous, SumConstants(0, 0, 0, 19), NumThreads(16, 16), 1 ); + { + // Inputs + PushInput( AsUint(Transient::TILES) ); + + if (isSmem) + { + PushInput( AsUint(Permanent::SPEC_ILLUM_PREV) ); + PushInput( AsUint(Permanent::DIFF_ILLUM_PREV) ); + } + else + { + PushInput( isEven ? AsUint(Transient::SPEC_ILLUM_PONG) : AsUint(Transient::SPEC_ILLUM_PING) ); + PushInput( isEven ? AsUint(Transient::DIFF_ILLUM_PONG) : AsUint(Transient::DIFF_ILLUM_PING) ); + } + + PushInput( AsUint(Transient::HISTORY_LENGTH) ); + PushInput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( hasConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); + PushInput( hasConfidenceInputs ? AsUint(ResourceType::IN_DIFF_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); + + if (isSmem) + { + PushInput( AsUint(Permanent::SPEC_ILLUM_PREV_SH1) ); + PushInput( AsUint(Permanent::DIFF_ILLUM_PREV_SH1) ); + } + else + { + PushInput( isEven ? AsUint(Transient::SPEC_ILLUM_PONG_SH1) : AsUint(Transient::SPEC_ILLUM_PING_SH1) ); + PushInput( isEven ? AsUint(Transient::DIFF_ILLUM_PONG_SH1) : AsUint(Transient::DIFF_ILLUM_PING_SH1) ); + } + + // Outputs + if (isLast) + { + PushOutput( AsUint(ResourceType::OUT_SPEC_SH0) ); + PushOutput( AsUint(ResourceType::OUT_DIFF_SH1) ); + } + else + { + PushOutput( isEven ? AsUint(Transient::SPEC_ILLUM_PING) : AsUint(Transient::SPEC_ILLUM_PONG) ); + PushOutput( isEven ? AsUint(Transient::DIFF_ILLUM_PING) : AsUint(Transient::DIFF_ILLUM_PONG) ); + } + + if (isSmem) + { + PushOutput( AsUint(Permanent::NORMAL_ROUGHNESS_PREV) ); + PushOutput( AsUint(Permanent::MATERIAL_ID_PREV) ); + PushOutput( AsUint(Permanent::VIEWZ_PREV) ); + } + + if (isLast) + { + PushOutput( AsUint(ResourceType::OUT_SPEC_SH1) ); + PushOutput( AsUint(ResourceType::OUT_DIFF_SH1) ); + } + else + { + PushOutput( isEven ? AsUint(Transient::SPEC_ILLUM_PING_SH1) : AsUint(Transient::SPEC_ILLUM_PONG_SH1) ); + PushOutput( isEven ? AsUint(Transient::DIFF_ILLUM_PING_SH1) : AsUint(Transient::DIFF_ILLUM_PONG_SH1) ); + } + + // Shaders + uint32_t repeatNum = isLast ? 1 : (RELAX_MAX_ATROUS_PASS_NUM - 2 + 1) / 2; + if (isSmem) + AddDispatch( RELAX_DiffuseSpecularSh_AtrousSmem, RELAX_AtrousSmem, 1 ); + else + AddDispatchRepeated( RELAX_DiffuseSpecularSh_Atrous, RELAX_Atrous, 1, repeatNum ); + } } } PushPass("Split screen"); { + // Inputs PushInput( AsUint(ResourceType::IN_VIEWZ) ); PushInput( AsUint(ResourceType::IN_SPEC_RADIANCE_HITDIST) ); PushInput( AsUint(ResourceType::IN_DIFF_RADIANCE_HITDIST) ); + // Outputs PushOutput( AsUint( ResourceType::OUT_SPEC_RADIANCE_HITDIST ) ); PushOutput( AsUint( ResourceType::OUT_DIFF_RADIANCE_HITDIST ) ); - AddDispatch( RELAX_DiffuseSpecular_SplitScreen, SumConstants(0, 0, 0, 3), NumThreads(16, 16), 1 ); + // Shaders + AddDispatch( RELAX_DiffuseSpecular_SplitScreen, RELAX_SplitScreen, 1 ); } RELAX_ADD_VALIDATION_DISPATCH; #undef DENOISER_NAME } - -void nrd::InstanceImpl::Update_RelaxDiffuseSpecularSh(const DenoiserData& denoiserData) -{ - enum class Dispatch - { - CLASSIFY_TILES, - HITDIST_RECONSTRUCTION_3x3, - HITDIST_RECONSTRUCTION_5x5, - PREPASS_AFTER_HITDIST_RECONSTRUCTION, - PREPASS, - TEMPORAL_ACCUMULATION, - TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS, - TEMPORAL_ACCUMULATION_WITH_THRESHOLD_MIX, - TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS_WITH_THRESHOLD_MIX, - HISTORY_FIX, - HISTORY_CLAMPING, - COPY, - FIREFLY, - ATROUS_SMEM, - ATROUS_ODD, - ATROUS_EVEN, - ATROUS_ODD_LAST, - ATROUS_EVEN_LAST, - ATROUS_SMEM_WITH_CONFIDENCE_INPUTS, - ATROUS_ODD_WITH_CONFIDENCE_INPUTS, - ATROUS_EVEN_WITH_CONFIDENCE_INPUTS, - ATROUS_ODD_LAST_WITH_CONFIDENCE_INPUTS, - ATROUS_EVEN_LAST_WITH_CONFIDENCE_INPUTS, - SPLIT_SCREEN, - VALIDATION, - }; - - const RelaxDiffuseSpecularSettings& settings = denoiserData.settings.diffuseSpecularRelax; - - NRD_DECLARE_DIMS; - - float maxDiffuseLuminanceRelativeDifference = -ml::Log( ml::Saturate(settings.diffuseMinLuminanceWeight) ); - float maxSpecularLuminanceRelativeDifference = -ml::Log( ml::Saturate(settings.specularMinLuminanceWeight) ); - - float disocclusionThreshold = m_CommonSettings.disocclusionThreshold + (1.0f + m_JitterDelta) / float(rectH); - float disocclusionThresholdOrtho = disocclusionThreshold; - float disocclusionThresholdAlternate = m_CommonSettings.disocclusionThresholdAlternate + (1.0f + m_JitterDelta) / float(rectH); - float disocclusionThresholdAlternateOrtho = disocclusionThresholdAlternate; - float depthThresholdOrtho = settings.depthThreshold; - - float tanHalfFov = 1.0f / m_ViewToClip.a00; - float aspect = m_ViewToClip.a00 / m_ViewToClip.a11; - ml::float3 frustumRight = m_WorldToView.GetRow0().To3d() * tanHalfFov; - ml::float3 frustumUp = m_WorldToView.GetRow1().To3d() * tanHalfFov * aspect; - ml::float3 frustumForward = RELAX_GetFrustumForward(m_ViewToWorld, m_Frustum); - - float prevTanHalfFov = 1.0f / m_ViewToClipPrev.a00; - float prevAspect = m_ViewToClipPrev.a00 / m_ViewToClipPrev.a11; - ml::float3 prevFrustumRight = m_WorldToViewPrev.GetRow0().To3d() * prevTanHalfFov; - ml::float3 prevFrustumUp = m_WorldToViewPrev.GetRow1().To3d() * prevTanHalfFov * prevAspect; - ml::float3 prevFrustumForward = RELAX_GetFrustumForward(m_ViewToWorldPrev, m_FrustumPrev); - bool isCameraStatic = RELAX_IsCameraStatic(ml::float3(m_CameraDelta.x, m_CameraDelta.y, m_CameraDelta.z), frustumRight, frustumUp, frustumForward, prevFrustumRight, prevFrustumUp, prevFrustumForward); - - bool enableHitDistanceReconstruction = settings.hitDistanceReconstructionMode != HitDistanceReconstructionMode::OFF && settings.checkerboardMode == CheckerboardMode::OFF; - - // Checkerboard logic - uint32_t specularCheckerboard = 2; - uint32_t diffuseCheckerboard = 2; - - switch (settings.checkerboardMode) - { - case CheckerboardMode::BLACK: - diffuseCheckerboard = 0; - specularCheckerboard = 1; - break; - case CheckerboardMode::WHITE: - diffuseCheckerboard = 1; - specularCheckerboard = 0; - break; - default: - break; - } - - // SPLIT_SCREEN (passthrough) - if (m_CommonSettings.splitScreen >= 1.0f) - { - Constant* data = PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - AddFloat(data, m_CommonSettings.splitScreen); - AddUint(data, diffuseCheckerboard); - AddUint(data, specularCheckerboard); - ValidateConstants(data); - - return; - } - - // CLASSIFY_TILES - Constant* data = PushDispatch(denoiserData, AsUint(Dispatch::CLASSIFY_TILES)); - AddFloat(data, m_CommonSettings.denoisingRange); - ValidateConstants(data); - - // HITDIST_RECONSTRUCTION - if (enableHitDistanceReconstruction) - { - bool is3x3 = settings.hitDistanceReconstructionMode == HitDistanceReconstructionMode::AREA_3X3; - data = PushDispatch(denoiserData, is3x3 ? AsUint(Dispatch::HITDIST_RECONSTRUCTION_3x3) : AsUint(Dispatch::HITDIST_RECONSTRUCTION_5x5)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - ValidateConstants(data); - } - - // PREPASS - data = PushDispatch(denoiserData, AsUint(enableHitDistanceReconstruction ? Dispatch::PREPASS_AFTER_HITDIST_RECONSTRUCTION : Dispatch::PREPASS)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - AddFloat4(data, m_Rotator_PrePass); - AddUint(data, diffuseCheckerboard); - AddUint(data, specularCheckerboard); - AddFloat(data, settings.diffusePrepassBlurRadius); - AddFloat(data, settings.specularPrepassBlurRadius); - AddFloat(data, 1.0f); - AddFloat(data, m_IsOrtho == 0 ? settings.depthThreshold : depthThresholdOrtho); - AddFloat(data, settings.diffuseLobeAngleFraction); - AddFloat(data, settings.specularLobeAngleFraction); - AddFloat(data, settings.specularLobeAngleSlack); - AddFloat(data, settings.roughnessFraction); - ValidateConstants(data); - - // TEMPORAL_ACCUMULATION - if (!m_CommonSettings.isDisocclusionThresholdMixAvailable) - { - data = PushDispatch( - denoiserData, - AsUint(m_CommonSettings.isHistoryConfidenceAvailable ? - Dispatch::TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS : - Dispatch::TEMPORAL_ACCUMULATION)); - } - else - { - data = PushDispatch( - denoiserData, - AsUint(m_CommonSettings.isHistoryConfidenceAvailable ? - Dispatch::TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS_WITH_THRESHOLD_MIX : - Dispatch::TEMPORAL_ACCUMULATION_WITH_THRESHOLD_MIX)); - } - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - AddFloat(data, (float)settings.specularMaxAccumulatedFrameNum); - AddFloat(data, (float)settings.specularMaxFastAccumulatedFrameNum); - AddFloat(data, (float)settings.diffuseMaxAccumulatedFrameNum); - AddFloat(data, (float)settings.diffuseMaxFastAccumulatedFrameNum); - AddUint(data, diffuseCheckerboard); - AddUint(data, specularCheckerboard); - AddFloat(data, m_IsOrtho == 0 ? disocclusionThreshold : disocclusionThresholdOrtho); - AddFloat(data, m_IsOrtho == 0 ? disocclusionThresholdAlternate : disocclusionThresholdAlternateOrtho); - AddFloat(data, settings.roughnessFraction); - AddFloat(data, settings.specularVarianceBoost); - AddUint(data, settings.enableReprojectionTestSkippingWithoutMotion && isCameraStatic); - AddUint(data, m_CommonSettings.isHistoryConfidenceAvailable ? 1 : 0); - AddUint(data, m_CommonSettings.isDisocclusionThresholdMixAvailable ? 1 : 0); - ValidateConstants(data); - - // HISTORY_FIX - data = PushDispatch(denoiserData, AsUint(Dispatch::HISTORY_FIX)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - AddFloat(data, m_IsOrtho == 0 ? settings.depthThreshold : depthThresholdOrtho); - AddFloat(data, settings.historyFixEdgeStoppingNormalPower); - AddFloat(data, settings.historyFixStrideBetweenSamples); - AddFloat(data, float(settings.historyFixFrameNum)); - AddFloat(data, settings.specularLobeAngleFraction); - AddFloat(data, ml::DegToRad(settings.specularLobeAngleSlack)); - AddFloat(data, settings.roughnessEdgeStoppingRelaxation); - AddFloat(data, settings.normalEdgeStoppingRelaxation); - ValidateConstants(data); - - - // HISTORY_CLAMPING - data = PushDispatch(denoiserData, AsUint(Dispatch::HISTORY_CLAMPING)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - AddFloat(data, settings.historyClampingColorBoxSigmaScale); - AddFloat(data, float(settings.historyFixFrameNum)); - AddUint(data, settings.specularMaxFastAccumulatedFrameNum < settings.specularMaxAccumulatedFrameNum ? 1 : 0); - AddUint(data, settings.diffuseMaxFastAccumulatedFrameNum < settings.diffuseMaxAccumulatedFrameNum ? 1 : 0); - AddFloat(data, float(settings.antilagSettings.accelerationAmount)); - AddFloat(data, float(settings.antilagSettings.temporalSigmaScale)); - AddFloat(data, float(settings.antilagSettings.spatialSigmaScale)); - AddFloat(data, float(settings.antilagSettings.resetAmount)); - ValidateConstants(data); - - if (settings.enableAntiFirefly) - { - // COPY - data = PushDispatch(denoiserData, AsUint(Dispatch::COPY)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - ValidateConstants(data); - - // FIREFLY - data = PushDispatch(denoiserData, AsUint(Dispatch::FIREFLY)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - ValidateConstants(data); - } - - // A-TROUS - uint32_t iterationNum = ml::Clamp(settings.atrousIterationNum, 2u, RELAX_MAX_ATROUS_PASS_NUM); - for (uint32_t i = 0; i < iterationNum; i++) - { - Dispatch dispatch; - if (!m_CommonSettings.isHistoryConfidenceAvailable) - { - if (i == 0) - dispatch = Dispatch::ATROUS_SMEM; - else if (i == iterationNum - 1) - dispatch = (i % 2 == 0) ? Dispatch::ATROUS_EVEN_LAST : Dispatch::ATROUS_ODD_LAST; - else - dispatch = (i % 2 == 0) ? Dispatch::ATROUS_EVEN : Dispatch::ATROUS_ODD; - } - else - { - if (i == 0) - dispatch = Dispatch::ATROUS_SMEM_WITH_CONFIDENCE_INPUTS; - else if (i == iterationNum - 1) - dispatch = (i % 2 == 0) ? Dispatch::ATROUS_EVEN_LAST_WITH_CONFIDENCE_INPUTS : Dispatch::ATROUS_ODD_LAST_WITH_CONFIDENCE_INPUTS; - else - dispatch = (i % 2 == 0) ? Dispatch::ATROUS_EVEN_WITH_CONFIDENCE_INPUTS : Dispatch::ATROUS_ODD_WITH_CONFIDENCE_INPUTS; - } - - data = PushDispatch(denoiserData, AsUint(dispatch)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - - if (i == 0) - { - AddUint2(data, screenW, screenH); // For Atrous_shmem - AddUint(data, settings.spatialVarianceEstimationHistoryThreshold); - } - - AddFloat(data, settings.specularPhiLuminance); - AddFloat(data, settings.diffusePhiLuminance); - AddFloat(data, maxDiffuseLuminanceRelativeDifference); - AddFloat(data, maxSpecularLuminanceRelativeDifference); - AddFloat(data, m_IsOrtho == 0 ? settings.depthThreshold : depthThresholdOrtho); - AddFloat(data, settings.diffuseLobeAngleFraction); - AddFloat(data, settings.roughnessFraction); - AddFloat(data, settings.specularLobeAngleFraction); - AddFloat(data, ml::DegToRad(settings.specularLobeAngleSlack)); - AddUint(data, 1 << i); - AddUint(data, settings.enableRoughnessEdgeStopping); - AddFloat(data, settings.roughnessEdgeStoppingRelaxation); - AddFloat(data, settings.normalEdgeStoppingRelaxation); - AddFloat(data, settings.luminanceEdgeStoppingRelaxation); - AddUint(data, m_CommonSettings.isHistoryConfidenceAvailable ? 1 : 0); - AddFloat(data, settings.confidenceDrivenRelaxationMultiplier); - AddFloat(data, settings.confidenceDrivenLuminanceEdgeStoppingRelaxation); - AddFloat(data, settings.confidenceDrivenNormalEdgeStoppingRelaxation); - if (i != 0) - { - AddUint(data, (i == iterationNum - 1) ? 1 : 0); - } - ValidateConstants(data); - } - - // SPLIT_SCREEN - if (m_CommonSettings.splitScreen > 0.0f) - { - data = PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - AddFloat(data, m_CommonSettings.splitScreen); - AddUint(data, diffuseCheckerboard); - AddUint(data, specularCheckerboard); - ValidateConstants(data); - } - - // VALIDATION - if (m_CommonSettings.enableValidation) - { - data = PushDispatch(denoiserData, AsUint(Dispatch::VALIDATION)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - AddFloat4x4(data, m_WorldToClipPrev); - AddFloat2(data, m_CommonSettings.cameraJitter[0], m_CommonSettings.cameraJitter[1]); - AddFloat(data, (float)ml::Max(settings.diffuseMaxAccumulatedFrameNum, settings.specularMaxAccumulatedFrameNum)); - ValidateConstants(data); - } -} diff --git a/Source/Denoisers/Relax_Specular.hpp b/Source/Denoisers/Relax_Specular.hpp index d0097c3..991f3b0 100644 --- a/Source/Denoisers/Relax_Specular.hpp +++ b/Source/Denoisers/Relax_Specular.hpp @@ -12,13 +12,8 @@ void nrd::InstanceImpl::Add_RelaxSpecular(DenoiserData& denoiserData) { #define DENOISER_NAME RELAX_Specular - denoiserData.settings.specularRelax = RelaxSpecularSettings(); - denoiserData.settingsSize = sizeof(denoiserData.settings.specularRelax); - - uint16_t w = denoiserData.desc.renderWidth; - uint16_t h = denoiserData.desc.renderHeight; - uint16_t tilesW = DivideUp(w, 16); - uint16_t tilesH = DivideUp(h, 16); + denoiserData.settings.relax = RelaxSettings(); + denoiserData.settingsSize = sizeof(denoiserData.settings.relax); enum class Permanent { @@ -32,14 +27,14 @@ void nrd::InstanceImpl::Add_RelaxSpecular(DenoiserData& denoiserData) VIEWZ_PREV }; - AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::R16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::R16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::R8_UNORM, w, h, 1} ); - AddTextureToPermanentPool( {Format::RGBA8_UNORM, w, h, 1} ); - AddTextureToPermanentPool( {Format::R8_UNORM, w, h, 1} ); - AddTextureToPermanentPool( {Format::R32_SFLOAT, w, h, 1} ); + AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::R16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::R16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::R8_UNORM, 1} ); + AddTextureToPermanentPool( {Format::RGBA8_UNORM, 1} ); + AddTextureToPermanentPool( {Format::R8_UNORM, 1} ); + AddTextureToPermanentPool( {Format::R32_SFLOAT, 1} ); enum class Transient { @@ -50,84 +45,75 @@ void nrd::InstanceImpl::Add_RelaxSpecular(DenoiserData& denoiserData) HISTORY_LENGTH }; - AddTextureToTransientPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, tilesW, tilesH, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, w, h, 1} ); - - RELAX_SET_SHARED_CONSTANTS; - - const uint32_t halfMaxPassNum = (RELAX_MAX_ATROUS_PASS_NUM - 2 + 1) / 2; + AddTextureToTransientPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::R8_UNORM, 1} ); + AddTextureToTransientPool( {Format::R8_UNORM, 16} ); + AddTextureToTransientPool( {Format::R8_UNORM, 1} ); PushPass("Classify tiles"); { - PushInput(AsUint(ResourceType::IN_VIEWZ)); - PushOutput(AsUint(Transient::TILES)); - - AddDispatch(RELAX_ClassifyTiles, SumConstants(0, 0, 0, 1, false), NumThreads(16, 16), 1); - } - - PushPass("Hit distance reconstruction"); // 3x3 - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_SPEC_RADIANCE_HITDIST) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + // Inputs PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushOutput( AsUint(Transient::SPEC_ILLUM_PING) ); + // Outputs + PushOutput( AsUint(Transient::TILES) ); - AddDispatch( RELAX_Specular_HitDistReconstruction, SumConstants(0, 0, 0, 0), NumThreads(8, 8), 1 ); + // Shaders + AddDispatch( RELAX_ClassifyTiles, RELAX_ClassifyTiles, 1 ); } - PushPass("Hit distance reconstruction"); // 5x5 + for (int i = 0; i < RELAX_HITDIST_RECONSTRUCTION_PERMUTATION_NUM; i++) { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_SPEC_RADIANCE_HITDIST) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); + bool is5x5 = ( ( ( i >> 0 ) & 0x1 ) != 0 ); - PushOutput( AsUint(Transient::SPEC_ILLUM_PING) ); - - AddDispatch( RELAX_Specular_HitDistReconstruction_5x5, SumConstants(0, 0, 0, 0), NumThreads(8, 8), 1 ); - } - - PushPass("Pre-pass"); // After hit distance reconstruction - { - // Does preblur (if enabled) and checkerboard reconstruction (if enabled) and generates - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PING) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushPass("Hit distance reconstruction"); + { + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_SPEC_RADIANCE_HITDIST) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushOutput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); + // Outputs + PushOutput( AsUint(Transient::SPEC_ILLUM_PING) ); - AddDispatch( RELAX_Specular_PrePass, SumConstants(0, 1, 0, 7), NumThreads(16, 16), 1 ); + // Shaders + if (is5x5) + AddDispatch( RELAX_Specular_HitDistReconstruction_5x5, RELAX_HitDistReconstruction, 1 ); + else + AddDispatch( RELAX_Specular_HitDistReconstruction, RELAX_HitDistReconstruction, 1 ); + } } - PushPass("Pre-pass"); // Without hit distance reconstruction + for (int i = 0; i < RELAX_PREPASS_PERMUTATION_NUM; i++) { - // Does preblur (if enabled) and checkerboard reconstruction (if enabled) and generates - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_SPEC_RADIANCE_HITDIST) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); + bool isAfterReconstruction = ( ( ( i >> 0 ) & 0x1 ) != 0 ); - PushOutput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); + PushPass("Pre-pass"); + { + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( isAfterReconstruction ? AsUint(Transient::SPEC_ILLUM_PING) : AsUint(ResourceType::IN_SPEC_RADIANCE_HITDIST) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); - AddDispatch( RELAX_Specular_PrePass, SumConstants(0, 1, 0, 7), NumThreads(16, 16), 1 ); + // Outputs + PushOutput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); + + // Shaders + AddDispatch( RELAX_Specular_PrePass, RELAX_PrePass, 1 ); + } } - for (int i = 0; i < 4; i++) + for (int i = 0; i < RELAX_TEMPORAL_ACCUMULATION_PERMUTATION_NUM; i++) { - // The following passes are defined here: - // REPROJECT, - // REPROJECT_WITH_CONFIDENCE_INPUTS, - // REPROJECT_WITH_THRESHOLD_MIX, - // REPROJECT_WITH_CONFIDENCE_INPUTS_WITH_THRESHOLD_MIX + bool hasDisocclusionThresholdMix = ( ( ( i >> 1 ) & 0x1 ) != 0 ); + bool hasConfidenceInputs = ( ( ( i >> 0 ) & 0x1 ) != 0 ); PushPass("Temporal accumulation"); { + // Inputs PushInput( AsUint(Transient::TILES) ); PushInput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); PushInput( AsUint(ResourceType::IN_MV) ); @@ -137,443 +123,148 @@ void nrd::InstanceImpl::Add_RelaxSpecular(DenoiserData& denoiserData) PushInput( AsUint(Permanent::SPEC_ILLUM_PREV) ); PushInput( AsUint(Permanent::NORMAL_ROUGHNESS_PREV) ); PushInput( AsUint(Permanent::VIEWZ_PREV) ); - PushInput( AsUint(Permanent::REFLECTION_HIT_T_PREV), 0, 1, AsUint(Permanent::REFLECTION_HIT_T_CURR) ); + PushInput( AsUint(Permanent::REFLECTION_HIT_T_PREV), AsUint(Permanent::REFLECTION_HIT_T_CURR) ); PushInput( AsUint(Permanent::HISTORY_LENGTH_PREV) ); PushInput( AsUint(Permanent::MATERIAL_ID_PREV) ); - // Confidence inputs: - if (i == 0) - { - PushInput( AsUint(ResourceType::IN_VIEWZ) ); // Bogus input that will not be fetched anyway - PushInput( AsUint(Permanent::HISTORY_LENGTH_PREV) ); // Bogus input that will not be fetched anyway - } - if (i == 1) - { - PushInput( AsUint(ResourceType::IN_SPEC_CONFIDENCE) ); - PushInput( AsUint(Permanent::HISTORY_LENGTH_PREV) ); // Bogus input that will not be fetched anyway - } - if (i == 2) - { - PushInput( AsUint(ResourceType::IN_VIEWZ) ); // Bogus input that will not be fetched anyway - PushInput( AsUint(ResourceType::IN_DISOCCLUSION_THRESHOLD_MIX) ); - } - if (i == 3) - { - PushInput( AsUint(ResourceType::IN_SPEC_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_DISOCCLUSION_THRESHOLD_MIX) ); - } + PushInput( hasConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : RELAX_DUMMY ); + PushInput( hasDisocclusionThresholdMix ? AsUint(ResourceType::IN_DISOCCLUSION_THRESHOLD_MIX) : RELAX_DUMMY ); + // Outputs PushOutput( AsUint(Transient::SPEC_ILLUM_PING) ); PushOutput( AsUint(Transient::SPEC_ILLUM_PONG) ); - PushOutput( AsUint(Permanent::REFLECTION_HIT_T_CURR), 0, 1, AsUint(Permanent::REFLECTION_HIT_T_PREV) ); + PushOutput( AsUint(Permanent::REFLECTION_HIT_T_CURR), AsUint(Permanent::REFLECTION_HIT_T_PREV) ); PushOutput( AsUint(Transient::HISTORY_LENGTH) ); PushOutput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); - AddDispatch( RELAX_Specular_TemporalAccumulation, SumConstants(0, 0, 0, 10), NumThreads(8, 8), 1 ); + // Shaders + AddDispatch( RELAX_Specular_TemporalAccumulation, RELAX_TemporalAccumulation, 1 ); } } PushPass("History fix"); { + // Inputs PushInput( AsUint(Transient::TILES) ); PushInput( AsUint(Transient::SPEC_ILLUM_PING) ); PushInput( AsUint(Transient::HISTORY_LENGTH) ); PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); PushInput( AsUint(ResourceType::IN_VIEWZ) ); + // Outputs PushOutput( AsUint(Transient::SPEC_ILLUM_PONG) ); - AddDispatch( RELAX_Specular_HistoryFix, SumConstants(0, 0, 0, 8), NumThreads(8, 8), 1 ); + AddDispatch( RELAX_Specular_HistoryFix, RELAX_HistoryFix, 1 ); } PushPass("History clamping"); { + // Inputs PushInput( AsUint(Transient::TILES) ); PushInput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); PushInput( AsUint(Transient::SPEC_ILLUM_PING) ); PushInput( AsUint(Transient::SPEC_ILLUM_PONG) ); PushInput( AsUint(Transient::HISTORY_LENGTH) ); + // Outputs PushOutput( AsUint(Permanent::SPEC_ILLUM_PREV) ); PushOutput( AsUint(Permanent::SPEC_ILLUM_RESPONSIVE_PREV) ); PushOutput( AsUint(Permanent::HISTORY_LENGTH_PREV) ); - AddDispatch( RELAX_Specular_HistoryClamping, SumConstants(0, 0, 0, 7), NumThreads(8, 8), 1 ); + AddDispatch( RELAX_Specular_HistoryClamping, RELAX_HistoryClamping, 1 ); } PushPass("Copy"); { + // Inputs PushInput( AsUint(Permanent::SPEC_ILLUM_PREV) ); + + // Outputs PushOutput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); - AddDispatch( RELAX_Specular_Copy, SumConstants(0, 0, 0, 0), NumThreads(8, 8), 1 ); + AddDispatch( RELAX_Specular_Copy, RELAX_Copy, 1 ); } PushPass("Anti-firefly"); { + // Inputs PushInput( AsUint(Transient::TILES) ); PushInput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); PushInput( AsUint(ResourceType::IN_VIEWZ) ); + // Outputs PushOutput( AsUint(Permanent::SPEC_ILLUM_PREV) ); - AddDispatch( RELAX_Specular_AntiFirefly, SumConstants(0, 0, 0, 0), NumThreads(16, 16), 1 ); + AddDispatch( RELAX_Specular_AntiFirefly, RELAX_AntiFirefly, 1 ); } - for (int i = 0; i < 2; i++) + for (int i = 0; i < RELAX_ATROUS_PERMUTATION_NUM; i++) { - bool withConfidenceInputs = (i == 1); - - // A-trous (first) - PushPass("A-trous (SMEM)"); - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Permanent::SPEC_ILLUM_PREV) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - - PushOutput( AsUint(Transient::SPEC_ILLUM_PING) ); - PushOutput( AsUint(Permanent::NORMAL_ROUGHNESS_PREV) ); - PushOutput( AsUint(Permanent::MATERIAL_ID_PREV) ); - PushOutput( AsUint(Permanent::VIEWZ_PREV) ); - - AddDispatch( RELAX_Specular_AtrousSmem, SumConstants(0, 0, 1, 17), NumThreads(8, 8), 1 ); - } - - // A-trous (odd) - PushPass("A-trous"); - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PING) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - - PushOutput( AsUint(Transient::SPEC_ILLUM_PONG) ); - - AddDispatchRepeated( RELAX_Specular_Atrous, SumConstants(0, 0, 0, 16), NumThreads(16, 16), 1, halfMaxPassNum ); - } - - // A-trous (even) - PushPass("A-trous"); - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PONG) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); + bool hasConfidenceInputs = ( ( ( i >> 0 ) & 0x1 ) != 0 ); - PushOutput( AsUint(Transient::SPEC_ILLUM_PING) ); - - AddDispatchRepeated( RELAX_Specular_Atrous, SumConstants(0, 0, 0, 16), NumThreads(16, 16), 1, halfMaxPassNum ); - } - - // A-trous (odd, last) - PushPass("A-trous"); - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PING) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - - PushOutput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); - - AddDispatch( RELAX_Specular_Atrous, SumConstants(0, 0, 0, 16), NumThreads(16, 16), 1 ); - } - - // A-trous (even, last) - PushPass("A-trous"); + for (int j = 0; j < RELAX_ATROUS_BINDING_VARIANT_NUM; j++) { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PONG) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); + bool isSmem = j == 0; + bool isEven = j % 2 == 0; + bool isLast = j > 2; - PushOutput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); + if (isSmem) + PushPass("A-trous (SMEM)"); + else + PushPass("A-trous"); - AddDispatch( RELAX_Specular_Atrous, SumConstants(0, 0, 0, 16), NumThreads(16, 16), 1 ); + { + // Inputs + PushInput( AsUint(Transient::TILES) ); + + if (isSmem) + PushInput( AsUint(Permanent::SPEC_ILLUM_PREV) ); + else + PushInput( isEven ? AsUint(Transient::SPEC_ILLUM_PONG) : AsUint(Transient::SPEC_ILLUM_PING) ); + + PushInput( AsUint(Transient::HISTORY_LENGTH) ); + PushInput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( hasConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); + + // Outputs + if (isLast) + PushOutput( AsUint(ResourceType::OUT_SPEC_RADIANCE_HITDIST) ); + else + PushOutput( isEven ? AsUint(Transient::SPEC_ILLUM_PING) : AsUint(Transient::SPEC_ILLUM_PONG) ); + + if (isSmem) + { + PushOutput( AsUint(Permanent::NORMAL_ROUGHNESS_PREV) ); + PushOutput( AsUint(Permanent::MATERIAL_ID_PREV) ); + PushOutput( AsUint(Permanent::VIEWZ_PREV) ); + } + + // Shaders + uint32_t repeatNum = isLast ? 1 : (RELAX_MAX_ATROUS_PASS_NUM - 2 + 1) / 2; + if (isSmem) + AddDispatch( RELAX_Specular_AtrousSmem, RELAX_AtrousSmem, 1 ); + else + AddDispatchRepeated( RELAX_Specular_Atrous, RELAX_Atrous, 1, repeatNum ); + } } } PushPass("Split screen"); { + // Inputs PushInput( AsUint(ResourceType::IN_VIEWZ) ); PushInput( AsUint(ResourceType::IN_SPEC_RADIANCE_HITDIST)); + // Outputs PushOutput( AsUint( ResourceType::OUT_SPEC_RADIANCE_HITDIST ) ); - AddDispatch( RELAX_Specular_SplitScreen, SumConstants(0, 0, 0, 2), NumThreads(16, 16), 1 ); + // Shaders + AddDispatch( RELAX_Specular_SplitScreen, RELAX_SplitScreen, 1 ); } RELAX_ADD_VALIDATION_DISPATCH; #undef DENOISER_NAME } - -void nrd::InstanceImpl::Update_RelaxSpecular(const DenoiserData& denoiserData) -{ - enum class Dispatch - { - CLASSIFY_TILES, - HITDIST_RECONSTRUCTION_3x3, - HITDIST_RECONSTRUCTION_5x5, - PREPASS_AFTER_HITDIST_RECONSTRUCTION, - PREPASS, - TEMPORAL_ACCUMULATION, - TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS, - TEMPORAL_ACCUMULATION_WITH_THRESHOLD_MIX, - TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS_WITH_THRESHOLD_MIX, - HISTORY_FIX, - HISTORY_CLAMPING, - COPY, - FIREFLY, - ATROUS_SMEM, - ATROUS_ODD, - ATROUS_EVEN, - ATROUS_ODD_LAST, - ATROUS_EVEN_LAST, - ATROUS_SMEM_WITH_CONFIDENCE_INPUTS, - ATROUS_ODD_WITH_CONFIDENCE_INPUTS, - ATROUS_EVEN_WITH_CONFIDENCE_INPUTS, - ATROUS_ODD_LAST_WITH_CONFIDENCE_INPUTS, - ATROUS_EVEN_LAST_WITH_CONFIDENCE_INPUTS, - SPLIT_SCREEN, - VALIDATION, - }; - - const RelaxSpecularSettings& settings = denoiserData.settings.specularRelax; - - NRD_DECLARE_DIMS; - - float maxLuminanceRelativeDifference = -ml::Log(ml::Saturate(settings.minLuminanceWeight)); - - float disocclusionThreshold = m_CommonSettings.disocclusionThreshold + (1.0f + m_JitterDelta) / float(rectH); - float disocclusionThresholdOrtho = disocclusionThreshold; - float disocclusionThresholdAlternate = m_CommonSettings.disocclusionThresholdAlternate + (1.0f + m_JitterDelta) / float(rectH); - float disocclusionThresholdAlternateOrtho = disocclusionThresholdAlternate; - float depthThresholdOrtho = settings.depthThreshold; - - float tanHalfFov = 1.0f / m_ViewToClip.a00; - float aspect = m_ViewToClip.a00 / m_ViewToClip.a11; - ml::float3 frustumRight = m_WorldToView.GetRow0().To3d() * tanHalfFov; - ml::float3 frustumUp = m_WorldToView.GetRow1().To3d() * tanHalfFov * aspect; - ml::float3 frustumForward = RELAX_GetFrustumForward(m_ViewToWorld, m_Frustum); - - float prevTanHalfFov = 1.0f / m_ViewToClipPrev.a00; - float prevAspect = m_ViewToClipPrev.a00 / m_ViewToClipPrev.a11; - ml::float3 prevFrustumRight = m_WorldToViewPrev.GetRow0().To3d() * prevTanHalfFov; - ml::float3 prevFrustumUp = m_WorldToViewPrev.GetRow1().To3d() * prevTanHalfFov * prevAspect; - ml::float3 prevFrustumForward = RELAX_GetFrustumForward(m_ViewToWorldPrev, m_FrustumPrev); - bool isCameraStatic = RELAX_IsCameraStatic(ml::float3(m_CameraDelta.x, m_CameraDelta.y, m_CameraDelta.z), frustumRight, frustumUp, frustumForward, prevFrustumRight, prevFrustumUp, prevFrustumForward); - - bool enableHitDistanceReconstruction = settings.hitDistanceReconstructionMode != HitDistanceReconstructionMode::OFF && settings.checkerboardMode == CheckerboardMode::OFF; - - // Checkerboard logic - uint32_t specularCheckerboard = 2; - - switch (settings.checkerboardMode) - { - case CheckerboardMode::BLACK: - specularCheckerboard = 0; - break; - case CheckerboardMode::WHITE: - specularCheckerboard = 1; - break; - default: - break; - } - - // SPLIT_SCREEN (passthrough) - if (m_CommonSettings.splitScreen >= 1.0f) - { - Constant* data = PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_SPECULAR); - AddFloat(data, m_CommonSettings.splitScreen); - AddUint(data, specularCheckerboard); - ValidateConstants(data); - - return; - } - - // CLASSIFY_TILES - Constant* data = PushDispatch(denoiserData, AsUint(Dispatch::CLASSIFY_TILES)); - AddFloat(data, m_CommonSettings.denoisingRange); - ValidateConstants(data); - - // HITDIST_RECONSTRUCTION - if (enableHitDistanceReconstruction) - { - bool is3x3 = settings.hitDistanceReconstructionMode == HitDistanceReconstructionMode::AREA_3X3; - data = PushDispatch(denoiserData, is3x3 ? AsUint(Dispatch::HITDIST_RECONSTRUCTION_3x3) : AsUint(Dispatch::HITDIST_RECONSTRUCTION_5x5)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_SPECULAR); - ValidateConstants(data); - } - - // PREPASS - data = PushDispatch(denoiserData, AsUint(enableHitDistanceReconstruction ? Dispatch::PREPASS_AFTER_HITDIST_RECONSTRUCTION : Dispatch::PREPASS)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_SPECULAR); - AddFloat4(data, m_Rotator_PrePass); - AddUint(data, specularCheckerboard); - AddFloat(data, settings.prepassBlurRadius); - AddFloat(data, 1.0f); - AddFloat(data, m_IsOrtho == 0 ? settings.depthThreshold : depthThresholdOrtho); - AddFloat(data, settings.specularLobeAngleFraction); - AddFloat(data, settings.specularLobeAngleSlack); - AddFloat(data, settings.roughnessFraction); - ValidateConstants(data); - - // TEMPORAL_ACCUMULATION - if (!m_CommonSettings.isDisocclusionThresholdMixAvailable) - { - data = PushDispatch( - denoiserData, - AsUint(m_CommonSettings.isHistoryConfidenceAvailable ? - Dispatch::TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS : - Dispatch::TEMPORAL_ACCUMULATION)); - } - else - { - data = PushDispatch( - denoiserData, - AsUint(m_CommonSettings.isHistoryConfidenceAvailable ? - Dispatch::TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS_WITH_THRESHOLD_MIX : - Dispatch::TEMPORAL_ACCUMULATION_WITH_THRESHOLD_MIX)); - } - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_SPECULAR); - AddFloat(data, (float)settings.specularMaxAccumulatedFrameNum); - AddFloat(data, (float)settings.specularMaxFastAccumulatedFrameNum); - AddUint(data, specularCheckerboard); - AddFloat(data, m_IsOrtho == 0 ? disocclusionThreshold : disocclusionThresholdOrtho); - AddFloat(data, m_IsOrtho == 0 ? disocclusionThresholdAlternate : disocclusionThresholdAlternateOrtho); - AddFloat(data, settings.roughnessFraction); - AddFloat(data, settings.specularVarianceBoost); - AddUint(data, settings.enableReprojectionTestSkippingWithoutMotion && isCameraStatic); - AddUint(data, m_CommonSettings.isHistoryConfidenceAvailable ? 1 : 0); - AddUint(data, m_CommonSettings.isDisocclusionThresholdMixAvailable ? 1 : 0); - ValidateConstants(data); - - // HISTORY_FIX - data = PushDispatch(denoiserData, AsUint(Dispatch::HISTORY_FIX)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_SPECULAR); - AddFloat(data, m_IsOrtho == 0 ? settings.depthThreshold : depthThresholdOrtho); - AddFloat(data, settings.historyFixEdgeStoppingNormalPower); - AddFloat(data, settings.historyFixStrideBetweenSamples); - AddFloat(data, float(settings.historyFixFrameNum)); - AddFloat(data, settings.specularLobeAngleFraction); - AddFloat(data, ml::DegToRad(settings.specularLobeAngleSlack)); - AddFloat(data, settings.roughnessEdgeStoppingRelaxation); - AddFloat(data, settings.normalEdgeStoppingRelaxation); - ValidateConstants(data); - - // HISTORY_CLAMPING - data = PushDispatch(denoiserData, AsUint(Dispatch::HISTORY_CLAMPING)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_SPECULAR); - AddFloat(data, settings.historyClampingColorBoxSigmaScale); - AddFloat(data, float(settings.historyFixFrameNum)); - AddUint(data, settings.specularMaxFastAccumulatedFrameNum < settings.specularMaxAccumulatedFrameNum ? 1 : 0); - AddFloat(data, float(settings.antilagSettings.accelerationAmount)); - AddFloat(data, float(settings.antilagSettings.temporalSigmaScale)); - AddFloat(data, float(settings.antilagSettings.spatialSigmaScale)); - AddFloat(data, float(settings.antilagSettings.resetAmount)); - ValidateConstants(data); - - if (settings.enableAntiFirefly) - { - // COPY - data = PushDispatch(denoiserData, AsUint(Dispatch::COPY)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_SPECULAR); - ValidateConstants(data); - - // FIREFLY - data = PushDispatch(denoiserData, AsUint(Dispatch::FIREFLY)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_SPECULAR); - ValidateConstants(data); - } - - - // A-TROUS - uint32_t iterationNum = ml::Clamp(settings.atrousIterationNum, 2u, RELAX_MAX_ATROUS_PASS_NUM); - for (uint32_t i = 0; i < iterationNum; i++) - { - Dispatch dispatch; - if (!m_CommonSettings.isHistoryConfidenceAvailable) - { - if (i == 0) - dispatch = Dispatch::ATROUS_SMEM; - else if (i == iterationNum - 1) - dispatch = (i % 2 == 0) ? Dispatch::ATROUS_EVEN_LAST : Dispatch::ATROUS_ODD_LAST; - else - dispatch = (i % 2 == 0) ? Dispatch::ATROUS_EVEN : Dispatch::ATROUS_ODD; - } - else - { - if (i == 0) - dispatch = Dispatch::ATROUS_SMEM_WITH_CONFIDENCE_INPUTS; - else if (i == iterationNum - 1) - dispatch = (i % 2 == 0) ? Dispatch::ATROUS_EVEN_LAST_WITH_CONFIDENCE_INPUTS : Dispatch::ATROUS_ODD_LAST_WITH_CONFIDENCE_INPUTS; - else - dispatch = (i % 2 == 0) ? Dispatch::ATROUS_EVEN_WITH_CONFIDENCE_INPUTS : Dispatch::ATROUS_ODD_WITH_CONFIDENCE_INPUTS; - } - - data = PushDispatch(denoiserData, AsUint(dispatch)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_SPECULAR); - - if (i == 0) - { - AddUint2(data, screenW, screenH); // For Atrous_shmem - AddUint(data, settings.spatialVarianceEstimationHistoryThreshold); - } - - AddFloat(data, settings.specularPhiLuminance); - AddFloat(data, maxLuminanceRelativeDifference); - AddFloat(data, m_IsOrtho == 0 ? settings.depthThreshold : depthThresholdOrtho); - AddFloat(data, settings.diffuseLobeAngleFraction); - AddFloat(data, settings.roughnessFraction); - AddFloat(data, settings.specularLobeAngleFraction); - AddFloat(data, ml::DegToRad(settings.specularLobeAngleSlack)); - AddUint(data, 1 << i); - AddUint(data, settings.enableRoughnessEdgeStopping); - AddFloat(data, settings.roughnessEdgeStoppingRelaxation); - AddFloat(data, settings.normalEdgeStoppingRelaxation); - AddFloat(data, settings.luminanceEdgeStoppingRelaxation); - AddUint(data, m_CommonSettings.isHistoryConfidenceAvailable ? 1 : 0); - AddFloat(data, settings.confidenceDrivenRelaxationMultiplier); - AddFloat(data, settings.confidenceDrivenLuminanceEdgeStoppingRelaxation); - AddFloat(data, settings.confidenceDrivenNormalEdgeStoppingRelaxation); - ValidateConstants(data); - } - - // SPLIT_SCREEN - if (m_CommonSettings.splitScreen > 0.0f) - { - data = PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_SPECULAR); - AddFloat(data, m_CommonSettings.splitScreen); - AddUint(data, specularCheckerboard); - ValidateConstants(data); - } - - // VALIDATION - if (m_CommonSettings.enableValidation) - { - data = PushDispatch(denoiserData, AsUint(Dispatch::VALIDATION)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - AddFloat4x4(data, m_WorldToClipPrev); - AddFloat2(data, m_CommonSettings.cameraJitter[0], m_CommonSettings.cameraJitter[1]); - AddFloat(data, (float)settings.specularMaxAccumulatedFrameNum); - ValidateConstants(data); - } -} diff --git a/Source/Denoisers/Relax_SpecularSh.hpp b/Source/Denoisers/Relax_SpecularSh.hpp index 8c6598c..44bcf39 100644 --- a/Source/Denoisers/Relax_SpecularSh.hpp +++ b/Source/Denoisers/Relax_SpecularSh.hpp @@ -12,13 +12,8 @@ void nrd::InstanceImpl::Add_RelaxSpecularSh(DenoiserData& denoiserData) { #define DENOISER_NAME RELAX_Specular - denoiserData.settings.specularRelax = RelaxSpecularSettings(); - denoiserData.settingsSize = sizeof(denoiserData.settings.specularRelax); - - uint16_t w = denoiserData.desc.renderWidth; - uint16_t h = denoiserData.desc.renderHeight; - uint16_t tilesW = DivideUp(w, 16); - uint16_t tilesH = DivideUp(h, 16); + denoiserData.settings.relax = RelaxSettings(); + denoiserData.settingsSize = sizeof(denoiserData.settings.relax); enum class Permanent { @@ -34,16 +29,16 @@ void nrd::InstanceImpl::Add_RelaxSpecularSh(DenoiserData& denoiserData) VIEWZ_PREV }; - m_PermanentPool.push_back({ Format::RGBA16_SFLOAT, w, h, 1 }); - m_PermanentPool.push_back({ Format::RGBA16_SFLOAT, w, h, 1 }); - AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::R16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::R16_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::R8_UNORM, w, h, 1} ); - AddTextureToPermanentPool( {Format::RGBA8_UNORM, w, h, 1} ); - AddTextureToPermanentPool( {Format::R8_UNORM, w, h, 1} ); - AddTextureToPermanentPool( {Format::R32_SFLOAT, w, h, 1} ); + AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::R16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::R16_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::R8_UNORM, 1} ); + AddTextureToPermanentPool( {Format::RGBA8_UNORM, 1} ); + AddTextureToPermanentPool( {Format::R8_UNORM, 1} ); + AddTextureToPermanentPool( {Format::R32_SFLOAT, 1} ); enum class Transient { @@ -56,90 +51,79 @@ void nrd::InstanceImpl::Add_RelaxSpecularSh(DenoiserData& denoiserData) HISTORY_LENGTH }; - AddTextureToTransientPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::RGBA16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, tilesW, tilesH, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, w, h, 1} ); - - RELAX_SET_SHARED_CONSTANTS; - - const uint32_t halfMaxPassNum = (RELAX_MAX_ATROUS_PASS_NUM - 2 + 1) / 2; + AddTextureToTransientPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::RGBA16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::R8_UNORM, 1} ); + AddTextureToTransientPool( {Format::R8_UNORM, 16} ); + AddTextureToTransientPool( {Format::R8_UNORM, 1} ); PushPass("Classify tiles"); { - PushInput(AsUint(ResourceType::IN_VIEWZ)); - PushOutput(AsUint(Transient::TILES)); - - AddDispatch(RELAX_ClassifyTiles, SumConstants(0, 0, 0, 1, false), NumThreads(16, 16), 1); - } - - PushPass("Hit distance reconstruction 3x3"); // 3x3 - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_SPEC_SH0) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + // Inputs PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushOutput( AsUint(Transient::SPEC_ILLUM_PING) ); + // Outputs + PushOutput( AsUint(Transient::TILES) ); - AddDispatch( RELAX_Specular_HitDistReconstruction, SumConstants(0, 0, 0, 0), NumThreads(8, 8), 1 ); + // Shaders + AddDispatch( RELAX_ClassifyTiles, RELAX_ClassifyTiles, 1 ); } - PushPass("Hit distance reconstruction 5x5"); // 5x5 + for (int i = 0; i < RELAX_HITDIST_RECONSTRUCTION_PERMUTATION_NUM; i++) { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_SPEC_SH0) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - - PushOutput( AsUint(Transient::SPEC_ILLUM_PING) ); - - AddDispatch( RELAX_Specular_HitDistReconstruction_5x5, SumConstants(0, 0, 0, 0), NumThreads(8, 8), 1 ); - } + bool is5x5 = ( ( ( i >> 0 ) & 0x1 ) != 0 ); - PushPass("Pre-pass"); // After hit distance reconstruction - { - // Does preblur (if enabled) and checkerboard reconstruction (if enabled) - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PING) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(ResourceType::IN_SPEC_SH1) ); + PushPass("Hit distance reconstruction"); + { + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( AsUint(ResourceType::IN_SPEC_SH0) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushOutput( AsUint(ResourceType::OUT_SPEC_SH0) ); - PushOutput( AsUint(ResourceType::OUT_SPEC_SH1) ); + // Outputs + PushOutput( AsUint(Transient::SPEC_ILLUM_PING) ); - AddDispatch( RELAX_SpecularSh_PrePass, SumConstants(0, 1, 0, 7), NumThreads(16, 16), 1 ); + // Shaders + if (is5x5) + AddDispatch( RELAX_Specular_HitDistReconstruction_5x5, RELAX_HitDistReconstruction, 1 ); + else + AddDispatch( RELAX_Specular_HitDistReconstruction, RELAX_HitDistReconstruction, 1 ); + } } - PushPass("Pre-pass"); // Without hit distance reconstruction + for (int i = 0; i < RELAX_PREPASS_PERMUTATION_NUM; i++) { - // Does preblur (if enabled) and checkerboard reconstruction (if enabled) - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(ResourceType::IN_SPEC_SH0) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(ResourceType::IN_SPEC_SH1) ); + bool isAfterReconstruction = ( ( ( i >> 0 ) & 0x1 ) != 0 ); - PushOutput( AsUint(ResourceType::OUT_SPEC_SH0) ); - PushOutput( AsUint(ResourceType::OUT_SPEC_SH1) ); + PushPass("Pre-pass"); + { + // Inputs + PushInput( AsUint(Transient::TILES) ); + PushInput( isAfterReconstruction ? AsUint(ResourceType::IN_SPEC_SH0) : AsUint(Transient::SPEC_ILLUM_PING) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( AsUint(ResourceType::IN_SPEC_SH1) ); + + // Outputs + PushOutput( AsUint(ResourceType::OUT_SPEC_SH0) ); + PushOutput( AsUint(ResourceType::OUT_SPEC_SH1) ); - AddDispatch( RELAX_SpecularSh_PrePass, SumConstants(0, 1, 0, 7), NumThreads(16, 16), 1 ); + // Shaders + AddDispatch( RELAX_SpecularSh_PrePass, RELAX_PrePass, 1 ); + } } - for (int i = 0; i < 4; i++) + for (int i = 0; i < RELAX_TEMPORAL_ACCUMULATION_PERMUTATION_NUM; i++) { - // The following passes are defined here: - // REPROJECT, - // REPROJECT_WITH_CONFIDENCE_INPUTS, - // REPROJECT_WITH_THRESHOLD_MIX, - // REPROJECT_WITH_CONFIDENCE_INPUTS_WITH_THRESHOLD_MIX + bool hasDisocclusionThresholdMix = ( ( ( i >> 1 ) & 0x1 ) != 0 ); + bool hasConfidenceInputs = ( ( ( i >> 0 ) & 0x1 ) != 0 ); PushPass("Temporal accumulation"); { + // Inputs PushInput( AsUint(Transient::TILES) ); PushInput( AsUint(ResourceType::OUT_SPEC_SH0) ); PushInput( AsUint(ResourceType::IN_MV) ); @@ -149,48 +133,32 @@ void nrd::InstanceImpl::Add_RelaxSpecularSh(DenoiserData& denoiserData) PushInput( AsUint(Permanent::SPEC_ILLUM_PREV) ); PushInput( AsUint(Permanent::NORMAL_ROUGHNESS_PREV) ); PushInput( AsUint(Permanent::VIEWZ_PREV) ); - PushInput( AsUint(Permanent::REFLECTION_HIT_T_PREV), 0, 1, AsUint(Permanent::REFLECTION_HIT_T_CURR) ); + PushInput( AsUint(Permanent::REFLECTION_HIT_T_PREV), AsUint(Permanent::REFLECTION_HIT_T_CURR) ); PushInput( AsUint(Permanent::HISTORY_LENGTH_PREV) ); PushInput( AsUint(Permanent::MATERIAL_ID_PREV) ); - // Confidence inputs: - if (i == 0) - { - PushInput( AsUint(ResourceType::IN_VIEWZ) ); // Bogus input that will not be fetched anyway - PushInput( AsUint(Permanent::HISTORY_LENGTH_PREV) ); // Bogus input that will not be fetched anyway - } - if (i == 1) - { - PushInput( AsUint(ResourceType::IN_SPEC_CONFIDENCE) ); - PushInput( AsUint(Permanent::HISTORY_LENGTH_PREV) ); // Bogus input that will not be fetched anyway - } - if (i == 2) - { - PushInput( AsUint(ResourceType::IN_VIEWZ) ); // Bogus input that will not be fetched anyway - PushInput( AsUint(ResourceType::IN_DISOCCLUSION_THRESHOLD_MIX) ); - } - if (i == 3) - { - PushInput( AsUint(ResourceType::IN_SPEC_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_DISOCCLUSION_THRESHOLD_MIX) ); - } + PushInput( hasConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : RELAX_DUMMY ); + PushInput( hasDisocclusionThresholdMix ? AsUint(ResourceType::IN_DISOCCLUSION_THRESHOLD_MIX) : RELAX_DUMMY ); PushInput( AsUint(ResourceType::OUT_SPEC_SH1) ); PushInput( AsUint(Permanent::SPEC_ILLUM_RESPONSIVE_PREV_SH1) ); PushInput( AsUint(Permanent::SPEC_ILLUM_PREV_SH1) ); + // Outputs PushOutput( AsUint(Transient::SPEC_ILLUM_PING) ); PushOutput( AsUint(Transient::SPEC_ILLUM_PONG) ); - PushOutput( AsUint(Permanent::REFLECTION_HIT_T_CURR), 0, 1, AsUint(Permanent::REFLECTION_HIT_T_PREV) ); + PushOutput( AsUint(Permanent::REFLECTION_HIT_T_CURR), AsUint(Permanent::REFLECTION_HIT_T_PREV) ); PushOutput( AsUint(Transient::HISTORY_LENGTH) ); PushOutput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); PushOutput( AsUint(Transient::SPEC_ILLUM_PING_SH1) ); PushOutput( AsUint(Transient::SPEC_ILLUM_PONG_SH1) ); - AddDispatch( RELAX_SpecularSh_TemporalAccumulation, SumConstants(0, 0, 0, 10), NumThreads(8, 8), 1 ); + // Shaders + AddDispatch( RELAX_SpecularSh_TemporalAccumulation, RELAX_TemporalAccumulation, 1 ); } } PushPass("History fix"); { + // Inputs PushInput( AsUint(Transient::TILES) ); PushInput( AsUint(Transient::SPEC_ILLUM_PING) ); PushInput( AsUint(Transient::HISTORY_LENGTH) ); @@ -198,14 +166,16 @@ void nrd::InstanceImpl::Add_RelaxSpecularSh(DenoiserData& denoiserData) PushInput( AsUint(ResourceType::IN_VIEWZ) ); PushInput( AsUint(Transient::SPEC_ILLUM_PING_SH1) ); + // Outputs PushOutput( AsUint(Transient::SPEC_ILLUM_PONG) ); PushOutput( AsUint(Transient::SPEC_ILLUM_PONG_SH1) ); - AddDispatch( RELAX_SpecularSh_HistoryFix, SumConstants(0, 0, 0, 8), NumThreads(8, 8), 1 ); + AddDispatch( RELAX_SpecularSh_HistoryFix, RELAX_HistoryFix, 1 ); } PushPass("History clamping"); { + // Inputs PushInput( AsUint(Transient::TILES) ); PushInput( AsUint(ResourceType::OUT_SPEC_SH0) ); PushInput( AsUint(Transient::SPEC_ILLUM_PING) ); @@ -214,402 +184,118 @@ void nrd::InstanceImpl::Add_RelaxSpecularSh(DenoiserData& denoiserData) PushInput( AsUint(Transient::SPEC_ILLUM_PING_SH1) ); PushInput( AsUint(Transient::SPEC_ILLUM_PONG_SH1) ); + // Outputs PushOutput( AsUint(Permanent::SPEC_ILLUM_PREV) ); PushOutput( AsUint(Permanent::SPEC_ILLUM_RESPONSIVE_PREV) ); PushOutput( AsUint(Permanent::HISTORY_LENGTH_PREV) ); PushOutput( AsUint(Permanent::SPEC_ILLUM_PREV_SH1) ); PushOutput( AsUint(Permanent::SPEC_ILLUM_RESPONSIVE_PREV_SH1) ); - AddDispatch( RELAX_SpecularSh_HistoryClamping, SumConstants(0, 0, 0, 7), NumThreads(8, 8), 1 ); + AddDispatch( RELAX_SpecularSh_HistoryClamping, RELAX_HistoryClamping, 1 ); } PushPass("Copy"); { + // Inputs PushInput( AsUint(Permanent::SPEC_ILLUM_PREV) ); + + // Outputs PushOutput( AsUint(ResourceType::OUT_SPEC_SH0) ); - AddDispatch( RELAX_SpecularSh_Copy, SumConstants(0, 0, 0, 0), NumThreads(8, 8), 1 ); + AddDispatch( RELAX_SpecularSh_Copy, RELAX_Copy, 1 ); } PushPass("Anti-firefly"); { + // Inputs PushInput( AsUint(Transient::TILES) ); PushInput( AsUint(ResourceType::OUT_SPEC_SH0) ); PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); PushInput( AsUint(ResourceType::IN_VIEWZ) ); + // Outputs PushOutput( AsUint(Permanent::SPEC_ILLUM_PREV) ); - AddDispatch( RELAX_SpecularSh_AntiFirefly, SumConstants(0, 0, 0, 0), NumThreads(16, 16), 1 ); + AddDispatch( RELAX_SpecularSh_AntiFirefly, RELAX_AntiFirefly, 1 ); } - for (int i = 0; i < 2; i++) - { - bool withConfidenceInputs = (i == 1); - - // A-trous (first) - PushPass("A-trous (SMEM)"); - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Permanent::SPEC_ILLUM_PREV) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(Permanent::SPEC_ILLUM_PREV_SH1) ); - - PushOutput( AsUint(Transient::SPEC_ILLUM_PING) ); - PushOutput( AsUint(Permanent::NORMAL_ROUGHNESS_PREV) ); - PushOutput( AsUint(Permanent::MATERIAL_ID_PREV) ); - PushOutput( AsUint(Permanent::VIEWZ_PREV) ); - PushOutput( AsUint(Transient::SPEC_ILLUM_PING_SH1) ); - - AddDispatch( RELAX_SpecularSh_AtrousSmem, SumConstants(0, 0, 1, 17), NumThreads(8, 8), 1 ); - } - - // A-trous (odd) - PushPass("A-trous"); - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PING) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PING_SH1) ); - - PushOutput( AsUint(Transient::SPEC_ILLUM_PONG) ); - PushOutput( AsUint(Transient::SPEC_ILLUM_PONG_SH1) ); - - AddDispatchRepeated( RELAX_SpecularSh_Atrous, SumConstants(0, 0, 0, 17), NumThreads(16, 16), 1, halfMaxPassNum ); - } - - // A-trous (even) - PushPass("A-trous"); - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PONG) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PONG_SH1) ); - PushOutput( AsUint(Transient::SPEC_ILLUM_PING) ); - PushOutput( AsUint(Transient::SPEC_ILLUM_PING_SH1) ); - - AddDispatchRepeated( RELAX_SpecularSh_Atrous, SumConstants(0, 0, 0, 17), NumThreads(16, 16), 1, halfMaxPassNum ); - } - - // A-trous (odd, last) - PushPass("A-trous"); - { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PING) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PING_SH1) ); - - PushOutput( AsUint(ResourceType::OUT_SPEC_SH0) ); - PushOutput( AsUint(ResourceType::OUT_SPEC_SH1) ); - - AddDispatch( RELAX_SpecularSh_Atrous, SumConstants(0, 0, 0, 17), NumThreads(16, 16), 1 ); - } + for (int i = 0; i < RELAX_ATROUS_PERMUTATION_NUM; i++) + { + bool hasConfidenceInputs = ( ( ( i >> 0 ) & 0x1 ) != 0 ); - // A-trous (even, last) - PushPass("A-trous"); + for (int j = 0; j < RELAX_ATROUS_BINDING_VARIANT_NUM; j++) { - PushInput( AsUint(Transient::TILES) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PONG) ); - PushInput( AsUint(Transient::HISTORY_LENGTH) ); - PushInput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); - PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); - PushInput( AsUint(ResourceType::IN_VIEWZ) ); - PushInput( withConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); - PushInput( AsUint(Transient::SPEC_ILLUM_PONG_SH1) ); + bool isSmem = j == 0; + bool isEven = j % 2 == 0; + bool isLast = j > 2; - PushOutput( AsUint(ResourceType::OUT_SPEC_SH0) ); - PushOutput( AsUint(ResourceType::OUT_SPEC_SH1) ); + if (isSmem) + PushPass("A-trous (SMEM)"); + else + PushPass("A-trous"); - AddDispatch( RELAX_SpecularSh_Atrous, SumConstants(0, 0, 0, 17), NumThreads(16, 16), 1 ); + { + // Inputs + PushInput( AsUint(Transient::TILES) ); + + if (isSmem) + PushInput( AsUint(Permanent::SPEC_ILLUM_PREV) ); + else + PushInput( isEven ? AsUint(Transient::SPEC_ILLUM_PONG) : AsUint(Transient::SPEC_ILLUM_PING) ); + + PushInput( AsUint(Transient::HISTORY_LENGTH) ); + PushInput( AsUint(Transient::SPEC_REPROJECTION_CONFIDENCE) ); + PushInput( AsUint(ResourceType::IN_NORMAL_ROUGHNESS) ); + PushInput( AsUint(ResourceType::IN_VIEWZ) ); + PushInput( hasConfidenceInputs ? AsUint(ResourceType::IN_SPEC_CONFIDENCE) : AsUint(ResourceType::IN_VIEWZ) ); + + if (isSmem) + PushInput( AsUint(Permanent::SPEC_ILLUM_PREV_SH1) ); + else + PushInput( isEven ? AsUint(Transient::SPEC_ILLUM_PONG_SH1) : AsUint(Transient::SPEC_ILLUM_PING_SH1) ); + + // Outputs + if (isLast) + PushOutput( AsUint(ResourceType::OUT_SPEC_SH0) ); + else + PushOutput( isEven ? AsUint(Transient::SPEC_ILLUM_PING) : AsUint(Transient::SPEC_ILLUM_PONG) ); + + if (isSmem) + { + PushOutput( AsUint(Permanent::NORMAL_ROUGHNESS_PREV) ); + PushOutput( AsUint(Permanent::MATERIAL_ID_PREV) ); + PushOutput( AsUint(Permanent::VIEWZ_PREV) ); + } + + if (isLast) + PushOutput( AsUint(ResourceType::OUT_SPEC_SH1) ); + else + PushOutput( isEven ? AsUint(Transient::SPEC_ILLUM_PING_SH1) : AsUint(Transient::SPEC_ILLUM_PONG_SH1) ); + + // Shaders + uint32_t repeatNum = isLast ? 1 : (RELAX_MAX_ATROUS_PASS_NUM - 2 + 1) / 2; + if (isSmem) + AddDispatch( RELAX_SpecularSh_AtrousSmem, RELAX_AtrousSmem, 1 ); + else + AddDispatchRepeated( RELAX_SpecularSh_Atrous, RELAX_Atrous, 1, repeatNum ); + } } } PushPass("Split screen"); { + // Inputs PushInput( AsUint(ResourceType::IN_VIEWZ) ); PushInput( AsUint(ResourceType::IN_SPEC_RADIANCE_HITDIST)); + // Outputs PushOutput( AsUint( ResourceType::OUT_SPEC_RADIANCE_HITDIST ) ); - AddDispatch( RELAX_Specular_SplitScreen, SumConstants(0, 0, 0, 2), NumThreads(16, 16), 1 ); + // Shaders + AddDispatch( RELAX_Specular_SplitScreen, RELAX_SplitScreen, 1 ); } RELAX_ADD_VALIDATION_DISPATCH; #undef DENOISER_NAME } - -void nrd::InstanceImpl::Update_RelaxSpecularSh(const DenoiserData& denoiserData) -{ - enum class Dispatch - { - CLASSIFY_TILES, - HITDIST_RECONSTRUCTION_3x3, - HITDIST_RECONSTRUCTION_5x5, - PREPASS_AFTER_HITDIST_RECONSTRUCTION, - PREPASS, - TEMPORAL_ACCUMULATION, - TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS, - TEMPORAL_ACCUMULATION_WITH_THRESHOLD_MIX, - TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS_WITH_THRESHOLD_MIX, - HISTORY_FIX, - HISTORY_CLAMPING, - COPY, - FIREFLY, - ATROUS_SMEM, - ATROUS_ODD, - ATROUS_EVEN, - ATROUS_ODD_LAST, - ATROUS_EVEN_LAST, - ATROUS_SMEM_WITH_CONFIDENCE_INPUTS, - ATROUS_ODD_WITH_CONFIDENCE_INPUTS, - ATROUS_EVEN_WITH_CONFIDENCE_INPUTS, - ATROUS_ODD_LAST_WITH_CONFIDENCE_INPUTS, - ATROUS_EVEN_LAST_WITH_CONFIDENCE_INPUTS, - SPLIT_SCREEN, - VALIDATION, - }; - - const RelaxSpecularSettings& settings = denoiserData.settings.specularRelax; - - NRD_DECLARE_DIMS; - - float maxLuminanceRelativeDifference = -ml::Log(ml::Saturate(settings.minLuminanceWeight)); - - float disocclusionThreshold = m_CommonSettings.disocclusionThreshold + (1.0f + m_JitterDelta) / float(rectH); - float disocclusionThresholdOrtho = disocclusionThreshold; - float disocclusionThresholdAlternate = m_CommonSettings.disocclusionThresholdAlternate + (1.0f + m_JitterDelta) / float(rectH); - float disocclusionThresholdAlternateOrtho = disocclusionThresholdAlternate; - float depthThresholdOrtho = settings.depthThreshold; - - float tanHalfFov = 1.0f / m_ViewToClip.a00; - float aspect = m_ViewToClip.a00 / m_ViewToClip.a11; - ml::float3 frustumRight = m_WorldToView.GetRow0().To3d() * tanHalfFov; - ml::float3 frustumUp = m_WorldToView.GetRow1().To3d() * tanHalfFov * aspect; - ml::float3 frustumForward = RELAX_GetFrustumForward(m_ViewToWorld, m_Frustum); - - float prevTanHalfFov = 1.0f / m_ViewToClipPrev.a00; - float prevAspect = m_ViewToClipPrev.a00 / m_ViewToClipPrev.a11; - ml::float3 prevFrustumRight = m_WorldToViewPrev.GetRow0().To3d() * prevTanHalfFov; - ml::float3 prevFrustumUp = m_WorldToViewPrev.GetRow1().To3d() * prevTanHalfFov * prevAspect; - ml::float3 prevFrustumForward = RELAX_GetFrustumForward(m_ViewToWorldPrev, m_FrustumPrev); - bool isCameraStatic = RELAX_IsCameraStatic(ml::float3(m_CameraDelta.x, m_CameraDelta.y, m_CameraDelta.z), frustumRight, frustumUp, frustumForward, prevFrustumRight, prevFrustumUp, prevFrustumForward); - - bool enableHitDistanceReconstruction = settings.hitDistanceReconstructionMode != HitDistanceReconstructionMode::OFF && settings.checkerboardMode == CheckerboardMode::OFF; - - // Checkerboard logic - uint32_t specularCheckerboard = 2; - - switch (settings.checkerboardMode) - { - case CheckerboardMode::BLACK: - specularCheckerboard = 0; - break; - case CheckerboardMode::WHITE: - specularCheckerboard = 1; - break; - default: - break; - } - - // SPLIT_SCREEN (passthrough) - if (m_CommonSettings.splitScreen >= 1.0f) - { - Constant* data = PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_SPECULAR); - AddFloat(data, m_CommonSettings.splitScreen); - AddUint(data, specularCheckerboard); - ValidateConstants(data); - - return; - } - - // CLASSIFY_TILES - Constant* data = PushDispatch(denoiserData, AsUint(Dispatch::CLASSIFY_TILES)); - AddFloat(data, m_CommonSettings.denoisingRange); - ValidateConstants(data); - - // HITDIST_RECONSTRUCTION - if (enableHitDistanceReconstruction) - { - bool is3x3 = settings.hitDistanceReconstructionMode == HitDistanceReconstructionMode::AREA_3X3; - data = PushDispatch(denoiserData, is3x3 ? AsUint(Dispatch::HITDIST_RECONSTRUCTION_3x3) : AsUint(Dispatch::HITDIST_RECONSTRUCTION_5x5)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_SPECULAR); - ValidateConstants(data); - } - - // PREPASS - data = PushDispatch(denoiserData, AsUint(enableHitDistanceReconstruction ? Dispatch::PREPASS_AFTER_HITDIST_RECONSTRUCTION : Dispatch::PREPASS)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_SPECULAR); - AddFloat4(data, m_Rotator_PrePass); - AddUint(data, specularCheckerboard); - AddFloat(data, settings.prepassBlurRadius); - AddFloat(data, 1.0f); - AddFloat(data, m_IsOrtho == 0 ? settings.depthThreshold : depthThresholdOrtho); - AddFloat(data, settings.specularLobeAngleFraction); - AddFloat(data, settings.specularLobeAngleSlack); - AddFloat(data, settings.roughnessFraction); - ValidateConstants(data); - - // TEMPORAL_ACCUMULATION - if (!m_CommonSettings.isDisocclusionThresholdMixAvailable) - { - data = PushDispatch( - denoiserData, - AsUint(m_CommonSettings.isHistoryConfidenceAvailable ? - Dispatch::TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS : - Dispatch::TEMPORAL_ACCUMULATION)); - } - else - { - data = PushDispatch( - denoiserData, - AsUint(m_CommonSettings.isHistoryConfidenceAvailable ? - Dispatch::TEMPORAL_ACCUMULATION_WITH_CONFIDENCE_INPUTS_WITH_THRESHOLD_MIX : - Dispatch::TEMPORAL_ACCUMULATION_WITH_THRESHOLD_MIX)); - } - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_SPECULAR); - AddFloat(data, (float)settings.specularMaxAccumulatedFrameNum); - AddFloat(data, (float)settings.specularMaxFastAccumulatedFrameNum); - AddUint(data, specularCheckerboard); - AddFloat(data, m_IsOrtho == 0 ? disocclusionThreshold : disocclusionThresholdOrtho); - AddFloat(data, m_IsOrtho == 0 ? disocclusionThresholdAlternate : disocclusionThresholdAlternateOrtho); - AddFloat(data, settings.roughnessFraction); - AddFloat(data, settings.specularVarianceBoost); - AddUint(data, settings.enableReprojectionTestSkippingWithoutMotion && isCameraStatic); - AddUint(data, m_CommonSettings.isHistoryConfidenceAvailable ? 1 : 0); - AddUint(data, m_CommonSettings.isDisocclusionThresholdMixAvailable ? 1 : 0); - ValidateConstants(data); - - // HISTORY_FIX - data = PushDispatch(denoiserData, AsUint(Dispatch::HISTORY_FIX)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_SPECULAR); - AddFloat(data, m_IsOrtho == 0 ? settings.depthThreshold : depthThresholdOrtho); - AddFloat(data, settings.historyFixEdgeStoppingNormalPower); - AddFloat(data, settings.historyFixStrideBetweenSamples); - AddFloat(data, float(settings.historyFixFrameNum)); - AddFloat(data, settings.specularLobeAngleFraction); - AddFloat(data, ml::DegToRad(settings.specularLobeAngleSlack)); - AddFloat(data, settings.roughnessEdgeStoppingRelaxation); - AddFloat(data, settings.normalEdgeStoppingRelaxation); - ValidateConstants(data); - - // HISTORY_CLAMPING - data = PushDispatch(denoiserData, AsUint(Dispatch::HISTORY_CLAMPING)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_SPECULAR); - AddFloat(data, settings.historyClampingColorBoxSigmaScale); - AddFloat(data, float(settings.historyFixFrameNum)); - AddUint(data, settings.specularMaxFastAccumulatedFrameNum < settings.specularMaxAccumulatedFrameNum ? 1 : 0); - AddFloat(data, float(settings.antilagSettings.accelerationAmount)); - AddFloat(data, float(settings.antilagSettings.temporalSigmaScale)); - AddFloat(data, float(settings.antilagSettings.spatialSigmaScale)); - AddFloat(data, float(settings.antilagSettings.resetAmount)); - ValidateConstants(data); - - if (settings.enableAntiFirefly) - { - // COPY - data = PushDispatch(denoiserData, AsUint(Dispatch::COPY)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_SPECULAR); - ValidateConstants(data); - - // FIREFLY - data = PushDispatch(denoiserData, AsUint(Dispatch::FIREFLY)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_SPECULAR); - ValidateConstants(data); - } - - - // A-TROUS - uint32_t iterationNum = ml::Clamp(settings.atrousIterationNum, 2u, RELAX_MAX_ATROUS_PASS_NUM); - for (uint32_t i = 0; i < iterationNum; i++) - { - Dispatch dispatch; - if (!m_CommonSettings.isHistoryConfidenceAvailable) - { - if (i == 0) - dispatch = Dispatch::ATROUS_SMEM; - else if (i == iterationNum - 1) - dispatch = (i % 2 == 0) ? Dispatch::ATROUS_EVEN_LAST : Dispatch::ATROUS_ODD_LAST; - else - dispatch = (i % 2 == 0) ? Dispatch::ATROUS_EVEN : Dispatch::ATROUS_ODD; - } - else - { - if (i == 0) - dispatch = Dispatch::ATROUS_SMEM_WITH_CONFIDENCE_INPUTS; - else if (i == iterationNum - 1) - dispatch = (i % 2 == 0) ? Dispatch::ATROUS_EVEN_LAST_WITH_CONFIDENCE_INPUTS : Dispatch::ATROUS_ODD_LAST_WITH_CONFIDENCE_INPUTS; - else - dispatch = (i % 2 == 0) ? Dispatch::ATROUS_EVEN_WITH_CONFIDENCE_INPUTS : Dispatch::ATROUS_ODD_WITH_CONFIDENCE_INPUTS; - } - - data = PushDispatch(denoiserData, AsUint(dispatch)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_SPECULAR); - - if (i == 0) - { - AddUint2(data, screenW, screenH); // For Atrous_shmem - AddUint(data, settings.spatialVarianceEstimationHistoryThreshold); - } - - AddFloat(data, settings.specularPhiLuminance); - AddFloat(data, maxLuminanceRelativeDifference); - AddFloat(data, m_IsOrtho == 0 ? settings.depthThreshold : depthThresholdOrtho); - AddFloat(data, settings.diffuseLobeAngleFraction); - AddFloat(data, settings.roughnessFraction); - AddFloat(data, settings.specularLobeAngleFraction); - AddFloat(data, ml::DegToRad(settings.specularLobeAngleSlack)); - AddUint(data, 1 << i); - AddUint(data, settings.enableRoughnessEdgeStopping); - AddFloat(data, settings.roughnessEdgeStoppingRelaxation); - AddFloat(data, settings.normalEdgeStoppingRelaxation); - AddFloat(data, settings.luminanceEdgeStoppingRelaxation); - AddUint(data, m_CommonSettings.isHistoryConfidenceAvailable ? 1 : 0); - AddFloat(data, settings.confidenceDrivenRelaxationMultiplier); - AddFloat(data, settings.confidenceDrivenLuminanceEdgeStoppingRelaxation); - AddFloat(data, settings.confidenceDrivenNormalEdgeStoppingRelaxation); - if (i != 0) - { - AddUint(data, (i == iterationNum - 1) ? 1 : 0); - } - ValidateConstants(data); - } - - // SPLIT_SCREEN - if (m_CommonSettings.splitScreen > 0.0f) - { - data = PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_SPECULAR); - AddFloat(data, m_CommonSettings.splitScreen); - AddUint(data, specularCheckerboard); - ValidateConstants(data); - } - - // VALIDATION - if (m_CommonSettings.enableValidation) - { - data = PushDispatch(denoiserData, AsUint(Dispatch::VALIDATION)); - AddSharedConstants_Relax(denoiserData, data, Denoiser::RELAX_DIFFUSE_SPECULAR); - AddFloat4x4(data, m_WorldToClipPrev); - AddFloat2(data, m_CommonSettings.cameraJitter[0], m_CommonSettings.cameraJitter[1]); - AddFloat(data, (float)settings.specularMaxAccumulatedFrameNum); - ValidateConstants(data); - } -} diff --git a/Source/Denoisers/Sigma_Shadow.hpp b/Source/Denoisers/Sigma_Shadow.hpp index 51f59cd..14f5b7a 100644 --- a/Source/Denoisers/Sigma_Shadow.hpp +++ b/Source/Denoisers/Sigma_Shadow.hpp @@ -15,11 +15,6 @@ void nrd::InstanceImpl::Add_SigmaShadow(DenoiserData& denoiserData) denoiserData.settings.sigma = SigmaSettings(); denoiserData.settingsSize = sizeof(denoiserData.settings.sigma); - uint16_t w = denoiserData.desc.renderWidth; - uint16_t h = denoiserData.desc.renderHeight; - uint16_t tilesW = DivideUp(w, 16); - uint16_t tilesH = DivideUp(h, 16); - enum class Transient { DATA_1 = TRANSIENT_POOL_START, @@ -31,15 +26,13 @@ void nrd::InstanceImpl::Add_SigmaShadow(DenoiserData& denoiserData) SMOOTHED_TILES, }; - AddTextureToTransientPool( {Format::RG16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::RG16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, w, h, 1} ); - AddTextureToTransientPool( {Format::R8_UNORM, w, h, 1} ); - AddTextureToTransientPool( {Format::RGBA8_UNORM, tilesW, tilesH, 1} ); - AddTextureToTransientPool( {Format::RG8_UNORM, tilesW, tilesH, 1} ); - - SIGMA_SET_SHARED_CONSTANTS; + AddTextureToTransientPool( {Format::RG16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::RG16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::R8_UNORM, 1} ); + AddTextureToTransientPool( {Format::R8_UNORM, 1} ); + AddTextureToTransientPool( {Format::R8_UNORM, 1} ); + AddTextureToTransientPool( {Format::RGBA8_UNORM, 16} ); + AddTextureToTransientPool( {Format::RG8_UNORM, 16} ); PushPass("Classify tiles"); { @@ -47,7 +40,7 @@ void nrd::InstanceImpl::Add_SigmaShadow(DenoiserData& denoiserData) PushOutput( AsUint(Transient::TILES) ); - AddDispatch( SIGMA_Shadow_ClassifyTiles, SIGMA_CLASSIFY_TILES_SET_CONSTANTS, SIGMA_CLASSIFY_TILES_NUM_THREADS, 16 ); + AddDispatch( SIGMA_Shadow_ClassifyTiles, SIGMA_ClassifyTiles, 1 ); } PushPass("Smooth tiles"); @@ -56,7 +49,7 @@ void nrd::InstanceImpl::Add_SigmaShadow(DenoiserData& denoiserData) PushOutput( AsUint(Transient::SMOOTHED_TILES) ); - AddDispatch( SIGMA_Shadow_SmoothTiles, SIGMA_SMOOTH_TILES_SET_CONSTANTS, SIGMA_SMOOTH_TILES_NUM_THREADS, 16 ); + AddDispatch( SIGMA_Shadow_SmoothTiles, SIGMA_SmoothTiles, 16 ); } PushPass("Blur"); @@ -70,7 +63,7 @@ void nrd::InstanceImpl::Add_SigmaShadow(DenoiserData& denoiserData) PushOutput( AsUint(Transient::TEMP_1) ); PushOutput( AsUint(Transient::HISTORY) ); - AddDispatch( SIGMA_Shadow_Blur, SIGMA_BLUR_SET_CONSTANTS, SIGMA_BLUR_NUM_THREADS, USE_MAX_DIMS ); + AddDispatch( SIGMA_Shadow_Blur, SIGMA_Blur, USE_MAX_DIMS ); } PushPass("Post-blur"); @@ -83,7 +76,7 @@ void nrd::InstanceImpl::Add_SigmaShadow(DenoiserData& denoiserData) PushOutput( AsUint(Transient::DATA_2) ); PushOutput( AsUint(Transient::TEMP_2) ); - AddDispatch( SIGMA_Shadow_PostBlur, SIGMA_BLUR_SET_CONSTANTS, SIGMA_BLUR_NUM_THREADS, 1 ); + AddDispatch( SIGMA_Shadow_PostBlur, SIGMA_Blur, 1 ); } PushPass("Temporal stabilization"); @@ -96,7 +89,7 @@ void nrd::InstanceImpl::Add_SigmaShadow(DenoiserData& denoiserData) PushOutput( AsUint(ResourceType::OUT_SHADOW_TRANSLUCENCY) ); - AddDispatch( SIGMA_Shadow_TemporalStabilization, SIGMA_TEMPORAL_STABILIZATION_SET_CONSTANTS, SIGMA_TEMPORAL_STABILIZATION_NUM_THREADS, 1 ); + AddDispatch( SIGMA_Shadow_TemporalStabilization, SIGMA_TemporalStabilization, 1 ); } PushPass("Split screen"); @@ -105,7 +98,7 @@ void nrd::InstanceImpl::Add_SigmaShadow(DenoiserData& denoiserData) PushOutput( AsUint(ResourceType::OUT_SHADOW_TRANSLUCENCY) ); - AddDispatch( SIGMA_Shadow_SplitScreen, SIGMA_SPLIT_SCREEN_SET_CONSTANTS, SIGMA_SPLIT_SCREEN_NUM_THREADS, 1 ); + AddDispatch( SIGMA_Shadow_SplitScreen, SIGMA_SplitScreen, 1 ); } #undef DENOISER_NAME diff --git a/Source/Denoisers/Sigma_ShadowTranslucency.hpp b/Source/Denoisers/Sigma_ShadowTranslucency.hpp index dd0432c..5cbe894 100644 --- a/Source/Denoisers/Sigma_ShadowTranslucency.hpp +++ b/Source/Denoisers/Sigma_ShadowTranslucency.hpp @@ -15,11 +15,6 @@ void nrd::InstanceImpl::Add_SigmaShadowTranslucency(nrd::DenoiserData& denoiserD denoiserData.settings.sigma = SigmaSettings(); denoiserData.settingsSize = sizeof(denoiserData.settings.sigma); - uint16_t w = denoiserData.desc.renderWidth; - uint16_t h = denoiserData.desc.renderHeight; - uint16_t tilesW = DivideUp(w, 16); - uint16_t tilesH = DivideUp(h, 16); - enum class Transient { DATA_1 = TRANSIENT_POOL_START, @@ -31,15 +26,13 @@ void nrd::InstanceImpl::Add_SigmaShadowTranslucency(nrd::DenoiserData& denoiserD SMOOTHED_TILES, }; - AddTextureToTransientPool( {Format::RG16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::RG16_SFLOAT, w, h, 1} ); - AddTextureToTransientPool( {Format::RGBA8_UNORM, w, h, 1} ); - AddTextureToTransientPool( {Format::RGBA8_UNORM, w, h, 1} ); - AddTextureToTransientPool( {Format::RGBA8_UNORM, w, h, 1} ); - AddTextureToTransientPool( {Format::RGBA8_UNORM, tilesW, tilesH, 1} ); - AddTextureToTransientPool( {Format::RG8_UNORM, tilesW, tilesH, 1} ); - - SIGMA_SET_SHARED_CONSTANTS; + AddTextureToTransientPool( {Format::RG16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::RG16_SFLOAT, 1} ); + AddTextureToTransientPool( {Format::RGBA8_UNORM, 1} ); + AddTextureToTransientPool( {Format::RGBA8_UNORM, 1} ); + AddTextureToTransientPool( {Format::RGBA8_UNORM, 1} ); + AddTextureToTransientPool( {Format::RGBA8_UNORM, 16} ); + AddTextureToTransientPool( {Format::RG8_UNORM, 16} ); PushPass("Classify tiles"); { @@ -48,7 +41,7 @@ void nrd::InstanceImpl::Add_SigmaShadowTranslucency(nrd::DenoiserData& denoiserD PushOutput( AsUint(Transient::TILES) ); - AddDispatch( SIGMA_ShadowTranslucency_ClassifyTiles, SIGMA_CLASSIFY_TILES_SET_CONSTANTS, SIGMA_CLASSIFY_TILES_NUM_THREADS, 16 ); + AddDispatch( SIGMA_ShadowTranslucency_ClassifyTiles, SIGMA_ClassifyTiles, 1 ); } PushPass("Smooth tiles"); @@ -57,7 +50,7 @@ void nrd::InstanceImpl::Add_SigmaShadowTranslucency(nrd::DenoiserData& denoiserD PushOutput( AsUint(Transient::SMOOTHED_TILES) ); - AddDispatch( SIGMA_Shadow_SmoothTiles, SIGMA_SMOOTH_TILES_SET_CONSTANTS, SIGMA_SMOOTH_TILES_NUM_THREADS, 16 ); + AddDispatch( SIGMA_Shadow_SmoothTiles, SIGMA_SmoothTiles, 16 ); } PushPass("Blur"); @@ -72,7 +65,7 @@ void nrd::InstanceImpl::Add_SigmaShadowTranslucency(nrd::DenoiserData& denoiserD PushOutput( AsUint(Transient::TEMP_1) ); PushOutput( AsUint(Transient::HISTORY) ); - AddDispatch( SIGMA_ShadowTranslucency_Blur, SIGMA_BLUR_SET_CONSTANTS, SIGMA_BLUR_NUM_THREADS, USE_MAX_DIMS ); + AddDispatch( SIGMA_ShadowTranslucency_Blur, SIGMA_Blur, USE_MAX_DIMS ); } PushPass("Post-blur"); @@ -85,7 +78,7 @@ void nrd::InstanceImpl::Add_SigmaShadowTranslucency(nrd::DenoiserData& denoiserD PushOutput( AsUint(Transient::DATA_2) ); PushOutput( AsUint(Transient::TEMP_2) ); - AddDispatch( SIGMA_ShadowTranslucency_PostBlur, SIGMA_BLUR_SET_CONSTANTS, SIGMA_BLUR_NUM_THREADS, 1 ); + AddDispatch( SIGMA_ShadowTranslucency_PostBlur, SIGMA_Blur, 1 ); } PushPass("Temporal stabilization"); @@ -98,7 +91,7 @@ void nrd::InstanceImpl::Add_SigmaShadowTranslucency(nrd::DenoiserData& denoiserD PushOutput( AsUint(ResourceType::OUT_SHADOW_TRANSLUCENCY) ); - AddDispatch( SIGMA_ShadowTranslucency_TemporalStabilization, SIGMA_TEMPORAL_STABILIZATION_SET_CONSTANTS, SIGMA_TEMPORAL_STABILIZATION_NUM_THREADS, 1 ); + AddDispatch( SIGMA_ShadowTranslucency_TemporalStabilization, SIGMA_TemporalStabilization, 1 ); } PushPass("Split screen"); @@ -108,7 +101,7 @@ void nrd::InstanceImpl::Add_SigmaShadowTranslucency(nrd::DenoiserData& denoiserD PushOutput( AsUint(ResourceType::OUT_SHADOW_TRANSLUCENCY) ); - AddDispatch( SIGMA_ShadowTranslucency_SplitScreen, SIGMA_SPLIT_SCREEN_SET_CONSTANTS, SIGMA_SPLIT_SCREEN_NUM_THREADS, 1 ); + AddDispatch( SIGMA_ShadowTranslucency_SplitScreen, SIGMA_SplitScreen, 1 ); } #undef DENOISER_NAME diff --git a/Source/Denoisers/SpecularDeltaMv.hpp b/Source/Denoisers/SpecularDeltaMv.hpp index 8735635..ee4921f 100644 --- a/Source/Denoisers/SpecularDeltaMv.hpp +++ b/Source/Denoisers/SpecularDeltaMv.hpp @@ -8,15 +8,14 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ +#include "../Shaders/Resources/SpecularDeltaMv_Compute.resources.hlsli" + void nrd::InstanceImpl::Add_SpecularDeltaMv(DenoiserData& denoiserData) { #define DENOISER_NAME SpecularDeltaMv denoiserData.settings.specularDeltaMv = SpecularDeltaMvSettings(); denoiserData.settingsSize = sizeof(denoiserData.settings.specularDeltaMv); - - uint16_t w = denoiserData.desc.renderWidth; - uint16_t h = denoiserData.desc.renderHeight; enum class Permanent { @@ -24,22 +23,20 @@ void nrd::InstanceImpl::Add_SpecularDeltaMv(DenoiserData& denoiserData) DELTA_SECONDARY_POS_PREV }; - AddTextureToPermanentPool( {Format::RGBA32_SFLOAT, w, h, 1} ); - AddTextureToPermanentPool( {Format::RGBA32_SFLOAT, w, h, 1} ); - - SetSharedConstants(0, 0, 0, 0); + AddTextureToPermanentPool( {Format::RGBA32_SFLOAT, 1} ); + AddTextureToPermanentPool( {Format::RGBA32_SFLOAT, 1} ); PushPass("Compute"); { PushInput( AsUint(ResourceType::IN_MV) ); PushInput( AsUint(ResourceType::IN_DELTA_PRIMARY_POS) ); PushInput( AsUint(ResourceType::IN_DELTA_SECONDARY_POS) ); - PushInput( AsUint(Permanent::DELTA_SECONDARY_POS_PREV), 0, 1, AsUint(Permanent::DELTA_SECONDARY_POS_CURR) ); + PushInput( AsUint(Permanent::DELTA_SECONDARY_POS_PREV), AsUint(Permanent::DELTA_SECONDARY_POS_CURR) ); PushOutput( AsUint(ResourceType::OUT_DELTA_MV) ); - PushOutput( AsUint(Permanent::DELTA_SECONDARY_POS_CURR), 0, 1, AsUint(Permanent::DELTA_SECONDARY_POS_PREV) ); + PushOutput( AsUint(Permanent::DELTA_SECONDARY_POS_CURR), AsUint(Permanent::DELTA_SECONDARY_POS_PREV) ); - AddDispatch( SpecularDeltaMv_Compute, SumConstants(1, 1, 3, 1), NumThreads(16, 16), 1 ); + AddDispatch( SpecularDeltaMv_Compute, SpecularDeltaMv_Compute, 1 ); } #undef DENOISER_NAME @@ -54,13 +51,13 @@ void nrd::InstanceImpl::Update_SpecularDeltaMv(const DenoiserData& denoiserData) NRD_DECLARE_DIMS; - // COMPUTE - Constant* data = PushDispatch(denoiserData, AsUint(Dispatch::COMPUTE)); - AddFloat4x4(data, m_WorldToClipPrev); - AddFloat4(data, ml::float4(m_CommonSettings.motionVectorScale[0], m_CommonSettings.motionVectorScale[1], m_CommonSettings.motionVectorScale[2], m_CommonSettings.debug)); - AddUint2(data, rectW, rectH); - AddFloat2(data, 1.0f / float(rectW), 1.0f / float(rectH)); - AddUint2(data, m_CommonSettings.inputSubrectOrigin[0], m_CommonSettings.inputSubrectOrigin[1]); - AddUint(data, m_CommonSettings.isMotionVectorInWorldSpace ? 1 : 0); - ValidateConstants(data); + { // COMPUTE + SpecularDeltaMv_ComputeConstants* consts = (SpecularDeltaMv_ComputeConstants*)PushDispatch(denoiserData, AsUint(Dispatch::COMPUTE)); + consts->gWorldToClipPrev = m_WorldToClipPrev; + consts->gMvScale = float4(m_CommonSettings.motionVectorScale[0], m_CommonSettings.motionVectorScale[1], m_CommonSettings.motionVectorScale[2], m_CommonSettings.isMotionVectorInWorldSpace ? 1.0f : 0.0f); + consts->gRectOrigin = uint2(m_CommonSettings.rectOrigin[0], m_CommonSettings.rectOrigin[1]); + consts->gRectSize = uint2(rectW, rectH); + consts->gRectSizeInv = float2(1.0f / float(rectW), 1.0f / float(rectH)); + consts->gDebug = m_CommonSettings.debug; + } } diff --git a/Source/Denoisers/SpecularReflectionMv.hpp b/Source/Denoisers/SpecularReflectionMv.hpp index 7f2ed24..002e690 100644 --- a/Source/Denoisers/SpecularReflectionMv.hpp +++ b/Source/Denoisers/SpecularReflectionMv.hpp @@ -8,14 +8,14 @@ distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited. */ +#include "../Shaders/Resources/SpecularReflectionMv_Compute.resources.hlsli" + void nrd::InstanceImpl::Add_SpecularReflectionMv(DenoiserData& denoiserData) { #define DENOISER_NAME SpecularReflectionMv denoiserData.settings.specularReflectionMv = SpecularReflectionMvSettings(); denoiserData.settingsSize = sizeof(denoiserData.settings.specularReflectionMv); - - SetSharedConstants(0, 0, 0, 0); PushPass("Compute"); { @@ -26,7 +26,7 @@ void nrd::InstanceImpl::Add_SpecularReflectionMv(DenoiserData& denoiserData) PushOutput( AsUint(ResourceType::OUT_REFLECTION_MV) ); - AddDispatch( SpecularReflectionMv_Compute, SumConstants(4, 5, 5, 2), NumThreads(16, 16), 1 ); + AddDispatch( SpecularReflectionMv_Compute, SpecularReflectionMv_Compute, 1 ); } #undef DENOISER_NAME @@ -41,26 +41,27 @@ void nrd::InstanceImpl::Update_SpecularReflectionMv(const DenoiserData& denoiser NRD_DECLARE_DIMS; - // DRS will increase reprojected values, needed for stability, compensated by blur radius adjustment float unproject = 1.0f / (0.5f * rectH * m_ProjectY); - // COMPUTE - Constant* data = PushDispatch(denoiserData, AsUint(Dispatch::COMPUTE)); - AddFloat4x4(data, m_ViewToWorld); - AddFloat4x4(data, m_WorldToClip); - AddFloat4x4(data, m_WorldToClipPrev); - AddFloat4x4(data, m_WorldToViewPrev); - AddFloat4(data, m_FrustumPrev); - AddFloat4(data, m_Frustum); - AddFloat4(data, ml::float4(m_ViewDirection.x, m_ViewDirection.y, m_ViewDirection.z, m_IsOrtho)); - AddFloat4(data, ml::float4(m_CameraDelta.x, m_CameraDelta.y, m_CameraDelta.z, unproject)); - AddFloat4(data, ml::float4(m_CommonSettings.motionVectorScale[0], m_CommonSettings.motionVectorScale[1], m_CommonSettings.motionVectorScale[2], m_CommonSettings.debug)); - AddFloat2(data, float(rectW), float(rectH)); - AddFloat2(data, 1.0f / float(rectW), 1.0f / float(rectH)); - AddFloat2(data, float(m_CommonSettings.inputSubrectOrigin[0]) / float(screenW), float(m_CommonSettings.inputSubrectOrigin[1]) / float(screenH)); - AddFloat2(data, float(rectW) / float(screenW), float(rectH) / float(screenH)); - AddUint2(data, m_CommonSettings.inputSubrectOrigin[0], m_CommonSettings.inputSubrectOrigin[1]); - AddFloat(data, m_CommonSettings.denoisingRange); - AddUint(data, m_CommonSettings.isMotionVectorInWorldSpace ? 1 : 0); - ValidateConstants(data); + { // COMPUTE + SpecularReflectionMv_ComputeConstants* consts = (SpecularReflectionMv_ComputeConstants*)PushDispatch(denoiserData, AsUint(Dispatch::COMPUTE)); + consts->gViewToWorld = m_ViewToWorld; + consts->gWorldToClip = m_WorldToClip; + consts->gWorldToClipPrev = m_WorldToClipPrev; + consts->gWorldToViewPrev = m_WorldToViewPrev; + consts->gFrustumPrev = m_FrustumPrev; + consts->gFrustum = m_Frustum; + consts->gViewVectorWorld = float4(m_ViewDirection.x, m_ViewDirection.y, m_ViewDirection.z, 0.0f); + consts->gCameraDelta = float4(m_CameraDelta.x, m_CameraDelta.y, m_CameraDelta.z, 0.0f); + consts->gMvScale = float4(m_CommonSettings.motionVectorScale[0], m_CommonSettings.motionVectorScale[1], m_CommonSettings.motionVectorScale[2], m_CommonSettings.isMotionVectorInWorldSpace ? 1.0f : 0.0f); + consts->gRectSize = float2(float(rectW), float(rectH)); + consts->gRectSizeInv = float2(1.0f / float(rectW), 1.0f / float(rectH)); + consts->gRectOffset = float2(float(m_CommonSettings.rectOrigin[0]) / float(resourceW), float(m_CommonSettings.rectOrigin[1]) / float(resourceH)); + consts->gResolutionScale = float2(float(rectW) / float(resourceW), float(rectH) / float(resourceH)); + consts->gRectOrigin = uint2(m_CommonSettings.rectOrigin[0], m_CommonSettings.rectOrigin[1]); + consts->gDenoisingRange = m_CommonSettings.denoisingRange; + consts->gOrthoMode = m_OrthoMode; + consts->gUnproject = unproject; + consts->gDebug = m_CommonSettings.debug; + } } diff --git a/Source/InstanceImpl.cpp b/Source/InstanceImpl.cpp index 959dfb6..7b00d1f 100644 --- a/Source/InstanceImpl.cpp +++ b/Source/InstanceImpl.cpp @@ -16,9 +16,7 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. constexpr std::array g_Samplers = { nrd::Sampler::NEAREST_CLAMP, - nrd::Sampler::NEAREST_MIRRORED_REPEAT, nrd::Sampler::LINEAR_CLAMP, - nrd::Sampler::LINEAR_MIRRORED_REPEAT, }; constexpr std::array g_IsIntegerFormat = @@ -69,19 +67,22 @@ constexpr std::array g_IsIntegerFormat = false, // R9_G9_B9_E5_UFLOAT }; +#include "../Shaders/Resources/Clear_Float.resources.hlsli" +#include "../Shaders/Resources/Clear_Uint.resources.hlsli" + #ifdef NRD_EMBEDS_DXBC_SHADERS - #include "Clear_f.cs.dxbc.h" - #include "Clear_ui.cs.dxbc.h" + #include "Clear_Float.cs.dxbc.h" + #include "Clear_Uint.cs.dxbc.h" #endif #ifdef NRD_EMBEDS_DXIL_SHADERS - #include "Clear_f.cs.dxil.h" - #include "Clear_ui.cs.dxil.h" + #include "Clear_Float.cs.dxil.h" + #include "Clear_Uint.cs.dxil.h" #endif #ifdef NRD_EMBEDS_SPIRV_SHADERS - #include "Clear_f.cs.spirv.h" - #include "Clear_ui.cs.spirv.h" + #include "Clear_Float.cs.spirv.h" + #include "Clear_Uint.cs.spirv.h" #endif inline bool IsInList(nrd::Identifier identifier, const nrd::Identifier* identifiers, uint32_t identifiersNum) @@ -181,6 +182,13 @@ nrd::Result nrd::InstanceImpl::Create(const InstanceCreationDesc& instanceCreati denoiserData.pingPongNum = m_PingPongs.size() - denoiserData.pingPongOffset; + // Patch identifiers + for (size_t dispatchIndex = denoiserData.dispatchOffset; dispatchIndex < m_Dispatches.size(); dispatchIndex++) + { + InternalDispatchDesc& internalDispatchDesc = m_Dispatches[dispatchIndex]; + internalDispatchDesc.identifier = denoiserDesc.identifier; + } + // Gather resources, which need to be cleared for (size_t resourceIndex = resourceOffset; resourceIndex < m_Resources.size(); resourceIndex++) { @@ -190,43 +198,37 @@ nrd::Result nrd::InstanceImpl::Create(const InstanceCreationDesc& instanceCreati if (resource.stateNeeded != DescriptorType::STORAGE_TEXTURE) continue; + // Skip "OUT_VALIDATION" resource because it can be not provided + if (resource.type == ResourceType::OUT_VALIDATION) + continue; + // Keep only unique instances bool isFound = false; for (const ClearResource& temp : m_ClearResources) { if (temp.resource.stateNeeded == resource.stateNeeded && temp.resource.type == resource.type && - temp.resource.indexInPool == resource.indexInPool && - temp.resource.mipOffset == resource.mipOffset && - temp.resource.mipNum == resource.mipNum) + temp.resource.indexInPool == resource.indexInPool) { isFound = true; break; } } - // Skip "OUT_VALIDATION" resource because it can be not provided - if (resource.type == ResourceType::OUT_VALIDATION) - isFound = true; - if (!isFound) { - // Texture props - uint32_t w = denoiserDesc.renderWidth; - uint32_t h = denoiserDesc.renderHeight; + // Is integer? bool isInteger = false; - + uint16_t downsampleFactor = 1; if (resource.type == ResourceType::PERMANENT_POOL || resource.type == ResourceType::TRANSIENT_POOL) { TextureDesc& textureDesc = resource.type == ResourceType::PERMANENT_POOL ? m_PermanentPool[resource.indexInPool] : m_TransientPool[resource.indexInPool]; - - w = textureDesc.width >> resource.mipOffset; - h = textureDesc.height >> resource.mipOffset; isInteger = g_IsIntegerFormat[(size_t)textureDesc.format]; + downsampleFactor = textureDesc.downsampleFactor; } // Add PING resource - m_ClearResources.push_back( {denoiserDesc.identifier, resource, w, h, isInteger} ); + m_ClearResources.push_back( {denoiserDesc.identifier, resource, downsampleFactor, isInteger} ); // Add PONG resource for (uint32_t p = 0; p < denoiserData.pingPongNum; p++) @@ -234,8 +236,8 @@ nrd::Result nrd::InstanceImpl::Create(const InstanceCreationDesc& instanceCreati const PingPong& pingPong = m_PingPongs[denoiserData.pingPongOffset + p]; if (pingPong.resourceIndex == (uint32_t)resourceIndex) { - ResourceDesc resourcePong = {resource.stateNeeded, resource.type, pingPong.indexInPoolToSwapWith, resource.mipOffset, resource.mipNum}; - m_ClearResources.push_back( {denoiserDesc.identifier, resourcePong, w, h, isInteger} ); + ResourceDesc resourcePong = {resource.stateNeeded, resource.type, pingPong.indexInPoolToSwapWith}; + m_ClearResources.push_back( {denoiserDesc.identifier, resourcePong, downsampleFactor, isInteger} ); break; } } @@ -249,15 +251,15 @@ nrd::Result nrd::InstanceImpl::Create(const InstanceCreationDesc& instanceCreati m_DispatchClearIndex[0] = m_Dispatches.size(); _PushPass("Clear (f)"); { - PushOutput(0, 0, 1); - AddDispatch( Clear_f, 0, NumThreads(16, 16), 1 ); + PushOutput(0); + AddDispatchNoConstants( Clear_Float, Clear_Float, 1 ); } m_DispatchClearIndex[1] = m_Dispatches.size(); _PushPass("Clear (ui)"); { - PushOutput(0, 0, 1); - AddDispatch( Clear_ui, 0, NumThreads(16, 16), 1 ); + PushOutput(0); + AddDispatchNoConstants( Clear_Uint, Clear_Uint, 1 ); } PrepareDesc(); @@ -269,65 +271,76 @@ nrd::Result nrd::InstanceImpl::Create(const InstanceCreationDesc& instanceCreati nrd::Result nrd::InstanceImpl::SetCommonSettings(const CommonSettings& commonSettings) { - // TODO: add a lot of verifications of fields in CommonSettings + // TODO: matrix verifications? return INVALID_ARGUMENT? + assert("'resourceSize' can't be 0" && commonSettings.resourceSize[0] != 0 && commonSettings.resourceSize[1] != 0); + assert("'resourceSizePrev' can't be 0" && commonSettings.resourceSizePrev[0] != 0 && commonSettings.resourceSizePrev[1] != 0); + assert("'rectSize' can't be 0" && commonSettings.rectSize[0] != 0 && commonSettings.rectSize[1] != 0); + assert("'rectSizePrev' can't be 0" && commonSettings.rectSizePrev[0] != 0 && commonSettings.rectSizePrev[1] != 0); + assert("'mvScale.xy' can't be 0" && ((commonSettings.motionVectorScale[0] != 0.0f && commonSettings.motionVectorScale[1] != 0.0f) || commonSettings.isMotionVectorInWorldSpace)); + assert("'cameraJitter' must be in range [-0.5; 0.5]" && commonSettings.cameraJitter[0] >= -0.5f && commonSettings.cameraJitter[0] <= 0.5f && commonSettings.cameraJitter[1] >= -0.5f && commonSettings.cameraJitter[1] <= 0.5f); + assert("'cameraJitterPrev' must be in range [-0.5; 0.5]" && commonSettings.cameraJitterPrev[0] >= -0.5f && commonSettings.cameraJitterPrev[0] <= 0.5f && commonSettings.cameraJitterPrev[1] >= -0.5f && commonSettings.cameraJitterPrev[1] <= 0.5f); + assert("'denoisingRange' must be >= 0" && commonSettings.denoisingRange > 0.0f); + assert("'disocclusionThreshold' must be > 0" && commonSettings.disocclusionThreshold > 0.0f); + assert("'disocclusionThresholdAlternate' must be > 0" && commonSettings.disocclusionThresholdAlternate > 0.0f); + memcpy(&m_CommonSettings, &commonSettings, sizeof(commonSettings)); // Rotators - ml::float4 rndScale = ml::float4(1.0f) + ml::Rand::sf4(&m_FastRandState) * 0.25f; - ml::float4 rndAngle = ml::Rand::uf4(&m_FastRandState) * ml::DegToRad(360.0f); - rndAngle.w = ml::DegToRad( 120.0f * float(m_CommonSettings.frameIndex % 3) ); + float4 rndScale = float4(1.0f) + Rand::sf4(&m_FastRandState) * 0.25f; + float4 rndAngle = Rand::uf4(&m_FastRandState) * DegToRad(360.0f); + rndAngle.w = DegToRad( 120.0f * float(m_CommonSettings.frameIndex % 3) ); - float ca = ml::Cos( rndAngle.x ); - float sa = ml::Sin( rndAngle.x ); - m_Rotator_PrePass = ml::float4( ca, sa, -sa, ca ) * rndScale.x; + float ca = Cos( rndAngle.x ); + float sa = Sin( rndAngle.x ); + m_Rotator_PrePass = float4( ca, sa, -sa, ca ) * rndScale.x; - ca = ml::Cos( rndAngle.y ); - sa = ml::Sin( rndAngle.y ); - m_Rotator_Blur = ml::float4( ca, sa, -sa, ca ) * rndScale.y; + ca = Cos( rndAngle.y ); + sa = Sin( rndAngle.y ); + m_Rotator_Blur = float4( ca, sa, -sa, ca ) * rndScale.y; - ca = ml::Cos( rndAngle.z ); - sa = ml::Sin( rndAngle.z ); - m_Rotator_PostBlur = ml::float4( ca, sa, -sa, ca ) * rndScale.z; + ca = Cos( rndAngle.z ); + sa = Sin( rndAngle.z ); + m_Rotator_PostBlur = float4( ca, sa, -sa, ca ) * rndScale.z; // Main matrices - m_ViewToClip = ml::float4x4 + m_ViewToClip = float4x4 ( - ml::float4(m_CommonSettings.viewToClipMatrix), - ml::float4(m_CommonSettings.viewToClipMatrix + 4), - ml::float4(m_CommonSettings.viewToClipMatrix + 8), - ml::float4(m_CommonSettings.viewToClipMatrix + 12) + float4(m_CommonSettings.viewToClipMatrix), + float4(m_CommonSettings.viewToClipMatrix + 4), + float4(m_CommonSettings.viewToClipMatrix + 8), + float4(m_CommonSettings.viewToClipMatrix + 12) ); - m_ViewToClipPrev = ml::float4x4 + m_ViewToClipPrev = float4x4 ( - ml::float4(m_CommonSettings.viewToClipMatrixPrev), - ml::float4(m_CommonSettings.viewToClipMatrixPrev + 4), - ml::float4(m_CommonSettings.viewToClipMatrixPrev + 8), - ml::float4(m_CommonSettings.viewToClipMatrixPrev + 12) + float4(m_CommonSettings.viewToClipMatrixPrev), + float4(m_CommonSettings.viewToClipMatrixPrev + 4), + float4(m_CommonSettings.viewToClipMatrixPrev + 8), + float4(m_CommonSettings.viewToClipMatrixPrev + 12) ); - m_WorldToView = ml::float4x4 + m_WorldToView = float4x4 ( - ml::float4(m_CommonSettings.worldToViewMatrix), - ml::float4(m_CommonSettings.worldToViewMatrix + 4), - ml::float4(m_CommonSettings.worldToViewMatrix + 8), - ml::float4(m_CommonSettings.worldToViewMatrix + 12) + float4(m_CommonSettings.worldToViewMatrix), + float4(m_CommonSettings.worldToViewMatrix + 4), + float4(m_CommonSettings.worldToViewMatrix + 8), + float4(m_CommonSettings.worldToViewMatrix + 12) ); - m_WorldToViewPrev = ml::float4x4 + m_WorldToViewPrev = float4x4 ( - ml::float4(m_CommonSettings.worldToViewMatrixPrev), - ml::float4(m_CommonSettings.worldToViewMatrixPrev + 4), - ml::float4(m_CommonSettings.worldToViewMatrixPrev + 8), - ml::float4(m_CommonSettings.worldToViewMatrixPrev + 12) + float4(m_CommonSettings.worldToViewMatrixPrev), + float4(m_CommonSettings.worldToViewMatrixPrev + 4), + float4(m_CommonSettings.worldToViewMatrixPrev + 8), + float4(m_CommonSettings.worldToViewMatrixPrev + 12) ); - m_WorldPrevToWorld = ml::float4x4 + m_WorldPrevToWorld = float4x4 ( - ml::float4(m_CommonSettings.worldPrevToWorldMatrix), - ml::float4(m_CommonSettings.worldPrevToWorldMatrix + 4), - ml::float4(m_CommonSettings.worldPrevToWorldMatrix + 8), - ml::float4(m_CommonSettings.worldPrevToWorldMatrix + 12) + float4(m_CommonSettings.worldPrevToWorldMatrix), + float4(m_CommonSettings.worldPrevToWorldMatrix + 4), + float4(m_CommonSettings.worldPrevToWorldMatrix + 8), + float4(m_CommonSettings.worldPrevToWorldMatrix + 12) ); // There are many cases, where history buffers contain garbage - handle at least one of them internally @@ -341,9 +354,9 @@ nrd::Result nrd::InstanceImpl::SetCommonSettings(const CommonSettings& commonSet // Convert to LH uint32_t flags = 0; - ml::DecomposeProjection(NDC_D3D, NDC_D3D, m_ViewToClip, &flags, nullptr, nullptr, m_Frustum.pv, nullptr, nullptr); + DecomposeProjection(STYLE_D3D, STYLE_D3D, m_ViewToClip, &flags, nullptr, nullptr, m_Frustum.pv, nullptr, nullptr); - if ( !(flags & ml::PROJ_LEFT_HANDED) ) + if ( !(flags & PROJ_LEFT_HANDED) ) { m_ViewToClip.col2 = (-m_ViewToClip.GetCol2()).xmm; m_ViewToClipPrev.col2 = (-m_ViewToClipPrev.GetCol2()).xmm; @@ -364,12 +377,12 @@ nrd::Result nrd::InstanceImpl::SetCommonSettings(const CommonSettings& commonSet m_ViewToWorldPrev = m_WorldToViewPrev; m_ViewToWorldPrev.InvertOrtho(); - const ml::float3& cameraPosition = m_ViewToWorld.GetCol3().To3d(); - const ml::float3& cameraPositionPrev = m_ViewToWorldPrev.GetCol3().To3d(); - ml::float3 translationDelta = cameraPositionPrev - cameraPosition; + const float3& cameraPosition = m_ViewToWorld.GetCol3().To3d(); + const float3& cameraPositionPrev = m_ViewToWorldPrev.GetCol3().To3d(); + float3 translationDelta = cameraPositionPrev - cameraPosition; // IMPORTANT: this part is mandatory needed to preserve precision by making matrices camera relative - m_ViewToWorld.SetTranslation( ml::float3::Zero() ); + m_ViewToWorld.SetTranslation( float3::Zero() ); m_WorldToView = m_ViewToWorld; m_WorldToView.InvertOrtho(); @@ -393,38 +406,38 @@ nrd::Result nrd::InstanceImpl::SetCommonSettings(const CommonSettings& commonSet m_ClipToWorld.Invert(); float project[3]; - float settings[ml::PROJ_NUM]; - ml::DecomposeProjection(NDC_D3D, NDC_D3D, m_ViewToClip, &flags, settings, nullptr, m_Frustum.pv, project, nullptr); + float settings[PROJ_NUM]; + DecomposeProjection(STYLE_D3D, STYLE_D3D, m_ViewToClip, &flags, settings, nullptr, m_Frustum.pv, project, nullptr); m_ProjectY = project[1]; - m_IsOrtho = (flags & ml::PROJ_ORTHO) ? -1.0f : 0.0f; + m_OrthoMode = (flags & PROJ_ORTHO) ? -1.0f : 0.0f; - ml::DecomposeProjection(NDC_D3D, NDC_D3D, m_ViewToClipPrev, &flags, nullptr, nullptr, m_FrustumPrev.pv, nullptr, nullptr); + DecomposeProjection(STYLE_D3D, STYLE_D3D, m_ViewToClipPrev, &flags, nullptr, nullptr, m_FrustumPrev.pv, nullptr, nullptr); - m_ViewDirection = -ml::float3(m_ViewToWorld.GetCol2().xmm); - m_ViewDirectionPrev = -ml::float3(m_ViewToWorldPrev.GetCol2().xmm); + m_ViewDirection = -float3(m_ViewToWorld.GetCol2().xmm); + m_ViewDirectionPrev = -float3(m_ViewToWorldPrev.GetCol2().xmm); - m_CameraDelta = ml::float3(translationDelta.x, translationDelta.y, translationDelta.z); + m_CameraDelta = float3(translationDelta.x, translationDelta.y, translationDelta.z); m_Timer.UpdateElapsedTimeSinceLastSave(); m_Timer.SaveCurrentTime(); m_TimeDelta = m_CommonSettings.timeDeltaBetweenFrames > 0.0f ? m_CommonSettings.timeDeltaBetweenFrames : m_Timer.GetSmoothedElapsedTime(); - m_FrameRateScale = ml::Max(33.333f / m_TimeDelta, 1.0f); + m_FrameRateScale = Max(33.333f / m_TimeDelta, 1.0f); - float dx = ml::Abs(m_CommonSettings.cameraJitter[0] - m_CommonSettings.cameraJitterPrev[0]); - float dy = ml::Abs(m_CommonSettings.cameraJitter[1] - m_CommonSettings.cameraJitterPrev[1]); - m_JitterDelta = ml::Max(dx, dy); + float dx = Abs(m_CommonSettings.cameraJitter[0] - m_CommonSettings.cameraJitterPrev[0]); + float dy = Abs(m_CommonSettings.cameraJitter[1] - m_CommonSettings.cameraJitterPrev[1]); + m_JitterDelta = Max(dx, dy); float FPS = m_FrameRateScale * 30.0f; float nonLinearAccumSpeed = FPS * 0.25f / (1.0f + FPS * 0.25f); - m_CheckerboardResolveAccumSpeed = ml::Lerp(nonLinearAccumSpeed, 0.5f, m_JitterDelta); + m_CheckerboardResolveAccumSpeed = Lerp(nonLinearAccumSpeed, 0.5f, m_JitterDelta); return Result::SUCCESS; } nrd::Result nrd::InstanceImpl::SetDenoiserSettings(Identifier identifier, const void* denoiserSettings) { - for( DenoiserData& denoiserData : m_DenoiserData ) + for (DenoiserData& denoiserData : m_DenoiserData) { if (denoiserData.desc.identifier == identifier) { @@ -439,6 +452,7 @@ nrd::Result nrd::InstanceImpl::SetDenoiserSettings(Identifier identifier, const nrd::Result nrd::InstanceImpl::GetComputeDispatches(const Identifier* identifiers, uint32_t identifiersNum, const DispatchDesc*& dispatchDescs, uint32_t& dispatchDescsNum) { + m_ConstantDataOffset = 0; m_ActiveDispatches.clear(); // Trivial checks @@ -462,13 +476,17 @@ nrd::Result nrd::InstanceImpl::GetComputeDispatches(const Identifier* identifier // Add a clear dispatch const InternalDispatchDesc& internalDispatchDesc = m_Dispatches[ m_DispatchClearIndex[clearResource.isInteger ? 1 : 0] ]; + uint16_t w = DivideUp(m_CommonSettings.resourceSize[0], clearResource.downsampleFactor); + uint16_t h = DivideUp(m_CommonSettings.resourceSize[1], clearResource.downsampleFactor); + DispatchDesc dispatchDesc = {}; - dispatchDesc.resourcesNum = 1; dispatchDesc.name = internalDispatchDesc.name; + dispatchDesc.identifier = clearResource.identifier; dispatchDesc.resources = &clearResource.resource; + dispatchDesc.resourcesNum = 1; dispatchDesc.pipelineIndex = internalDispatchDesc.pipelineIndex; - dispatchDesc.gridWidth = DivideUp(clearResource.w, internalDispatchDesc.numThreads.width); - dispatchDesc.gridHeight = DivideUp(clearResource.h, internalDispatchDesc.numThreads.height); + dispatchDesc.gridWidth = DivideUp(w, internalDispatchDesc.numThreads.width); + dispatchDesc.gridHeight = DivideUp(h, internalDispatchDesc.numThreads.height); m_ActiveDispatches.push_back(dispatchDesc); } @@ -484,29 +502,21 @@ nrd::Result nrd::InstanceImpl::GetComputeDispatches(const Identifier* identifier // Update denoiser and gather dispatches UpdatePingPong(denoiserData); - if( denoiserData.desc.denoiser == Denoiser::REBLUR_DIFFUSE || denoiserData.desc.denoiser == Denoiser::REBLUR_DIFFUSE_SH || + if (denoiserData.desc.denoiser == Denoiser::REBLUR_DIFFUSE || denoiserData.desc.denoiser == Denoiser::REBLUR_DIFFUSE_SH || denoiserData.desc.denoiser == Denoiser::REBLUR_SPECULAR || denoiserData.desc.denoiser == Denoiser::REBLUR_SPECULAR_SH || denoiserData.desc.denoiser == Denoiser::REBLUR_DIFFUSE_SPECULAR || denoiserData.desc.denoiser == Denoiser::REBLUR_DIFFUSE_SPECULAR_SH || - denoiserData.desc.denoiser == Denoiser::REBLUR_DIFFUSE_DIRECTIONAL_OCCLUSION ) + denoiserData.desc.denoiser == Denoiser::REBLUR_DIFFUSE_DIRECTIONAL_OCCLUSION) Update_Reblur(denoiserData); else if (denoiserData.desc.denoiser == Denoiser::REBLUR_DIFFUSE_OCCLUSION || denoiserData.desc.denoiser == Denoiser::REBLUR_SPECULAR_OCCLUSION || - denoiserData.desc.denoiser == Denoiser::REBLUR_DIFFUSE_SPECULAR_OCCLUSION ) + denoiserData.desc.denoiser == Denoiser::REBLUR_DIFFUSE_SPECULAR_OCCLUSION) Update_ReblurOcclusion(denoiserData); else if (denoiserData.desc.denoiser == Denoiser::SIGMA_SHADOW || denoiserData.desc.denoiser == Denoiser::SIGMA_SHADOW_TRANSLUCENCY) Update_SigmaShadow(denoiserData); - else if (denoiserData.desc.denoiser == Denoiser::RELAX_DIFFUSE) - Update_RelaxDiffuse(denoiserData); - else if (denoiserData.desc.denoiser == Denoiser::RELAX_DIFFUSE_SH) - Update_RelaxDiffuseSh(denoiserData); - else if (denoiserData.desc.denoiser == Denoiser::RELAX_SPECULAR) - Update_RelaxSpecular(denoiserData); - else if (denoiserData.desc.denoiser == Denoiser::RELAX_SPECULAR_SH) - Update_RelaxSpecularSh(denoiserData); - else if (denoiserData.desc.denoiser == Denoiser::RELAX_DIFFUSE_SPECULAR) - Update_RelaxDiffuseSpecular(denoiserData); - else if (denoiserData.desc.denoiser == Denoiser::RELAX_DIFFUSE_SPECULAR_SH) - Update_RelaxDiffuseSpecularSh(denoiserData); + else if (denoiserData.desc.denoiser == Denoiser::RELAX_DIFFUSE || denoiserData.desc.denoiser == Denoiser::RELAX_DIFFUSE_SH || + denoiserData.desc.denoiser == Denoiser::RELAX_SPECULAR || denoiserData.desc.denoiser == Denoiser::RELAX_SPECULAR_SH || + denoiserData.desc.denoiser == Denoiser::RELAX_DIFFUSE_SPECULAR || denoiserData.desc.denoiser == Denoiser::RELAX_DIFFUSE_SPECULAR_SH) + Update_Relax(denoiserData); else if (denoiserData.desc.denoiser == Denoiser::REFERENCE) Update_Reference(denoiserData); else if (denoiserData.desc.denoiser == Denoiser::SPECULAR_REFLECTION_MV) @@ -594,7 +604,7 @@ void nrd::InstanceImpl::PrepareDesc() { m_Desc = {}; - m_Desc.constantBufferRegisterIndex = 0; + m_Desc.constantBufferRegisterIndex = NRD_CONSTANT_BUFFER_REGISTER_INDEX; m_Desc.constantBufferSpaceIndex = NRD_CONSTANT_BUFFER_SPACE_INDEX; m_Desc.samplers = g_Samplers.data(); @@ -675,11 +685,11 @@ void nrd::InstanceImpl::UpdatePingPong(const DenoiserData& denoiserData) PingPong& pingPong = m_PingPongs[denoiserData.pingPongOffset + i]; ResourceDesc& resource = m_Resources[pingPong.resourceIndex]; - ml::Swap(resource.indexInPool, pingPong.indexInPoolToSwapWith); + Swap(resource.indexInPool, pingPong.indexInPoolToSwapWith); } } -void nrd::InstanceImpl::PushTexture(DescriptorType descriptorType, uint16_t localIndex, uint16_t mipOffset, uint16_t mipNum, uint16_t indexToSwapWith) +void nrd::InstanceImpl::PushTexture(DescriptorType descriptorType, uint16_t localIndex, uint16_t indexToSwapWith) { ResourceType resourceType = (ResourceType)localIndex; uint16_t globalIndex = 0; @@ -711,7 +721,7 @@ void nrd::InstanceImpl::PushTexture(DescriptorType descriptorType, uint16_t loca } } - m_Resources.push_back( {descriptorType, resourceType, globalIndex, mipOffset, mipNum} ); + m_Resources.push_back( {descriptorType, resourceType, globalIndex} ); } void nrd::InstanceImpl::AddTextureToTransientPool(const TextureDesc& textureDesc) @@ -721,7 +731,7 @@ void nrd::InstanceImpl::AddTextureToTransientPool(const TextureDesc& textureDesc { // Format and dimensions must match const TextureDesc& t = m_TransientPool[i]; - if (t.format == textureDesc.format && t.width == textureDesc.width && t.height == textureDesc.height && t.mipNum == textureDesc.mipNum) + if (t.format == textureDesc.format && t.downsampleFactor == textureDesc.downsampleFactor) { // The candidate must not be already in use in the current denoiser size_t j = 0; @@ -746,7 +756,7 @@ void nrd::InstanceImpl::AddTextureToTransientPool(const TextureDesc& textureDesc m_TransientPool.push_back(textureDesc); } -nrd::Constant* nrd::InstanceImpl::PushDispatch(const DenoiserData& denoiserData, uint32_t localIndex) +void* nrd::InstanceImpl::PushDispatch(const DenoiserData& denoiserData, uint32_t localIndex) { size_t dispatchIndex = denoiserData.dispatchOffset + localIndex; const InternalDispatchDesc& internalDispatchDesc = m_Dispatches[dispatchIndex]; @@ -754,31 +764,54 @@ nrd::Constant* nrd::InstanceImpl::PushDispatch(const DenoiserData& denoiserData, // Copy data DispatchDesc dispatchDesc = {}; dispatchDesc.name = internalDispatchDesc.name; + dispatchDesc.identifier = internalDispatchDesc.identifier; dispatchDesc.resources = internalDispatchDesc.resources; dispatchDesc.resourcesNum = internalDispatchDesc.resourcesNum; dispatchDesc.pipelineIndex = internalDispatchDesc.pipelineIndex; // Update constant data if (m_ConstantDataOffset + internalDispatchDesc.constantBufferDataSize > CONSTANT_DATA_SIZE) - m_ConstantDataOffset = 0; - dispatchDesc.constantBufferData = m_ConstantData + m_ConstantDataOffset; + { + assert("Constant data doesn't fit into the prealocated array!" && false); + dispatchDesc.constantBufferData = nullptr; // TODO: better crash + } + else + dispatchDesc.constantBufferData = m_ConstantData + m_ConstantDataOffset; + dispatchDesc.constantBufferDataSize = internalDispatchDesc.constantBufferDataSize; m_ConstantDataOffset += internalDispatchDesc.constantBufferDataSize; + dispatchDesc.constantBufferDataMatchesPreviousDispatch = false; + if (!m_ActiveDispatches.empty()) + { + const DispatchDesc& dispatchDescPrev = m_ActiveDispatches.back(); + if (dispatchDescPrev.constantBufferDataSize == dispatchDesc.constantBufferDataSize) + { + if (!memcmp(dispatchDescPrev.constantBufferData, dispatchDesc.constantBufferData, dispatchDesc.constantBufferDataSize)) + dispatchDesc.constantBufferDataMatchesPreviousDispatch = true; + } + } + // Update grid size - float sx = ml::Max(internalDispatchDesc.downsampleFactor == USE_MAX_DIMS ? m_CommonSettings.resolutionScalePrev[0] : 0.0f, m_CommonSettings.resolutionScale[0]); - float sy = ml::Max(internalDispatchDesc.downsampleFactor == USE_MAX_DIMS ? m_CommonSettings.resolutionScalePrev[1] : 0.0f, m_CommonSettings.resolutionScale[1]); - uint16_t d = internalDispatchDesc.downsampleFactor == USE_MAX_DIMS ? 1 : internalDispatchDesc.downsampleFactor; + uint16_t w = m_CommonSettings.rectSize[0]; + uint16_t h = m_CommonSettings.rectSize[1]; + uint16_t d = internalDispatchDesc.downsampleFactor; - if (internalDispatchDesc.downsampleFactor == IGNORE_RS) + if (d == USE_MAX_DIMS) + { + w = Max(w, m_CommonSettings.rectSizePrev[0]); + h = Max(h, m_CommonSettings.rectSizePrev[1]); + d = 1; + } + else if (d == IGNORE_RS) { - sx = 1.0f; - sy = 1.0f; + w = m_CommonSettings.resourceSize[0]; + h = m_CommonSettings.resourceSize[1]; d = 1; } - uint16_t w = uint16_t( float(DivideUp(denoiserData.desc.renderWidth, d)) * sx + 0.5f ); - uint16_t h = uint16_t( float(DivideUp(denoiserData.desc.renderHeight, d)) * sy + 0.5f ); + w = DivideUp(w, d); + h = DivideUp(h, d); dispatchDesc.gridWidth = DivideUp(w, internalDispatchDesc.numThreads.width); dispatchDesc.gridHeight = DivideUp(h, internalDispatchDesc.numThreads.height); @@ -786,5 +819,5 @@ nrd::Constant* nrd::InstanceImpl::PushDispatch(const DenoiserData& denoiserData, // Store m_ActiveDispatches.push_back(dispatchDesc); - return (Constant*)dispatchDesc.constantBufferData; + return (void*)dispatchDesc.constantBufferData; } diff --git a/Source/InstanceImpl.h b/Source/InstanceImpl.h index 19bfac8..07e4f19 100644 --- a/Source/InstanceImpl.h +++ b/Source/InstanceImpl.h @@ -11,14 +11,13 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #pragma once #include "NRD.h" - -#define MATH_NAMESPACE #include "MathLib/MathLib.h" typedef nrd::MemoryAllocatorInterface MemoryAllocatorInterface; #include "StdAllocator.h" #include "Timer.h" +#include #define _NRD_STRINGIFY(s) #s #define NRD_STRINGIFY(s) _NRD_STRINGIFY(s) @@ -41,29 +40,64 @@ typedef nrd::MemoryAllocatorInterface MemoryAllocatorInterface; #define GET_SPIRV_SHADER_DESC(shaderName) {} #endif -#define AddDispatch(shaderName, constantNum, numThreads, downsampleFactor) \ - AddComputeDispatchDesc(numThreads, downsampleFactor, constantNum, 1, #shaderName ".cs", GET_DXBC_SHADER_DESC(shaderName), GET_DXIL_SHADER_DESC(shaderName), GET_SPIRV_SHADER_DESC(shaderName)) +#define AddDispatch(shaderName, passName, downsampleFactor) \ + AddComputeDispatchDesc(NumThreads(passName ## GroupX, passName ## GroupY), \ + downsampleFactor, sizeof(passName ## Constants), 1, #shaderName ".cs", \ + GET_DXBC_SHADER_DESC(shaderName), GET_DXIL_SHADER_DESC(shaderName), GET_SPIRV_SHADER_DESC(shaderName)) + +#define AddDispatchNoConstants(shaderName, passName, downsampleFactor) \ + AddComputeDispatchDesc(NumThreads(passName ## GroupX, passName ## GroupY), \ + downsampleFactor, 0, 1, #shaderName ".cs", \ + GET_DXBC_SHADER_DESC(shaderName), GET_DXIL_SHADER_DESC(shaderName), GET_SPIRV_SHADER_DESC(shaderName)) -#define AddDispatchRepeated(shaderName, constantNum, numThreads, downsampleFactor, repeatNum) \ - AddComputeDispatchDesc(numThreads, downsampleFactor, constantNum, repeatNum, #shaderName ".cs", GET_DXBC_SHADER_DESC(shaderName), GET_DXIL_SHADER_DESC(shaderName), GET_SPIRV_SHADER_DESC(shaderName)) +#define AddDispatchRepeated(shaderName, passName, downsampleFactor, repeatNum) \ + AddComputeDispatchDesc(NumThreads(passName ## GroupX, passName ## GroupY), \ + downsampleFactor, sizeof(passName ## Constants), repeatNum, #shaderName ".cs", \ + GET_DXBC_SHADER_DESC(shaderName), GET_DXIL_SHADER_DESC(shaderName), GET_SPIRV_SHADER_DESC(shaderName)) #define PushPass(passName) \ _PushPass(NRD_STRINGIFY(DENOISER_NAME) " - " passName) // TODO: rework is needed, but still better than copy-pasting #define NRD_DECLARE_DIMS \ - uint16_t screenW = denoiserData.desc.renderWidth; \ - uint16_t screenH = denoiserData.desc.renderHeight; \ - [[maybe_unused]] uint16_t rectW = uint16_t(screenW * m_CommonSettings.resolutionScale[0] + 0.5f); \ - [[maybe_unused]] uint16_t rectH = uint16_t(screenH * m_CommonSettings.resolutionScale[1] + 0.5f); \ - [[maybe_unused]] uint16_t rectWprev = uint16_t(screenW * m_CommonSettings.resolutionScalePrev[0] + 0.5f); \ - [[maybe_unused]] uint16_t rectHprev = uint16_t(screenH * m_CommonSettings.resolutionScalePrev[1] + 0.5f) + [[maybe_unused]] uint16_t resourceW = m_CommonSettings.resourceSize[0]; \ + [[maybe_unused]] uint16_t resourceH = m_CommonSettings.resourceSize[1]; \ + [[maybe_unused]] uint16_t resourceWprev = m_CommonSettings.resourceSizePrev[0]; \ + [[maybe_unused]] uint16_t resourceHprev = m_CommonSettings.resourceSizePrev[1]; \ + [[maybe_unused]] uint16_t rectW = m_CommonSettings.rectSize[0]; \ + [[maybe_unused]] uint16_t rectH = m_CommonSettings.rectSize[1]; \ + [[maybe_unused]] uint16_t rectWprev = m_CommonSettings.rectSizePrev[0]; \ + [[maybe_unused]] uint16_t rectHprev = m_CommonSettings.rectSizePrev[1]; + + +// IMPORTANT: needed only for DXBC produced by ShaderMake without "--useAPI" +#undef BYTE +#define BYTE uint8_t +// Macro magic for shared headers +// IMPORTANT: do not use "float3" constants because of sizeof( ml::float3 ) = 16! +#define NRD_CONSTANTS_START( name ) struct name { +#define NRD_CONSTANT( type, name ) type name; +#define NRD_CONSTANTS_END }; + +#define NRD_INPUTS_START +#define NRD_INPUT(...) +#define NRD_INPUTS_END +#define NRD_OUTPUTS_START +#define NRD_OUTPUT(...) +#define NRD_OUTPUTS_END +#define NRD_SAMPLERS_START +#define NRD_SAMPLER(...) +#define NRD_SAMPLERS_END + +typedef uint32_t uint; + +// Implementation namespace nrd { constexpr uint16_t PERMANENT_POOL_START = 1000; constexpr uint16_t TRANSIENT_POOL_START = 2000; - constexpr size_t CONSTANT_DATA_SIZE = 2 * 1024 * 2014; + constexpr size_t CONSTANT_DATA_SIZE = 128 * 1024; // TODO: improve constexpr uint16_t USE_MAX_DIMS = 0xFFFF; constexpr uint16_t IGNORE_RS = 0xFFFE; @@ -75,20 +109,12 @@ namespace nrd inline uint16_t AsUint(T x) { return (uint16_t)x; } - union Constant - { - float f; - uint32_t ui; - }; - union Settings { // Add settings here ReblurSettings reblur; SigmaSettings sigma; - RelaxDiffuseSettings diffuseRelax; - RelaxSpecularSettings specularRelax; - RelaxDiffuseSpecularSettings diffuseSpecularRelax; + RelaxSettings relax; ReferenceSettings reference; SpecularReflectionMvSettings specularReflectionMv; SpecularDeltaMvSettings specularDeltaMv; @@ -129,6 +155,7 @@ namespace nrd uint32_t resourcesNum; const uint8_t* constantBufferData; uint32_t constantBufferDataSize; + Identifier identifier; uint16_t pipelineIndex; uint16_t downsampleFactor; uint16_t maxRepeatsNum; // mostly for internal use @@ -139,8 +166,7 @@ namespace nrd { Identifier identifier; ResourceDesc resource; - uint32_t w; - uint32_t h; + uint16_t downsampleFactor; bool isInteger; }; @@ -159,19 +185,9 @@ namespace nrd void Add_ReblurDiffuseSpecularOcclusion(DenoiserData& denoiserData); void Add_ReblurDiffuseSpecularSh(DenoiserData& denoiserData); void Add_ReblurDiffuseDirectionalOcclusion(DenoiserData& denoiserData); - void Update_Reblur(const DenoiserData& denoiserData); void Update_ReblurOcclusion(const DenoiserData& denoiserData); - - void AddSharedConstants_Reblur(const DenoiserData& denoiserData, const ReblurSettings& settings, Constant*& data); - - // Sigma - void Add_SigmaShadow(DenoiserData& denoiserData); - void Add_SigmaShadowTranslucency(DenoiserData& denoiserData); - - void Update_SigmaShadow(const DenoiserData& denoiserData); - - void AddSharedConstants_Sigma(const DenoiserData& denoiserData, const SigmaSettings& settings, Constant*& data); + void AddSharedConstants_Reblur(const ReblurSettings& settings, void* data); // Relax void Add_RelaxDiffuse(DenoiserData& denoiserData); @@ -180,15 +196,14 @@ namespace nrd void Add_RelaxSpecularSh(DenoiserData& denoiserData); void Add_RelaxDiffuseSpecular(DenoiserData& denoiserData); void Add_RelaxDiffuseSpecularSh(DenoiserData& denoiserData); + void Update_Relax(const DenoiserData& denoiserData); + void AddSharedConstants_Relax(const RelaxSettings& settings, void* data); - void Update_RelaxDiffuse(const DenoiserData& denoiserData); - void Update_RelaxDiffuseSh(const DenoiserData& denoiserData); - void Update_RelaxSpecular(const DenoiserData& denoiserData); - void Update_RelaxSpecularSh(const DenoiserData& denoiserData); - void Update_RelaxDiffuseSpecular(const DenoiserData& denoiserData); - void Update_RelaxDiffuseSpecularSh(const DenoiserData& denoiserData); - - void AddSharedConstants_Relax(const DenoiserData& denoiserData, Constant*& data, Denoiser denoiser); + // Sigma + void Add_SigmaShadow(DenoiserData& denoiserData); + void Add_SigmaShadowTranslucency(DenoiserData& denoiserData); + void Update_SigmaShadow(const DenoiserData& denoiserData); + void AddSharedConstants_Sigma(const SigmaSettings& settings, void* data); // Other void Add_Reference(DenoiserData& denoiserData); @@ -216,7 +231,13 @@ namespace nrd , m_ActiveDispatches(GetStdAllocator()) , m_IndexRemap(GetStdAllocator()) { - m_ConstantData = m_StdAllocator.allocate(CONSTANT_DATA_SIZE); + m_ConstantDataUnaligned = m_StdAllocator.allocate(CONSTANT_DATA_SIZE + sizeof(float4)); + + // IMPORTANT: underlying memory for constants must be aligned, as well as any individual SSE-type containing member, + // because a compiler can generate dangerous "movaps" instruction! + m_ConstantData = Align(m_ConstantDataUnaligned, sizeof(float4)); + memset(m_ConstantData, 0, CONSTANT_DATA_SIZE); + m_DenoiserData.reserve(8); m_PermanentPool.reserve(32); m_TransientPool.reserve(32); @@ -230,7 +251,7 @@ namespace nrd } ~InstanceImpl() - { m_StdAllocator.deallocate(m_ConstantData, 0); } + { m_StdAllocator.deallocate(m_ConstantDataUnaligned, 0); } inline const InstanceDesc& GetDesc() const { return m_Desc; } @@ -258,30 +279,21 @@ namespace nrd void PrepareDesc(); void UpdatePingPong(const DenoiserData& denoiserData); - void PushTexture(DescriptorType descriptorType, uint16_t localIndex, uint16_t mipOffset, uint16_t mipNum, uint16_t indexToSwapWith = uint16_t(-1)); + void PushTexture(DescriptorType descriptorType, uint16_t localIndex, uint16_t indexToSwapWith = uint16_t(-1)); // Available in denoiser implementations private: void AddTextureToTransientPool(const TextureDesc& textureDesc); - Constant* PushDispatch(const DenoiserData& denoiserData, uint32_t localIndex); + void* PushDispatch(const DenoiserData& denoiserData, uint32_t localIndex); inline void AddTextureToPermanentPool(const TextureDesc& textureDesc) { m_PermanentPool.push_back(textureDesc); } - inline void SetSharedConstants(uint32_t num4x4, uint32_t num4, uint32_t num2, uint32_t num1) - { - m_SharedConstantNum = 16 * num4x4 + 4 * num4 + 2 * num2 + 1 * num1; - assert( m_SharedConstantNum % 4 == 0 ); - } - - inline uint32_t SumConstants(uint32_t num4x4, uint32_t num4, uint32_t num2, uint32_t num1, bool addShared = true) - { return ( 16 * num4x4 + 4 * num4 + 2 * num2 + 1 * num1 + ( addShared ? m_SharedConstantNum : 0 ) ) * sizeof(uint32_t); } + inline void PushInput(uint16_t indexInPool, uint16_t indexToSwapWith = uint16_t(-1)) + { PushTexture(DescriptorType::TEXTURE, indexInPool, indexToSwapWith); } - inline void PushInput(uint16_t indexInPool, uint16_t mipOffset = 0, uint16_t mipNum = 1, uint16_t indexToSwapWith = uint16_t(-1)) - { PushTexture(DescriptorType::TEXTURE, indexInPool, mipOffset, mipNum, indexToSwapWith); } - - inline void PushOutput(uint16_t indexInPool, uint16_t mipOffset = 0, uint16_t mipNum = 1, uint16_t indexToSwapWith = uint16_t(-1)) - { PushTexture(DescriptorType::STORAGE_TEXTURE, indexInPool, mipOffset, mipNum, indexToSwapWith); } + inline void PushOutput(uint16_t indexInPool, uint16_t indexToSwapWith = uint16_t(-1)) + { PushTexture(DescriptorType::STORAGE_TEXTURE, indexInPool, indexToSwapWith); } inline void _PushPass(const char* name) { @@ -289,15 +301,6 @@ namespace nrd m_ResourceOffset = m_Resources.size(); } - inline void ValidateConstants(const Constant* lastConstant) const - { - const DispatchDesc& dispatchDesc = m_ActiveDispatches.back(); - - [[maybe_unused]] size_t num = size_t(lastConstant - (const Constant*)dispatchDesc.constantBufferData); - [[maybe_unused]] size_t bytes = num * sizeof(uint32_t); - assert( bytes == dispatchDesc.constantBufferDataSize ); - } - private: StdAllocator m_StdAllocator; Vector m_DenoiserData; @@ -312,91 +315,45 @@ namespace nrd Vector m_ActiveDispatches; Vector m_IndexRemap; Timer m_Timer; - ml::sFastRand m_FastRandState = {}; + sFastRand m_FastRandState = {}; InstanceDesc m_Desc = {}; CommonSettings m_CommonSettings = {}; - ml::float4x4 m_ViewToClip = ml::float4x4::Identity(); - ml::float4x4 m_ViewToClipPrev = ml::float4x4::Identity(); - ml::float4x4 m_ClipToView = ml::float4x4::Identity(); - ml::float4x4 m_ClipToViewPrev = ml::float4x4::Identity(); - ml::float4x4 m_WorldToView = ml::float4x4::Identity(); - ml::float4x4 m_WorldToViewPrev = ml::float4x4::Identity(); - ml::float4x4 m_ViewToWorld = ml::float4x4::Identity(); - ml::float4x4 m_ViewToWorldPrev = ml::float4x4::Identity(); - ml::float4x4 m_WorldToClip = ml::float4x4::Identity(); - ml::float4x4 m_WorldToClipPrev = ml::float4x4::Identity(); - ml::float4x4 m_ClipToWorld = ml::float4x4::Identity(); - ml::float4x4 m_ClipToWorldPrev = ml::float4x4::Identity(); - ml::float4x4 m_WorldPrevToWorld = ml::float4x4::Identity(); - ml::float4 m_Rotator_PrePass = ml::float4::Zero(); - ml::float4 m_Rotator_Blur = ml::float4::Zero(); - ml::float4 m_Rotator_PostBlur = ml::float4::Zero(); - ml::float4 m_Frustum = ml::float4::Zero(); - ml::float4 m_FrustumPrev = ml::float4::Zero(); - ml::float3 m_CameraDelta = ml::float3::Zero(); - ml::float3 m_ViewDirection = ml::float3::Zero(); - ml::float3 m_ViewDirectionPrev = ml::float3::Zero(); + float4x4 m_ViewToClip = float4x4::Identity(); + float4x4 m_ViewToClipPrev = float4x4::Identity(); + float4x4 m_ClipToView = float4x4::Identity(); + float4x4 m_ClipToViewPrev = float4x4::Identity(); + float4x4 m_WorldToView = float4x4::Identity(); + float4x4 m_WorldToViewPrev = float4x4::Identity(); + float4x4 m_ViewToWorld = float4x4::Identity(); + float4x4 m_ViewToWorldPrev = float4x4::Identity(); + float4x4 m_WorldToClip = float4x4::Identity(); + float4x4 m_WorldToClipPrev = float4x4::Identity(); + float4x4 m_ClipToWorld = float4x4::Identity(); + float4x4 m_ClipToWorldPrev = float4x4::Identity(); + float4x4 m_WorldPrevToWorld = float4x4::Identity(); + float4 m_Rotator_PrePass = float4::Zero(); + float4 m_Rotator_Blur = float4::Zero(); + float4 m_Rotator_PostBlur = float4::Zero(); + float4 m_Frustum = float4::Zero(); + float4 m_FrustumPrev = float4::Zero(); + float3 m_CameraDelta = float3::Zero(); + float3 m_ViewDirection = float3::Zero(); + float3 m_ViewDirectionPrev = float3::Zero(); const char* m_PassName = nullptr; + uint8_t* m_ConstantDataUnaligned = nullptr; uint8_t* m_ConstantData = nullptr; size_t m_ConstantDataOffset = 0; size_t m_ResourceOffset = 0; size_t m_DispatchClearIndex[2] = {}; - float m_IsOrtho = 0.0f; + float m_OrthoMode = 0.0f; float m_CheckerboardResolveAccumSpeed = 0.0f; float m_JitterDelta = 0.0f; float m_TimeDelta = 0.0f; float m_FrameRateScale = 0.0f; float m_ProjectY = 0.0f; - uint32_t m_SharedConstantNum = 0; uint32_t m_AccumulatedFrameNum = 0; uint16_t m_TransientPoolOffset = 0; uint16_t m_PermanentPoolOffset = 0; bool m_IsFirstUse = true; }; - - inline void AddFloat4x4(Constant*& dst, const ml::float4x4& x) - { - memcpy(dst, &x, sizeof(ml::float4x4)); - dst += 16; - } - - inline void AddFloat4(Constant*& dst, const ml::float4& x) - { - memcpy(dst, &x, sizeof(ml::float4)); - dst += 4; - } - - inline void AddFloat2(Constant*& dst, float x, float y) - { - dst->f = x; - dst++; - - dst->f = y; - dst++; - } - - inline void AddFloat(Constant*& dst, float x) - { - dst->f = x; - dst++; - } - - inline void AddUint(Constant*& dst, uint32_t x) - { - dst->ui = x; - dst++; - } - - inline void AddUint2(Constant*& dst, uint32_t x, uint32_t y) - { - dst->ui = x; - dst++; - - dst->ui = y; - dst++; - } } - -// IMPORTANT: needed only for DXBC produced by ShaderMake without "--useAPI" -#undef BYTE -#define BYTE uint8_t diff --git a/Source/Reblur.cpp b/Source/Reblur.cpp index e62f489..c8723b0 100644 --- a/Source/Reblur.cpp +++ b/Source/Reblur.cpp @@ -12,57 +12,28 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include -// Constants -#define REBLUR_SET_SHARED_CONSTANTS SetSharedConstants(2, 5, 9, 22) - -#define REBLUR_CLASSIFY_TILES_CONSTANT_NUM SumConstants(0, 0, 0, 1, false) -#define REBLUR_CLASSIFY_TILES_NUM_THREADS NumThreads(16, 16) - -#define REBLUR_HITDIST_RECONSTRUCTION_CONSTANT_NUM SumConstants(0, 0, 0, 0) -#define REBLUR_HITDIST_RECONSTRUCTION_NUM_THREADS NumThreads(8, 8) - -#define REBLUR_PREPASS_CONSTANT_NUM SumConstants(0, 1, 0, 2) -#define REBLUR_PREPASS_NUM_THREADS NumThreads(16, 16) - -#define REBLUR_TEMPORAL_ACCUMULATION_CONSTANT_NUM SumConstants(4, 2, 0, 7) -#define REBLUR_TEMPORAL_ACCUMULATION_NUM_THREADS NumThreads(8, 8) - -#define REBLUR_HISTORY_FIX_CONSTANT_NUM SumConstants(0, 0, 0, 1) -#define REBLUR_HISTORY_FIX_NUM_THREADS NumThreads(16, 16) - -#define REBLUR_BLUR_CONSTANT_NUM SumConstants(0, 1, 0, 0) -#define REBLUR_BLUR_NUM_THREADS NumThreads(8, 8) - -#define REBLUR_POST_BLUR_CONSTANT_NUM SumConstants(0, 1, 0, 0) -#define REBLUR_POST_BLUR_NUM_THREADS NumThreads(8, 8) - -#define REBLUR_COPY_STABILIZED_HISTORY_CONSTANT_NUM SumConstants(0, 0, 0, 1, false) -#define REBLUR_COPY_STABILIZED_HISTORY_NUM_THREADS NumThreads(16, 16) - -#define REBLUR_TEMPORAL_STABILIZATION_CONSTANT_NUM SumConstants(3, 3, 1, 1) -#define REBLUR_TEMPORAL_STABILIZATION_NUM_THREADS NumThreads(8, 8) - -#define REBLUR_SPLIT_SCREEN_CONSTANT_NUM SumConstants(0, 0, 0, 3) -#define REBLUR_SPLIT_SCREEN_NUM_THREADS NumThreads(16, 16) +#include "../Shaders/Include/REBLUR_Config.hlsli" +#include "../Shaders/Resources/REBLUR_Blur.resources.hlsli" +#include "../Shaders/Resources/REBLUR_ClassifyTiles.resources.hlsli" +#include "../Shaders/Resources/REBLUR_Copy.resources.hlsli" +#include "../Shaders/Resources/REBLUR_HistoryFix.resources.hlsli" +#include "../Shaders/Resources/REBLUR_HitDistReconstruction.resources.hlsli" +#include "../Shaders/Resources/REBLUR_PostBlur.resources.hlsli" +#include "../Shaders/Resources/REBLUR_PrePass.resources.hlsli" +#include "../Shaders/Resources/REBLUR_SplitScreen.resources.hlsli" +#include "../Shaders/Resources/REBLUR_TemporalAccumulation.resources.hlsli" +#include "../Shaders/Resources/REBLUR_TemporalStabilization.resources.hlsli" +#include "../Shaders/Resources/REBLUR_Validation.resources.hlsli" // Permutations -#define REBLUR_CLASSIFY_TILES_PERMUTATION_NUM 1 #define REBLUR_HITDIST_RECONSTRUCTION_PERMUTATION_NUM 4 #define REBLUR_PREPASS_PERMUTATION_NUM 2 #define REBLUR_TEMPORAL_ACCUMULATION_PERMUTATION_NUM 16 -#define REBLUR_HISTORY_FIX_PERMUTATION_NUM 1 -#define REBLUR_BLUR_PERMUTATION_NUM 1 #define REBLUR_POST_BLUR_PERMUTATION_NUM 2 -#define REBLUR_COPY_STABILIZED_HISTORY_PERMUTATION_NUM 1 #define REBLUR_TEMPORAL_STABILIZATION_PERMUTATION_NUM 2 -#define REBLUR_SPLIT_SCREEN_PERMUTATION_NUM 1 #define REBLUR_OCCLUSION_HITDIST_RECONSTRUCTION_PERMUTATION_NUM 2 #define REBLUR_OCCLUSION_TEMPORAL_ACCUMULATION_PERMUTATION_NUM 8 -#define REBLUR_OCCLUSION_HISTORY_FIX_PERMUTATION_NUM 1 -#define REBLUR_OCCLUSION_BLUR_PERMUTATION_NUM 1 -#define REBLUR_OCCLUSION_POST_BLUR_PERMUTATION_NUM 1 -#define REBLUR_OCCLUSION_SPLIT_SCREEN_PERMUTATION_NUM 1 // Formats #define REBLUR_FORMAT Format::RGBA16_SFLOAT // .xyz - color, .w - normalized hit distance @@ -82,6 +53,7 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. // Other #define REBLUR_DUMMY AsUint(ResourceType::IN_VIEWZ) +#define REBLUR_NO_PERMUTATIONS 1 #define REBLUR_ADD_VALIDATION_DISPATCH( data2, diff, spec ) \ PushPass("Validation"); \ @@ -94,7 +66,7 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. PushInput( AsUint(diff) ); \ PushInput( AsUint(spec) ); \ PushOutput( AsUint(ResourceType::OUT_VALIDATION) ); \ - AddDispatch( REBLUR_Validation, SumConstants(1, 0, 1, 4), NumThreads(16, 16), IGNORE_RS ); \ + AddDispatch( REBLUR_Validation, REBLUR_Validation, IGNORE_RS ); \ } struct ReblurProps @@ -122,16 +94,16 @@ void nrd::InstanceImpl::Update_Reblur(const DenoiserData& denoiserData) enum class Dispatch { CLASSIFY_TILES, - HITDIST_RECONSTRUCTION = CLASSIFY_TILES + REBLUR_CLASSIFY_TILES_PERMUTATION_NUM * 1, // CLASSIFY_TILES doesn't have perf mode + HITDIST_RECONSTRUCTION = CLASSIFY_TILES + REBLUR_NO_PERMUTATIONS * 1, // CLASSIFY_TILES doesn't have perf mode PREPASS = HITDIST_RECONSTRUCTION + REBLUR_HITDIST_RECONSTRUCTION_PERMUTATION_NUM * 2, TEMPORAL_ACCUMULATION = PREPASS + REBLUR_PREPASS_PERMUTATION_NUM * 2, HISTORY_FIX = TEMPORAL_ACCUMULATION + REBLUR_TEMPORAL_ACCUMULATION_PERMUTATION_NUM * 2, - BLUR = HISTORY_FIX + REBLUR_HISTORY_FIX_PERMUTATION_NUM * 2, - POST_BLUR = BLUR + REBLUR_BLUR_PERMUTATION_NUM * 2, - COPY_STABILIZED_HISTORY = POST_BLUR + REBLUR_POST_BLUR_PERMUTATION_NUM * 2, - TEMPORAL_STABILIZATION = COPY_STABILIZED_HISTORY + REBLUR_COPY_STABILIZED_HISTORY_PERMUTATION_NUM * 1, // COPY_STABILIZED_HISTORY doesn't have perf mode + BLUR = HISTORY_FIX + REBLUR_NO_PERMUTATIONS * 2, + POST_BLUR = BLUR + REBLUR_NO_PERMUTATIONS * 2, + COPY = POST_BLUR + REBLUR_POST_BLUR_PERMUTATION_NUM * 2, + TEMPORAL_STABILIZATION = COPY + REBLUR_NO_PERMUTATIONS * 1, // COPY doesn't have perf mode SPLIT_SCREEN = TEMPORAL_STABILIZATION + REBLUR_TEMPORAL_STABILIZATION_PERMUTATION_NUM * 2, - VALIDATION = SPLIT_SCREEN + REBLUR_SPLIT_SCREEN_PERMUTATION_NUM * 1, // SPLIT_SCREEN doesn't have perf mode + VALIDATION = SPLIT_SCREEN + REBLUR_NO_PERMUTATIONS * 1, // SPLIT_SCREEN doesn't have perf mode }; NRD_DECLARE_DIMS; @@ -139,167 +111,97 @@ void nrd::InstanceImpl::Update_Reblur(const DenoiserData& denoiserData) const ReblurSettings& settings = denoiserData.settings.reblur; const ReblurProps& props = g_ReblurProps[ size_t(denoiserData.desc.denoiser) - size_t(Denoiser::REBLUR_DIFFUSE) ]; - bool isRectChanged = rectW != rectWprev || rectH != rectHprev; bool enableHitDistanceReconstruction = settings.hitDistanceReconstructionMode != HitDistanceReconstructionMode::OFF && settings.checkerboardMode == CheckerboardMode::OFF; bool skipTemporalStabilization = settings.stabilizationStrength == 0.0f; bool skipPrePass = (settings.diffusePrepassBlurRadius == 0.0f || !props.hasDiffuse) && (settings.specularPrepassBlurRadius == 0.0f || !props.hasSpecular) && settings.checkerboardMode == CheckerboardMode::OFF; - float disocclusionThresholdBonus = (1.0f + m_JitterDelta) / float(rectH); - float disocclusionThreshold = m_CommonSettings.disocclusionThreshold + disocclusionThresholdBonus; - float disocclusionThresholdAlternate = m_CommonSettings.disocclusionThresholdAlternate + disocclusionThresholdBonus; - - uint32_t specCheckerboard = 2; - uint32_t diffCheckerboard = 2; - - switch (settings.checkerboardMode) - { - case CheckerboardMode::BLACK: - diffCheckerboard = 0; - specCheckerboard = 1; - break; - case CheckerboardMode::WHITE: - diffCheckerboard = 1; - specCheckerboard = 0; - break; - default: - break; - } - // SPLIT_SCREEN (passthrough) if (m_CommonSettings.splitScreen >= 1.0f) { - Constant* data = PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); - AddSharedConstants_Reblur(denoiserData, settings, data); - AddFloat(data, m_CommonSettings.splitScreen); - AddUint(data, diffCheckerboard); - AddUint(data, specCheckerboard); - ValidateConstants(data); + PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); return; } - // CLASSIFY_TILES - Constant* data = PushDispatch(denoiserData, AsUint(Dispatch::CLASSIFY_TILES)); - AddFloat(data, m_CommonSettings.denoisingRange); - ValidateConstants(data); + { // CLASSIFY_TILES + void* consts = PushDispatch(denoiserData, AsUint(Dispatch::CLASSIFY_TILES)); + AddSharedConstants_Reblur(settings, consts); + } // HITDIST_RECONSTRUCTION if (enableHitDistanceReconstruction) { uint32_t passIndex = AsUint(Dispatch::HITDIST_RECONSTRUCTION) + (settings.hitDistanceReconstructionMode == HitDistanceReconstructionMode::AREA_5X5 ? 4 : 0) + (!skipPrePass ? 2 : 0) + (settings.enablePerformanceMode ? 1 : 0); - data = PushDispatch(denoiserData, passIndex); - AddSharedConstants_Reblur(denoiserData, settings, data); - ValidateConstants(data); + void* consts = PushDispatch(denoiserData, passIndex); + AddSharedConstants_Reblur(settings, consts); } // PREPASS if (!skipPrePass) { uint32_t passIndex = AsUint(Dispatch::PREPASS) + (enableHitDistanceReconstruction ? 2 : 0) + (settings.enablePerformanceMode ? 1 : 0); - data = PushDispatch(denoiserData, passIndex); - AddSharedConstants_Reblur(denoiserData, settings, data); - AddFloat4(data, m_Rotator_PrePass); - AddUint(data, diffCheckerboard); - AddUint(data, specCheckerboard); - ValidateConstants(data); + REBLUR_PrePassConstants* consts = (REBLUR_PrePassConstants*)PushDispatch(denoiserData, passIndex); + AddSharedConstants_Reblur(settings, consts); + consts->gRotator = m_Rotator_PrePass; // TODO: push constant + } + + { // TEMPORAL_ACCUMULATION + uint32_t passIndex = AsUint(Dispatch::TEMPORAL_ACCUMULATION) + (m_CommonSettings.isDisocclusionThresholdMixAvailable ? 16 : 0) + + (!skipTemporalStabilization ? 8 : 0) + (m_CommonSettings.isHistoryConfidenceAvailable ? 4 : 0) + + ((!skipPrePass || enableHitDistanceReconstruction) ? 2 : 0) + (settings.enablePerformanceMode ? 1 : 0); + void* consts = PushDispatch(denoiserData, passIndex); + AddSharedConstants_Reblur(settings, consts); + } + + { // HISTORY_FIX + uint32_t passIndex = AsUint(Dispatch::HISTORY_FIX) + (settings.enablePerformanceMode ? 1 : 0); + void* consts = PushDispatch(denoiserData, passIndex); + AddSharedConstants_Reblur(settings, consts); + } + + { // BLUR + uint32_t passIndex = AsUint(Dispatch::BLUR) + (settings.enablePerformanceMode ? 1 : 0); + REBLUR_BlurConstants* consts = (REBLUR_BlurConstants*)PushDispatch(denoiserData, passIndex); + AddSharedConstants_Reblur(settings, consts); + consts->gRotator = m_Rotator_Blur; // TODO: push constant } - // TEMPORAL_ACCUMULATION - uint32_t passIndex = AsUint(Dispatch::TEMPORAL_ACCUMULATION) + (m_CommonSettings.isDisocclusionThresholdMixAvailable ? 16 : 0) + - (!skipTemporalStabilization ? 8 : 0) + (m_CommonSettings.isHistoryConfidenceAvailable ? 4 : 0) + - ((!skipPrePass || enableHitDistanceReconstruction) ? 2 : 0) + (settings.enablePerformanceMode ? 1 : 0); - data = PushDispatch(denoiserData, passIndex); - AddSharedConstants_Reblur(denoiserData, settings, data); - AddFloat4x4(data, m_WorldToViewPrev); - AddFloat4x4(data, m_WorldToClipPrev); - AddFloat4x4(data, m_WorldToClip); - AddFloat4x4(data, m_WorldPrevToWorld); - AddFloat4(data, m_FrustumPrev); - AddFloat4(data, ml::float4(m_CameraDelta.x, m_CameraDelta.y, m_CameraDelta.z, disocclusionThreshold)); - AddFloat(data, disocclusionThresholdAlternate); - AddFloat(data, m_CheckerboardResolveAccumSpeed); - AddUint(data, diffCheckerboard); - AddUint(data, specCheckerboard); - AddUint(data, skipPrePass ? 0 : 1); - AddUint(data, m_CommonSettings.isHistoryConfidenceAvailable ? 1 : 0); - AddUint(data, m_CommonSettings.isDisocclusionThresholdMixAvailable ? 1 : 0); - ValidateConstants(data); - - // HISTORY_FIX - passIndex = AsUint(Dispatch::HISTORY_FIX) + (settings.enablePerformanceMode ? 1 : 0); - data = PushDispatch(denoiserData, passIndex); - AddSharedConstants_Reblur(denoiserData, settings, data); - AddFloat(data, settings.historyFixStrideBetweenSamples); - ValidateConstants(data); - - // BLUR - passIndex = AsUint(Dispatch::BLUR) + (settings.enablePerformanceMode ? 1 : 0); - data = PushDispatch(denoiserData, passIndex); - AddSharedConstants_Reblur(denoiserData, settings, data); - AddFloat4(data, m_Rotator_Blur); - ValidateConstants(data); - - // POST_BLUR - passIndex = AsUint(Dispatch::POST_BLUR) + (skipTemporalStabilization ? 0 : 2) + (settings.enablePerformanceMode ? 1 : 0); - data = PushDispatch(denoiserData, passIndex); - AddSharedConstants_Reblur(denoiserData, settings, data); - AddFloat4(data, m_Rotator_PostBlur); - ValidateConstants(data); - - // COPY_STABILIZED_HISTORY + { // POST_BLUR + uint32_t passIndex = AsUint(Dispatch::POST_BLUR) + (skipTemporalStabilization ? 0 : 2) + (settings.enablePerformanceMode ? 1 : 0); + REBLUR_PostBlurConstants* consts = (REBLUR_PostBlurConstants*)PushDispatch(denoiserData, passIndex); + AddSharedConstants_Reblur(settings, consts); + consts->gRotator = m_Rotator_PostBlur; // TODO: push constant + } + + // COPY if (!skipTemporalStabilization) { - passIndex = AsUint(Dispatch::COPY_STABILIZED_HISTORY); - data = PushDispatch(denoiserData, passIndex); - AddUint(data, isRectChanged ? 1 : 0); - ValidateConstants(data); + uint32_t passIndex = AsUint(Dispatch::COPY); + void* consts = (REBLUR_CopyConstants*)PushDispatch(denoiserData, passIndex); + AddSharedConstants_Reblur(settings, consts); } // TEMPORAL_STABILIZATION if (!skipTemporalStabilization) { - passIndex = AsUint(Dispatch::TEMPORAL_STABILIZATION) + (m_CommonSettings.isBaseColorMetalnessAvailable ? 2 : 0) + (settings.enablePerformanceMode ? 1 : 0); - data = PushDispatch(denoiserData, passIndex); - AddSharedConstants_Reblur(denoiserData, settings, data); - AddFloat4x4(data, m_WorldToClip); - AddFloat4x4(data, m_WorldToClipPrev); - AddFloat4x4(data, m_WorldToViewPrev); - AddFloat4(data, m_FrustumPrev); - AddFloat4(data, ml::float4(m_CameraDelta.x, m_CameraDelta.y, m_CameraDelta.z, settings.stabilizationStrength)); - AddFloat4(data, ml::float4(settings.antilagSettings.luminanceSigmaScale, settings.antilagSettings.hitDistanceSigmaScale, settings.antilagSettings.luminanceAntilagPower, settings.antilagSettings.hitDistanceAntilagPower)); - if (m_CommonSettings.isBaseColorMetalnessAvailable) - AddFloat2(data, settings.specularProbabilityThresholdsForMvModification[0], settings.specularProbabilityThresholdsForMvModification[1]); - else - AddFloat2(data, 2.0f, 3.0f); - AddFloat(data, m_CommonSettings.splitScreen); - ValidateConstants(data); + uint32_t passIndex = AsUint(Dispatch::TEMPORAL_STABILIZATION) + (m_CommonSettings.isBaseColorMetalnessAvailable ? 2 : 0) + (settings.enablePerformanceMode ? 1 : 0); + void* consts = PushDispatch(denoiserData, passIndex); + AddSharedConstants_Reblur(settings, consts); } // SPLIT_SCREEN if (m_CommonSettings.splitScreen > 0.0f) - { - data = PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); - AddSharedConstants_Reblur(denoiserData, settings, data); - AddFloat(data, m_CommonSettings.splitScreen); - AddUint(data, diffCheckerboard); - AddUint(data, specCheckerboard); - ValidateConstants(data); - } + PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); // VALIDATION if (m_CommonSettings.enableValidation) { - data = PushDispatch(denoiserData, AsUint(Dispatch::VALIDATION)); - AddSharedConstants_Reblur(denoiserData, settings, data); - AddFloat4x4(data, m_WorldToClipPrev); - AddFloat2(data, m_CommonSettings.cameraJitter[0], m_CommonSettings.cameraJitter[1]); - AddUint(data, props.hasDiffuse ? 1 : 0); - AddUint(data, props.hasSpecular ? 1 : 0); - AddUint(data, diffCheckerboard); - AddUint(data, specCheckerboard); - ValidateConstants(data); + REBLUR_ValidationConstants* consts = (REBLUR_ValidationConstants*)PushDispatch(denoiserData, AsUint(Dispatch::VALIDATION)); + AddSharedConstants_Reblur(settings, consts); + consts->gHasDiffuse = props.hasDiffuse ? 1 : 0; // TODO: push constant + consts->gHasSpecular = props.hasSpecular ? 1 : 0; // TODO: push constant } } @@ -308,13 +210,13 @@ void nrd::InstanceImpl::Update_ReblurOcclusion(const DenoiserData& denoiserData) enum class Dispatch { CLASSIFY_TILES, - HITDIST_RECONSTRUCTION = CLASSIFY_TILES + REBLUR_CLASSIFY_TILES_PERMUTATION_NUM * 1, // CLASSIFY_TILES doesn't have perf mode + HITDIST_RECONSTRUCTION = CLASSIFY_TILES + REBLUR_NO_PERMUTATIONS * 1, // CLASSIFY_TILES doesn't have perf mode TEMPORAL_ACCUMULATION = HITDIST_RECONSTRUCTION + REBLUR_OCCLUSION_HITDIST_RECONSTRUCTION_PERMUTATION_NUM * 2, HISTORY_FIX = TEMPORAL_ACCUMULATION + REBLUR_OCCLUSION_TEMPORAL_ACCUMULATION_PERMUTATION_NUM * 2, - BLUR = HISTORY_FIX + REBLUR_OCCLUSION_HISTORY_FIX_PERMUTATION_NUM * 2, - POST_BLUR = BLUR + REBLUR_OCCLUSION_BLUR_PERMUTATION_NUM * 2, - SPLIT_SCREEN = POST_BLUR + REBLUR_OCCLUSION_POST_BLUR_PERMUTATION_NUM * 2, - VALIDATION = SPLIT_SCREEN + REBLUR_SPLIT_SCREEN_PERMUTATION_NUM * 1, // SPLIT_SCREEN doesn't have perf mode + BLUR = HISTORY_FIX + REBLUR_NO_PERMUTATIONS * 2, + POST_BLUR = BLUR + REBLUR_NO_PERMUTATIONS * 2, + SPLIT_SCREEN = POST_BLUR + REBLUR_NO_PERMUTATIONS * 2, + VALIDATION = SPLIT_SCREEN + REBLUR_NO_PERMUTATIONS * 1, // SPLIT_SCREEN doesn't have perf mode }; NRD_DECLARE_DIMS; @@ -324,178 +226,166 @@ void nrd::InstanceImpl::Update_ReblurOcclusion(const DenoiserData& denoiserData) bool enableHitDistanceReconstruction = settings.hitDistanceReconstructionMode != HitDistanceReconstructionMode::OFF && settings.checkerboardMode == CheckerboardMode::OFF; - float disocclusionThresholdBonus = (1.0f + m_JitterDelta) / float(rectH); - float disocclusionThreshold = m_CommonSettings.disocclusionThreshold + disocclusionThresholdBonus; - float disocclusionThresholdAlternate = m_CommonSettings.disocclusionThresholdAlternate + disocclusionThresholdBonus; - - uint32_t specCheckerboard = 2; - uint32_t diffCheckerboard = 2; - - switch (settings.checkerboardMode) - { - case CheckerboardMode::BLACK: - diffCheckerboard = 0; - specCheckerboard = 1; - break; - case CheckerboardMode::WHITE: - diffCheckerboard = 1; - specCheckerboard = 0; - break; - default: - break; - } - // SPLIT_SCREEN (passthrough) if (m_CommonSettings.splitScreen >= 1.0f) { - Constant* data = PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); - AddSharedConstants_Reblur(denoiserData, settings, data); - AddFloat(data, m_CommonSettings.splitScreen); - AddUint(data, diffCheckerboard); - AddUint(data, specCheckerboard); - ValidateConstants(data); + void* consts = PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); + AddSharedConstants_Reblur(settings, consts); return; } - // CLASSIFY_TILES - Constant* data = PushDispatch(denoiserData, AsUint(Dispatch::CLASSIFY_TILES)); - AddFloat(data, m_CommonSettings.denoisingRange); - ValidateConstants(data); + { // CLASSIFY_TILES + void* consts = PushDispatch(denoiserData, AsUint(Dispatch::CLASSIFY_TILES)); + AddSharedConstants_Reblur(settings, consts); + } // HITDIST_RECONSTRUCTION if (enableHitDistanceReconstruction) { uint32_t passIndex = AsUint(Dispatch::HITDIST_RECONSTRUCTION) + (settings.hitDistanceReconstructionMode == HitDistanceReconstructionMode::AREA_5X5 ? 2 : 0) + (settings.enablePerformanceMode ? 1 : 0); - data = PushDispatch(denoiserData, passIndex); - AddSharedConstants_Reblur(denoiserData, settings, data); - ValidateConstants(data); + void* consts = PushDispatch(denoiserData, passIndex); + AddSharedConstants_Reblur(settings, consts); } - // TEMPORAL_ACCUMULATION - uint32_t passIndex = AsUint(Dispatch::TEMPORAL_ACCUMULATION) + (m_CommonSettings.isDisocclusionThresholdMixAvailable ? 8 : 0) + - (m_CommonSettings.isHistoryConfidenceAvailable ? 4 : 0) + (enableHitDistanceReconstruction ? 2 : 0) + (settings.enablePerformanceMode ? 1 : 0); - data = PushDispatch(denoiserData, passIndex); - AddSharedConstants_Reblur(denoiserData, settings, data); - AddFloat4x4(data, m_WorldToViewPrev); - AddFloat4x4(data, m_WorldToClipPrev); - AddFloat4x4(data, m_WorldToClip); - AddFloat4x4(data, m_WorldPrevToWorld); - AddFloat4(data, m_FrustumPrev); - AddFloat4(data, ml::float4(m_CameraDelta.x, m_CameraDelta.y, m_CameraDelta.z, disocclusionThreshold)); - AddFloat(data, disocclusionThresholdAlternate); - AddFloat(data, m_CheckerboardResolveAccumSpeed); - AddUint(data, diffCheckerboard); - AddUint(data, specCheckerboard); - AddUint(data, 0); - AddUint(data, m_CommonSettings.isHistoryConfidenceAvailable); - AddUint(data, m_CommonSettings.isDisocclusionThresholdMixAvailable); - ValidateConstants(data); - - // HISTORY_FIX - passIndex = AsUint(Dispatch::HISTORY_FIX) + (!settings.enableAntiFirefly ? 1 : 0); - data = PushDispatch(denoiserData, passIndex); - AddSharedConstants_Reblur(denoiserData, settings, data); - AddFloat(data, settings.historyFixStrideBetweenSamples); - ValidateConstants(data); - - // BLUR - passIndex = AsUint(Dispatch::BLUR) + (settings.enablePerformanceMode ? 1 : 0); - data = PushDispatch(denoiserData, passIndex); - AddSharedConstants_Reblur(denoiserData, settings, data); - AddFloat4(data, m_Rotator_Blur); - ValidateConstants(data); - - // POST_BLUR - passIndex = AsUint(Dispatch::POST_BLUR) + (settings.enablePerformanceMode ? 1 : 0); - data = PushDispatch(denoiserData, passIndex); - AddSharedConstants_Reblur(denoiserData, settings, data); - AddFloat4(data, m_Rotator_PostBlur); - ValidateConstants(data); + { // TEMPORAL_ACCUMULATION + uint32_t passIndex = AsUint(Dispatch::TEMPORAL_ACCUMULATION) + (m_CommonSettings.isDisocclusionThresholdMixAvailable ? 8 : 0) + + (m_CommonSettings.isHistoryConfidenceAvailable ? 4 : 0) + (enableHitDistanceReconstruction ? 2 : 0) + (settings.enablePerformanceMode ? 1 : 0); + void* consts = PushDispatch(denoiserData, passIndex); + AddSharedConstants_Reblur(settings, consts); + } + + { // HISTORY_FIX + uint32_t passIndex = AsUint(Dispatch::HISTORY_FIX) + (!settings.enableAntiFirefly ? 1 : 0); + void* consts = PushDispatch(denoiserData, passIndex); + AddSharedConstants_Reblur(settings, consts); + } + + { // BLUR + uint32_t passIndex = AsUint(Dispatch::BLUR) + (settings.enablePerformanceMode ? 1 : 0); + REBLUR_BlurConstants* consts = (REBLUR_BlurConstants* )PushDispatch(denoiserData, passIndex); + AddSharedConstants_Reblur(settings, consts); + consts->gRotator = m_Rotator_Blur; // TODO: push constant + } + + { // POST_BLUR + uint32_t passIndex = AsUint(Dispatch::POST_BLUR) + (settings.enablePerformanceMode ? 1 : 0); + REBLUR_PostBlurConstants* consts = (REBLUR_PostBlurConstants*)PushDispatch(denoiserData, passIndex); + AddSharedConstants_Reblur(settings, consts); + consts->gRotator = m_Rotator_PostBlur; // TODO: push constant + } // SPLIT_SCREEN if (m_CommonSettings.splitScreen > 0.0f) { - data = PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); - AddSharedConstants_Reblur(denoiserData, settings, data); - AddFloat(data, m_CommonSettings.splitScreen); - AddUint(data, diffCheckerboard); - AddUint(data, specCheckerboard); - ValidateConstants(data); + void* consts = PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); + AddSharedConstants_Reblur(settings, consts); } // VALIDATION if (m_CommonSettings.enableValidation) { - data = PushDispatch(denoiserData, AsUint(Dispatch::VALIDATION)); - AddSharedConstants_Reblur(denoiserData, settings, data); - AddFloat4x4(data, m_WorldToClipPrev); - AddFloat2(data, m_CommonSettings.cameraJitter[0], m_CommonSettings.cameraJitter[1]); - AddUint(data, props.hasDiffuse ? 1 : 0); - AddUint(data, props.hasSpecular ? 1 : 0); - AddUint(data, diffCheckerboard); - AddUint(data, specCheckerboard); - ValidateConstants(data); + REBLUR_ValidationConstants* consts = (REBLUR_ValidationConstants*)PushDispatch(denoiserData, AsUint(Dispatch::VALIDATION)); + AddSharedConstants_Reblur(settings, consts); + consts->gHasDiffuse = props.hasDiffuse ? 1 : 0; // TODO: push constant + consts->gHasSpecular = props.hasSpecular ? 1 : 0; // TODO: push constant } } -void nrd::InstanceImpl::AddSharedConstants_Reblur(const DenoiserData& denoiserData, const ReblurSettings& settings, Constant*& data) +void nrd::InstanceImpl::AddSharedConstants_Reblur(const ReblurSettings& settings, void* data) { + struct SharedConstants + { + REBLUR_SHARED_CONSTANTS + }; + NRD_DECLARE_DIMS; + bool isRectChanged = rectW != rectWprev || rectH != rectHprev; bool isHistoryReset = m_CommonSettings.accumulationMode != AccumulationMode::CONTINUE; float unproject = 1.0f / (0.5f * rectH * m_ProjectY); - uint32_t maxAccumulatedFrameNum = ml::Min(settings.maxAccumulatedFrameNum, REBLUR_MAX_HISTORY_FRAME_NUM); - - AddFloat4x4(data, m_ViewToClip); - AddFloat4x4(data, m_ViewToWorld); - - AddFloat4(data, m_Frustum); - AddFloat4(data, ml::float4(settings.hitDistanceParameters.A, settings.hitDistanceParameters.B, settings.hitDistanceParameters.C, settings.hitDistanceParameters.D)); - AddFloat4(data, ml::float4(m_ViewDirection.x, m_ViewDirection.y, m_ViewDirection.z, 0.0f)); - AddFloat4(data, ml::float4(m_ViewDirectionPrev.x, m_ViewDirectionPrev.y, m_ViewDirectionPrev.z, 0.0f)); - AddFloat4(data, ml::float4(m_CommonSettings.motionVectorScale[0], m_CommonSettings.motionVectorScale[1], m_CommonSettings.motionVectorScale[2], m_CommonSettings.debug)); - - AddFloat2(data, 1.0f / float(screenW), 1.0f / float(screenH)); - AddFloat2(data, float(screenW), float(screenH)); - - AddFloat2(data, 1.0f / float(rectW), 1.0f / float(rectH)); - AddFloat2(data, float(rectW), float(rectH)); - - AddFloat2(data, float(rectW) / float(screenW), float(rectH) / float(screenH)); - AddFloat2(data, float(rectWprev) / float(screenW), float(rectHprev) / float(screenH)); - - AddFloat2(data, float(rectWprev), float(rectHprev)); - AddFloat2(data, float(m_CommonSettings.inputSubrectOrigin[0]) / float(screenW), float(m_CommonSettings.inputSubrectOrigin[1]) / float(screenH)); - - AddUint2(data, m_CommonSettings.inputSubrectOrigin[0], m_CommonSettings.inputSubrectOrigin[1]); - AddFloat(data, m_IsOrtho); - AddFloat(data, unproject); - - AddFloat(data, m_CommonSettings.denoisingRange); - AddFloat(data, settings.planeDistanceSensitivity); - AddFloat(data, m_FrameRateScale); - AddFloat(data, settings.blurRadius); - - AddFloat(data, isHistoryReset ? 0 : float(maxAccumulatedFrameNum)); - AddFloat(data, float(settings.maxFastAccumulatedFrameNum)); - AddFloat(data, settings.enableAntiFirefly ? 1.0f : 0.0f); - AddFloat(data, settings.lobeAngleFraction); - - AddFloat(data, settings.roughnessFraction); - AddFloat(data, settings.responsiveAccumulationRoughnessThreshold); - AddFloat(data, settings.diffusePrepassBlurRadius); - AddFloat(data, settings.specularPrepassBlurRadius); + float worstResolutionScale = Min(float(rectW) / float(resourceW), float(rectH) / float(resourceH)); + float blurRadius = settings.blurRadius * worstResolutionScale; + float diffusePrepassBlurRadius = settings.diffusePrepassBlurRadius * worstResolutionScale; + float specularPrepassBlurRadius = settings.specularPrepassBlurRadius * worstResolutionScale; + float disocclusionThresholdBonus = (1.0f + m_JitterDelta) / float(rectH); + float disocclusionThreshold = m_CommonSettings.disocclusionThreshold + disocclusionThresholdBonus; + float disocclusionThresholdAlternate = m_CommonSettings.disocclusionThresholdAlternate + disocclusionThresholdBonus; + uint32_t maxAccumulatedFrameNum = Min(settings.maxAccumulatedFrameNum, REBLUR_MAX_HISTORY_FRAME_NUM); - AddFloat(data, (float)settings.historyFixFrameNum); - AddFloat(data, (float)ml::Min(rectW, rectH) * unproject); - AddFloat(data, settings.usePrepassOnlyForSpecularMotionEstimation ? 0.0f : 1.0f); - AddUint(data, m_CommonSettings.isMotionVectorInWorldSpace ? 1 : 0); + uint32_t diffCheckerboard = 2; + uint32_t specCheckerboard = 2; + switch (settings.checkerboardMode) + { + case CheckerboardMode::BLACK: + diffCheckerboard = 0; + specCheckerboard = 1; + break; + case CheckerboardMode::WHITE: + diffCheckerboard = 1; + specCheckerboard = 0; + break; + } - AddUint(data, m_CommonSettings.frameIndex); - AddUint(data, settings.enableMaterialTestForDiffuse ? 1 : 0); - AddUint(data, settings.enableMaterialTestForSpecular ? 1 : 0); - AddUint(data, isHistoryReset ? 1 : 0); + SharedConstants* consts = (SharedConstants*)data; + consts->gViewToClip = m_ViewToClip; + consts->gViewToWorld = m_ViewToWorld; + consts->gWorldToViewPrev = m_WorldToViewPrev; + consts->gWorldToClipPrev = m_WorldToClipPrev; + consts->gWorldPrevToWorld = m_WorldPrevToWorld; + consts->gFrustum = m_Frustum; + consts->gFrustumPrev = m_FrustumPrev; + consts->gCameraDelta = m_CameraDelta; + consts->gAntilagParams = float4(settings.antilagSettings.luminanceSigmaScale, settings.antilagSettings.hitDistanceSigmaScale, settings.antilagSettings.luminanceAntilagPower, settings.antilagSettings.hitDistanceAntilagPower); + consts->gHitDistParams = float4(settings.hitDistanceParameters.A, settings.hitDistanceParameters.B, settings.hitDistanceParameters.C, settings.hitDistanceParameters.D); + consts->gViewVectorWorld = m_ViewDirection; + consts->gViewVectorWorldPrev = m_ViewDirectionPrev; + consts->gMvScale = float4(m_CommonSettings.motionVectorScale[0], m_CommonSettings.motionVectorScale[1], m_CommonSettings.motionVectorScale[2], m_CommonSettings.isMotionVectorInWorldSpace ? 1.0f : 0.0f); + consts->gResourceSize = float2(float(resourceW), float(resourceH)); + consts->gResourceSizeInv = float2(1.0f / float(resourceW), 1.0f / float(resourceH)); + consts->gResourceSizeInvPrev = float2(1.0f / float(resourceWprev), 1.0f / float(resourceHprev)); + consts->gRectSize = float2(float(rectW), float(rectH)); + consts->gRectSizeInv = float2(1.0f / float(rectW), 1.0f / float(rectH)); + consts->gRectSizePrev = float2(float(rectWprev), float(rectHprev)); + consts->gResolutionScale = float2(float(rectW) / float(resourceW), float(rectH) / float(resourceH)); + consts->gResolutionScalePrev = float2(float(rectWprev) / float(resourceWprev), float(rectHprev) / float(resourceHprev)); + consts->gRectOffset = float2(float(m_CommonSettings.rectOrigin[0]) / float(resourceW), float(m_CommonSettings.rectOrigin[1]) / float(resourceH)); + consts->gSpecProbabilityThresholdsForMvModification = float2(m_CommonSettings.isBaseColorMetalnessAvailable ? settings.specularProbabilityThresholdsForMvModification[0] : 2.0f, m_CommonSettings.isBaseColorMetalnessAvailable ? settings.specularProbabilityThresholdsForMvModification[1] : 3.0f); + consts->gJitter = float2(m_CommonSettings.cameraJitter[0], m_CommonSettings.cameraJitter[1]); + consts->gRectOrigin = uint2(m_CommonSettings.rectOrigin[0], m_CommonSettings.rectOrigin[1]); + consts->gRectSizeMinusOne = int2(rectW - 1, rectH - 1); + consts->gDisocclusionThreshold = disocclusionThreshold; + consts->gDisocclusionThresholdAlternate = disocclusionThresholdAlternate; + consts->gStabilizationStrength = settings.stabilizationStrength; + consts->gDebug = m_CommonSettings.debug; + consts->gOrthoMode = m_OrthoMode; + consts->gUnproject = unproject; + consts->gDenoisingRange = m_CommonSettings.denoisingRange; + consts->gPlaneDistSensitivity = settings.planeDistanceSensitivity; + consts->gFramerateScale = m_FrameRateScale; + consts->gBlurRadius = blurRadius; + consts->gMaxAccumulatedFrameNum = isHistoryReset ? 0 : float(maxAccumulatedFrameNum); + consts->gMaxFastAccumulatedFrameNum = float(settings.maxFastAccumulatedFrameNum); + consts->gAntiFirefly = settings.enableAntiFirefly ? 1.0f : 0.0f; + consts->gLobeAngleFraction = settings.lobeAngleFraction; + consts->gRoughnessFraction = settings.roughnessFraction; + consts->gResponsiveAccumulationRoughnessThreshold = settings.responsiveAccumulationRoughnessThreshold; + consts->gDiffPrepassBlurRadius = diffusePrepassBlurRadius; + consts->gSpecPrepassBlurRadius = specularPrepassBlurRadius; + consts->gHistoryFixFrameNum = (float)Min(settings.historyFixFrameNum, 3u); + consts->gMinRectDimMulUnproject = (float)Min(rectW, rectH) * unproject; + consts->gUsePrepassNotOnlyForSpecularMotionEstimation = settings.usePrepassOnlyForSpecularMotionEstimation ? 0.0f : 1.0f; + consts->gSplitScreen = m_CommonSettings.splitScreen; + consts->gCheckerboardResolveAccumSpeed = m_CheckerboardResolveAccumSpeed; + consts->gHasHistoryConfidence = m_CommonSettings.isHistoryConfidenceAvailable; + consts->gHasDisocclusionThresholdMix = m_CommonSettings.isDisocclusionThresholdMixAvailable; + consts->gDiffCheckerboard = diffCheckerboard; + consts->gSpecCheckerboard = specCheckerboard; + consts->gFrameIndex = m_CommonSettings.frameIndex; + consts->gDiffMaterialMask = settings.enableMaterialTestForDiffuse ? 1 : 0; + consts->gSpecMaterialMask = settings.enableMaterialTestForSpecular ? 1 : 0; + consts->gIsRectChanged = isRectChanged ? 1 : 0; + consts->gResetHistory = isHistoryReset ? 1 : 0; } // REBLUR_SHARED @@ -524,7 +414,7 @@ void nrd::InstanceImpl::AddSharedConstants_Reblur(const DenoiserData& denoiserDa #include "REBLUR_Diffuse_Blur.cs.dxbc.h" #include "REBLUR_Diffuse_PostBlur.cs.dxbc.h" #include "REBLUR_Diffuse_PostBlur_NoTemporalStabilization.cs.dxbc.h" - #include "REBLUR_Diffuse_CopyStabilizedHistory.cs.dxbc.h" + #include "REBLUR_Diffuse_Copy.cs.dxbc.h" #include "REBLUR_Diffuse_TemporalStabilization.cs.dxbc.h" #include "REBLUR_Diffuse_SplitScreen.cs.dxbc.h" @@ -548,7 +438,7 @@ void nrd::InstanceImpl::AddSharedConstants_Reblur(const DenoiserData& denoiserDa #include "REBLUR_Diffuse_Blur.cs.dxil.h" #include "REBLUR_Diffuse_PostBlur.cs.dxil.h" #include "REBLUR_Diffuse_PostBlur_NoTemporalStabilization.cs.dxil.h" - #include "REBLUR_Diffuse_CopyStabilizedHistory.cs.dxil.h" + #include "REBLUR_Diffuse_Copy.cs.dxil.h" #include "REBLUR_Diffuse_TemporalStabilization.cs.dxil.h" #include "REBLUR_Diffuse_SplitScreen.cs.dxil.h" @@ -570,7 +460,7 @@ void nrd::InstanceImpl::AddSharedConstants_Reblur(const DenoiserData& denoiserDa #include "REBLUR_Diffuse_TemporalAccumulation.cs.spirv.h" #include "REBLUR_Diffuse_HistoryFix.cs.spirv.h" #include "REBLUR_Diffuse_Blur.cs.spirv.h" - #include "REBLUR_Diffuse_CopyStabilizedHistory.cs.spirv.h" + #include "REBLUR_Diffuse_Copy.cs.spirv.h" #include "REBLUR_Diffuse_TemporalStabilization.cs.spirv.h" #include "REBLUR_Diffuse_PostBlur.cs.spirv.h" #include "REBLUR_Diffuse_PostBlur_NoTemporalStabilization.cs.spirv.h" @@ -650,7 +540,7 @@ void nrd::InstanceImpl::AddSharedConstants_Reblur(const DenoiserData& denoiserDa #include "REBLUR_DiffuseSh_Blur.cs.dxbc.h" #include "REBLUR_DiffuseSh_PostBlur.cs.dxbc.h" #include "REBLUR_DiffuseSh_PostBlur_NoTemporalStabilization.cs.dxbc.h" - #include "REBLUR_DiffuseSh_CopyStabilizedHistory.cs.dxbc.h" + #include "REBLUR_DiffuseSh_Copy.cs.dxbc.h" #include "REBLUR_DiffuseSh_TemporalStabilization.cs.dxbc.h" #include "REBLUR_DiffuseSh_SplitScreen.cs.dxbc.h" @@ -670,7 +560,7 @@ void nrd::InstanceImpl::AddSharedConstants_Reblur(const DenoiserData& denoiserDa #include "REBLUR_DiffuseSh_Blur.cs.dxil.h" #include "REBLUR_DiffuseSh_PostBlur.cs.dxil.h" #include "REBLUR_DiffuseSh_PostBlur_NoTemporalStabilization.cs.dxil.h" - #include "REBLUR_DiffuseSh_CopyStabilizedHistory.cs.dxil.h" + #include "REBLUR_DiffuseSh_Copy.cs.dxil.h" #include "REBLUR_DiffuseSh_TemporalStabilization.cs.dxil.h" #include "REBLUR_DiffuseSh_SplitScreen.cs.dxil.h" @@ -688,7 +578,7 @@ void nrd::InstanceImpl::AddSharedConstants_Reblur(const DenoiserData& denoiserDa #include "REBLUR_DiffuseSh_TemporalAccumulation.cs.spirv.h" #include "REBLUR_DiffuseSh_HistoryFix.cs.spirv.h" #include "REBLUR_DiffuseSh_Blur.cs.spirv.h" - #include "REBLUR_DiffuseSh_CopyStabilizedHistory.cs.spirv.h" + #include "REBLUR_DiffuseSh_Copy.cs.spirv.h" #include "REBLUR_DiffuseSh_TemporalStabilization.cs.spirv.h" #include "REBLUR_DiffuseSh_PostBlur.cs.spirv.h" #include "REBLUR_DiffuseSh_PostBlur_NoTemporalStabilization.cs.spirv.h" @@ -716,7 +606,7 @@ void nrd::InstanceImpl::AddSharedConstants_Reblur(const DenoiserData& denoiserDa #include "REBLUR_Specular_Blur.cs.dxbc.h" #include "REBLUR_Specular_PostBlur.cs.dxbc.h" #include "REBLUR_Specular_PostBlur_NoTemporalStabilization.cs.dxbc.h" - #include "REBLUR_Specular_CopyStabilizedHistory.cs.dxbc.h" + #include "REBLUR_Specular_Copy.cs.dxbc.h" #include "REBLUR_Specular_TemporalStabilization.cs.dxbc.h" #include "REBLUR_Specular_SplitScreen.cs.dxbc.h" @@ -740,7 +630,7 @@ void nrd::InstanceImpl::AddSharedConstants_Reblur(const DenoiserData& denoiserDa #include "REBLUR_Specular_Blur.cs.dxil.h" #include "REBLUR_Specular_PostBlur.cs.dxil.h" #include "REBLUR_Specular_PostBlur_NoTemporalStabilization.cs.dxil.h" - #include "REBLUR_Specular_CopyStabilizedHistory.cs.dxil.h" + #include "REBLUR_Specular_Copy.cs.dxil.h" #include "REBLUR_Specular_TemporalStabilization.cs.dxil.h" #include "REBLUR_Specular_SplitScreen.cs.dxil.h" @@ -765,7 +655,7 @@ void nrd::InstanceImpl::AddSharedConstants_Reblur(const DenoiserData& denoiserDa #include "REBLUR_Specular_Blur.cs.spirv.h" #include "REBLUR_Specular_PostBlur.cs.spirv.h" #include "REBLUR_Specular_PostBlur_NoTemporalStabilization.cs.spirv.h" - #include "REBLUR_Specular_CopyStabilizedHistory.cs.spirv.h" + #include "REBLUR_Specular_Copy.cs.spirv.h" #include "REBLUR_Specular_TemporalStabilization.cs.spirv.h" #include "REBLUR_Specular_SplitScreen.cs.spirv.h" @@ -843,7 +733,7 @@ void nrd::InstanceImpl::AddSharedConstants_Reblur(const DenoiserData& denoiserDa #include "REBLUR_SpecularSh_Blur.cs.dxbc.h" #include "REBLUR_SpecularSh_PostBlur.cs.dxbc.h" #include "REBLUR_SpecularSh_PostBlur_NoTemporalStabilization.cs.dxbc.h" - #include "REBLUR_SpecularSh_CopyStabilizedHistory.cs.dxbc.h" + #include "REBLUR_SpecularSh_Copy.cs.dxbc.h" #include "REBLUR_SpecularSh_TemporalStabilization.cs.dxbc.h" #include "REBLUR_SpecularSh_SplitScreen.cs.dxbc.h" @@ -863,7 +753,7 @@ void nrd::InstanceImpl::AddSharedConstants_Reblur(const DenoiserData& denoiserDa #include "REBLUR_SpecularSh_Blur.cs.dxil.h" #include "REBLUR_SpecularSh_PostBlur.cs.dxil.h" #include "REBLUR_SpecularSh_PostBlur_NoTemporalStabilization.cs.dxil.h" - #include "REBLUR_SpecularSh_CopyStabilizedHistory.cs.dxil.h" + #include "REBLUR_SpecularSh_Copy.cs.dxil.h" #include "REBLUR_SpecularSh_TemporalStabilization.cs.dxil.h" #include "REBLUR_SpecularSh_SplitScreen.cs.dxil.h" @@ -883,7 +773,7 @@ void nrd::InstanceImpl::AddSharedConstants_Reblur(const DenoiserData& denoiserDa #include "REBLUR_SpecularSh_Blur.cs.spirv.h" #include "REBLUR_SpecularSh_PostBlur.cs.spirv.h" #include "REBLUR_SpecularSh_PostBlur_NoTemporalStabilization.cs.spirv.h" - #include "REBLUR_SpecularSh_CopyStabilizedHistory.cs.spirv.h" + #include "REBLUR_SpecularSh_Copy.cs.spirv.h" #include "REBLUR_SpecularSh_TemporalStabilization.cs.spirv.h" #include "REBLUR_SpecularSh_SplitScreen.cs.spirv.h" @@ -907,7 +797,7 @@ void nrd::InstanceImpl::AddSharedConstants_Reblur(const DenoiserData& denoiserDa #include "REBLUR_DiffuseSpecular_TemporalAccumulation.cs.dxbc.h" #include "REBLUR_DiffuseSpecular_HistoryFix.cs.dxbc.h" #include "REBLUR_DiffuseSpecular_Blur.cs.dxbc.h" - #include "REBLUR_DiffuseSpecular_CopyStabilizedHistory.cs.dxbc.h" + #include "REBLUR_DiffuseSpecular_Copy.cs.dxbc.h" #include "REBLUR_DiffuseSpecular_TemporalStabilization.cs.dxbc.h" #include "REBLUR_DiffuseSpecular_PostBlur.cs.dxbc.h" #include "REBLUR_DiffuseSpecular_PostBlur_NoTemporalStabilization.cs.dxbc.h" @@ -931,7 +821,7 @@ void nrd::InstanceImpl::AddSharedConstants_Reblur(const DenoiserData& denoiserDa #include "REBLUR_DiffuseSpecular_TemporalAccumulation.cs.dxil.h" #include "REBLUR_DiffuseSpecular_HistoryFix.cs.dxil.h" #include "REBLUR_DiffuseSpecular_Blur.cs.dxil.h" - #include "REBLUR_DiffuseSpecular_CopyStabilizedHistory.cs.dxil.h" + #include "REBLUR_DiffuseSpecular_Copy.cs.dxil.h" #include "REBLUR_DiffuseSpecular_TemporalStabilization.cs.dxil.h" #include "REBLUR_DiffuseSpecular_PostBlur.cs.dxil.h" #include "REBLUR_DiffuseSpecular_PostBlur_NoTemporalStabilization.cs.dxil.h" @@ -955,7 +845,7 @@ void nrd::InstanceImpl::AddSharedConstants_Reblur(const DenoiserData& denoiserDa #include "REBLUR_DiffuseSpecular_TemporalAccumulation.cs.spirv.h" #include "REBLUR_DiffuseSpecular_HistoryFix.cs.spirv.h" #include "REBLUR_DiffuseSpecular_Blur.cs.spirv.h" - #include "REBLUR_DiffuseSpecular_CopyStabilizedHistory.cs.spirv.h" + #include "REBLUR_DiffuseSpecular_Copy.cs.spirv.h" #include "REBLUR_DiffuseSpecular_TemporalStabilization.cs.spirv.h" #include "REBLUR_DiffuseSpecular_PostBlur.cs.spirv.h" #include "REBLUR_DiffuseSpecular_PostBlur_NoTemporalStabilization.cs.spirv.h" @@ -1033,7 +923,7 @@ void nrd::InstanceImpl::AddSharedConstants_Reblur(const DenoiserData& denoiserDa #include "REBLUR_DiffuseSpecularSh_TemporalAccumulation.cs.dxbc.h" #include "REBLUR_DiffuseSpecularSh_HistoryFix.cs.dxbc.h" #include "REBLUR_DiffuseSpecularSh_Blur.cs.dxbc.h" - #include "REBLUR_DiffuseSpecularSh_CopyStabilizedHistory.cs.dxbc.h" + #include "REBLUR_DiffuseSpecularSh_Copy.cs.dxbc.h" #include "REBLUR_DiffuseSpecularSh_TemporalStabilization.cs.dxbc.h" #include "REBLUR_DiffuseSpecularSh_PostBlur.cs.dxbc.h" #include "REBLUR_DiffuseSpecularSh_PostBlur_NoTemporalStabilization.cs.dxbc.h" @@ -1053,7 +943,7 @@ void nrd::InstanceImpl::AddSharedConstants_Reblur(const DenoiserData& denoiserDa #include "REBLUR_DiffuseSpecularSh_TemporalAccumulation.cs.dxil.h" #include "REBLUR_DiffuseSpecularSh_HistoryFix.cs.dxil.h" #include "REBLUR_DiffuseSpecularSh_Blur.cs.dxil.h" - #include "REBLUR_DiffuseSpecularSh_CopyStabilizedHistory.cs.dxil.h" + #include "REBLUR_DiffuseSpecularSh_Copy.cs.dxil.h" #include "REBLUR_DiffuseSpecularSh_TemporalStabilization.cs.dxil.h" #include "REBLUR_DiffuseSpecularSh_PostBlur.cs.dxil.h" #include "REBLUR_DiffuseSpecularSh_PostBlur_NoTemporalStabilization.cs.dxil.h" @@ -1073,7 +963,7 @@ void nrd::InstanceImpl::AddSharedConstants_Reblur(const DenoiserData& denoiserDa #include "REBLUR_DiffuseSpecularSh_TemporalAccumulation.cs.spirv.h" #include "REBLUR_DiffuseSpecularSh_HistoryFix.cs.spirv.h" #include "REBLUR_DiffuseSpecularSh_Blur.cs.spirv.h" - #include "REBLUR_DiffuseSpecularSh_CopyStabilizedHistory.cs.spirv.h" + #include "REBLUR_DiffuseSpecularSh_Copy.cs.spirv.h" #include "REBLUR_DiffuseSpecularSh_TemporalStabilization.cs.spirv.h" #include "REBLUR_DiffuseSpecularSh_PostBlur.cs.spirv.h" #include "REBLUR_DiffuseSpecularSh_PostBlur_NoTemporalStabilization.cs.spirv.h" diff --git a/Source/Relax.cpp b/Source/Relax.cpp index ae9a9d2..333c21e 100644 --- a/Source/Relax.cpp +++ b/Source/Relax.cpp @@ -10,9 +10,32 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "InstanceImpl.h" -constexpr uint32_t RELAX_MAX_ATROUS_PASS_NUM = 8; +#include "../Shaders/Include/RELAX_Config.hlsli" +#include "../Shaders/Resources/RELAX_AntiFirefly.resources.hlsli" +#include "../Shaders/Resources/RELAX_Atrous.resources.hlsli" +#include "../Shaders/Resources/RELAX_AtrousSmem.resources.hlsli" +#include "../Shaders/Resources/RELAX_ClassifyTiles.resources.hlsli" +#include "../Shaders/Resources/RELAX_Copy.resources.hlsli" +#include "../Shaders/Resources/RELAX_HistoryClamping.resources.hlsli" +#include "../Shaders/Resources/RELAX_HistoryFix.resources.hlsli" +#include "../Shaders/Resources/RELAX_HitDistReconstruction.resources.hlsli" +#include "../Shaders/Resources/RELAX_PrePass.resources.hlsli" +#include "../Shaders/Resources/RELAX_SplitScreen.resources.hlsli" +#include "../Shaders/Resources/RELAX_TemporalAccumulation.resources.hlsli" +#include "../Shaders/Resources/RELAX_Validation.resources.hlsli" + +// Permutations +#define RELAX_HITDIST_RECONSTRUCTION_PERMUTATION_NUM 2 +#define RELAX_PREPASS_PERMUTATION_NUM 2 +#define RELAX_TEMPORAL_ACCUMULATION_PERMUTATION_NUM 4 +#define RELAX_ATROUS_PERMUTATION_NUM 2 // * RELAX_ATROUS_BINDING_VARIANT_NUM + +// Other +#define RELAX_DUMMY AsUint(ResourceType::IN_VIEWZ) +#define RELAX_NO_PERMUTATIONS 1 +#define RELAX_ATROUS_BINDING_VARIANT_NUM 5 -#define RELAX_SET_SHARED_CONSTANTS SetSharedConstants(5, 8, 7, 14) +constexpr uint32_t RELAX_MAX_ATROUS_PASS_NUM = 8; #define RELAX_ADD_VALIDATION_DISPATCH \ PushPass("Validation"); \ @@ -22,123 +45,259 @@ constexpr uint32_t RELAX_MAX_ATROUS_PASS_NUM = 8; PushInput( AsUint(ResourceType::IN_MV) ); \ PushInput( AsUint(Transient::HISTORY_LENGTH) ); \ PushOutput( AsUint(ResourceType::OUT_VALIDATION) ); \ - AddDispatch( RELAX_Validation, SumConstants(1, 0, 1, 1), NumThreads(16, 16), IGNORE_RS ); \ + AddDispatch( RELAX_Validation, RELAX_Validation, IGNORE_RS ); \ } -inline ml::float3 RELAX_GetFrustumForward(const ml::float4x4& viewToWorld, const ml::float4& frustum) +inline float3 RELAX_GetFrustumForward(const float4x4& viewToWorld, const float4& frustum) { - // Note: this vector is not normalized for non-symmetric projections but that's correct. - // It has to have .z coordinate equal to 1.0 to correctly reconstruct world position in shaders. - ml::float4 frustumForwardView = ml::float4(0.5f, 0.5f, 1.0f, 0.0f) * ml::float4(frustum.z, frustum.w, 1.0f, 0.0f) + ml::float4(frustum.x, frustum.y, 0.0f, 0.0f); - ml::float3 frustumForwardWorld = (viewToWorld * frustumForwardView).To3d(); + float4 frustumForwardView = float4(0.5f, 0.5f, 1.0f, 0.0f) * float4(frustum.z, frustum.w, 1.0f, 0.0f) + float4(frustum.x, frustum.y, 0.0f, 0.0f); + float3 frustumForwardWorld = (viewToWorld * frustumForwardView).To3d(); + + // Vector is not normalized for non-symmetric projections, it has to have .z = 1.0 to correctly reconstruct world position in shaders return frustumForwardWorld; } -inline bool RELAX_IsCameraStatic -( - const ml::float3& cameraDelta, - const ml::float3& frustumRight, const ml::float3& frustumUp, const ml::float3& frustumForward, - const ml::float3& prevFrustumRight, const ml::float3& prevFrustumUp, const ml::float3& prevFrustumForward, float eps = ml::c_fEps -) +void nrd::InstanceImpl::AddSharedConstants_Relax(const RelaxSettings& settings, void* data) { - return ml::Length(cameraDelta) < eps && ml::Length(frustumRight - prevFrustumRight) < eps && ml::Length(frustumUp - prevFrustumUp) < eps && ml::Length(frustumForward - prevFrustumForward) < eps; -} + struct SharedConstants + { + RELAX_SHARED_CONSTANTS + }; -void nrd::InstanceImpl::AddSharedConstants_Relax(const DenoiserData& denoiserData, Constant*& data, Denoiser denoiser) -{ NRD_DECLARE_DIMS; - // Calculate camera right and up vectors in worldspace scaled according to frustum extents, - // and unit forward vector, for fast worldspace position reconstruction in shaders float tanHalfFov = 1.0f / m_ViewToClip.a00; float aspect = m_ViewToClip.a00 / m_ViewToClip.a11; - ml::float3 frustumRight = m_WorldToView.GetRow0().To3d() * tanHalfFov; - ml::float3 frustumUp = m_WorldToView.GetRow1().To3d() * tanHalfFov * aspect; - ml::float3 frustumForward = RELAX_GetFrustumForward(m_ViewToWorld, m_Frustum); + float3 frustumRight = m_WorldToView.GetRow0().To3d() * tanHalfFov; + float3 frustumUp = m_WorldToView.GetRow1().To3d() * tanHalfFov * aspect; + float3 frustumForward = RELAX_GetFrustumForward(m_ViewToWorld, m_Frustum); float prevTanHalfFov = 1.0f / m_ViewToClipPrev.a00; float prevAspect = m_ViewToClipPrev.a00 / m_ViewToClipPrev.a11; - ml::float3 prevFrustumRight = m_WorldToViewPrev.GetRow0().To3d() * prevTanHalfFov; - ml::float3 prevFrustumUp = m_WorldToViewPrev.GetRow1().To3d() * prevTanHalfFov * prevAspect; - ml::float3 prevFrustumForward = RELAX_GetFrustumForward(m_ViewToWorldPrev, m_FrustumPrev); - - AddFloat4x4(data, m_WorldToClipPrev); - AddFloat4x4(data, m_WorldToViewPrev); - AddFloat4x4(data, m_WorldToClip); - AddFloat4x4(data, m_WorldPrevToWorld); - AddFloat4x4(data, m_ViewToWorld); - - AddFloat4(data, ml::float4(frustumRight.x, frustumRight.y, frustumRight.z, 0)); - AddFloat4(data, ml::float4(frustumUp.x, frustumUp.y, frustumUp.z, 0)); - AddFloat4(data, ml::float4(frustumForward.x, frustumForward.y, frustumForward.z, 0)); - AddFloat4(data, ml::float4(prevFrustumRight.x, prevFrustumRight.y, prevFrustumRight.z, 0)); - AddFloat4(data, ml::float4(prevFrustumUp.x, prevFrustumUp.y, prevFrustumUp.z, 0)); - AddFloat4(data, ml::float4(prevFrustumForward.x, prevFrustumForward.y, prevFrustumForward.z, 0)); - AddFloat4(data, ml::float4(m_CameraDelta.x, m_CameraDelta.y, m_CameraDelta.z, 0.0f)); - AddFloat4(data, ml::float4(m_CommonSettings.motionVectorScale[0], m_CommonSettings.motionVectorScale[1], m_CommonSettings.motionVectorScale[2], m_CommonSettings.debug)); - - AddFloat2(data, float(rectW) / float(screenW), float(rectH) / float(screenH)); - AddUint2(data, m_CommonSettings.inputSubrectOrigin[0], m_CommonSettings.inputSubrectOrigin[1]); - - AddFloat2(data, float(m_CommonSettings.inputSubrectOrigin[0]) / float(screenW), float(m_CommonSettings.inputSubrectOrigin[1]) / float(screenH)); - AddUint2(data, rectW, rectH); - - AddFloat2(data, 1.0f / screenW, 1.0f / screenH); - AddFloat2(data, 1.0f / rectW, 1.0f / rectH); - - AddFloat2(data, float(rectWprev), float(rectHprev)); - AddUint(data, m_CommonSettings.isMotionVectorInWorldSpace ? 1 : 0); - AddFloat(data, m_IsOrtho); - - AddFloat(data, 1.0f / (0.5f * rectH * m_ProjectY)); - AddUint(data, m_CommonSettings.frameIndex); - AddFloat(data, m_CommonSettings.denoisingRange); - AddFloat(data, ml::Clamp(16.66f / m_TimeDelta, 0.25f, 4.0f)); // Normalizing to 60 FPS - - AddFloat(data, m_CheckerboardResolveAccumSpeed); - AddFloat(data, m_JitterDelta); - switch (denoiser) + float3 prevFrustumRight = m_WorldToViewPrev.GetRow0().To3d() * prevTanHalfFov; + float3 prevFrustumUp = m_WorldToViewPrev.GetRow1().To3d() * prevTanHalfFov * prevAspect; + float3 prevFrustumForward = RELAX_GetFrustumForward(m_ViewToWorldPrev, m_FrustumPrev); + + float maxDiffuseLuminanceRelativeDifference = -Log( Saturate(settings.diffuseMinLuminanceWeight) ); + float maxSpecularLuminanceRelativeDifference = -Log( Saturate(settings.specularMinLuminanceWeight) ); + float disocclusionThresholdBonus = (1.0f + m_JitterDelta) / float(rectH); + float disocclusionThreshold = m_CommonSettings.disocclusionThreshold + disocclusionThresholdBonus; + float disocclusionThresholdAlternate = m_CommonSettings.disocclusionThresholdAlternate + disocclusionThresholdBonus; + + // Checkerboard logic + uint32_t specCheckerboard = 2; + uint32_t diffCheckerboard = 2; + switch (settings.checkerboardMode) { - case Denoiser::RELAX_DIFFUSE: - case Denoiser::RELAX_DIFFUSE_SH: - AddUint(data, denoiserData.settings.diffuseRelax.enableMaterialTest ? 1 : 0); - AddUint(data, 0); - break; - case Denoiser::RELAX_SPECULAR: - case Denoiser::RELAX_SPECULAR_SH: - AddUint(data, 0); - AddUint(data, denoiserData.settings.specularRelax.enableMaterialTest ? 1 : 0); + case CheckerboardMode::BLACK: + diffCheckerboard = 0; + specCheckerboard = 1; break; - case Denoiser::RELAX_DIFFUSE_SPECULAR: - case Denoiser::RELAX_DIFFUSE_SPECULAR_SH: - AddUint(data, denoiserData.settings.diffuseSpecularRelax.enableMaterialTestForDiffuse ? 1 : 0); - AddUint(data, denoiserData.settings.diffuseSpecularRelax.enableMaterialTestForSpecular ? 1 : 0); - break; - default: - // Should never get here - AddUint(data, 0); - AddUint(data, 0); + case CheckerboardMode::WHITE: + diffCheckerboard = 1; + specCheckerboard = 0; break; } - // 1 if m_WorldPrevToWorld should be used in shader, otherwise we can skip multiplication - AddUint(data, (m_WorldPrevToWorld != ml::float4x4::Identity()) ? 1 : 0); - AddUint(data, m_CommonSettings.accumulationMode != AccumulationMode::CONTINUE ? 1 : 0); - AddUint(data, 0); - AddUint(data, 0); + SharedConstants* consts = (SharedConstants*)data; + consts->gWorldToClipPrev = m_WorldToClipPrev; + consts->gWorldToViewPrev = m_WorldToViewPrev; + consts->gWorldPrevToWorld = m_WorldPrevToWorld; + consts->gFrustumRight = float4(frustumRight.x, frustumRight.y, frustumRight.z, 0.0f); + consts->gFrustumUp = float4(frustumUp.x, frustumUp.y, frustumUp.z, 0.0f); + consts->gFrustumForward = float4(frustumForward.x, frustumForward.y, frustumForward.z, 0.0f); + consts->gPrevFrustumRight = float4(prevFrustumRight.x, prevFrustumRight.y, prevFrustumRight.z, 0.0f); + consts->gPrevFrustumUp = float4(prevFrustumUp.x, prevFrustumUp.y, prevFrustumUp.z, 0.0f); + consts->gPrevFrustumForward = float4(prevFrustumForward.x, prevFrustumForward.y, prevFrustumForward.z, 0.0f); + consts->gCameraDelta = float4(m_CameraDelta.x, m_CameraDelta.y, m_CameraDelta.z, 0.0f); + consts->gMvScale = float4(m_CommonSettings.motionVectorScale[0], m_CommonSettings.motionVectorScale[1], m_CommonSettings.motionVectorScale[2], m_CommonSettings.isMotionVectorInWorldSpace ? 1.0f : 0.0f); + consts->gJitter = float2(m_CommonSettings.cameraJitter[0], m_CommonSettings.cameraJitter[1]); + consts->gResolutionScale = float2(float(rectW) / float(resourceW), float(rectH) / float(resourceH)); + consts->gRectOffset = float2(float(m_CommonSettings.rectOrigin[0]) / float(resourceW), float(m_CommonSettings.rectOrigin[1]) / float(resourceH)); + consts->gResourceSizeInv = float2(1.0f / resourceW, 1.0f / resourceH); + consts->gResourceSize = float2(resourceW, resourceH); + consts->gRectSizeInv = float2(1.0f / rectW, 1.0f / rectH); + consts->gRectSizePrev = float2(float(rectWprev), float(rectHprev)); + consts->gResourceSizeInvPrev = float2(1.0f / resourceWprev, 1.0f / resourceHprev); + consts->gRectOrigin = uint2(m_CommonSettings.rectOrigin[0], m_CommonSettings.rectOrigin[1]); + consts->gRectSize = uint2(rectW, rectH); + consts->gSpecMaxAccumulatedFrameNum = (float)settings.specularMaxAccumulatedFrameNum; + consts->gSpecMaxFastAccumulatedFrameNum = (float)settings.specularMaxFastAccumulatedFrameNum; + consts->gDiffMaxAccumulatedFrameNum = (float)settings.diffuseMaxAccumulatedFrameNum; + consts->gDiffMaxFastAccumulatedFrameNum = (float)settings.diffuseMaxFastAccumulatedFrameNum; + consts->gDisocclusionDepthThreshold = disocclusionThreshold; + consts->gDisocclusionDepthThresholdAlternate = disocclusionThresholdAlternate; + consts->gRoughnessFraction = settings.roughnessFraction; + consts->gSpecVarianceBoost = settings.specularVarianceBoost; + consts->gSplitScreen = m_CommonSettings.splitScreen; + consts->gDiffBlurRadius = settings.diffusePrepassBlurRadius; + consts->gSpecBlurRadius = settings.specularPrepassBlurRadius; + consts->gDepthThreshold = settings.depthThreshold; + consts->gDiffLobeAngleFraction = settings.diffuseLobeAngleFraction; + consts->gSpecLobeAngleFraction = settings.specularLobeAngleFraction; + consts->gSpecLobeAngleSlack = DegToRad(settings.specularLobeAngleSlack); + consts->gHistoryFixEdgeStoppingNormalPower = settings.historyFixEdgeStoppingNormalPower; + consts->gRoughnessEdgeStoppingRelaxation = settings.roughnessEdgeStoppingRelaxation; + consts->gNormalEdgeStoppingRelaxation = settings.normalEdgeStoppingRelaxation; + consts->gColorBoxSigmaScale = settings.historyClampingColorBoxSigmaScale; + consts->gHistoryAccelerationAmount = settings.antilagSettings.accelerationAmount; + consts->gHistoryResetTemporalSigmaScale = settings.antilagSettings.temporalSigmaScale; + consts->gHistoryResetSpatialSigmaScale = settings.antilagSettings.spatialSigmaScale; + consts->gHistoryResetAmount = settings.antilagSettings.resetAmount; + consts->gDenoisingRange = m_CommonSettings.denoisingRange; + consts->gSpecPhiLuminance = settings.specularPhiLuminance; + consts->gDiffPhiLuminance = settings.diffusePhiLuminance; + consts->gDiffMaxLuminanceRelativeDifference = maxDiffuseLuminanceRelativeDifference; + consts->gSpecMaxLuminanceRelativeDifference = maxSpecularLuminanceRelativeDifference; + consts->gLuminanceEdgeStoppingRelaxation = settings.roughnessEdgeStoppingRelaxation; + consts->gConfidenceDrivenRelaxationMultiplier = settings.confidenceDrivenRelaxationMultiplier; + consts->gConfidenceDrivenLuminanceEdgeStoppingRelaxation = settings.confidenceDrivenLuminanceEdgeStoppingRelaxation; + consts->gConfidenceDrivenNormalEdgeStoppingRelaxation = settings.confidenceDrivenNormalEdgeStoppingRelaxation; + consts->gDebug = m_CommonSettings.debug; + consts->gOrthoMode = m_OrthoMode; + consts->gUnproject = 1.0f / (0.5f * rectH * m_ProjectY); + consts->gFramerateScale = Clamp(16.66f / m_TimeDelta, 0.25f, 4.0f); // TODO: use m_FrameRateScale? + consts->gCheckerboardResolveAccumSpeed = m_CheckerboardResolveAccumSpeed; + consts->gJitterDelta = m_JitterDelta; + consts->gHistoryFixFrameNum = Min(settings.historyFixFrameNum, 3u) + 1.0f; + consts->gHistoryThreshold = (float)settings.spatialVarianceEstimationHistoryThreshold; + consts->gRoughnessEdgeStoppingEnabled = settings.enableRoughnessEdgeStopping ? 1 : 0; + consts->gFrameIndex = m_CommonSettings.frameIndex; + consts->gDiffCheckerboard = diffCheckerboard; + consts->gSpecCheckerboard = specCheckerboard; + consts->gUseConfidenceInputs = m_CommonSettings.isHistoryConfidenceAvailable ? 1 : 0; + consts->gUseDisocclusionThresholdMix = m_CommonSettings.isDisocclusionThresholdMixAvailable ? 1 : 0; + consts->gDiffMaterialMask = settings.enableMaterialTestForDiffuse ? 1 : 0; + consts->gSpecMaterialMask = settings.enableMaterialTestForSpecular ? 1 : 0; + consts->gResetHistory = m_CommonSettings.accumulationMode != AccumulationMode::CONTINUE ? 1 : 0; +} + +void nrd::InstanceImpl::Update_Relax(const DenoiserData& denoiserData) +{ + enum class Dispatch + { + CLASSIFY_TILES, + HITDIST_RECONSTRUCTION = CLASSIFY_TILES + RELAX_NO_PERMUTATIONS, + PREPASS = HITDIST_RECONSTRUCTION + RELAX_HITDIST_RECONSTRUCTION_PERMUTATION_NUM, + TEMPORAL_ACCUMULATION = PREPASS + RELAX_PREPASS_PERMUTATION_NUM, + HISTORY_FIX = TEMPORAL_ACCUMULATION + RELAX_TEMPORAL_ACCUMULATION_PERMUTATION_NUM, + HISTORY_CLAMPING = HISTORY_FIX + RELAX_NO_PERMUTATIONS, + COPY = HISTORY_CLAMPING + RELAX_NO_PERMUTATIONS, + ANTI_FIREFLY = COPY + RELAX_NO_PERMUTATIONS, + ATROUS = ANTI_FIREFLY + RELAX_NO_PERMUTATIONS, + SPLIT_SCREEN = ATROUS + RELAX_ATROUS_PERMUTATION_NUM * RELAX_ATROUS_BINDING_VARIANT_NUM, + VALIDATION = SPLIT_SCREEN + RELAX_NO_PERMUTATIONS, + }; + + NRD_DECLARE_DIMS; + + const RelaxSettings& settings = denoiserData.settings.relax; + bool enableHitDistanceReconstruction = settings.hitDistanceReconstructionMode != HitDistanceReconstructionMode::OFF && settings.checkerboardMode == CheckerboardMode::OFF; + uint32_t iterationNum = Clamp(settings.atrousIterationNum, 2u, RELAX_MAX_ATROUS_PASS_NUM); + + // SPLIT_SCREEN (passthrough) + if (m_CommonSettings.splitScreen >= 1.0f) + { + void* consts = PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); + AddSharedConstants_Relax(settings, consts); + + return; + } + + { // CLASSIFY_TILES + void* consts = PushDispatch(denoiserData, AsUint(Dispatch::CLASSIFY_TILES)); + AddSharedConstants_Relax(settings, consts); + } + + // HITDIST_RECONSTRUCTION + if (enableHitDistanceReconstruction) + { + bool is5x5 = settings.hitDistanceReconstructionMode == HitDistanceReconstructionMode::AREA_5X5; + uint32_t passIndex = AsUint(Dispatch::HITDIST_RECONSTRUCTION) + (is5x5 ? 1 : 0); + void* consts = PushDispatch(denoiserData, passIndex); + AddSharedConstants_Relax(settings, consts); + } + + { // PREPASS + uint32_t passIndex = AsUint(Dispatch::PREPASS) + (enableHitDistanceReconstruction ? 1 : 0); + RELAX_PrePassConstants* consts = (RELAX_PrePassConstants*)PushDispatch(denoiserData, passIndex); + AddSharedConstants_Relax(settings, consts); + consts->gRotator = m_Rotator_PrePass; // TODO: push constant + } + + { // TEMPORAL_ACCUMULATION + uint32_t passIndex = AsUint(Dispatch::TEMPORAL_ACCUMULATION) + (m_CommonSettings.isDisocclusionThresholdMixAvailable ? 2 : 0) + (m_CommonSettings.isHistoryConfidenceAvailable ? 1 : 0); + void* consts = PushDispatch(denoiserData, passIndex); + AddSharedConstants_Relax(settings, consts); + } + + { // HISTORY_FIX + void* consts = PushDispatch(denoiserData, AsUint(Dispatch::HISTORY_FIX)); + AddSharedConstants_Relax(settings, consts); + } + + { // HISTORY_CLAMPING + void* consts = PushDispatch(denoiserData, AsUint(Dispatch::HISTORY_CLAMPING)); + AddSharedConstants_Relax(settings, consts); + } + + if (settings.enableAntiFirefly) + { + { // COPY + void* consts = PushDispatch(denoiserData, AsUint(Dispatch::COPY)); + AddSharedConstants_Relax(settings, consts); + } + + { // ANTI_FIREFLY + void* consts = PushDispatch(denoiserData, AsUint(Dispatch::ANTI_FIREFLY)); + AddSharedConstants_Relax(settings, consts); + } + } + + // A-TROUS + for (uint32_t i = 0; i < iterationNum; i++) + { + uint32_t passIndex = AsUint(Dispatch::ATROUS) + (m_CommonSettings.isHistoryConfidenceAvailable ? RELAX_ATROUS_BINDING_VARIANT_NUM : 0); + if (i != 0) + passIndex += 2 - (i & 0x1); + if (i == iterationNum - 1) + passIndex += 2; + + RELAX_AtrousConstants* consts = (RELAX_AtrousConstants*)PushDispatch(denoiserData, AsUint(passIndex)); // TODO: same as "RELAX_AtrousSmemConstants" + AddSharedConstants_Relax(settings, consts); + consts->gStepSize = 1 << i; // TODO: push constants + consts->gIsLastPass = i == iterationNum - 1 ? 1 : 0; // TODO: push constants + } + + // SPLIT_SCREEN + if (m_CommonSettings.splitScreen > 0.0f) + { + void* consts = PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); + AddSharedConstants_Relax(settings, consts); + } + + // VALIDATION + if (m_CommonSettings.enableValidation) + { + void* consts = PushDispatch(denoiserData, AsUint(Dispatch::VALIDATION)); + AddSharedConstants_Relax(settings, consts); + } } // RELAX_SHARED #ifdef NRD_EMBEDS_DXBC_SHADERS #include "RELAX_ClassifyTiles.cs.dxbc.h" + #include "RELAX_Validation.cs.dxbc.h" #endif #ifdef NRD_EMBEDS_DXIL_SHADERS #include "RELAX_ClassifyTiles.cs.dxil.h" + #include "RELAX_Validation.cs.dxil.h" #endif #ifdef NRD_EMBEDS_SPIRV_SHADERS #include "RELAX_ClassifyTiles.cs.spirv.h" + #include "RELAX_Validation.cs.spirv.h" #endif // RELAX_DIFFUSE @@ -154,7 +313,6 @@ void nrd::InstanceImpl::AddSharedConstants_Relax(const DenoiserData& denoiserDat #include "RELAX_Diffuse_AtrousSmem.cs.dxbc.h" #include "RELAX_Diffuse_Atrous.cs.dxbc.h" #include "RELAX_Diffuse_SplitScreen.cs.dxbc.h" - #include "RELAX_Validation.cs.dxbc.h" #endif #ifdef NRD_EMBEDS_DXIL_SHADERS @@ -169,7 +327,6 @@ void nrd::InstanceImpl::AddSharedConstants_Relax(const DenoiserData& denoiserDat #include "RELAX_Diffuse_AtrousSmem.cs.dxil.h" #include "RELAX_Diffuse_Atrous.cs.dxil.h" #include "RELAX_Diffuse_SplitScreen.cs.dxil.h" - #include "RELAX_Validation.cs.dxil.h" #endif #ifdef NRD_EMBEDS_SPIRV_SHADERS @@ -184,7 +341,6 @@ void nrd::InstanceImpl::AddSharedConstants_Relax(const DenoiserData& denoiserDat #include "RELAX_Diffuse_AtrousSmem.cs.spirv.h" #include "RELAX_Diffuse_Atrous.cs.spirv.h" #include "RELAX_Diffuse_SplitScreen.cs.spirv.h" - #include "RELAX_Validation.cs.spirv.h" #endif #include "Denoisers/Relax_Diffuse.hpp" diff --git a/Source/Sigma.cpp b/Source/Sigma.cpp index faf6e6d..763e9df 100644 --- a/Source/Sigma.cpp +++ b/Source/Sigma.cpp @@ -10,22 +10,12 @@ license agreement from NVIDIA CORPORATION is strictly prohibited. #include "InstanceImpl.h" -#define SIGMA_SET_SHARED_CONSTANTS SetSharedConstants(1, 2, 8, 8) - -#define SIGMA_CLASSIFY_TILES_SET_CONSTANTS SumConstants(0, 0, 0, 0) -#define SIGMA_CLASSIFY_TILES_NUM_THREADS NumThreads(1, 1) - -#define SIGMA_SMOOTH_TILES_SET_CONSTANTS SumConstants(0, 0, 1, 0) -#define SIGMA_SMOOTH_TILES_NUM_THREADS NumThreads(16, 16) - -#define SIGMA_BLUR_SET_CONSTANTS SumConstants(1, 1, 0, 0) -#define SIGMA_BLUR_NUM_THREADS NumThreads(16, 16) - -#define SIGMA_TEMPORAL_STABILIZATION_SET_CONSTANTS SumConstants(2, 0, 0, 0) -#define SIGMA_TEMPORAL_STABILIZATION_NUM_THREADS NumThreads(16, 16) - -#define SIGMA_SPLIT_SCREEN_SET_CONSTANTS SumConstants(0, 0, 0, 1) -#define SIGMA_SPLIT_SCREEN_NUM_THREADS NumThreads(16, 16) +#include "../Shaders/Include/SIGMA_Config.hlsli" +#include "../Shaders/Resources/SIGMA_ClassifyTiles.resources.hlsli" +#include "../Shaders/Resources/SIGMA_SmoothTiles.resources.hlsli" +#include "../Shaders/Resources/SIGMA_Blur.resources.hlsli" +#include "../Shaders/Resources/SIGMA_TemporalStabilization.resources.hlsli" +#include "../Shaders/Resources/SIGMA_SplitScreen.resources.hlsli" void nrd::InstanceImpl::Update_SigmaShadow(const DenoiserData& denoiserData) { @@ -41,97 +31,88 @@ void nrd::InstanceImpl::Update_SigmaShadow(const DenoiserData& denoiserData) const SigmaSettings& settings = denoiserData.settings.sigma; - NRD_DECLARE_DIMS; - - uint16_t tilesW = DivideUp(rectW, 16); - uint16_t tilesH = DivideUp(rectH, 16); - // SPLIT_SCREEN (passthrough) if (m_CommonSettings.splitScreen >= 1.0f) { - Constant* data = PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); - AddSharedConstants_Sigma(denoiserData, settings, data); - AddFloat(data, m_CommonSettings.splitScreen); - ValidateConstants(data); + void* consts = PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); + AddSharedConstants_Sigma(settings, consts); return; } - // CLASSIFY_TILES - Constant* data = PushDispatch(denoiserData, AsUint(Dispatch::CLASSIFY_TILES)); - AddSharedConstants_Sigma(denoiserData, settings, data); - ValidateConstants(data); - - // SMOOTH_TILES - data = PushDispatch(denoiserData, AsUint(Dispatch::SMOOTH_TILES)); - AddSharedConstants_Sigma(denoiserData, settings, data); - AddUint2(data, tilesW - 1, tilesH - 1); - ValidateConstants(data); - - // BLUR - data = PushDispatch(denoiserData, AsUint(Dispatch::BLUR)); - AddSharedConstants_Sigma(denoiserData, settings, data); - AddFloat4x4(data, m_WorldToView); - AddFloat4(data, m_Rotator_Blur); - ValidateConstants(data); - - // POST_BLUR - data = PushDispatch(denoiserData, AsUint(Dispatch::POST_BLUR)); - AddSharedConstants_Sigma(denoiserData, settings, data); - AddFloat4x4(data, m_WorldToView); - AddFloat4(data, m_Rotator_PostBlur); - ValidateConstants(data); - - // TEMPORAL_STABILIZATION - data = PushDispatch(denoiserData, AsUint(Dispatch::TEMPORAL_STABILIZATION)); - AddSharedConstants_Sigma(denoiserData, settings, data); - AddFloat4x4(data, m_WorldToClipPrev); - AddFloat4x4(data, m_ViewToWorld); - ValidateConstants(data); + { // CLASSIFY_TILES + void* consts = PushDispatch(denoiserData, AsUint(Dispatch::CLASSIFY_TILES)); + AddSharedConstants_Sigma(settings, consts); + } + + { // SMOOTH_TILES + void* consts = PushDispatch(denoiserData, AsUint(Dispatch::SMOOTH_TILES)); + AddSharedConstants_Sigma(settings, consts); + } + + { // BLUR + SIGMA_BlurConstants* consts = (SIGMA_BlurConstants*)PushDispatch(denoiserData, AsUint(Dispatch::BLUR)); + AddSharedConstants_Sigma(settings, consts); + consts->gRotator = m_Rotator_Blur; // TODO: push constant + } + + { // POST_BLUR + SIGMA_BlurConstants* consts = (SIGMA_BlurConstants*)PushDispatch(denoiserData, AsUint(Dispatch::POST_BLUR)); + AddSharedConstants_Sigma(settings, consts); + consts->gRotator = m_Rotator_PostBlur; // TODO: push constant + } + + { // TEMPORAL_STABILIZATION + void* consts = PushDispatch(denoiserData, AsUint(Dispatch::TEMPORAL_STABILIZATION)); + AddSharedConstants_Sigma(settings, consts); + } // SPLIT_SCREEN if (m_CommonSettings.splitScreen > 0.0f) { - data = PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); - AddSharedConstants_Sigma(denoiserData, settings, data); - AddFloat(data, m_CommonSettings.splitScreen); - ValidateConstants(data); + void* consts = PushDispatch(denoiserData, AsUint(Dispatch::SPLIT_SCREEN)); + AddSharedConstants_Sigma(settings, consts); } } -void nrd::InstanceImpl::AddSharedConstants_Sigma(const DenoiserData& denoiserData, const SigmaSettings& settings, Constant*& data) +void nrd::InstanceImpl::AddSharedConstants_Sigma(const SigmaSettings& settings, void* data) { - NRD_DECLARE_DIMS; - - // Even with DRS keep radius, it works well for shadows - float unproject = 1.0f / (0.5f * screenH * m_ProjectY); - - AddFloat4x4(data, m_ViewToClip); - - AddFloat4(data, m_Frustum); - AddFloat4(data, ml::float4(m_CommonSettings.motionVectorScale[0], m_CommonSettings.motionVectorScale[1], m_CommonSettings.motionVectorScale[2], m_CommonSettings.debug)); - - AddFloat2(data, 1.0f / float(screenW), 1.0f / float(screenH)); - AddFloat2(data, float(screenW), float(screenH)); - - AddFloat2(data, 1.0f / float(rectW), 1.0f / float(rectH)); - AddFloat2(data, float(rectW), float(rectH)); - - AddFloat2(data, float(rectWprev), float(rectHprev)); - AddFloat2(data, float(rectW) / float(screenW), float(rectH) / float(screenH)); + struct SharedConstants + { + SIGMA_SHARED_CONSTANTS + }; - AddFloat2(data, float(m_CommonSettings.inputSubrectOrigin[0]) / float(screenW), float(m_CommonSettings.inputSubrectOrigin[1]) / float(screenH)); - AddUint2(data, m_CommonSettings.inputSubrectOrigin[0], m_CommonSettings.inputSubrectOrigin[1]); + NRD_DECLARE_DIMS; - AddFloat(data, m_IsOrtho); - AddFloat(data, unproject); - AddFloat(data, m_CommonSettings.denoisingRange); - AddFloat(data, settings.planeDistanceSensitivity); + float unproject = 1.0f / (0.5f * rectH * m_ProjectY); + uint16_t tilesW = DivideUp(rectW, 16); + uint16_t tilesH = DivideUp(rectH, 16); - AddFloat(data, settings.blurRadiusScale); - AddFloat(data, m_CommonSettings.accumulationMode != AccumulationMode::CONTINUE ? 0.0f : 1.0f); - AddUint(data, m_CommonSettings.isMotionVectorInWorldSpace ? 1 : 0); - AddUint(data, m_CommonSettings.frameIndex); + SharedConstants* consts = (SharedConstants*)data; + consts->gWorldToView = m_WorldToView; + consts->gViewToClip = m_ViewToClip; + consts->gWorldToClipPrev = m_WorldToClipPrev; + consts->gFrustum = m_Frustum; + consts->gMvScale = float4(m_CommonSettings.motionVectorScale[0], m_CommonSettings.motionVectorScale[1], m_CommonSettings.motionVectorScale[2], m_CommonSettings.isMotionVectorInWorldSpace ? 1.0f : 0.0f); + consts->gResourceSizeInv = float2(1.0f / float(resourceW), 1.0f / float(resourceH)); + consts->gResourceSizeInvPrev = float2(1.0f / float(resourceWprev), 1.0f / float(resourceHprev)); + consts->gRectSize = float2(float(rectW), float(rectH)); + consts->gRectSizeInv = float2(1.0f / float(rectW), 1.0f / float(rectH)); + consts->gRectSizePrev = float2(float(rectWprev), float(rectHprev)); + consts->gResolutionScale = float2(float(rectW) / float(resourceW), float(rectH) / float(resourceH)); + consts->gRectOffset = float2(float(m_CommonSettings.rectOrigin[0]) / float(resourceW), float(m_CommonSettings.rectOrigin[1]) / float(resourceH)); + consts->gRectOrigin = uint2(m_CommonSettings.rectOrigin[0], m_CommonSettings.rectOrigin[1]); + consts->gRectSizeMinusOne = int2(rectW - 1, rectH - 1); + consts->gTilesSizeMinusOne = int2(tilesW - 1, tilesH - 1); + consts->gOrthoMode = m_OrthoMode; + consts->gUnproject = unproject; + consts->gDenoisingRange = m_CommonSettings.denoisingRange; + consts->gPlaneDistSensitivity = settings.planeDistanceSensitivity; + consts->gBlurRadiusScale = settings.blurRadiusScale; + consts->gContinueAccumulation = m_CommonSettings.accumulationMode != AccumulationMode::CONTINUE ? 0.0f : 1.0f; + consts->gDebug = m_CommonSettings.debug; + consts->gSplitScreen = m_CommonSettings.splitScreen; + consts->gFrameIndex = m_CommonSettings.frameIndex; } // SIGMA_SHADOW diff --git a/Source/Wrapper.cpp b/Source/Wrapper.cpp index aae825c..f606cf9 100644 --- a/Source/Wrapper.cpp +++ b/Source/Wrapper.cpp @@ -75,7 +75,7 @@ const char* g_NrdResourceTypeNames[] = "IN_BASECOLOR_METALNESS", "IN_SHADOWDATA", "IN_SHADOW_TRANSLUCENCY", - "IN_RADIANCE", + "IN_SIGNAL", "IN_DELTA_PRIMARY_POS", "IN_DELTA_SECONDARY_POS", @@ -89,7 +89,7 @@ const char* g_NrdResourceTypeNames[] = "OUT_SPEC_HITDIST", "OUT_DIFF_DIRECTION_HITDIST", "OUT_SHADOW_TRANSLUCENCY", - "OUT_RADIANCE", + "OUT_SIGNAL", "OUT_REFLECTION_MV", "OUT_DELTA_MV", "OUT_VALIDATION", diff --git a/UPDATE.md b/UPDATE.md index 593a412..20fa088 100644 --- a/UPDATE.md +++ b/UPDATE.md @@ -183,3 +183,33 @@ A single NRD instance can now include any combination of denoisers, including re - Removed `enableReferenceAccumulation` - Introduced `usePrepassOnlyForSpecularMotionEstimation` - `AntilagIntensitySettings` and `AntilagHitDistanceSettings` replaced with simpler `ReblurAntilagSettings` + +## To v4.4 + +- *API*: + - `inputSubrectOrigin` => `rectOrigin` and clarified usage + - improved dynamic resolution scaling support: now not only viewport can be adjusted on the fly, but resources can be suballocated from a heap on the fly too + - removed `DenoiserDesc::renderWidth` and `DenoiserDesc::renderHeight` + - removed `CommonSettings::resolutionScale` and `CommonSettings::resolutionScalePrev` + - exposed `CommonSettings::resourceSize` and `CommonSettings::resourceSizePrev` + - exposed `CommonSettings::rectSize` and `CommonSettings::rectSizePrev` + - *NRD INTEGRATION*: currently statically allocates resources at NRD instance creation time + - all denoisers use resources without mips: + - removed `TextureDesc::mipNum` + - removed `ResourceDesc::mipNum` and `ResourceDesc::mipOffset` + - simplified number of samplers + - removed `Sampler::NEAREST_MIRRORED_REPEAT` and `Sampler::LINEAR_MIRRORED_REPEAT` +- *NRD.hlsli*: + - added `NRD_FrontEnd_SpecHitDistAveraging_X` functions, needed to properly average specular hit distance for correct specular tracking in case of many RPP + - `NRD_INPUT/OUTPUT_TEXTURE_START` renamed to `NRD_INPUTS/OUTPUTS_START` + - `NRD_INPUT/OUTPUT_TEXTURE` renamed to `NRD_INPUT/OUTPUT` + - `NRD_INPUT/OUTPUT_TEXTURE_END` renamed to `NRD_INPUTS/OUTPUTS_END` + - `NRD_SAMPLER_START/END` renamed to `NRD_SAMPLERS_START/END` +- *REBLUR*: + - removed `historyFixStrideBetweenSamples` +- *RELAX*: + - removed `historyFixStrideBetweenSamples` + - removed `enableReprojectionTestSkippingWithoutMotion` +- *REFERENCE*: + - `IN_RADIANCE` renamed to `IN_SIGNAL` + - `OUT_RADIANCE` renamed to `OUT_SIGNAL`