From 0d2a38eb2aba46422b067484c6ebb9fc0c3ced11 Mon Sep 17 00:00:00 2001 From: Sultim Tsyrendashiev Date: Fri, 23 Feb 2024 00:00:37 +0000 Subject: [PATCH] Sanitize unreliable interpolated normals, produced by a game -- if the perfect reflection over the interpolated normal would point into the surface: correct the normal, so the reflected direction points mostly coplanar to a normal plane. This fixes POM, where it was more pronounced. --- .../shaders/rtx/concept/surface/surface_interaction.slangh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dxvk/shaders/rtx/concept/surface/surface_interaction.slangh b/src/dxvk/shaders/rtx/concept/surface/surface_interaction.slangh index d2b3b6dd2..96dd0ad9b 100644 --- a/src/dxvk/shaders/rtx/concept/surface/surface_interaction.slangh +++ b/src/dxvk/shaders/rtx/concept/surface/surface_interaction.slangh @@ -330,8 +330,8 @@ SurfaceInteraction surfaceInteractionCreate( // Really the only reason to flip this normal is for double-sided geometry. Do not flip based on view vector! const bool interpolatedNormalSameDirection = dot(interpolatedNormal, flippedTriangleNormal) >= float16_t(0.0); const f16vec3 flippedInterpolatedNormal = interpolatedNormalSameDirection ? interpolatedNormal : -interpolatedNormal; - - surfaceInteraction.interpolatedNormal = flippedInterpolatedNormal; + + surfaceInteraction.interpolatedNormal = getBentNormal(surfaceInteraction.triangleNormal, flippedInterpolatedNormal, ray.direction); } // Compute motion