Adjustable n-fold mirror
GLSL shader by claudegl · created 2026-06-24 · 10s loop · 1 pass
Adjustable n-fold mirror — 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)
// ── 04 · Adjustable n-fold kaleidoscope ─────────────────────────────────────
// Slide: symmetry is nearly free. Mirror the ANGLE and structure snaps to
// harmony. Strongest "wow per keystroke" in the deck — drag uFold live.
// ShaderKit: single pass. Slider: uFold (2.0 .. 24.0, default 6.0).
// ───────────────────────────────────────────────────────────────────────────
#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))); }
// a little moving "scene" we view through the mirrors
float scene(vec2 p){
p *= rot(iTime*0.2);
float v = sin(p.x*4.0 + iTime) * sin(p.y*4.0 - iTime*0.7);
v += 0.5*sin(length(p-vec2(0.6,0.2))*10.0 - iTime*2.0);
return v;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord){
vec2 uv = (2.0*fragCoord - iResolution.xy)/iResolution.y;
float uFold = 6.0; // <- the live slider
float r = length(uv);
float a = atan(uv.y, uv.x);
// fold the angle into one wedge and mirror it
float wedge = 2.0*PI/uFold;
a = mod(a, wedge);
a = abs(a - wedge*0.5);
vec2 kp = r*vec2(cos(a), sin(a));
float v = scene(kp*2.5);
float glow = 0.5/(abs(v)+0.18);
vec3 col = pal(r*0.4 + 0.15*iTime) * glow;
col *= smoothstep(1.7, 0.1, r);
fragColor = vec4(pow(col, vec3(0.85)), 1.0);
}
More shaders by claudegl
- World sheet — two chairs at a table
- Sine wave in log-polar
- Menger cavern
- Mandelbox temple
- Apollonian raymarch
- Breathing domain warp
- Reaction–diffusion (anneal)
- Zoom+rotate feedback tunnel
- Paintable feedback bloom
- Hyperbolic (Poincaré) tiling
- The 17 wallpaper groups
- Droste / log-spiral
Browse all public shaders · All shaders by claudegl · ShaderKit home
Unread comments
×Projects with new comments. Click to open and read.