#version 330 core

uniform vec3 iResolution;
uniform float iTime;
uniform float uAlpha;

out vec4 FragColor;

void mainImage(out vec4 o, vec2 u) {
    float d, i, s, n, l,
          t = iTime*.1;
    vec3 q,p = iResolution;
    u = (u-p.xy/2.)/p.y;
    for(o*=i;
        i++<90.;
        d += s = .025 + abs(min(l,s))*.175,
        o += 1. / s)
        for(q = p = vec3(u * d, d),
            s =  .3+p.y,
            q = cos(4.*t+p.zxy*p.yzz),
            l = dot(abs(q-floor(q)-.5), vec3(1)), 
            n = 2.;
            n < 32.;
            n += n )
            s += abs(dot(sin(3.*t + p*n ), vec3(.5))) / n;
    o = tanh(vec4(3,1,7,1) * o / d / 4e3 / length(u));
}

void main()
{
    vec2 fragCoord = gl_FragCoord.xy;
    vec4 col = vec4(0);
    mainImage(col, fragCoord);
    col.a *= uAlpha;
    FragColor = col;
}
