vec3 palette( float t )
{
    vec3 a = vec3(1.198, 0.500, 0.508);
    vec3 b = vec3(0.958, 0.500, 0.908);
    vec3 c = vec3(0.188, 2.048, 1.088);
    vec3 d = vec3(0.638, 0.428, 0.748);
    
    return a + b*cos(6.28318*(c*t+d));
}

void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
    // Normalized pixel coordinates (from 0 to 1)
    vec2 uv = (fragCoord * 2.0 - iResolution.xy) / iResolution.y;
    vec2 uv0 = uv;
    
    vec3 finalColor = vec3(0.0);
    
    for (float i = 0.0; i < 3.0; i++) {
        uv = fract(uv * 1.25) - 0.5;

        float d = length(uv) * exp(-length(uv0));
        vec3 col = palette(length(uv0) + i*0.4 + iTime*0.4);
        d = sin(d * 20.0 + iTime * 2.0)/5.0; 
        d = abs(d);
        d = pow(0.01 / d, 1.3);

        finalColor += col*d;
    }
    
    // Output to screen
    fragColor = vec4(finalColor,1.0);
}
