#define SAMPLES_X 4
#define SAMPLES_Y 4

#define PI 3.14159265

vec3 palette(float x)
{
    return 0.5 + 0.5 * cos(x * PI * 2.0 + vec3(0,2,4));
}


vec2 distort(vec2 p)
{
    return p * (1.0 + 1.0 * pow(dot(p,p), sin(iTime)));
}

vec3 getCol(vec2 p)
{
    vec2 distorted = distort(p);
    float a = 3.0;
    float b = 10.0;
    const float lineThickness = 0.01;
    float lineFuzzy = 1.0 / iResolution.y;
    vec3 col = palette((floor(distorted.x * a) + floor(distorted.y * a) + iTime * 3.0) / b);
    col *= float(abs(distorted.x * a - round(distorted.x * a)) > 0.02);
    col *= float(abs(distorted.y * a - round(distorted.y * a)) > 0.02);
    return col;
}

void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
    vec2 p = (2.0 * fragCoord - iResolution.xy ) / iResolution.y;
    
    vec3 col = vec3(0.0);
    for (int i = 0; i < SAMPLES_X; i++) {
        for (int j = 0; j < SAMPLES_Y; j++) {
            vec2 offs = vec2(float(i) / float(SAMPLES_X - 1),
                             float(j) / float(SAMPLES_Y - 1)) * 2.0 - 1.0;
            offs /= iResolution.y;
            col += getCol(p + offs);
        }
    }
    col /= float(SAMPLES_X * SAMPLES_Y);
    
    fragColor = vec4(col,1.0);
}` 
