aboutsummaryrefslogtreecommitdiff
path: root/res/shaders/glsl330/curved-line.fs
blob: 58e65ed7ce81336c726912b8666bbbf92182b788 (plain)
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
#version 330 core

#define PI 3.14159265359

uniform vec2 resolution;
uniform vec2 mouse;
uniform float time;

out vec4 color;

float
plot (vec2 st, float pct)
{
  return
    smoothstep (pct - 0.02, pct,        st.y) -
    smoothstep (pct,        pct + 0.02, st.y);
}

void
main ()
{
  vec2 st = gl_FragCoord.xy/resolution;
  vec2 mt = mouse/resolution;

  float x = st.x;
  float y;

  y = pow (x, PI);
  // y = exp (x - 1);
  // y = log (x + 1);
  // y = sqrt (x);
  // y = step (mt.x, x);
  // y = smoothstep (mt.x, 1 - mt.x, x);
  // y =
  //   smoothstep (.2, .5, x) -
  //   smoothstep (.5, .8, x);
  // y = (sin (2*PI*x + time) + 1)/2;
  // y = (cos (2*PI*x + time) + 1)/2;
  // y = mod (x, 1./4)*4;
  // y = fract (x*4);
  // y = ceil (x*4)/4;
  // y = floor (x*4)/4;
  // y = sign (x - 0.5);
  // y = abs (x - 1./2)*2;
  // y = (clamp (x, 1./4, 3./4) - 1./4)*2;
  // y = min (1./2, x)*2;
  // y = (max (.5, x) - 1./2)*2;

  vec3 c = vec3 (y);

  float pct = plot (st, y);
  c = (1 - pct)*c + pct*vec3 (0, 1, 0);

  color = vec4 (c, 1);
}