-
Notifications
You must be signed in to change notification settings - Fork 6
/
math_functions.frag
62 lines (47 loc) · 1.92 KB
/
math_functions.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
55
56
57
58
59
60
61
62
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
#include "lygia/draw/stroke.glsl"
#include "lygia/space/ratio.glsl"
#include "lygia/space/scale.glsl"
#include "lygia/color/palette/hue.glsl"
#include "lygia/math/gain.glsl"
#include "lygia/math/bump.glsl"
#include "lygia/math/parabola.glsl"
#include "lygia/math/gaussian.glsl"
#include "lygia/math/permute.glsl"
#include "lygia/math/cubic.glsl"
#include "lygia/math/invCubic.glsl"
#include "lygia/math/quartic.glsl"
#include "lygia/math/invQuartic.glsl"
#include "lygia/math/quintic.glsl"
#include "lygia/math/saturate.glsl"
#include "lygia/math/decimate.glsl"
#include "lygia/math/mirror.glsl"
void main(void) {
vec3 color = vec3(0.0);
vec2 pixel = 1.0/u_resolution.xy;
vec2 st = scale(ratio(gl_FragCoord.xy * pixel, u_resolution), 1.5);
float x = st.x;
float w = pixel.y * 5.0;
color += stroke(st.y, bump(x * 2.0 - 1.0, 0.0), w) * hue(0.0);
color += stroke(st.y, parabola(x, 0.7), w) * hue(0.25);
color += stroke(st.y, gaussian(x * 2.0 - 1.0, 0.7), w) * hue(0.6);
color += stroke(st.y, permute(x * 2.0 - 1.0), w) * hue(0.75);
color += stroke(st.y, gain(x, 0.7), w) * hue(0.1);
color += stroke(st.y, cubic(x), w) * hue(0.2);
color += stroke(st.y, invCubic(x), w) * hue(0.3);
color += stroke(st.y, quartic(x), w) * hue(0.4);
color += stroke(st.y, invQuartic(x), w) * hue(0.5);
color += stroke(st.y, quintic(x), w) * hue(0.6);
color += stroke(st.y, saturate(x), w) * hue(0.7);
color += stroke(st.y, mirror(x), w) * hue(0.8);
color += stroke(st.y, decimate(x, 10.0), w) * hue(0.9);
// draw grid
color += stroke(fract(st.y), 0.01, pixel.y * 2.0) * 0.25;
color += stroke(fract(st.x), 0.01, pixel.x * 2.0) * 0.25;
color += stroke(fract(st.y * 10.0), 0.1, pixel.y * 10.) * 0.2;
color += stroke(fract(st.x * 10.0), 0.1, pixel.x * 10.) * 0.2;
gl_FragColor = vec4(color, 1.0);
}