Part Tools Import
[VesselSimulator.git] / Assets / SquadCore / Shaders / ParticleAdd.shader
cybutek 1 Shader "KSP/Particles/Additive"
2 {
3 Properties
4 {
5 _TintColor ("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 {
12 Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
13 Blend SrcAlpha One
14 AlphaTest Greater .01
15 ColorMask RGB
16 Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) }
17 BindChannels {
18 Bind "Color", color
19 Bind "Vertex", vertex
20 Bind "TexCoord", texcoord
21 }
22
23 // ---- Fragment program cards
24 SubShader
25 {
26 Pass
27 {
28
29 CGPROGRAM
30 #pragma vertex vert
31 #pragma fragment frag
32 #pragma fragmentoption ARB_precision_hint_fastest
33 #pragma multi_compile_particles
34
35 #include "UnityCG.cginc"
36
37 sampler2D _MainTex;
38 fixed4 _TintColor;
39
40 struct appdata_t
41 {
42 float4 vertex : POSITION;
43 fixed4 color : COLOR;
44 float2 texcoord : TEXCOORD0;
45 };
46
47 struct v2f
48 {
49 float4 vertex : POSITION;
50 fixed4 color : COLOR;
51 float2 texcoord : TEXCOORD0;
52 #ifdef SOFTPARTICLES_ON
53 float4 projPos : TEXCOORD1;
54 #endif
55 };
56
57 float4 _MainTex_ST;
58
59 v2f vert (appdata_t v)
60 {
61 v2f o;
62 o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
63 #ifdef SOFTPARTICLES_ON
64 o.projPos = ComputeScreenPos (o.vertex);
65 COMPUTE_EYEDEPTH(o.projPos.z);
66 #endif
67 o.color = v.color;
68 o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
69 return o;
70 }
71
72 sampler2D _CameraDepthTexture;
73 float _InvFade;
74
75 fixed4 frag (v2f i) : COLOR
76 {
77 #ifdef SOFTPARTICLES_ON
78 float sceneZ = LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos))));
79 float partZ = i.projPos.z;
80 float fade = saturate (_InvFade * (sceneZ-partZ));
81 i.color.a *= fade;
82 #endif
83
84 return 2.0f * i.color * _TintColor * tex2D(_MainTex, i.texcoord);
85 }
86 ENDCG
87 }
88 }
89
90 // ---- Dual texture cards
91 SubShader {
92 Pass {
93 SetTexture [_MainTex] {
94 constantColor [_TintColor]
95 combine constant * primary
96 }
97 SetTexture [_MainTex] {
98 combine texture * previous DOUBLE
99 }
100 }
101 }
102
103 // ---- Single texture cards (does not do color tint)
104 SubShader
105 {
106 Pass
107 {
108 SetTexture [_MainTex] {
109 combine texture * primary
110 }
111 }
112 }
113 }
114 }
115