Guest User

Untitled

a guest
May 1st, 2017
192
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
  2.  
  3. Shader "Particles/Additive (Soft)" {
  4. Properties {
  5. _Color("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. }
  9.  
  10. Category {
  11. Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
  12. Blend One OneMinusSrcColor
  13. ColorMask RGBA
  14. Cull Off Lighting Off ZWrite Off
  15.  
  16. SubShader {
  17. Pass {
  18.  
  19. CGPROGRAM
  20. #pragma vertex vert
  21. #pragma fragment frag
  22. #pragma target 2.0
  23. #pragma multi_compile_particles
  24. #pragma multi_compile_fog
  25.  
  26. #include "UnityCG.cginc"
  27.  
  28. sampler2D _MainTex;
  29. fixed4 _TintColor;
  30.  
  31. struct appdata_t {
  32. float4 vertex : POSITION;
  33. fixed4 color : COLOR;
  34. float2 texcoord : TEXCOORD0;
  35. UNITY_VERTEX_INPUT_INSTANCE_ID
  36. };
  37.  
  38. struct v2f {
  39. float4 vertex : SV_POSITION;
  40. fixed4 color : COLOR;
  41. float2 texcoord : TEXCOORD0;
  42. UNITY_FOG_COORDS(1)
  43. #ifdef SOFTPARTICLES_ON
  44. float4 projPos : TEXCOORD2;
  45. #endif
  46. UNITY_VERTEX_OUTPUT_STEREO
  47. };
  48.  
  49. float4 _MainTex_ST;
  50.  
  51. v2f vert (appdata_t v)
  52. {
  53. v2f o;
  54. UNITY_SETUP_INSTANCE_ID(v);
  55. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  56. o.vertex = UnityObjectToClipPos(v.vertex);
  57. #ifdef SOFTPARTICLES_ON
  58. o.projPos = ComputeScreenPos (o.vertex);
  59. COMPUTE_EYEDEPTH(o.projPos.z);
  60. #endif
  61. o.color = v.color;
  62. o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
  63. UNITY_TRANSFER_FOG(o,o.vertex);
  64. return o;
  65. }
  66.  
  67. sampler2D_float _CameraDepthTexture;
  68. float _InvFade;
  69.  
  70. fixed4 frag (v2f i) : SV_Target
  71. {
  72. #ifdef SOFTPARTICLES_ON
  73. float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
  74. float partZ = i.projPos.z;
  75. float fade = saturate (_InvFade * (sceneZ-partZ));
  76. i.color.a *= fade;
  77. #endif
  78.  
  79. half4 col = i.color * tex2D(_MainTex, i.texcoord);
  80. col.rgb *= col.a;
  81. UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(0,0,0,0)); // fog towards black due to our blend mode
  82. return col;
  83. }
  84. ENDCG
  85. }
  86. }
  87. }
  88. }
RAW Paste Data Copied