aboutsummaryrefslogtreecommitdiff
path: root/res/shaders/glsl330/curved-line.fs
diff options
context:
space:
mode:
Diffstat (limited to 'res/shaders/glsl330/curved-line.fs')
-rw-r--r--res/shaders/glsl330/curved-line.fs55
1 files changed, 55 insertions, 0 deletions
diff --git a/res/shaders/glsl330/curved-line.fs b/res/shaders/glsl330/curved-line.fs
new file mode 100644
index 0000000..58e65ed
--- /dev/null
+++ b/res/shaders/glsl330/curved-line.fs
@@ -0,0 +1,55 @@
1#version 330 core
2
3#define PI 3.14159265359
4
5uniform vec2 resolution;
6uniform vec2 mouse;
7uniform float time;
8
9out vec4 color;
10
11float
12plot (vec2 st, float pct)
13{
14 return
15 smoothstep (pct - 0.02, pct, st.y) -
16 smoothstep (pct, pct + 0.02, st.y);
17}
18
19void
20main ()
21{
22 vec2 st = gl_FragCoord.xy/resolution;
23 vec2 mt = mouse/resolution;
24
25 float x = st.x;
26 float y;
27
28 y = pow (x, PI);
29 // y = exp (x - 1);
30 // y = log (x + 1);
31 // y = sqrt (x);
32 // y = step (mt.x, x);
33 // y = smoothstep (mt.x, 1 - mt.x, x);
34 // y =
35 // smoothstep (.2, .5, x) -
36 // smoothstep (.5, .8, x);
37 // y = (sin (2*PI*x + time) + 1)/2;
38 // y = (cos (2*PI*x + time) + 1)/2;
39 // y = mod (x, 1./4)*4;
40 // y = fract (x*4);
41 // y = ceil (x*4)/4;
42 // y = floor (x*4)/4;
43 // y = sign (x - 0.5);
44 // y = abs (x - 1./2)*2;
45 // y = (clamp (x, 1./4, 3./4) - 1./4)*2;
46 // y = min (1./2, x)*2;
47 // y = (max (.5, x) - 1./2)*2;
48
49 vec3 c = vec3 (y);
50
51 float pct = plot (st, y);
52 c = (1 - pct)*c + pct*vec3 (0, 1, 0);
53
54 color = vec4 (c, 1);
55}