Log in to post a comment.

#version 300 es
precision highp float;

// Forked from "Circle Inversion" by reinder
// https://oneshader.net/shader/ab89ae6583


uniform float iLoop;
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) * 2.;

            // reflection
            vec2 refl = qa + vec2(1,-1) * qa / dot(qa, qa) + vec2(iLoop * 2., 0);

            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.);
}