CFX3 Multiply Color.shader 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. // CartoonFX 3 Shader
  3. // (c) 2013, Jean Moreno
  4. Shader "Cartoon FX/Particle Multiply Colored"
  5. {
  6. Properties
  7. {
  8. _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
  9. _MainTex ("Particle Texture (alpha)", 2D) = "white" {}
  10. _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
  11. }
  12. Category
  13. {
  14. Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
  15. Blend DstColor Zero
  16. AlphaTest Greater .01
  17. ColorMask RGB
  18. Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) }
  19. BindChannels
  20. {
  21. Bind "Color", color
  22. Bind "Vertex", vertex
  23. Bind "TexCoord", texcoord
  24. }
  25. SubShader
  26. {
  27. Pass
  28. {
  29. CGPROGRAM
  30. #pragma vertex vert
  31. #pragma fragment frag
  32. #pragma fragmentoption ARB_precision_hint_fastest
  33. #pragma multi_compile_particles
  34. #include "UnityCG.cginc"
  35. sampler2D _MainTex;
  36. float4 _MainTex_ST;
  37. fixed4 _TintColor;
  38. sampler2D _CameraDepthTexture;
  39. float _InvFade;
  40. struct appdata_t
  41. {
  42. float4 vertex : POSITION;
  43. fixed4 color : COLOR;
  44. float2 texcoord : TEXCOORD0;
  45. };
  46. struct v2f
  47. {
  48. float4 vertex : POSITION;
  49. fixed4 color : COLOR;
  50. float2 texcoord : TEXCOORD0;
  51. #ifdef SOFTPARTICLES_ON
  52. float4 projPos : TEXCOORD1;
  53. #endif
  54. };
  55. v2f vert (appdata_t v)
  56. {
  57. v2f o;
  58. o.vertex = UnityObjectToClipPos(v.vertex);
  59. #ifdef SOFTPARTICLES_ON
  60. o.projPos = ComputeScreenPos (o.vertex);
  61. COMPUTE_EYEDEPTH(o.projPos.z);
  62. #endif
  63. o.color = v.color;
  64. o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
  65. return o;
  66. }
  67. fixed4 frag (v2f i) : COLOR
  68. {
  69. #ifdef SOFTPARTICLES_ON
  70. float sceneZ = LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos))));
  71. float partZ = i.projPos.z;
  72. float fade = saturate (_InvFade * (sceneZ-partZ));
  73. i.color.a *= fade;
  74. #endif
  75. fixed4 tex = tex2D(_MainTex, i.texcoord);
  76. // tex.rgb *= i.color.rgb * _TintColor.rgb * 2.0f;
  77. // tex = lerp(tex, fixed4(0.5,0.5,0.5,0.5), 1-tex * i.color.a);
  78. return lerp(fixed4(1,1,1,1), _TintColor * i.color, tex * i.color.a);
  79. // return 2.0f * i.color * _TintColor * lerp(fixed4(0,0,0,0), fixed4(1,1,1,1), tex2D(_MainTex, i.texcoord).a * i.color.a);
  80. }
  81. ENDCG
  82. }
  83. }
  84. }
  85. }