Update change log.
[VesselSimulator.git] / Assets / SquadCore / Shaders / KSPParticle AddSmooth.shader
1 Shader "KSP/Particles/Additive (Soft)" {
2 Properties {
3 _MainTex ("Particle Texture", 2D) = "white" {}
4 _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
5 _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
6 }
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
14 SubShader {
15 Pass {
16
17 CGPROGRAM
18 #pragma vertex vert
19 #pragma fragment frag
20 #pragma multi_compile_particles
21
22 #include "UnityCG.cginc"
23
24 sampler2D _MainTex;
25 fixed4 _TintColor;
26
27 struct appdata_t {
28 float4 vertex : POSITION;
29 fixed4 color : COLOR;
30 float2 texcoord : TEXCOORD0;
31 };
32
33 struct v2f {
34 float4 vertex : POSITION;
35 fixed4 color : COLOR;
36 float2 texcoord : TEXCOORD0;
37 #ifdef SOFTPARTICLES_ON
38 float4 projPos : TEXCOORD1;
39 #endif
40 };
41
42 float4 _MainTex_ST;
43
44 v2f vert (appdata_t v)
45 {
46 v2f o;
47 o.vertex = mul(UNITY_MATRIX_MVP, 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 return o;
55 }
56
57 sampler2D _CameraDepthTexture;
58 float _InvFade;
59
60 fixed4 frag (v2f i) : COLOR
61 {
62 #ifdef SOFTPARTICLES_ON
63 float sceneZ = LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_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
69 half4 prev = i.color * tex2D(_MainTex, i.texcoord);
70 prev.rgb *= prev.a;
71 return prev * _TintColor;
72 }
73 ENDCG
74 }
75 }
76 }
77 }