EffectDissolveAddSide.shader 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "MoleGame/Particles/EffectDissolveAddSide"
  3. {
  4. Properties
  5. {
  6. _MainTex ("Texture", 2D) = "white" {}
  7. _TintColor("Tint Color", Color) = (1, 1, 1, 1)
  8. _SideColor("Side Color", Color) = (1, 1, 1, 1)
  9. _SideStep("Side Step", float) = 5
  10. _DissolveTex("DissolveTex", 2D) = "white" {}
  11. _Dissolve("Dissolve", Range(0, 1)) = 0
  12. }
  13. SubShader
  14. {
  15. Tags { "IgnoreProjector"="True"
  16. "Queue"="Transparent"
  17. "RenderType"="Transparent" }
  18. LOD 100
  19. Pass
  20. {
  21. Cull Off
  22. ZWrite off
  23. Lighting Off
  24. Blend SrcAlpha One
  25. CGPROGRAM
  26. #pragma fragmentoption ARB_precision_hint_fastest
  27. #pragma vertex vert
  28. #pragma fragment frag
  29. #pragma multi_compile_particles
  30. #include "UnityCG.cginc"
  31. struct appdata
  32. {
  33. half4 vertex : POSITION;
  34. fixed4 color : COLOR;
  35. half2 uv : TEXCOORD0;
  36. };
  37. struct v2f
  38. {
  39. half4 vertex : SV_POSITION;
  40. fixed4 color : COLOR;
  41. half2 uv : TEXCOORD0;
  42. half2 uv2 : TEXCOORD1;
  43. };
  44. sampler2D _MainTex;
  45. sampler2D _DissolveTex;
  46. fixed4 _MainTex_ST;
  47. fixed4 _DissolveTex_ST;
  48. v2f vert (appdata v)
  49. {
  50. v2f o;
  51. o.vertex = UnityObjectToClipPos(v.vertex);
  52. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  53. o.uv2 = TRANSFORM_TEX(v.uv, _DissolveTex);
  54. o.color = v.color;
  55. return o;
  56. }
  57. fixed4 _TintColor;
  58. fixed _Dissolve;
  59. fixed4 _SideColor;
  60. fixed _SideStep;
  61. fixed4 frag (v2f i) : SV_Target
  62. {
  63. fixed4 disov = tex2D(_DissolveTex, i.uv2);
  64. disov.r += i.color.a - 1;
  65. fixed clip_amount = disov.r - _Dissolve;
  66. clip(clip_amount);
  67. // sample the texture
  68. fixed4 col = tex2D(_MainTex, i.uv) * _TintColor;
  69. clip_amount = clamp(clip_amount * _SideStep, 0, 1);
  70. col.rgb = lerp(_SideColor, col.rgb, clip_amount); // clip_amount * col.rgb + (1 - clip_amount) * _SideColor;
  71. col.rgb *= i.color.rgb;
  72. return col;
  73. }
  74. ENDCG
  75. }
  76. }
  77. SubShader {
  78. Lighting Off
  79. ZWrite off
  80. Blend SrcAlpha One
  81. Pass {
  82. Name "BASE"
  83. SetTexture [_MainTex] {
  84. constantColor [_TintColor]
  85. combine texture * constant
  86. }
  87. SetTexture [_MainTex] {
  88. combine previous * Primary
  89. }
  90. }
  91. }
  92. }