#version 460 core #include "consts.h" layout(location = 0) out vec4 color; in vec4 gl_FragCoord; layout(location = U_LOC_TIME) uniform float time; layout(location = U_LOC_PASS1) uniform sampler2D buf; ivec2 res = ivec2(RES_H, RES_V); const float step = 0.02; const float turns = 9.0; const vec3 white = vec3(1.0, 1.0, 1.0); const vec3 black = vec3(0.0, 0.0, 0.0); void main() { color = vec4(black, 0.0); vec2 uv = gl_FragCoord.xy / res.xy; float r = 0.007; // circle radius vec2 gc = (uv - 0.5) * 2.0; // graph coordinates (-1,-1) to (1,1) gc.x *= float(res.x) / float(res.y); // adjust circle aspect ratio float offset = time * 4.0; float mag = 1.5 + 0.5 * sin(2 * time); // braid ratio float size = 0.4 + 0.1 * sin(3 * time); // total size for (float t = 0.0; t < PI_2; t += step) { // vec2 f = vec2( cos(t) + mag * cos(turns * t + offset), sin(t) + mag * sin(turns * t + offset) ); f *= size; if (length(f - gc) < r) { color += vec4(white, 1.0); } } // create border if (uv.x < 0.002) color += vec4(white * 0.7, 1.0); if (uv.y < 0.002) color += vec4(white * 0.7, 1.0); if (uv.x > 0.998) color += vec4(white * 0.7, 1.0); if (uv.y > 0.998) color += vec4(white * 0.7, 1.0); vec2 fbuv = uv; // framebuffer transformed uv const float sway = 0.1; fbuv -= 0.5; // center at (0,0) const float angle = 0.04 * sin(sway * time); fbuv *= mat2(cos(angle), -sin(angle), sin(angle), cos(angle)); // rotate fbuv *= 1.0 + 0.02 * sin(2 * sway * time); // zoom out fbuv += 0.5; // restore center // add transformed version of previous frame on top color += texture(buf, fbuv) * 0.99; }