Global Game Jam 2022
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.

116 lines
2.6 KiB

  1. Shader "TextMeshPro/Sprite"
  2. {
  3. Properties
  4. {
  5. [PerRendererData] _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. Name "Default"
  44. CGPROGRAM
  45. #pragma vertex vert
  46. #pragma fragment frag
  47. #pragma target 2.0
  48. #include "UnityCG.cginc"
  49. #include "UnityUI.cginc"
  50. #pragma multi_compile __ UNITY_UI_CLIP_RECT
  51. #pragma multi_compile __ UNITY_UI_ALPHACLIP
  52. struct appdata_t
  53. {
  54. float4 vertex : POSITION;
  55. float4 color : COLOR;
  56. float2 texcoord : TEXCOORD0;
  57. UNITY_VERTEX_INPUT_INSTANCE_ID
  58. };
  59. struct v2f
  60. {
  61. float4 vertex : SV_POSITION;
  62. fixed4 color : COLOR;
  63. float2 texcoord : TEXCOORD0;
  64. float4 worldPosition : TEXCOORD1;
  65. UNITY_VERTEX_OUTPUT_STEREO
  66. };
  67. sampler2D _MainTex;
  68. fixed4 _Color;
  69. fixed4 _TextureSampleAdd;
  70. float4 _ClipRect;
  71. float4 _MainTex_ST;
  72. v2f vert(appdata_t v)
  73. {
  74. v2f OUT;
  75. UNITY_SETUP_INSTANCE_ID(v);
  76. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
  77. OUT.worldPosition = v.vertex;
  78. OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
  79. OUT.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
  80. OUT.color = v.color * _Color;
  81. return OUT;
  82. }
  83. fixed4 frag(v2f IN) : SV_Target
  84. {
  85. half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
  86. #ifdef UNITY_UI_CLIP_RECT
  87. color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
  88. #endif
  89. #ifdef UNITY_UI_ALPHACLIP
  90. clip (color.a - 0.001);
  91. #endif
  92. return color;
  93. }
  94. ENDCG
  95. }
  96. }
  97. }