Skip to content

Commit

Permalink
fix: fix TextMeshPro shader (underlay and bevel)
Browse files Browse the repository at this point in the history
  • Loading branch information
mob-sakai committed Dec 14, 2024
1 parent c893cb0 commit f39097a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
Expand Down

0 comments on commit f39097a

Please sign in to comment.