#define H(a) (cos(radians(vec3(100, 140, 190))-((a)*6.2832))*.5+.5) // hue pallete
#define RT(a) mat2(cos(m.a*1.571+vec4(0,-1.571,1.571,0))) // rotate
void mainImage( out vec4 C, in vec2 U )
{
    vec3  c = vec3(0),
          o = vec3(1 ,1.732, 1),
          u, v, a, b;
    vec2  R = iResolution.xy,
          m = iMouse.xy/R*4.-2.,
          uv = (U-.5*R)/R.y; // 2d coords
    float t = iTime/5.,
          tr = smoothstep(0., 1., sin(t)*.6+.5),
          s = tr*4.+2., // scale
          h;
    if (iMouse.z < 1.)
        m = vec2(sin(t/2.)*.6, sin(t)*.4); // rotate with time
    mat2  pitch = RT(y),
          yaw = RT(x);
    for (float i = .1; i < 1.; i+=.1)
    {
        u = normalize(vec3(uv, .7*sqrt(i)))*s; // 3d coords
        u.yz *= pitch;
        u.xz *= yaw;

        // add distortion
        u.xy += sin(uv.yx*20.0+t)*0.1;
        u.xz += sin(uv.yx*30.0+t)*0.2;
        u.yz += sin(uv.yx*10.0+t)*0.15;

        // simple hexagonal tiles by lomateron https://www.shadertoy.com/view/MlXyDl
        a = mod(u, o)*2.-o;
        b = mod(u+o*.5, o)*2.-o;
        h = min(dot(a, a), dot(b, b))*.5;

        v = h*h*H(i-t/5.);
        float k = 1.2-max(i, tr-i); // increase contrast
        c += v*k;
    }
    // add more color
    c *= vec3(1.0, 0.8, 1.2);
    c = pow(c, vec3(2.5)) * 0.5 + 0.05;
    C = vec4(c, 1);
}