shader({ width: 600, height: 400, iTime: true, visibility })`
vec3 cosPalette(float t, vec3 brightness,vec3 contrast, vec3 osc, vec3 phase) {
return brightness + contrast *cos(6.28318 *(osc*t+phase));
}
// smooth mod(x,y) with radius smoothness of e
float smoothMod(float x, float y, float e){
float PI = 3.1415;
float top = cos(PI * (x/y)) * sin(PI * (x/y));
float bot = pow(sin(PI * (x/y)),2.);
float at = atan(top/bot);
return y * (1./2.) - (1./PI) * at ;
}
// Repeat around the origin by a fixed angle.
// For easier use, num of repetitions is use to specify the angle.
vec2 pModPolar(inout vec2 p, float repetitions) {
float PI = 3.14;
float angle = 2.*PI/repetitions;
float a = atan(p.y, p.x) + angle/2.;
float r = length(p);
float c = floor(a/angle);
a = smoothMod(a,angle,0.1) - angle/2.;
vec2 p2 = vec2(cos(a), sin(a))*r;
// For an odd number of repetitions, fix cell index of the cell in -x direction
// (cell index would be e.g. -5 and 5 in the two halves of the cell):
//if (abs(c) >= (repetitions/2.)) c = abs(c);
return p2;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 normCoord = fragCoord.xy/iResolution.xy;
float time = iTime*1.0;
vec2 uv = -1.0 + 2. * normCoord; // center coords
uv.x *= iResolution.x/iResolution.y; // remap uv.x to solvxqe
uv = pModPolar(uv,20.0);
uv.x += sin(iTime/10.);
float radius = length(uv*10.0);
float rings = sin(time-radius);
float angle= sin(atan(uv.x,uv.y)+time);
float swirly = sin(rings - cos(angle)*0.2 +time);
vec3 brightness = vec3(mix(0.7,0.1, sin(time+length(uv*20.))+1.)/2.);
vec3 contrast = vec3(0.15);
vec3 osc=vec3(0.5,1.0,0.0);
vec3 phase =vec3(0.4,0.9,0.2);
vec3 pallete = cosPalette(angle+swirly+rings,brightness,contrast,osc,phase);
vec4 color = vec4(pallete,1.0);
fragColor = color;
}
`