-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathedge.fs
43 lines (31 loc) · 1.07 KB
/
edge.fs
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
precision highp float;
varying vec3 v_position;
varying float v_opacity;
uniform vec2 mouse;
uniform float elapsed;
void main() {
float change = 0.0008;
float r = cos(elapsed * change);
float g = sin(elapsed * change);
float b = sin(elapsed * change);
float signR = r / abs(r);
float signG = g / abs(g);
float signB = b / abs(b);
float mouseX = abs(mouse.x);
float mouseY = abs(mouse.y);
r = (r / 2.0 + 0.5) * v_position.x * mouseX;
g = (g / 2.0 + 0.5) * v_position.y * mouseY;
b = (b / 2.0 + 0.5) * v_position.x * mouseX;
// r = pow(r, 1.2) * signR;
// g = pow(g, 1.2) * signG;
// b = pow(b, 1.2) * signB;
float mouseDistance = distance(mouse, v_position.xy);
r += max(0.0, 0.1 - mouseDistance) * (sin(elapsed / 10.0) / 2.0 + 0.5);
g += max(0.0, 0.1 - mouseDistance) * (cos(elapsed / 9.0) / 2.0 + 0.5);
b += max(0.0, 0.1 - mouseDistance) * (sin(elapsed / 8.0) / 2.0 + 0.5);
r = max(0.05, min(0.85, r));
g = max(0.1, min(0.9, g));
b = max(0.15, min(0.95, b));
float opacity = v_opacity * 2.0;
gl_FragColor = vec4(r, g, b, opacity);
}