Skip to content

Commit a090e4b

Browse files
authored
Create Additive-ScrollingUV.shader
1 parent e02307a commit a090e4b

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license
2+
3+
Shader "UnityLibrary/Particles/Additive Scrolling UV" {
4+
Properties {
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+
_ScrollingSpeed("Scrolling Speed",float) = 2
9+
}
10+
11+
Category {
12+
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
13+
Blend SrcAlpha One
14+
ColorMask RGB
15+
Cull Off Lighting Off ZWrite Off
16+
17+
SubShader {
18+
Pass {
19+
20+
CGPROGRAM
21+
#pragma vertex vert
22+
#pragma fragment frag
23+
#pragma target 2.0
24+
#pragma multi_compile_particles
25+
#pragma multi_compile_fog
26+
27+
#include "UnityCG.cginc"
28+
29+
sampler2D _MainTex;
30+
fixed4 _TintColor;
31+
float _ScrollingSpeed;
32+
33+
struct appdata_t {
34+
float4 vertex : POSITION;
35+
fixed4 color : COLOR;
36+
float2 texcoord : TEXCOORD0;
37+
UNITY_VERTEX_INPUT_INSTANCE_ID
38+
};
39+
40+
struct v2f {
41+
float4 vertex : SV_POSITION;
42+
fixed4 color : COLOR;
43+
float2 texcoord : TEXCOORD0;
44+
UNITY_FOG_COORDS(1)
45+
#ifdef SOFTPARTICLES_ON
46+
float4 projPos : TEXCOORD2;
47+
#endif
48+
UNITY_VERTEX_OUTPUT_STEREO
49+
};
50+
51+
float4 _MainTex_ST;
52+
53+
v2f vert (appdata_t v)
54+
{
55+
v2f o;
56+
UNITY_SETUP_INSTANCE_ID(v);
57+
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
58+
o.vertex = UnityObjectToClipPos(v.vertex);
59+
#ifdef SOFTPARTICLES_ON
60+
o.projPos = ComputeScreenPos (o.vertex);
61+
COMPUTE_EYEDEPTH(o.projPos.z);
62+
#endif
63+
o.color = v.color;
64+
o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
65+
UNITY_TRANSFER_FOG(o,o.vertex);
66+
return o;
67+
}
68+
69+
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
70+
float _InvFade;
71+
72+
fixed4 frag (v2f i) : SV_Target
73+
{
74+
#ifdef SOFTPARTICLES_ON
75+
float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
76+
float partZ = i.projPos.z;
77+
float fade = saturate (_InvFade * (sceneZ-partZ));
78+
i.color.a *= fade;
79+
#endif
80+
81+
fixed4 col = 2.0f * i.color * _TintColor * tex2D(_MainTex, float2(i.texcoord.x+_Time.x*_ScrollingSpeed,i.texcoord.y));
82+
UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(0,0,0,0)); // fog towards black due to our blend mode
83+
return col;
84+
}
85+
ENDCG
86+
}
87+
}
88+
}
89+
}

0 commit comments

Comments
 (0)