Mole_Particles_Overlay.shader 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. Shader "MoleGame/Particles/Overlay"
  2. {
  3. Properties
  4. {
  5. _MainTex ("Texture", 2D) = "white" {}
  6. _TintColor("Tint Color", Color) = (0.5,0.5,0.5,0.5)
  7. _Threshold("Threshold", Range(0.0,0.99)) = 0.5
  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. [Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip("Use Alpha Clip", Float) = 0
  15. }
  16. SubShader
  17. {
  18. Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent"}
  19. Stencil
  20. {
  21. Ref[_Stencil]
  22. Comp[_StencilComp]
  23. Pass[_StencilOp]
  24. ReadMask[_StencilReadMask]
  25. WriteMask[_StencilWriteMask]
  26. }
  27. ZTest[unity_GUIZTestMode]
  28. ColorMask[_ColorMask]
  29. Blend SrcAlpha One
  30. Cull Off Lighting Off ZWrite Off
  31. LOD 100
  32. Pass
  33. {
  34. CGPROGRAM
  35. #pragma vertex vert
  36. #pragma fragment frag
  37. #pragma target 2.0
  38. #include "UnityCG.cginc"
  39. #include "UnityUI.cginc"
  40. #pragma multi_compile __ UNITY_UI_CLIP_RECT
  41. #pragma multi_compile __ UNITY_UI_ALPHACLIP
  42. struct appdata
  43. {
  44. float4 vertex : POSITION;
  45. fixed4 color : COLOR;
  46. float2 uv : TEXCOORD0;
  47. UNITY_VERTEX_INPUT_INSTANCE_ID
  48. };
  49. struct v2f
  50. {
  51. float2 uv : TEXCOORD0;
  52. fixed4 color : COLOR;
  53. float4 vertex : SV_POSITION;
  54. float4 worldPosition : TEXCOORD1;
  55. UNITY_VERTEX_OUTPUT_STEREO
  56. };
  57. sampler2D _MainTex;
  58. float4 _MainTex_ST;
  59. half4 _TintColor;
  60. half _Threshold;
  61. float4 _ClipRect;
  62. v2f vert (appdata v)
  63. {
  64. v2f o;
  65. UNITY_SETUP_INSTANCE_ID(v);
  66. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  67. o.worldPosition = v.vertex;
  68. o.vertex = UnityObjectToClipPos(v.vertex);
  69. o.color = v.color;
  70. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  71. return o;
  72. }
  73. fixed4 frag (v2f i) : SV_Target
  74. {
  75. // sample the texture
  76. fixed4 col = tex2D(_MainTex, i.uv) * i.color;
  77. float a = col.a * i.color.a;
  78. col = 2*lerp(col*_TintColor, col, (col.r - _Threshold)/ (1-_Threshold));
  79. col.a = a;
  80. #ifdef UNITY_UI_CLIP_RECT
  81. col.a *= UnityGet2DClipping(i.worldPosition.xy, _ClipRect);
  82. #endif
  83. #ifdef UNITY_UI_ALPHACLIP
  84. clip(col.a - 0.001);
  85. #endif
  86. return col;
  87. }
  88. ENDCG
  89. }
  90. }
  91. }