diff options
Diffstat (limited to 'pass1.frag')
-rw-r--r-- | pass1.frag | 43 |
1 files changed, 31 insertions, 12 deletions
@@ -9,22 +9,25 @@ 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.04; +const float step = 0.03; 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 = 20.0; // circle radius - - vec2 norm = (uv - 0.5) * 2.0; - norm.x *= float(res.x) / float(res.y); // adjust for aspect ratio - float offset = time * 7.0; + 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 mag = 1.3 + 0.5 * sin(2 * time); - float size = 0.4 + 0.1 * sin(3 * time); + float offset = time * 1.0; - color = vec4(0.0); + float mag = 1.3 + 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) { // <https://www.desmos.com/calculator/e0kq6z1ndd> @@ -33,11 +36,27 @@ void main() { sin(t) + mag * sin(turns * t + offset) ); f *= size; - if (length(f - norm) < 0.01) { - color = vec4(1.0, 1.0, 1.0, 1.0); + if (length(f - gc) < r) { + color += vec4(white, 1.0); } } - color += texture(buf, ((uv - 0.5) * 0.99) + 0.5) * 0.97; + // 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.98; } |