From f39097a73fc8560a50f848290ce4c5a235b68cac Mon Sep 17 00:00:00 2001 From: mob-sakai <12690315+mob-sakai@users.noreply.github.com> Date: Wed, 11 Dec 2024 19:39:44 +0900 Subject: [PATCH] fix: fix TextMeshPro shader (underlay and bevel) --- .../Hidden-TMP_SDF-UIEffect-Unity6.shader | 14 ++------------ .../Hidden-TMP_SDF-UIEffect.shader | 5 ++--- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/Packages/src/Samples~/TextMeshPro Support (Unity 6)~/Hidden-TMP_SDF-UIEffect-Unity6.shader b/Packages/src/Samples~/TextMeshPro Support (Unity 6)~/Hidden-TMP_SDF-UIEffect-Unity6.shader index bd669b03..8a18653c 100755 --- a/Packages/src/Samples~/TextMeshPro Support (Unity 6)~/Hidden-TMP_SDF-UIEffect-Unity6.shader +++ b/Packages/src/Samples~/TextMeshPro Support (Unity 6)~/Hidden-TMP_SDF-UIEffect-Unity6.shader @@ -275,7 +275,7 @@ SubShader { float c = tex2D(_MainTex, input.atlas + uvMove).a; #ifndef UNDERLAY_ON - clip(c - input.param.x); + c *= step(input.param.x, c); #endif float scale = input.param.y; @@ -298,7 +298,7 @@ SubShader { #if BEVEL_ON float3 dxy = float3(0.5 / _TextureWidth, 0.5 / _TextureHeight, 0); - float3 n = GetSurfaceNormal(input.atlas, weight, dxy); + float3 n = GetSurfaceNormal(input.atlas + uvMove, weight, dxy); float3 bump = UnpackNormal(tex2D(_BumpMap, input.textures.xy + float2(_FaceUVSpeedX, _FaceUVSpeedY) * _Time.y)).xyz; bump *= lerp(_BumpFace, _BumpOutline, saturate(sd + outline * 0.5)); @@ -330,16 +330,6 @@ SubShader { faceColor.rgb += glowColor.rgb * glowColor.a; #endif - // Alternative implementation to UnityGet2DClipping with support for softness. - #if UNITY_UI_CLIP_RECT - half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * input.mask.zw); - faceColor *= m.x * m.y; - #endif - - #if UNITY_UI_ALPHACLIP - clip(faceColor.a - 0.001); - #endif - return faceColor * input.color.a; } #define UIEFFECT_TEXTMESHPRO 1 diff --git a/Packages/src/Samples~/TextMeshPro Support~/Hidden-TMP_SDF-UIEffect.shader b/Packages/src/Samples~/TextMeshPro Support~/Hidden-TMP_SDF-UIEffect.shader index 180e5b06..9bcef2fa 100644 --- a/Packages/src/Samples~/TextMeshPro Support~/Hidden-TMP_SDF-UIEffect.shader +++ b/Packages/src/Samples~/TextMeshPro Support~/Hidden-TMP_SDF-UIEffect.shader @@ -267,8 +267,7 @@ SubShader { float c = tex2D(_MainTex, input.atlas + uvMove).a; #ifndef UNDERLAY_ON - if (c - input.param.x < 0) - return fixed4(0,0,0,0); + c *= step(input.param.x, c); #endif float scale = input.param.y; @@ -291,7 +290,7 @@ SubShader { #if BEVEL_ON float3 dxy = float3(0.5 / _TextureWidth, 0.5 / _TextureHeight, 0); - float3 n = GetSurfaceNormal(input.atlas, weight, dxy); + float3 n = GetSurfaceNormal(input.atlas + uvMove, weight, dxy); float3 bump = UnpackNormal(tex2D(_BumpMap, input.textures.xy + float2(_FaceUVSpeedX, _FaceUVSpeedY) * _Time.y)).xyz; bump *= lerp(_BumpFace, _BumpOutline, saturate(sd + outline * 0.5));