Mole_Particles_Additive.shader 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //如果用在会被mask切掉的UI上,把Stencil Comparison改成4,Stencil ID改成2
  2. Shader "MoleGame/Particles/Additive" {
  3. Properties{
  4. _TintColor("Tint Color", Color) = (0.5,0.5,0.5,0.5)
  5. _MainTex("Particle Texture", 2D) = "white" {}
  6. //4 equal
  7. _StencilComp("Stencil Comparison", Float) = 8
  8. //2 ui mask
  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. Category{
  16. Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" "PreviewType" = "Plane" }
  17. Stencil{
  18. Ref[_Stencil]
  19. Comp[_StencilComp]
  20. Pass[_StencilOp]
  21. ReadMask[_StencilReadMask]
  22. WriteMask[_StencilWriteMask]
  23. }
  24. ZTest[unity_GUIZTestMode]
  25. ColorMask[_ColorMask]
  26. Blend SrcAlpha One
  27. Cull Off Lighting Off ZWrite Off
  28. SubShader{
  29. Pass{
  30. CGPROGRAM
  31. #pragma vertex vert
  32. #pragma fragment frag
  33. #pragma target 2.0
  34. //#pragma multi_compile_particles
  35. //#pragma multi_compile_fog
  36. #include "UnityCG.cginc"
  37. sampler2D _MainTex;
  38. float4 _MainTex_ST;
  39. fixed4 _TintColor;
  40. struct appdata_t {
  41. float4 vertex : POSITION;
  42. fixed4 color : COLOR;
  43. float2 texcoord : TEXCOORD0;
  44. };
  45. struct v2f {
  46. float4 vertex : SV_POSITION;
  47. fixed4 color : COLOR;
  48. float2 texcoord : TEXCOORD0;
  49. };
  50. v2f vert(appdata_t v)
  51. {
  52. v2f o;
  53. o.vertex = UnityObjectToClipPos(v.vertex);
  54. o.color = v.color;
  55. o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
  56. return o;
  57. }
  58. fixed4 frag(v2f i) : SV_Target
  59. {
  60. fixed4 col = i.color * _TintColor * tex2D(_MainTex, i.texcoord);
  61. #ifdef UNITY_UI_CLIP_RECT
  62. col.a *= UnityGet2DClipping(i.worldPosition.xy, _ClipRect);
  63. #endif
  64. return col;
  65. }
  66. ENDCG
  67. }
  68. }
  69. }
  70. }