2
0

TMP_Sprite.shader 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. Shader "TextMeshPro/Sprite"
  2. {
  3. Properties
  4. {
  5. _MainTex ("Sprite Texture", 2D) = "white" {}
  6. _Color ("Tint", Color) = (1,1,1,1)
  7. _StencilComp ("Stencil Comparison", Float) = 8
  8. _Stencil ("Stencil ID", Float) = 0
  9. _StencilOp ("Stencil Operation", Float) = 0
  10. _StencilWriteMask ("Stencil Write Mask", Float) = 255
  11. _StencilReadMask ("Stencil Read Mask", Float) = 255
  12. _CullMode ("Cull Mode", Float) = 0
  13. _ColorMask ("Color Mask", Float) = 15
  14. _ClipRect ("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
  15. [Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
  16. }
  17. SubShader
  18. {
  19. Tags
  20. {
  21. "Queue"="Transparent"
  22. "IgnoreProjector"="True"
  23. "RenderType"="Transparent"
  24. "PreviewType"="Plane"
  25. "CanUseSpriteAtlas"="True"
  26. }
  27. Stencil
  28. {
  29. Ref [_Stencil]
  30. Comp [_StencilComp]
  31. Pass [_StencilOp]
  32. ReadMask [_StencilReadMask]
  33. WriteMask [_StencilWriteMask]
  34. }
  35. Cull [_CullMode]
  36. Lighting Off
  37. ZWrite Off
  38. ZTest [unity_GUIZTestMode]
  39. Blend SrcAlpha OneMinusSrcAlpha
  40. ColorMask [_ColorMask]
  41. Pass
  42. {
  43. CGPROGRAM
  44. #pragma vertex vert
  45. #pragma fragment frag
  46. #include "UnityCG.cginc"
  47. #include "UnityUI.cginc"
  48. #pragma multi_compile __ UNITY_UI_CLIP_RECT
  49. #pragma multi_compile __ UNITY_UI_ALPHACLIP
  50. struct appdata_t
  51. {
  52. float4 vertex : POSITION;
  53. float4 color : COLOR;
  54. float2 texcoord : TEXCOORD0;
  55. };
  56. struct v2f
  57. {
  58. float4 vertex : SV_POSITION;
  59. fixed4 color : COLOR;
  60. half2 texcoord : TEXCOORD0;
  61. float4 worldPosition : TEXCOORD1;
  62. };
  63. fixed4 _Color;
  64. fixed4 _TextureSampleAdd;
  65. float4 _ClipRect;
  66. v2f vert(appdata_t IN)
  67. {
  68. v2f OUT;
  69. OUT.worldPosition = IN.vertex;
  70. OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
  71. OUT.texcoord = IN.texcoord;
  72. #ifdef UNITY_HALF_TEXEL_OFFSET
  73. OUT.vertex.xy += (_ScreenParams.zw-1.0)*float2(-1,1);
  74. #endif
  75. OUT.color = IN.color * _Color;
  76. return OUT;
  77. }
  78. sampler2D _MainTex;
  79. fixed4 frag(v2f IN) : SV_Target
  80. {
  81. half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
  82. #if UNITY_UI_CLIP_RECT
  83. color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
  84. #endif
  85. #ifdef UNITY_UI_ALPHACLIP
  86. clip (color.a - 0.001);
  87. #endif
  88. return color;
  89. }
  90. ENDCG
  91. }
  92. }
  93. }