AlphaBlendedCustom.shader 3.3 KB

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