EffectDissolveSide.shader 2.2 KB

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