UIAdditive.shader 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "UI/UIAdditive"
  3. {
  4. Properties
  5. {
  6. [PerRendererData] _MainTex("Sprite 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. 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[unity_GUIZTestMode]
  37. Blend SrcAlpha One
  38. ColorMask[_ColorMask]
  39. Pass
  40. {
  41. CGPROGRAM
  42. #pragma vertex vert
  43. #pragma fragment frag
  44. #include "UnityCG.cginc"
  45. #include "UnityUI.cginc"
  46. struct appdata_t
  47. {
  48. float4 vertex : POSITION;
  49. float4 color : COLOR;
  50. float2 texcoord : TEXCOORD0;
  51. };
  52. struct v2f
  53. {
  54. float4 vertex : SV_POSITION;
  55. fixed4 color : COLOR;
  56. half2 texcoord : TEXCOORD0;
  57. float4 worldPosition : TEXCOORD1;
  58. };
  59. fixed4 _Color;
  60. fixed4 _TextureSampleAdd;
  61. bool _UseClipRect;
  62. float4 _ClipRect;
  63. bool _UseAlphaClip;
  64. v2f vert(appdata_t IN)
  65. {
  66. v2f OUT;
  67. OUT.worldPosition = IN.vertex;
  68. OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
  69. OUT.texcoord = IN.texcoord;
  70. #ifdef UNITY_HALF_TEXEL_OFFSET
  71. OUT.vertex.xy += (_ScreenParams.zw - 1.0)*float2(-1,1);
  72. #endif
  73. OUT.color = IN.color * _Color;
  74. return OUT;
  75. }
  76. sampler2D _MainTex;
  77. fixed4 frag(v2f IN) : SV_Target
  78. {
  79. half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
  80. if (_UseClipRect)
  81. color *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
  82. if (_UseAlphaClip)
  83. clip(color.a - 0.001);
  84. return color;
  85. }
  86. ENDCG
  87. }
  88. }
  89. }