NW_Particle AddSmooth.shader 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "NeatWolf/Additive (Soft) HDR" {
  3. Properties {
  4. _MainTex ("Particle Texture", 2D) = "white" {}
  5. _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
  6. _DiffuseBoost ("Diffuse Boost", Float) = 1.0
  7. }
  8. Category {
  9. Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
  10. Blend One OneMinusSrcColor
  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. float _DiffuseBoost;
  23. struct appdata_t {
  24. float4 vertex : POSITION;
  25. float4 color : COLOR;
  26. float2 texcoord : TEXCOORD0;
  27. };
  28. struct v2f {
  29. float4 vertex : SV_POSITION;
  30. float4 color : COLOR;
  31. float2 texcoord : TEXCOORD0;
  32. #ifdef SOFTPARTICLES_ON
  33. float4 projPos : TEXCOORD1;
  34. #endif
  35. };
  36. float4 _MainTex_ST;
  37. v2f vert (appdata_t v)
  38. {
  39. v2f o;
  40. o.vertex = UnityObjectToClipPos(v.vertex);
  41. #ifdef SOFTPARTICLES_ON
  42. o.projPos = ComputeScreenPos (o.vertex);
  43. COMPUTE_EYEDEPTH(o.projPos.z);
  44. #endif
  45. o.color = v.color;
  46. o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
  47. return o;
  48. }
  49. sampler2D_float _CameraDepthTexture;
  50. float _InvFade;
  51. float4 frag (v2f i) : SV_Target
  52. {
  53. #ifdef SOFTPARTICLES_ON
  54. float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
  55. float partZ = i.projPos.z;
  56. float fade = saturate (_InvFade * (sceneZ-partZ));
  57. i.color.a *= fade;
  58. #endif
  59. half4 prev = i.color * tex2D(_MainTex, i.texcoord);
  60. prev.rgb *= prev.a * _DiffuseBoost * prev.a;
  61. return prev;
  62. }
  63. ENDCG
  64. }
  65. }
  66. }
  67. }