UIShader.shader 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "UI/Overlay"
  3. {
  4. Properties
  5. {
  6. [PerRendererData] _MainTex("Font Texture", 2D) = "white" {}
  7. _Color("Tint", Color) = (1,1,1,1)
  8. _StencilComp("Stencil Comparison", Float) = 8
  9. _Stencil("Stencil ID", Float) = 0
  10. _StencilOp("Stencil Operation", Float) = 0
  11. _StencilWriteMask("Stencil Write Mask", Float) = 255
  12. _StencilReadMask("Stencil Read Mask", Float) = 255
  13. _ColorMask("Color Mask", Float) = 15
  14. }
  15. SubShader
  16. {
  17. LOD 100
  18. Tags
  19. {
  20. "Queue" = "Transparent"
  21. "IgnoreProjector" = "True"
  22. "RenderType" = "Transparent"
  23. "PreviewType" = "Plane"
  24. "CanUseSpriteAtlas" = "True"
  25. }
  26. Stencil
  27. {
  28. Ref[_Stencil]
  29. Comp[_StencilComp]
  30. Pass[_StencilOp]
  31. ReadMask[_StencilReadMask]
  32. WriteMask[_StencilWriteMask]
  33. }
  34. Cull Off
  35. Lighting Off
  36. ZWrite Off
  37. ZTest Always
  38. Offset -1, -1
  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. struct appdata_t
  49. {
  50. float4 vertex : POSITION;
  51. float2 texcoord : TEXCOORD0;
  52. float4 color : COLOR;
  53. };
  54. struct v2f
  55. {
  56. float4 vertex : SV_POSITION;
  57. half2 texcoord : TEXCOORD0;
  58. fixed4 color : COLOR;
  59. };
  60. sampler2D _MainTex;
  61. float4 _MainTex_ST;
  62. fixed4 _Color;
  63. fixed4 _TextureSampleAdd;
  64. v2f vert(appdata_t v)
  65. {
  66. v2f o;
  67. o.vertex = UnityObjectToClipPos(v.vertex);
  68. o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
  69. o.color = v.color * _Color;
  70. #ifdef UNITY_HALF_TEXEL_OFFSET
  71. o.vertex.xy += (_ScreenParams.zw - 1.0)*float2(-1,1);
  72. #endif
  73. return o;
  74. }
  75. fixed4 frag(v2f i) : SV_Target
  76. {
  77. fixed4 col = (tex2D(_MainTex, i.texcoord) + _TextureSampleAdd) * i.color;
  78. clip(col.a - 0.01);
  79. return col;
  80. }
  81. ENDCG
  82. }
  83. }
  84. }