CFX2 Particle Alpha Blend Add.shader 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "Cartoon FX/Particles Alpha Blended Add"
  3. {
  4. Properties
  5. {
  6. _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
  7. _MainTex ("Particle Texture", 2D) = "white" {}
  8. _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
  9. }
  10. Category
  11. {
  12. Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
  13. Blend SrcAlpha OneMinusSrcAlpha
  14. AlphaTest Greater .01
  15. ColorMask RGB
  16. Cull Off Lighting Off ZWrite Off
  17. BindChannels
  18. {
  19. Bind "Color", color
  20. Bind "Vertex", vertex
  21. Bind "TexCoord", texcoord
  22. }
  23. // ---- Fragment program cards
  24. SubShader
  25. {
  26. Pass
  27. {
  28. CGPROGRAM
  29. #pragma vertex vert
  30. #pragma fragment frag
  31. #pragma fragmentoption ARB_precision_hint_fastest
  32. #pragma multi_compile_particles
  33. #include "UnityCG.cginc"
  34. sampler2D _MainTex;
  35. fixed4 _TintColor;
  36. struct appdata_t
  37. {
  38. float4 vertex : POSITION;
  39. fixed4 color : COLOR;
  40. float2 texcoord : TEXCOORD0;
  41. };
  42. struct v2f
  43. {
  44. float4 vertex : POSITION;
  45. fixed4 color : COLOR;
  46. float2 texcoord : TEXCOORD0;
  47. #ifdef SOFTPARTICLES_ON
  48. float4 projPos : TEXCOORD1;
  49. #endif
  50. };
  51. float4 _MainTex_ST;
  52. v2f vert (appdata_t v)
  53. {
  54. v2f o;
  55. o.vertex = UnityObjectToClipPos(v.vertex);
  56. #ifdef SOFTPARTICLES_ON
  57. o.projPos = ComputeScreenPos (o.vertex);
  58. COMPUTE_EYEDEPTH(o.projPos.z);
  59. #endif
  60. o.color = v.color;
  61. o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
  62. return o;
  63. }
  64. sampler2D _CameraDepthTexture;
  65. float _InvFade;
  66. fixed4 frag (v2f i) : COLOR
  67. {
  68. #ifdef SOFTPARTICLES_ON
  69. float sceneZ = LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos))));
  70. float partZ = i.projPos.z;
  71. float fade = saturate (_InvFade * (sceneZ-partZ));
  72. i.color.a *= fade;
  73. #endif
  74. fixed4 c = 4.0f * i.color * _TintColor * tex2D(_MainTex, i.texcoord);
  75. c.rgb += (_TintColor.rgb * 0.8f);
  76. return c;
  77. }
  78. ENDCG
  79. }
  80. }
  81. // ---- Dual texture cards
  82. SubShader
  83. {
  84. Pass
  85. {
  86. SetTexture [_MainTex]
  87. {
  88. constantColor [_TintColor]
  89. combine constant * primary
  90. }
  91. SetTexture [_MainTex]
  92. {
  93. combine texture * previous DOUBLE
  94. }
  95. }
  96. }
  97. // ---- Single texture cards (does not do color tint)
  98. SubShader
  99. {
  100. Pass
  101. {
  102. SetTexture [_MainTex]
  103. {
  104. combine texture * primary
  105. }
  106. }
  107. }
  108. }
  109. }