Global Game Jam 2021
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
2.3 KiB

  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. }