Skip to content

Instantly share code, notes, and snippets.

@KHN190 KHN190/dots.frag Secret
Created Sep 23, 2019

Embed
What would you like to do?
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform float u_time;
vec2 tiling(vec2 _st, float _zoom) {
_st *= _zoom;
_st.x += step(1., mod(_st.y, 2.0)) * 1.0;
return fract(_st);
}
float circle(in vec2 _st, in float _radius){
vec2 dist = _st - vec2(0.5);
return 1. - smoothstep(
_radius-0.01,
_radius+0.01,
dot(dist,dist)*4.0);
}
void main() {
vec2 st = gl_FragCoord.xy/u_resolution.xy;
float time = u_time * 0.1;
float xrow, yrow;
bool cycle = mod(time, .6) > .3;
if (cycle)
{
xrow = mod(st.x * 10.0, 2.0) - 1.0;
st.y += sign(xrow) * fract(time) * 1.0;
}
else
{
yrow = mod(st.y * 10.0, 2.0) - 1.0;
st.x += sign(yrow) * fract(time) * 1.0;
}
st = tiling(st, 10.0);
vec3 color = vec3(circle(st, .2));
gl_FragColor = vec4(color, 1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.