thebookofshaders/09/lines-wave.frag

35 lines
747 B
GLSL
Raw Normal View History

2015-09-15 14:07:53 +00:00
// Author @patriciogv - 2015 - patricio.io
2015-09-24 17:15:49 +00:00
2015-09-15 14:07:53 +00:00
#ifdef GL_ES
precision mediump float;
#endif
2015-09-24 17:15:49 +00:00
#define PI 3.1415926535897932384626433832795
2015-09-15 14:07:53 +00:00
uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;
2015-09-24 17:15:49 +00:00
vec2 wave(vec2 st, float freq) {
st.y += cos(st.x*freq);
return st;
}
vec2 zigzag(vec2 st, float freq) {
st.y += mix(abs(floor(sin(st.x*3.1415))),abs(floor(sin((st.x+1.)*3.1415))),fract(st.x*freq));
return st;
2015-09-15 14:07:53 +00:00
}
2015-09-24 17:15:49 +00:00
float line(vec2 st, float width) {
return step(width,1.0-smoothstep(.0,1.,abs(sin(st.y*PI))));
2015-09-15 14:07:53 +00:00
}
void main(){
vec2 st = gl_FragCoord.xy/u_resolution.xy;
st.x *= u_resolution.x/u_resolution.y;
2015-09-24 17:15:49 +00:00
st *= 10.;
st = wave(st, 3.);
vec3 color = vec3(line(st,.5));
2015-09-15 14:07:53 +00:00
gl_FragColor = vec4(color, 1.0);
}