ParticleAddCustom.shader 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "Particles/Additive_Custom" {
  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,30.0)) = 1.0
  7. }
  8. Category {
  9. Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
  10. Blend SrcAlpha One
  11. ColorMask RGB
  12. Cull Off Lighting Off ZWrite Off
  13. SubShader {
  14. Pass {
  15. CGPROGRAM
  16. #pragma vertex vert
  17. #pragma fragment frag
  18. #pragma multi_compile_particles
  19. #pragma multi_compile_fog
  20. #include "UnityCG.cginc"
  21. sampler2D _MainTex;
  22. fixed4 _TintColor;
  23. struct appdata_t {
  24. float4 vertex : POSITION;
  25. fixed4 color : COLOR;
  26. float2 texcoord : TEXCOORD0;
  27. };
  28. struct v2f {
  29. float4 vertex : SV_POSITION;
  30. fixed4 color : COLOR;
  31. float2 texcoord : TEXCOORD0;
  32. UNITY_FOG_COORDS(1)
  33. #ifdef SOFTPARTICLES_ON
  34. float4 projPos : TEXCOORD2;
  35. #endif
  36. };
  37. float4 _MainTex_ST;
  38. v2f vert (appdata_t v)
  39. {
  40. v2f o;
  41. o.vertex = UnityObjectToClipPos(v.vertex);
  42. #ifdef SOFTPARTICLES_ON
  43. o.projPos = ComputeScreenPos (o.vertex);
  44. COMPUTE_EYEDEPTH(o.projPos.z);
  45. #endif
  46. o.color = v.color;
  47. o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
  48. UNITY_TRANSFER_FOG(o,o.vertex);
  49. return o;
  50. }
  51. sampler2D_float _CameraDepthTexture;
  52. float _InvFade;
  53. fixed4 frag (v2f i) : SV_Target
  54. {
  55. #ifdef SOFTPARTICLES_ON
  56. float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
  57. float partZ = i.projPos.z;
  58. float fade = saturate (_InvFade * (sceneZ-partZ));
  59. i.color.a *= fade;
  60. #endif
  61. fixed4 col = 2.0f * i.color * _TintColor * tex2D(_MainTex, i.texcoord);
  62. UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(0,0,0,0)); // fog towards black due to our blend mode
  63. return col;
  64. }
  65. ENDCG
  66. }
  67. }
  68. }
  69. }