Seven is the number.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
2.2 KiB

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