Part Tools Import
[VesselSimulator.git] / Assets / SquadCore / Shaders / ParticleAlpha.shader
cybutek 1 Shader "KSP/Particles/Alpha Blended"
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 OneMinusSrcAlpha
14 AlphaTest Greater .01
15 ColorMask RGB
16 Cull Off Lighting Off ZWrite Off
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 float4 vertex : POSITION;
42 fixed4 color : COLOR;
43 float2 texcoord : TEXCOORD0;
44 };
45
46 struct v2f {
47 float4 vertex : POSITION;
48 fixed4 color : COLOR;
49 float2 texcoord : TEXCOORD0;
50 #ifdef SOFTPARTICLES_ON
51 float4 projPos : TEXCOORD1;
52 #endif
53 };
54
55 float4 _MainTex_ST;
56
57 v2f vert (appdata_t v)
58 {
59 v2f o;
60 o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
61 #ifdef SOFTPARTICLES_ON
62 o.projPos = ComputeScreenPos (o.vertex);
63 COMPUTE_EYEDEPTH(o.projPos.z);
64 #endif
65 o.color = v.color;
66 o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
67 return o;
68 }
69
70 sampler2D _CameraDepthTexture;
71 float _InvFade;
72
73 fixed4 frag (v2f i) : COLOR
74 {
75 #ifdef SOFTPARTICLES_ON
76 float sceneZ = LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos))));
77 float partZ = i.projPos.z;
78 float fade = saturate (_InvFade * (sceneZ-partZ));
79 i.color.a *= fade;
80 #endif
81
82 return 2.0f * i.color * _TintColor * tex2D(_MainTex, i.texcoord);
83 }
84 ENDCG
85 }
86 }
87
88 // ---- Dual texture cards
89 SubShader
90 {
91 Pass
92 {
93 SetTexture [_MainTex]
94 {
95 constantColor [_TintColor]
96 combine constant * primary
97 }
98 SetTexture [_MainTex]
99 {
100 combine texture * previous DOUBLE
101 }
102 }
103 }
104
105 // ---- Single texture cards (does not do color tint)
106 SubShader
107 {
108 Pass
109 {
110 SetTexture [_MainTex]
111 {
112 combine texture * primary
113 }
114 }
115 }
116 }
117 }
118