mirror of
https://github.com/patriciogonzalezvivo/thebookofshaders
synced 2024-11-08 01:10:27 +00:00
47 lines
1.0 KiB
GLSL
47 lines
1.0 KiB
GLSL
// Author @patriciogv - 2015 - patricio.io
|
|
|
|
#ifdef GL_ES
|
|
precision mediump float;
|
|
#endif
|
|
|
|
const float PI = 3.1415926535897932384626433832795;
|
|
|
|
uniform vec2 u_resolution;
|
|
uniform vec2 u_mouse;
|
|
uniform float u_time;
|
|
|
|
vec2 movingTiles(vec2 _st, float _zoom, float _speed){
|
|
_st *= _zoom;
|
|
float time = u_time*_speed;
|
|
if( fract(time)>0.5 ){
|
|
if (fract( _st.y * 0.5) > 0.5){
|
|
_st.x += fract(time)*2.0;
|
|
} else {
|
|
_st.x -= fract(time)*2.0;
|
|
}
|
|
} else {
|
|
if (fract( _st.x * 0.5) > 0.5){
|
|
_st.y += fract(time)*2.0;
|
|
} else {
|
|
_st.y -= fract(time)*2.0;
|
|
}
|
|
}
|
|
return fract(_st);
|
|
}
|
|
|
|
float circle(vec2 _st, float _radius){
|
|
vec2 pos = vec2(0.5)-_st;
|
|
return smoothstep(1.0-_radius,1.0-_radius+_radius*0.2,1.-dot(pos,pos)*3.14);
|
|
}
|
|
|
|
void main() {
|
|
vec2 st = gl_FragCoord.xy/u_resolution.xy;
|
|
st.x *= u_resolution.x/u_resolution.y;
|
|
|
|
st = movingTiles(st,10.,0.5);
|
|
|
|
vec3 color = vec3( 1.0-circle(st, 0.3 ) );
|
|
|
|
gl_FragColor = vec4(color,1.0);
|
|
}
|