0.00
60.0 fps

Circle Inversion

Circle inversion of a grid with circles.

Log in to post a comment.

#version 300 es
precision highp float;

uniform float iTime;
uniform vec2  iResolution;

out vec4 fragColor;

#define AA 4

void main() {
    vec2 q   = (2. * gl_FragCoord.xy - iResolution) / iResolution.y;

    vec3 outCol = vec3(0);
    
    for(int x=0; x<AA; x++) {
        for(int y=0; y<AA; y++) {
            vec2 qa = (q + 2. * vec2(x,y) / float(AA) / iResolution.y) * 1.5;

            // reflection
            vec2 refl = qa / dot(qa, qa) + vec2(2, 1.61803398875) * iTime * .2;

            vec3 col = mod(floor(refl.x) + floor(refl.y), 2.) > .5 ? vec3(80,153,160) : vec3(232,130,90);

            float dist = length(fract(refl)-.5);
            
            col *= .3 + .7 * smoothstep(.5, .5-fwidth(dist), dist);
            
            outCol += mix(vec3(233, 215, 175), col, smoothstep(.5+fwidth(dist), .5-fwidth(dist), dist)) / 255.;
        }
    }
    
    outCol /= (float(AA)*float(AA));

    fragColor = vec4(outCol, 1.);
}