File tree Expand file tree Collapse file tree 1 file changed +64
-0
lines changed
Assets/Shaders/2D/Effects Expand file tree Collapse file tree 1 file changed +64
-0
lines changed Original file line number Diff line number Diff line change
1
+ Shader "UnityLibrary/2D/Effects/ColorCycle"
2
+ {
3
+ Properties
4
+ {
5
+ _MainTex ( "Grayscale" , 2D ) = "white" {}
6
+ _GradientTex ( "Gradient" , 2D ) = "white" {}
7
+ _Speed( "Speed" ,float ) = 1
8
+ }
9
+
10
+ SubShader
11
+ {
12
+ Tags { "RenderType" ="Opaque" }
13
+ LOD 100
14
+
15
+ Pass
16
+ {
17
+ CGPROGRAM
18
+ #pragma vertex vert
19
+ #pragma fragment frag
20
+
21
+ #include "UnityCG.cginc"
22
+
23
+ struct appdata
24
+ {
25
+ float4 vertex : POSITION ;
26
+ float2 uv : TEXCOORD0 ;
27
+ };
28
+
29
+ struct v2f
30
+ {
31
+ float2 uv : TEXCOORD0 ;
32
+ float4 vertex : SV_POSITION ;
33
+ };
34
+
35
+ sampler2D _MainTex;
36
+ sampler2D _GradientTex;
37
+ float4 _MainTex_ST;
38
+ float _Speed;
39
+
40
+ v2f vert (appdata v)
41
+ {
42
+ v2f o;
43
+ o.vertex = UnityObjectToClipPos (v.vertex);
44
+ o.uv = TRANSFORM_TEX (v.uv, _MainTex);
45
+ return o;
46
+ }
47
+
48
+ fixed4 frag (v2f i) : SV_Target
49
+ {
50
+ // get (grayscale texture) pixel color
51
+ float gray = tex2D (_MainTex, i.uv).r;
52
+
53
+ // get scrolling
54
+ float scroll = frac (_Time .x*_Speed);
55
+
56
+ // get gradient color from texture
57
+ fixed4 col = tex2D (_GradientTex,float2 (gray+scroll,0.5 ));
58
+
59
+ return col;
60
+ }
61
+ ENDCG
62
+ }
63
+ }
64
+ }
You can’t perform that action at this time.
0 commit comments