Additive.shader 2.0 KB

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