
#define r(a)    mat2( cos(a+vec4(0,11,33,0)) )                // rotation
#define hue(v) ( .6 + .6 * cos( v  + vec4(0,23,21,0)  ) )     // hue

void mainImage(out vec4 O, vec2 U) {
    vec3  R = iResolution,     // 3.*R.y for normal field of view
          D = normalize(vec3( U+U, -R.y ) - R ),              // ray direction
          p = 30./R, q,                                       // marching point along ray
          M = cos(iTime+vec3(0,11,0)) / vec3(1,2,.5);         // camera animation
    float t=9.,d;

    for ( O += 1.1-O ; O.x > 0. && t > .01 ; O-=.01 ) //  O.x>0. just for security
        q = p,
        q.yz *= r( .5+M.y ),                                  // rotations
        q.xz *= r(    M.x ),          // R0=20        R1=17
        t = abs( length(vec2(d=length(q.xz)-20., q.y)) - 17.),// abs for inside + outside
        p += .9*t*D;                                          // step forward = dist to obj

    U  = 2.* atan( q.zy, vec2(q.x,d) );                       // strip texture
    O *= ( .5 + .5* sin(9.*(U.x+=U.y)) )  * hue(U.x);
}