From eb7bb211ab741b90de1350979ae5b3c0b660d18d Mon Sep 17 00:00:00 2001 From: drewcassidy Date: Sat, 26 Sep 2020 19:39:44 -0700 Subject: [PATCH] Fix bounds antialiasing on text Previously the gradient was being calculated before taking the boundaries into account, resulting in the edges being too hard or too soft --- Assets/Shaders/TextDecal.cginc | 4 ++-- GameData/ConformalDecals/Resources/conformaldecals.shab | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Assets/Shaders/TextDecal.cginc b/Assets/Shaders/TextDecal.cginc index 80be3cf..f8d6e6d 100644 --- a/Assets/Shaders/TextDecal.cginc +++ b/Assets/Shaders/TextDecal.cginc @@ -6,7 +6,6 @@ float _OutlineWidth; void surf(DecalSurfaceInput IN, inout SurfaceOutput o) { float4 color = _DecalColor; float dist = _Cutoff - tex2D(_Decal, IN.uv_decal).r; // text distance - float ddist = SDFdDist(dist); // distance gradient magnitude #ifdef DECAL_OUTLINE // Outline @@ -16,7 +15,7 @@ void surf(DecalSurfaceInput IN, inout SurfaceOutput o) { #ifdef DECAL_FILL // Outline and Fill float outlineDist = -dist - outlineOffset; - float outlineFactor = SDFAA(outlineDist, ddist); + float outlineFactor = SDFAA(outlineDist); dist -= outlineOffset; color = lerp(_DecalColor, _OutlineColor, outlineFactor); #else @@ -28,6 +27,7 @@ void surf(DecalSurfaceInput IN, inout SurfaceOutput o) { #endif dist = max(dist, BoundsDist(IN.uv, IN.vertex_normal, _DecalNormal)); + float ddist = SDFdDist(dist); // distance gradient magnitude o.Alpha = _DecalOpacity * SDFAA(dist, ddist); o.Albedo = UnderwaterFog(IN.worldPosition, color).rgb; diff --git a/GameData/ConformalDecals/Resources/conformaldecals.shab b/GameData/ConformalDecals/Resources/conformaldecals.shab index 3bc4a26..76f4bfd 100644 --- a/GameData/ConformalDecals/Resources/conformaldecals.shab +++ b/GameData/ConformalDecals/Resources/conformaldecals.shab @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4b9f1df541672d2c5aa8b7900bbba84d7845a72104b08e7be776c65fcf698f8f -size 888707 +oid sha256:92429ce733ae3a02250d831b6d1ebbcef733467be87f1ef10604964374d8b6f7 +size 890502