06
Connect
const float RES = 32.;
const vec3 red = vec3(.6016, .3125, .3203);
float t = u_time * 2.;
vec2 mouse_offset = (u_mouse / u_resolution.xy) * -RES + RES * .5;
float line(vec2 p, vec2 a, vec2 b) {
vec2 ab = b - a;
vec2 ap = p - a;
float t = clamp(dot(ap, ab) / dot(ab, ab), 0., 1.);
float d = length(ap - ab * t);
return smoothstep(.2, .1, d);
}
vec2 position(vec2 ipos, vec2 offset) {
return (offset + vec2(sin(t), cos(t + length(ipos + offset + mouse_offset))) * .4);
}
void main() {
vec2 st = gl_FragCoord.xy / u_resolution.xy - .5;
st *= RES;
vec2 fpos = fract(st) - .5;
vec2 ipos = floor(st);
float d = line(
fpos,
position(ipos, vec2(0.)),
position(ipos, vec2(-1., 0.))
);
d += line(
fpos,
position(ipos, vec2(0.)),
position(ipos, vec2(1., 0.))
);
d += line(
fpos,
position(ipos, vec2(0.)),
position(ipos, vec2(0., -1.))
);
d += line(
fpos,
position(ipos, vec2(0.)),
position(ipos, vec2(0., 1.))
);
d -= smoothstep(.2, .1, length(fpos - position(ipos, vec2(0.)))) * 4.;
vec3 a = vec3(d);
gl_FragColor = vec4(red, a);
}