HSL-Alpha.shader 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
  2. Shader "Particles/HSL Alpha Blended" {
  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", Color) = (0.0, 0.0, 0.0, 0.0)
  8. }
  9. Category {
  10. Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
  11. Blend SrcAlpha OneMinusSrcAlpha
  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 * _TintColor;
  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. fixed4 frag (v2f i) : SV_Target
  60. {
  61. #ifdef SOFTPARTICLES_ON
  62. float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
  63. float partZ = i.projPos.z;
  64. float fade = saturate (_InvFade * (sceneZ-partZ));
  65. i.color.a *= fade;
  66. #endif
  67. fixed4 col = 2.0f * i.color * tex2D(_MainTex, i.texcoord);
  68. UNITY_APPLY_FOG(i.fogCoord, col);
  69. return col;
  70. }
  71. ENDCG
  72. }
  73. }
  74. }
  75. }