-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgradientShiftingFromUpperLeftCorner.frag
54 lines (45 loc) · 2.25 KB
/
gradientShiftingFromUpperLeftCorner.frag
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifdef GL_ES
precision mediump float;
#endif
#define PI 3.14159265359
uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;
vec3 colorA = vec3(0.0157, 0.1412, 0.1451);
vec3 colorB = vec3(0.6353, 0.5529, 0.5529);
float plot(vec2 st, float pct) {
return smoothstep(pct - 0.01, pct, st.y) -
smoothstep(pct, pct + 0.01, st.y);
}
void main() {
vec2 st = gl_FragCoord.xy / u_resolution.xy;
vec3 color = vec3(0.0);
vec3 pct = vec3(0);
// float rShifttx = (sin(u_time * .9) + 1.) / 2.;
// float rShiftx = smoothstep(0., rShifttx, st.x) - smoothstep(rShifttx, 1., st.x);
// float rShiftty = (sin(u_time * 1.15) + 1.) / 2.;
// float rShifty = smoothstep(0., rShiftty, st.y) - smoothstep(rShiftty, 1., st.y);
float rShifttxy = (sin(u_time * 1.15) + 1.) / 2.;
float rShiftxy = smoothstep(0., rShifttxy, mix(st.x, st.y, rShifttxy)) - smoothstep(rShifttxy, 1., mix(st.x, st.y, rShifttxy));
pct.r = sin(rShiftxy * PI / 2.);
// float gShifttx = (sin(u_time) + 1.) / 2.;
// float gShiftx = smoothstep(0., gShifttx, st.x) - smoothstep(gShifttx, 1., st.x);
// float gShiftty = (sin(u_time * 1.32) + 1.) / 2.;
// float gShifty = smoothstep(0., gShiftty, st.y) - smoothstep(gShiftty, 1., st.y);
float gShifttxy = (sin(u_time * 1.03) + 1.) / 2.;
float gShiftxy = smoothstep(0., gShifttxy, mix(st.x, st.y, gShifttxy)) - smoothstep(gShifttxy, 1., mix(st.x, st.y, gShifttxy));
pct.g = sin(gShiftxy * PI / 2.);
// float bShifttx = (sin(u_time * 1.2) + 1.) / 2.;
// float bShiftx = smoothstep(0., bShifttx, st.x) - smoothstep(bShifttx, 1., st.x);
// float bShiftty = (sin(u_time * .83) + 1.) / 2.;
// float bShifty = smoothstep(0., bShiftty, st.y) - smoothstep(bShiftty, 1., st.y);
float bShifttxy = (sin(u_time * .98) + 1.) / 2.;
float bShiftxy = smoothstep(0., bShifttxy, mix(st.x, st.y, bShifttxy)) - smoothstep(bShifttxy, 1., mix(st.x, st.y, bShifttxy));
pct.b = sin(bShiftxy * PI / 2.);
color = mix(colorA, colorB, pct);
// Plot transition lines for each channel
// color = mix(color,vec3(1.0,0.0,0.0),plot(st,pct.r));
// color = mix(color,vec3(0.0,1.0,0.0),plot(st,pct.g));
// color = mix(color,vec3(0.0,0.0,1.0),plot(st,pct.b));
gl_FragColor = vec4(color, 1.0);
}