UIOverlay.shader 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. Shader "NAR/UIOverlay"
  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. }
  14. SubShader
  15. {
  16. LOD 100
  17. Tags
  18. {
  19. "Queue" = "Transparent"
  20. "IgnoreProjector" = "True"
  21. "RenderType" = "Transparent"
  22. "PreviewType"="Plane"
  23. "CanUseSpriteAtlas" = "True"
  24. }
  25. Stencil
  26. {
  27. Ref [_Stencil]
  28. Comp [_StencilComp]
  29. Pass [_StencilOp]
  30. ReadMask [_StencilReadMask]
  31. WriteMask [_StencilWriteMask]
  32. }
  33. Cull Off
  34. Lighting Off
  35. ZWrite Off
  36. ZTest Always
  37. Offset -1, -1
  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. v2f vert (appdata_t v)
  64. {
  65. v2f o;
  66. o.vertex = UnityObjectToClipPos(v.vertex);
  67. o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
  68. o.color = v.color * _Color;
  69. #ifdef UNITY_HALF_TEXEL_OFFSET
  70. o.vertex.xy += (_ScreenParams.zw-1.0)*float2(-1,1);
  71. #endif
  72. return o;
  73. }
  74. fixed4 frag (v2f i) : SV_Target
  75. {
  76. fixed4 col = (tex2D(_MainTex, i.texcoord) + _TextureSampleAdd) * i.color;
  77. clip (col.a - 0.01);
  78. return col;
  79. }
  80. ENDCG
  81. }
  82. }
  83. }