From 72609cb796a1ddf4e74ed4d8e8edb33d8794cdf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tur=C3=A1nszki=20J=C3=A1nos?= Date: Sat, 18 Feb 2023 17:43:09 +0100 Subject: [PATCH] shadow border shrink: using clamping instead of pulling uvs --- WickedEngine/shaders/shadowHF.hlsli | 6 ++---- WickedEngine/wiVersion.cpp | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/WickedEngine/shaders/shadowHF.hlsli b/WickedEngine/shaders/shadowHF.hlsli index 94ed0ab55..55f01fb46 100644 --- a/WickedEngine/shaders/shadowHF.hlsli +++ b/WickedEngine/shaders/shadowHF.hlsli @@ -42,7 +42,7 @@ inline float3 sample_shadow(float2 uv, float cmp) return shadow; } -// This is used to pull the uvs to the center to avoid sampling on the border and overfiltering into a different shadow +// This is used to clamp the uvs to last texel center to avoid sampling on the border and overfiltering into a different shadow inline void shadow_border_shrink(in ShaderEntity light, inout float2 shadow_uv) { const float2 shadow_resolution = light.shadowAtlasMulAdd.xy * GetFrame().shadow_atlas_resolution; @@ -51,9 +51,7 @@ inline void shadow_border_shrink(in ShaderEntity light, inout float2 shadow_uv) #else const float border_size = 1.5; #endif // DISABLE_SOFT_SHADOWMAP - shadow_uv *= shadow_resolution - border_size * 2; - shadow_uv += border_size; - shadow_uv /= shadow_resolution; + shadow_uv = clamp(shadow_uv * shadow_resolution, border_size, shadow_resolution - border_size) / shadow_resolution; } inline float3 shadow_2D(in ShaderEntity light, in float3 shadow_pos, in float2 shadow_uv, in uint cascade) diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 5bd90c2bb..65ebe63f0 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wi::version // minor features, major updates, breaking compatibility changes const int minor = 71; // minor bug fixes, alterations, refactors, updates - const int revision = 155; + const int revision = 156; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);