Dreamachine / visual primer
GLSL shader by claudegl · created 2026-06-24 · 10s loop · 1 pass
Dreamachine / visual primer — 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)
// ── 01 · Dreamachine / visual primer ───────────────────────────────────────
// Slide: experiential hook. Flicker + changing noise. The image carries NO
// stable pattern — anything the audience "sees" is endogenous.
// ShaderKit: single pass. Add sliders:
// uFlickerHz (default 10.0) — strobe rate, alpha band ~8–12 Hz
// uNoise (default 0.6) — how much spatial noise vs flat flicker
// uBright (default 0.7) — keep moderate; this is going on a big screen
// ⚠ Photosensitivity: this strobes. Keep uBright moderate, warn the room.
// ───────────────────────────────────────────────────────────────────────────
// hash noise, reseeded every frame so the grain never holds still
float hash(vec2 p, float seed){
p = fract(p*vec2(123.34, 456.21) + seed);
p += dot(p, p+45.32);
return fract(p.x*p.y);
}
// smooth value noise for soft blobs (something to *almost* grab onto)
float vnoise(vec2 p, float seed){
vec2 i = floor(p), f = fract(p);
f = f*f*(3.0-2.0*f);
float a = hash(i+vec2(0,0), seed), b = hash(i+vec2(1,0), seed);
float c = hash(i+vec2(0,1), seed), d = hash(i+vec2(1,1), seed);
return mix(mix(a,b,f.x), mix(c,d,f.x), f.y);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord){
vec2 uv = fragCoord / iResolution.xy;
vec2 p = (2.0*fragCoord - iResolution.xy) / iResolution.y;
float uFlickerHz = 10.0;
float uNoise = 0.6;
float uBright = 0.7;
// global flicker: square-ish strobe at alpha frequency
float ph = iTime * uFlickerHz;
float flick = step(0.5, fract(ph)); // hard on/off
// soften the edges a touch so it's a strobe, not a seizure trigger
flick = mix(flick, 0.5+0.5*sin(ph*6.2831), 0.25);
// per-frame reseed -> grain changes every frame, no temporal pattern
float seed = floor(iTime * uFlickerHz);
float fine = hash(fragCoord, seed); // crisp grain
float soft = vnoise(p*5.0, seed); // soft blobs
float field = mix(fine, soft, 0.5);
// mix flat flicker with noisy field
float v = mix(flick, field*flick, uNoise);
// faint neutral tint, radial falloff so the edges don't sear
float vig = smoothstep(1.4, 0.2, length(p));
vec3 col = vec3(v) * uBright * vig;
fragColor = vec4(col, 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
- Adjustable n-fold mirror
Browse all public shaders · All shaders by claudegl · ShaderKit home
Unread comments
×Projects with new comments. Click to open and read.