WFX_S Particle AddSoft A8.shader 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // WarFX Shader
  2. // (c) 2015 Jean Moreno
  3. Shader "WFX/Additive (Soft) Alpha8" {
  4. Properties {
  5. _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
  6. _MainTex ("Particle Texture (alpha)", 2D) = "white" {}
  7. _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
  8. }
  9. Category {
  10. Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
  11. Blend OneMinusDstColor One
  12. Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) }
  13. BindChannels {
  14. Bind "Color", color
  15. Bind "Vertex", vertex
  16. Bind "TexCoord", texcoord
  17. }
  18. // ---- Fragment program cards
  19. SubShader {
  20. Pass {
  21. CGPROGRAM
  22. #pragma vertex vert
  23. #pragma fragment frag
  24. #pragma fragmentoption ARB_precision_hint_fastest
  25. #pragma multi_compile_particles
  26. #include "UnityCG.cginc"
  27. sampler2D _MainTex;
  28. fixed4 _TintColor;
  29. struct appdata_t {
  30. float4 vertex : POSITION;
  31. fixed4 color : COLOR;
  32. float2 texcoord : TEXCOORD0;
  33. };
  34. struct v2f {
  35. float4 vertex : POSITION;
  36. fixed4 color : COLOR;
  37. float2 texcoord : TEXCOORD0;
  38. #ifdef SOFTPARTICLES_ON
  39. float4 projPos : TEXCOORD1;
  40. #endif
  41. };
  42. float4 _MainTex_ST;
  43. v2f vert (appdata_t v)
  44. {
  45. v2f o;
  46. o.vertex = UnityObjectToClipPos(v.vertex);
  47. #ifdef SOFTPARTICLES_ON
  48. o.projPos = ComputeScreenPos (o.vertex);
  49. COMPUTE_EYEDEPTH(o.projPos.z);
  50. #endif
  51. o.color = v.color;
  52. o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
  53. return o;
  54. }
  55. sampler2D _CameraDepthTexture;
  56. float _InvFade;
  57. fixed4 frag (v2f i) : COLOR
  58. {
  59. #ifdef SOFTPARTICLES_ON
  60. float sceneZ = LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos))));
  61. float partZ = i.projPos.z;
  62. float fade = saturate (_InvFade * (sceneZ-partZ));
  63. i.color.a *= fade;
  64. #endif
  65. return 2.0 * i.color * _TintColor * tex2D(_MainTex, i.texcoord).a;
  66. }
  67. ENDCG
  68. }
  69. }
  70. // ---- Dual texture cards
  71. SubShader {
  72. Pass {
  73. SetTexture [_MainTex] {
  74. constantColor [_TintColor]
  75. combine constant * primary
  76. }
  77. SetTexture [_MainTex] {
  78. combine texture alpha * previous DOUBLE
  79. }
  80. }
  81. }
  82. // ---- Single texture cards (does not do color tint)
  83. SubShader {
  84. Pass {
  85. SetTexture [_MainTex] {
  86. combine texture alpha * primary
  87. }
  88. }
  89. }
  90. }
  91. }