1818Shader "Graphics Tools/Text Mesh Pro" {
1919
2020Properties {
21- [ HDR ] _FaceColor ( "Face Color" , Color ) = (1 ,1 ,1 ,1 )
21+ _FaceColor ( "Face Color" , Color ) = (1 ,1 ,1 ,1 )
2222 _FaceDilate ( "Face Dilate" , Range (-1 ,1 )) = 0
2323
24- [ HDR ] _OutlineColor ( "Outline Color" , Color ) = (0 ,0 ,0 ,1 )
24+ _OutlineColor ( "Outline Color" , Color ) = (0 ,0 ,0 ,1 )
2525 _OutlineWidth ( "Outline Thickness" , Range (0 ,1 )) = 0
2626 _OutlineSoftness ( "Outline Softness" , Range (0 ,1 )) = 0
2727
28- [ HDR ] _UnderlayColor ( "Border Color" , Color ) = (0 ,0 ,0 ,.5 )
28+ _UnderlayColor ( "Border Color" , Color ) = (0 ,0 ,0 ,.5 )
2929 _UnderlayOffsetX ( "Border OffsetX" , Range (-1 ,1 )) = 0
3030 _UnderlayOffsetY ( "Border OffsetY" , Range (-1 ,1 )) = 0
3131 _UnderlayDilate ( "Border Dilate" , Range (-1 ,1 )) = 0
@@ -217,7 +217,11 @@ CBUFFER_END
217217 float4 vertex : POSITION ;
218218 float3 normal : NORMAL ;
219219 fixed4 color : COLOR ;
220+ #if UNITY_VERSION >= 202300 // Unity 6 (2023)+
221+ float4 texcoord0 : TEXCOORD0 ;
222+ #else
220223 float2 texcoord0 : TEXCOORD0 ;
224+ #endif
221225 float2 texcoord1 : TEXCOORD1 ;
222226 };
223227
@@ -239,6 +243,11 @@ CBUFFER_END
239243#endif
240244 };
241245
246+ #if UNITY_VERSION >= 202300 // Unity 6 (2023)+
247+ float _UIMaskSoftnessX;
248+ float _UIMaskSoftnessY;
249+ int _UIVertexColorAlwaysGammaSpace;
250+ #endif
242251
243252 pixel_t VertShader (vertex_t input)
244253 {
@@ -249,7 +258,11 @@ CBUFFER_END
249258 UNITY_TRANSFER_INSTANCE_ID (input, output);
250259 UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO (output);
251260
261+ #if UNITY_VERSION >= 202300 // Unity 6 (2023)+
262+ float bold = step (input.texcoord0.w, 0 );
263+ #else
252264 float bold = step (input.texcoord1.y, 0 );
265+ #endif
253266
254267 float4 vert = input.vertex;
255268 vert.x += _VertexOffsetX;
@@ -260,7 +273,11 @@ CBUFFER_END
260273 pixelSize /= float2 (_ScaleX, _ScaleY) * abs (mul ((float2x2 )UNITY_MATRIX_P , _ScreenParams .xy));
261274
262275 float scale = rsqrt (dot (pixelSize, pixelSize));
276+ #if UNITY_VERSION >= 202300 // Unity 6 (2023)+
277+ scale *= abs (input.texcoord0.w) * _GradientScale * (_Sharpness + 1 );
278+ #else
263279 scale *= abs (input.texcoord1.y) * _GradientScale * (_Sharpness + 1 );
280+ #endif
264281 if (UNITY_MATRIX_P [3 ][3 ] == 0 ) scale = lerp (abs (scale) * (1 - _PerspectiveFilter), scale, abs (dot (UnityObjectToWorldNormal (input.normal.xyz), normalize (WorldSpaceViewDir (vert)))));
265282
266283 float weight = lerp (_WeightNormal, _WeightBold, bold) / 4.0 ;
@@ -272,6 +289,12 @@ CBUFFER_END
272289 float bias = (0.5 - weight) * scale - 0.5 ;
273290 float outline = _OutlineWidth * _ScaleRatioA * 0.5 * scale;
274291
292+ #if UNITY_VERSION >= 202300 // Unity 6 (2023)+
293+ if (_UIVertexColorAlwaysGammaSpace && !IsGammaSpace ())
294+ {
295+ input.color.rgb = UIGammaToLinear (input.color.rgb);
296+ }
297+ #endif
275298 float opacity = input.color.a;
276299 #if (UNDERLAY_ON | UNDERLAY_INNER)
277300 opacity = 1.0 ;
@@ -312,7 +335,13 @@ CBUFFER_END
312335 output.outlineColor = outlineColor;
313336 output.texcoord0 = float4 (input.texcoord0.x, input.texcoord0.y, maskUV.x, maskUV.y);
314337 output.param = half4 (scale, bias - outline, bias + outline, bias);
315- output.mask = vert;//half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy));
338+ output.mask = vert;
339+ // #if UNITY_VERSION >= 202300 // Unity 6 (2023)+
340+ // const half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
341+ // output.mask = half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * maskSoftness + pixelSize.xy));
342+ // #else
343+ // output.mask = half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy));
344+ // #endif
316345 #if (UNDERLAY_ON || UNDERLAY_INNER)
317346 output.texcoord1 = float4 (input.texcoord0 + layerOffset, input.color.a, 0 );
318347 output.underlayParam = half2 (layerScale, layerBias);
0 commit comments