HSL-Add.shader 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
  2. Shader "Particles/HSL Additive" {
  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,3.0)) = 1.0
  7. _HueRGB ("Hue Shift RGB", Vector) = (0.0, 0.0, 0.0, 0.0)
  8. }
  9. Category {
  10. Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
  11. Blend SrcAlpha One
  12. ColorMask RGB
  13. Cull Off Lighting Off ZWrite Off
  14. SubShader {
  15. Pass {
  16. CGPROGRAM
  17. #pragma vertex vert
  18. #pragma fragment frag
  19. #pragma target 2.0
  20. #pragma multi_compile_particles
  21. #pragma multi_compile_fog
  22. #include "UnityCG.cginc"
  23. sampler2D _MainTex;
  24. fixed4 _TintColor;
  25. struct appdata_t {
  26. float4 vertex : POSITION;
  27. fixed4 color : COLOR;
  28. float2 texcoord : TEXCOORD0;
  29. UNITY_VERTEX_INPUT_INSTANCE_ID
  30. };
  31. struct v2f {
  32. float4 vertex : SV_POSITION;
  33. fixed4 color : COLOR;
  34. float2 texcoord : TEXCOORD0;
  35. UNITY_FOG_COORDS(1)
  36. #ifdef SOFTPARTICLES_ON
  37. float4 projPos : TEXCOORD2;
  38. #endif
  39. UNITY_VERTEX_OUTPUT_STEREO
  40. };
  41. float4 _MainTex_ST;
  42. v2f vert (appdata_t v)
  43. {
  44. v2f o;
  45. UNITY_SETUP_INSTANCE_ID(v);
  46. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  47. o.vertex = UnityObjectToClipPos(v.vertex);
  48. #ifdef SOFTPARTICLES_ON
  49. o.projPos = ComputeScreenPos (o.vertex);
  50. COMPUTE_EYEDEPTH(o.projPos.z);
  51. #endif
  52. o.color = v.color;
  53. o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
  54. UNITY_TRANSFER_FOG(o,o.vertex);
  55. return o;
  56. }
  57. UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
  58. float _InvFade;
  59. float4 _HueRGB;
  60. fixed4 frag (v2f i) : SV_Target
  61. {
  62. #ifdef SOFTPARTICLES_ON
  63. float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
  64. float partZ = i.projPos.z;
  65. float fade = saturate (_InvFade * (sceneZ-partZ));
  66. i.color.a *= fade;
  67. #endif
  68. fixed4 col = 2.0f * i.color * _TintColor * tex2D(_MainTex, i.texcoord);
  69. col.r += _HueRGB.x + _HueRGB.w;
  70. col.g += _HueRGB.y + _HueRGB.w;
  71. col.b += _HueRGB.z + _HueRGB.w;
  72. UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(0,0,0,0)); // fog towards black due to our blend mode
  73. return col;
  74. }
  75. ENDCG
  76. }
  77. }
  78. }
  79. }