diff --git a/Assets/Shaders/TextDecal.cginc b/Assets/Shaders/TextDecal.cginc index 9bc38d8..073cd3d 100644 --- a/Assets/Shaders/TextDecal.cginc +++ b/Assets/Shaders/TextDecal.cginc @@ -6,22 +6,32 @@ float _OutlineWidth; void surf(DecalSurfaceInput IN, inout SurfaceOutput o) { float4 color = _DecalColor; - float bias = _Cutoff - (_Weight / 4); - #ifdef DECAL_OUTLINE - bias -= _OutlineWidth * 0.25; - #endif - float dist = bias - tex2D(_Decal, IN.uv_decal).r; - float ddist = SDFdDist(dist); + float dist = bias - tex2D(_Decal, IN.uv_decal).r; // text distance + float ddist = SDFdDist(dist); // distance gradient magnitude #ifdef DECAL_OUTLINE - float outlineDist = (_OutlineWidth * 0.5) + dist; - float outline = SDFAA(outlineDist, -ddist); - color = lerp(color, _OutlineColor, outline); + // Outline + float outlineOffset = _OutlineWidth * 0.25; + float outlineRadius = _OutlineWidth * 0.5; + + #ifdef DECAL_FILL + // Outline and Fill + float outlineDist = -dist - outlineOffset; + float outlineFactor = SDFAA(outlineDist, ddist); + dist -= outlineOffset; + color = lerp(_DecalColor, _OutlineColor, outlineFactor); + #else + // Outline Only + float outlineDist = abs(dist) - outlineOffset; + dist = outlineDist; + color = _OutlineColor; + #endif #endif - + + dist = max(dist, BoundsDist(IN.uv, IN.vertex_normal, _DecalNormal)); + o.Alpha = _DecalOpacity * SDFAA(dist, ddist); o.Albedo = UnderwaterFog(IN.worldPosition, color).rgb; - o.Alpha = _DecalOpacity * SDFAA(dist, ddist); #ifdef DECAL_BASE_NORMAL float3 normal = IN.normal; diff --git a/Assets/Shaders/TextDecal.shader b/Assets/Shaders/TextDecal.shader index 4939898..3ac8933 100644 --- a/Assets/Shaders/TextDecal.shader +++ b/Assets/Shaders/TextDecal.shader @@ -3,6 +3,7 @@ Properties { [Header(Decal)] + [Toggle(DECAL_FILL)] _Fill ("Fill", int) = 0 _Decal("Decal Texture", 2D) = "gray" {} _DecalColor("Decal Color", Color) = (1,1,1,1) @@ -64,6 +65,7 @@ #pragma multi_compile_local __ DECAL_BASE_NORMAL #pragma multi_compile_local __ DECAL_SPECMAP #pragma multi_compile_local __ DECAL_OUTLINE + #pragma multi_compile_local __ DECAL_FILL #include "UnityCG.cginc" #include "DecalsCommon.cginc" @@ -93,6 +95,7 @@ #pragma multi_compile_local __ DECAL_BASE_NORMAL #pragma multi_compile_local __ DECAL_SPECMAP #pragma multi_compile_local __ DECAL_OUTLINE + #pragma multi_compile_local __ DECAL_FILL #include "UnityCG.cginc" #include "DecalsCommon.cginc" diff --git a/GameData/ConformalDecals/Resources/conformaldecals.shab b/GameData/ConformalDecals/Resources/conformaldecals.shab index 30fa933..e42033e 100644 Binary files a/GameData/ConformalDecals/Resources/conformaldecals.shab and b/GameData/ConformalDecals/Resources/conformaldecals.shab differ