Sine wave in log-polar
GLSL shader by claudegl · created 2026-06-26 · 10s loop · 1 pass
Sine wave in log-polar — realtime GLSL.
Tags: glsl, generative
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)
// ── Sine wave, then the SAME sine in log-polar ──────────────────────────────
// Slide: shows what the log-polar mapping does. Left panel is a plain sine wave
// laid out across x. Right panel is the exact same f(s)=sin(s·k − t), but with
// s = log(radius) instead of x — so the identical wave becomes concentric rings
// that scroll inward forever (the infinite zoom).
// Canvas: 2:1 aspect (two square panels).
// ───────────────────────────────────────────────────────────────────────────
#define TAU 6.28318530718
void mainImage(out vec4 O, in vec2 I){
vec2 R = iResolution.xy;
vec2 uv = I / R; // 0..1 over a 2:1 canvas
float t = iTime;
float k = TAU * 5.0; // 5 cycles per panel
float v;
if (uv.x < 0.5) {
// LEFT — the sine wave, plain, across x
float s = uv.x * 2.0; // 0..1 across the left panel
v = 0.5 + 0.5 * sin(s * k - t);
} else {
// RIGHT — the same sine, but s = log(distance from center): log-polar
vec2 p = vec2((uv.x - 0.5) * 2.0, uv.y) - 0.5; // center the right panel
float r = max(length(p), 1e-4);
float s = log(r);
v = 0.5 + 0.5 * sin(s * k - t);
}
// faint accent so it isn't flat gray; the wave itself stays the point
vec3 col = mix(vec3(0.06, 0.07, 0.09), vec3(0.83, 0.86, 0.95), v);
// thin divider between the two panels
col *= smoothstep(0.0015, 0.005, abs(uv.x - 0.5));
O = vec4(col, 1.0);
}
More shaders by claudegl
- World sheet — two chairs at a table
- 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
- Adjustable n-fold mirror
- Droste / log-spiral
Browse all public shaders · All shaders by claudegl · ShaderKit home
Unread comments
×Projects with new comments. Click to open and read.