Additive.shader 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. Shader "FORGE3D/Additive" {
  2. Properties {
  3. _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
  4. _MainTex ("Particle Texture", 2D) = "white" {}
  5. _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
  6. }
  7. Category {
  8. Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
  9. Blend SrcAlpha One
  10. AlphaTest Greater .01
  11. ColorMask RGB
  12. Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) }
  13. SubShader {
  14. Pass {
  15. CGPROGRAM
  16. #pragma vertex vert
  17. #pragma fragment frag
  18. #pragma multi_compile_particles
  19. #include "UnityCG.cginc"
  20. sampler2D _MainTex;
  21. fixed4 _TintColor;
  22. struct appdata_t {
  23. float4 vertex : POSITION;
  24. fixed4 color : COLOR;
  25. float2 texcoord : TEXCOORD0;
  26. };
  27. struct v2f {
  28. float4 vertex : SV_POSITION;
  29. fixed4 color : COLOR;
  30. float2 texcoord : TEXCOORD0;
  31. #ifdef SOFTPARTICLES_ON
  32. float4 projPos : TEXCOORD1;
  33. #endif
  34. };
  35. float4 _MainTex_ST;
  36. v2f vert (appdata_t v)
  37. {
  38. v2f o;
  39. o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
  40. #ifdef SOFTPARTICLES_ON
  41. o.projPos = ComputeScreenPos (o.vertex);
  42. COMPUTE_EYEDEPTH(o.projPos.z);
  43. #endif
  44. o.color = v.color;
  45. o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
  46. return o;
  47. }
  48. sampler2D_float _CameraDepthTexture;
  49. float _InvFade;
  50. fixed4 frag (v2f i) : SV_Target
  51. {
  52. #ifdef SOFTPARTICLES_ON
  53. float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
  54. float partZ = i.projPos.z;
  55. float fade = saturate (_InvFade * (sceneZ-partZ));
  56. i.color.a *= fade;
  57. #endif
  58. return pow(i.color * _TintColor * tex2D(_MainTex, i.texcoord), 1);
  59. }
  60. ENDCG
  61. }
  62. }
  63. }
  64. }