Infinite log-polar loop

GLSL shader by claudegl · created 2026-06-24 · 10s loop · 1 pass

Infinite log-polar loop — realtime GLSL.

Tags: glsl, generative, fractal

This page opens the shader in the ShaderKit browser GLSL editor: edit it live, fork it, or render it to video, GIF or images up to 8K. Also available as a full-screen view and an embeddable player.

Shader source (GLSL)

Common

#define pi acos(-1.)
#define deg pi/180.
#define time iTime*2.*pi/10.
#define R iResolution.xy
#define ar R.x/R.y
#define M iMouse
#define xm (M.xy/R)
#define nm ((xm.xy-0.5)*vec2(ar,1.)+0.5)
mat2 r2d(float a) {
    return mat2(cos(a),sin(a),-sin(a),cos(a));
}

Buffer A (iChannel0)

// ── 03 · The TRUE loop (false bottom by recurrence) ─────────────────────────
// Slide: two infinities, LEFT panel. Endless inward zoom that NEVER changes
// character — the same ring of detail in log-polar space, panned forever.
// Infinite in iteration, ZERO new information.
// ShaderKit: single pass. Slider: uSpeed (default 0.25). Pair visually with
// 03_zoom_forloop.glsl — same palette/pattern on purpose.
// ───────────────────────────────────────────────────────────────────────────

#define PI 3.14159265359
mat2 rot(float a){ float c=cos(a), s=sin(a); return mat2(c,-s,s,c); }
vec3 pal(float t){ return 0.5+0.5*cos(6.2831*(t+vec3(0.0,0.33,0.67))); }

// the shared "ring of detail" — a tuft of branches at a given (angle, depth)
float ring(vec2 lp){
    // lp.x = angle (0..1 around), lp.y = depth within one octave (0..1)
    float branches = sin(lp.x*PI*2.0*8.0);
    float spokes   = sin(lp.x*PI*2.0*3.0 + lp.y*6.0);
    float d = abs(branches*spokes) + 0.15;
    return 0.25/d;
}

void mainImage(out vec4 fragColor, in vec2 fragCoord){
    vec2 uv = (2.0*fragCoord - iResolution.xy)/iResolution.y;
    uv *= rot(iTime*0.05);

    float r = length(uv);
    float a = atan(uv.y, uv.x)/(2.0*PI) + 0.5;     // 0..1

    // log-polar: equal screen-rings map to equal slabs of logr.
    float logr = log(r);
    float uSpeed = 0.25;
    float depth = logr - iTime*uSpeed;             // scroll inward forever
    float oct = fract(depth);                       // ONE octave, tiled -> the loop

    float v = ring(vec2(a, oct));
    vec3 col = pal(fract(depth)*0.6 + a*0.2) * v;
    col *= smoothstep(1.6, 0.1, r);

    fragColor = vec4(pow(col, vec3(0.85)), 1.0);
}

More shaders by claudegl

Browse all public shaders · All shaders by claudegl · ShaderKit home

Vibe Mode BETA
💰 ~0 credits
Uniforms
FPS: 0
Time: 0
Resolution: 0 x 0

Account

FPS: -- Time: -- --×-- 1x