UI-NoZTest.shader 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. Shader "UI/NoZTest"
  2. {
  3. Properties
  4. {
  5. [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
  6. _Color ("Tint", Color) = (1,1,1,1)
  7. [Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
  8. }
  9. SubShader
  10. {
  11. Tags
  12. {
  13. "Queue"="Transparent"
  14. "IgnoreProjector"="True"
  15. "RenderType"="Transparent"
  16. "PreviewType"="Plane"
  17. "CanUseSpriteAtlas"="True"
  18. }
  19. Cull Off
  20. Lighting Off
  21. ZWrite Off
  22. ZTest Off
  23. Blend SrcAlpha OneMinusSrcAlpha
  24. Pass
  25. {
  26. Name "Default"
  27. CGPROGRAM
  28. #pragma vertex vert
  29. #pragma fragment frag
  30. #pragma target 2.0
  31. #include "UnityCG.cginc"
  32. #include "UnityUI.cginc"
  33. #pragma multi_compile_local _ UNITY_UI_CLIP_RECT
  34. #pragma multi_compile_local _ UNITY_UI_ALPHACLIP
  35. struct appdata_t
  36. {
  37. float4 vertex : POSITION;
  38. float4 color : COLOR;
  39. float2 texcoord : TEXCOORD0;
  40. UNITY_VERTEX_INPUT_INSTANCE_ID
  41. };
  42. struct v2f
  43. {
  44. float4 vertex : SV_POSITION;
  45. fixed4 color : COLOR;
  46. float2 texcoord : TEXCOORD0;
  47. float4 worldPosition : TEXCOORD1;
  48. UNITY_VERTEX_OUTPUT_STEREO
  49. };
  50. sampler2D _MainTex;
  51. fixed4 _Color;
  52. fixed4 _TextureSampleAdd;
  53. float4 _ClipRect;
  54. float4 _MainTex_ST;
  55. v2f vert(appdata_t v)
  56. {
  57. v2f OUT;
  58. UNITY_SETUP_INSTANCE_ID(v);
  59. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
  60. OUT.worldPosition = v.vertex;
  61. OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
  62. OUT.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
  63. OUT.color = v.color * _Color;
  64. return OUT;
  65. }
  66. fixed4 frag(v2f IN) : SV_Target
  67. {
  68. half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
  69. #ifdef UNITY_UI_CLIP_RECT
  70. color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
  71. #endif
  72. #ifdef UNITY_UI_ALPHACLIP
  73. clip (color.a - 0.001);
  74. #endif
  75. return color;
  76. }
  77. ENDCG
  78. }
  79. }
  80. }