OverlayCustom.shader 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. Shader "ZED/UI/OverlayCustom"
  2. {
  3. Properties
  4. {
  5. [PerRendererData] _MainTex("Font 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. _ColorMask("Color Mask", Float) = 15
  13. [MaterialToggle] _OverrideColor("Override color", Int) = 0
  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. Blend SrcAlpha OneMinusSrcAlpha
  39. ColorMask[_ColorMask]
  40. Pass
  41. {
  42. CGPROGRAM
  43. #pragma vertex vert
  44. #pragma fragment frag
  45. #include "UnityCG.cginc"
  46. #include "UnityUI.cginc"
  47. struct appdata_t
  48. {
  49. float4 vertex : POSITION;
  50. float2 texcoord : TEXCOORD0;
  51. float4 color : COLOR;
  52. };
  53. struct v2f
  54. {
  55. float4 vertex : SV_POSITION;
  56. half2 texcoord : TEXCOORD0;
  57. fixed4 color : COLOR;
  58. };
  59. sampler2D _MainTex;
  60. float4 _MainTex_ST;
  61. fixed4 _Color;
  62. fixed4 _TextureSampleAdd;
  63. int _OverrideColor;
  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. half4 color = (tex2D(_MainTex, i.texcoord) + _TextureSampleAdd) * i.color;
  78. if (_OverrideColor == 1) color.rgb = _Color;
  79. clip(color.a - 0.01);
  80. return color;
  81. }
  82. ENDCG
  83. }
  84. }
  85. }