Particle Alpha Blend.shader 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. Shader /*ase_name*/ "Hidden/Templates/Legacy/Particles Alpha Blended" /*end*/
  2. {
  3. Properties
  4. {
  5. _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
  6. _MainTex ("Particle Texture", 2D) = "white" {}
  7. _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
  8. /*ase_props*/
  9. }
  10. Category
  11. {
  12. SubShader
  13. {
  14. Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" "PreviewType" = "Plane" }
  15. Blend SrcAlpha OneMinusSrcAlpha
  16. ColorMask RGB
  17. Cull Off
  18. Lighting Off
  19. ZWrite Off
  20. ZTest LEqual
  21. /*ase_pass*/
  22. Pass {
  23. CGPROGRAM
  24. #ifndef UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX
  25. #define UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input)
  26. #endif
  27. #pragma vertex vert
  28. #pragma fragment frag
  29. #pragma target 3.5
  30. #pragma multi_compile_instancing
  31. #pragma multi_compile_particles
  32. #pragma multi_compile_fog
  33. /*ase_pragma*/
  34. #include "UnityCG.cginc"
  35. struct appdata_t
  36. {
  37. float4 vertex : POSITION;
  38. fixed4 color : COLOR;
  39. float4 texcoord : TEXCOORD0;
  40. UNITY_VERTEX_INPUT_INSTANCE_ID
  41. /*ase_vdata:p=p;uv0=tc0;c=c*/
  42. };
  43. struct v2f
  44. {
  45. float4 vertex : SV_POSITION;
  46. fixed4 color : COLOR;
  47. float4 texcoord : TEXCOORD0;
  48. UNITY_FOG_COORDS(1)
  49. #ifdef SOFTPARTICLES_ON
  50. float4 projPos : TEXCOORD2;
  51. #endif
  52. UNITY_VERTEX_INPUT_INSTANCE_ID
  53. UNITY_VERTEX_OUTPUT_STEREO
  54. /*ase_interp(3,):sp=sp.xyzw;uv0=tc0;c=c*/
  55. };
  56. #if UNITY_VERSION >= 560
  57. UNITY_DECLARE_DEPTH_TEXTURE( _CameraDepthTexture );
  58. #else
  59. uniform sampler2D_float _CameraDepthTexture;
  60. #endif
  61. //Don't delete this comment
  62. // uniform sampler2D_float _CameraDepthTexture;
  63. uniform sampler2D _MainTex;
  64. uniform fixed4 _TintColor;
  65. uniform float4 _MainTex_ST;
  66. uniform float _InvFade;
  67. /*ase_globals*/
  68. v2f vert ( appdata_t v /*ase_vert_input*/ )
  69. {
  70. v2f o;
  71. UNITY_SETUP_INSTANCE_ID(v);
  72. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  73. UNITY_TRANSFER_INSTANCE_ID(v, o);
  74. /*ase_vert_code:v=appdata_t;o=v2f*/
  75. v.vertex.xyz += /*ase_vert_out:Offset;Float3*/ float3( 0, 0, 0 ) /*end*/;
  76. o.vertex = UnityObjectToClipPos(v.vertex);
  77. #ifdef SOFTPARTICLES_ON
  78. o.projPos = ComputeScreenPos (o.vertex);
  79. COMPUTE_EYEDEPTH(o.projPos.z);
  80. #endif
  81. o.color = v.color;
  82. o.texcoord = v.texcoord;
  83. UNITY_TRANSFER_FOG(o,o.vertex);
  84. return o;
  85. }
  86. fixed4 frag ( v2f i /*ase_frag_input*/ ) : SV_Target
  87. {
  88. UNITY_SETUP_INSTANCE_ID( i );
  89. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( i );
  90. #ifdef SOFTPARTICLES_ON
  91. float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
  92. float partZ = i.projPos.z;
  93. float fade = saturate (_InvFade * (sceneZ-partZ));
  94. i.color.a *= fade;
  95. #endif
  96. /*ase_frag_code:i=v2f*/
  97. fixed4 col = /*ase_frag_out:Color;Float4*/2.0f * i.color * _TintColor * tex2D(_MainTex, i.texcoord.xy*_MainTex_ST.xy + _MainTex_ST.zw )/*end*/;
  98. UNITY_APPLY_FOG(i.fogCoord, col);
  99. return col;
  100. }
  101. ENDCG
  102. }
  103. }
  104. }
  105. CustomEditor "AmplifyShaderEditor.MaterialInspector"
  106. }