AdditiveCustom.shader 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. Shader "YXJ/Particles/Through/AdditiveCustom"
  2. {
  3. Properties
  4. {
  5. _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
  6. _MainTex ("Texture", 2D) = "white" {}
  7. [Space]
  8. [Toggle(MASK)] _MaskOn ("Enable Mask?", float) = 0
  9. _MaskTex ("Mask (A)", 2D) = "white" {}
  10. _CutOff ("Alpha CutOff", Range(0,1.0)) = 0.5
  11. [Space]
  12. [Toggle(SCROLL)] _ScrollOn ("Enable Scroll?", float) = 0
  13. [Enum(Manual, 0, AutoMain, 1, AutoMask, 2)] _ScrollType ("Scroll Type", float) = 0
  14. [Space]
  15. _UV ("UV Main", vector) = (1,1,0,0)
  16. _UV2 ("UV Mask", vector) = (1,1,0,0)
  17. _SpeedU ("Scroll Speed U", float) = 1
  18. _SpeedV ("Scroll Speed V", float) = 0
  19. [Enum(Close, 0, Open, 1)] _FogSwitch("Fog", float) = 0
  20. }
  21. Category
  22. {
  23. Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
  24. Blend SrcAlpha One
  25. ColorMask RGB
  26. Cull Off Lighting Off ZWrite Off
  27. SubShader
  28. {
  29. Pass
  30. {
  31. CGPROGRAM
  32. #pragma vertex vert
  33. #pragma fragment frag
  34. #pragma multi_compile_fog
  35. #pragma multi_compile __ MASK
  36. #pragma multi_compile __ SCROLL
  37. #include "UnityCG.cginc"
  38. sampler2D _MainTex;
  39. fixed4 _TintColor;
  40. float4 _MainTex_ST;
  41. float _FogSwitch;
  42. #if MASK
  43. sampler2D _MaskTex;
  44. float4 _MaskTex_ST;
  45. float _CutOff;
  46. struct appdata_t
  47. {
  48. float4 vertex : POSITION;
  49. fixed4 color : COLOR;
  50. float2 texcoord : TEXCOORD0;
  51. float2 texcoordm : TEXCOORD1;
  52. };
  53. struct v2f
  54. {
  55. float4 vertex : SV_POSITION;
  56. fixed4 color : COLOR;
  57. float2 texcoord : TEXCOORD0;
  58. float2 texcoordm : TEXCOORD1;
  59. UNITY_FOG_COORDS(2)
  60. };
  61. #else
  62. struct appdata_t
  63. {
  64. float4 vertex : POSITION;
  65. fixed4 color : COLOR;
  66. float2 texcoord : TEXCOORD0;
  67. };
  68. struct v2f
  69. {
  70. float4 vertex : SV_POSITION;
  71. fixed4 color : COLOR;
  72. float2 texcoord : TEXCOORD0;
  73. UNITY_FOG_COORDS(1)
  74. };
  75. #endif
  76. #if SCROLL
  77. float _ScrollType;
  78. float4 _UV;
  79. float4 _UV2;
  80. float _SpeedU;
  81. float _SpeedV;
  82. #endif
  83. v2f vert(appdata_t v)
  84. {
  85. v2f o;
  86. o.vertex = UnityObjectToClipPos(v.vertex);
  87. o.color = v.color;
  88. o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
  89. if(_FogSwitch == 1) { UNITY_TRANSFER_FOG(o,o.vertex); }
  90. #if SCROLL
  91. if (_ScrollType == 0)
  92. {
  93. o.texcoord = float2(o.texcoord.x * _UV.x + _UV.z, o.texcoord.y * _UV.y + _UV.w);
  94. }
  95. else if (_ScrollType == 1)
  96. {
  97. o.texcoord += _Time.x * float2(_SpeedU, _SpeedV);
  98. }
  99. #endif
  100. #if MASK
  101. o.texcoordm = TRANSFORM_TEX(v.texcoordm, _MaskTex);
  102. #if SCROLL
  103. if (_ScrollType == 0) {
  104. o.texcoordm = float2(o.texcoordm.x * _UV2.x + _UV2.z, o.texcoordm.y * _UV2.y + _UV2.w);
  105. }
  106. else if (_ScrollType == 2) {
  107. o.texcoordm += _Time.x * float2(_SpeedU, _SpeedV);
  108. }
  109. #endif
  110. #endif
  111. return o;
  112. }
  113. fixed4 frag(v2f i) : SV_Target
  114. {
  115. fixed4 col = tex2D(_MainTex, i.texcoord) * i.color;
  116. #if MASK
  117. col.a *= UNITY_SAMPLE_1CHANNEL(_MaskTex, i.texcoordm);
  118. clip(col.a - _CutOff);
  119. #endif
  120. col *= _TintColor * 2.44;
  121. if(_FogSwitch == 1) { UNITY_APPLY_FOG(i.fogCoord, col); }
  122. return col;
  123. }
  124. ENDCG
  125. }
  126. }
  127. }
  128. }