From 685d0dae923f69cfaf9cc2b36ad3c4b91028e4a2 Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Sat, 2 Jul 2022 19:37:16 +0200 Subject: [PATCH] Use more lenient KSep for non-inverted depth. Getting some false depth clip values otherwise. --- src/ffx-fsr2-api/shaders/ffx_fsr2_depth_clip.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ffx-fsr2-api/shaders/ffx_fsr2_depth_clip.h b/src/ffx-fsr2-api/shaders/ffx_fsr2_depth_clip.h index b44cc59..eb20236 100644 --- a/src/ffx-fsr2-api/shaders/ffx_fsr2_depth_clip.h +++ b/src/ffx-fsr2-api/shaders/ffx_fsr2_depth_clip.h @@ -31,8 +31,12 @@ FfxFloat32 ComputeSampleDepthClip(FFX_MIN16_I2 iPxSamplePos, FfxFloat32 fPreviou const FfxFloat32 fHalfViewportWidth = RenderSize().x * 0.5f; FfxFloat32 fDepthThreshold = ffxMin(fCurrentDepthViewSpace, fPrevNearestDepthViewSpace); +#if !FFX_FSR2_OPTION_INVERTED_DEPTH + const FfxFloat32 Ksep = 4.0f * 1.37e-05f; // Arbitrary hack to make normal depth work better. +#else // WARNING: Ksep only works with reversed-z with infinite projection. const FfxFloat32 Ksep = 1.37e-05f; +#endif FfxFloat32 fRequiredDepthSeparation = Ksep * fDepthThreshold * TanHalfFoV() * fHalfViewportWidth; FfxFloat32 fDepthDiff = fCurrentDepthViewSpace - fPrevNearestDepthViewSpace;