Skip to content

Commit f39097a

Browse files
committed
fix: fix TextMeshPro shader (underlay and bevel)
1 parent c893cb0 commit f39097a

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

Packages/src/Samples~/TextMeshPro Support (Unity 6)~/Hidden-TMP_SDF-UIEffect-Unity6.shader

+2-12
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ SubShader {
275275
float c = tex2D(_MainTex, input.atlas + uvMove).a;
276276

277277
#ifndef UNDERLAY_ON
278-
clip(c - input.param.x);
278+
c *= step(input.param.x, c);
279279
#endif
280280

281281
float scale = input.param.y;
@@ -298,7 +298,7 @@ SubShader {
298298

299299
#if BEVEL_ON
300300
float3 dxy = float3(0.5 / _TextureWidth, 0.5 / _TextureHeight, 0);
301-
float3 n = GetSurfaceNormal(input.atlas, weight, dxy);
301+
float3 n = GetSurfaceNormal(input.atlas + uvMove, weight, dxy);
302302

303303
float3 bump = UnpackNormal(tex2D(_BumpMap, input.textures.xy + float2(_FaceUVSpeedX, _FaceUVSpeedY) * _Time.y)).xyz;
304304
bump *= lerp(_BumpFace, _BumpOutline, saturate(sd + outline * 0.5));
@@ -330,16 +330,6 @@ SubShader {
330330
faceColor.rgb += glowColor.rgb * glowColor.a;
331331
#endif
332332

333-
// Alternative implementation to UnityGet2DClipping with support for softness.
334-
#if UNITY_UI_CLIP_RECT
335-
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * input.mask.zw);
336-
faceColor *= m.x * m.y;
337-
#endif
338-
339-
#if UNITY_UI_ALPHACLIP
340-
clip(faceColor.a - 0.001);
341-
#endif
342-
343333
return faceColor * input.color.a;
344334
}
345335
#define UIEFFECT_TEXTMESHPRO 1

Packages/src/Samples~/TextMeshPro Support~/Hidden-TMP_SDF-UIEffect.shader

+2-3
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,7 @@ SubShader {
267267
float c = tex2D(_MainTex, input.atlas + uvMove).a;
268268

269269
#ifndef UNDERLAY_ON
270-
if (c - input.param.x < 0)
271-
return fixed4(0,0,0,0);
270+
c *= step(input.param.x, c);
272271
#endif
273272

274273
float scale = input.param.y;
@@ -291,7 +290,7 @@ SubShader {
291290

292291
#if BEVEL_ON
293292
float3 dxy = float3(0.5 / _TextureWidth, 0.5 / _TextureHeight, 0);
294-
float3 n = GetSurfaceNormal(input.atlas, weight, dxy);
293+
float3 n = GetSurfaceNormal(input.atlas + uvMove, weight, dxy);
295294

296295
float3 bump = UnpackNormal(tex2D(_BumpMap, input.textures.xy + float2(_FaceUVSpeedX, _FaceUVSpeedY) * _Time.y)).xyz;
297296
bump *= lerp(_BumpFace, _BumpOutline, saturate(sd + outline * 0.5));

0 commit comments

Comments
 (0)