-
Notifications
You must be signed in to change notification settings - Fork 1
/
Functions_&_Curves_II.frag
43 lines (33 loc) · 1002 Bytes
/
Functions_&_Curves_II.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
// Author: Jeremy Rotsztain
// Workshop: Generating Images with Shaders @ InterAccess, 2020
// Title: Functions & Curves II
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;
// Function from Iñigo Quiles
// https://www.iquilezles.org/www/articles/functions/functions.htm
float cubicPulse( float c, float w, float x )
{
x = abs(x - c);
if( x>w ) return 0.0;
x /= w;
return 1.0 - x*x*(3.0-2.0*x);
}
float plot( vec2 xy, float amt){
if( amt > xy.y - 0.006 && amt < xy.y + 0.006) return 1.0;
return 0.;
}
void main() {
vec2 st = gl_FragCoord.xy/u_resolution.xy;
st.x *= u_resolution.x/u_resolution.y;
vec3 color;
color.r = (cubicPulse(.5, 0.500, st.x ));
//color.g = (cubicPulse(0.036, 0.7, st.x ));
//color.b = (cubicPulse(0.700, 1.308, st.x ));
// plot it
color = mix( color, vec3(0.0, 1.0, 0.0), plot(st, color.r));
gl_FragColor = vec4(color,1.0);
}