Aurora
glint · Examples · Tutorials · Gallery
Northern lights over a mirror-still lake: layered volumetric curtains of warped noise, stars, and a reflection with ripples. The curtains dance to the mids.
Audio-reactive: it moves with music from a microphone, line-in or a file.

An example in glint, a free live shader editor in the browser: the GLSL code floats over the running picture and recompiles as you type.
The code
One pass, in GLSL.
fragment shader
#version 300 es
precision highp float;
uniform float time;
uniform vec2 resolution;
uniform vec2 mouse;
uniform vec3 spectrum;
uniform vec3 spectrumIntegrated;
uniform float beat;
in vec2 v_texcoord;
out vec4 fragColor;
mat2 rot(float a) { float c = cos(a), s = sin(a); return mat2(c, -s, s, c); }
float hash21(vec2 p) { p = fract(p * vec2(123.34, 456.21)); p += dot(p, p + 45.32); return fract(p.x * p.y); }
float tri(float x) { return clamp(abs(fract(x) - 0.5), 0.01, 0.49); }
vec2 tri2(vec2 p) { return vec2(tri(p.x) + tri(p.y), tri(p.y + tri(p.x))); }
// Triangle-wave noise (nimitz's trick): cheap, sharp, good for curtains.
float triNoise(vec2 p, float spd) {
float z = 1.8, z2 = 2.5, rz = 0.0;
p *= rot(p.x * 0.06);
vec2 bp = p;
for (int i = 0; i < 5; i++) {
vec2 dg = tri2(bp * 1.85) * 0.75;
dg *= rot(time * spd);
p -= dg / z2;
bp *= 1.3;
z2 *= 0.45;
z *= 0.42;
p *= 1.21 + (rz - 1.0) * 0.02;
rz += tri(p.x + tri(p.y)) * z;
p *= -mat2(0.95534, 0.29552, -0.29552, 0.95534);
}
return clamp(1.0 / pow(rz * 29.0, 1.3), 0.0, 0.55);
}
vec4 aurora(vec3 ro, vec3 rd) {
vec4 col = vec4(0.0), avg = vec4(0.0);
for (int i = 0; i < 40; i++) {
float of = 0.006 * hash21(gl_FragCoord.xy) * smoothstep(0.0, 15.0, float(i));
float pt = ((0.8 + pow(float(i), 1.4) * 0.002) - ro.y) / (rd.y * 2.0 + 0.4);
pt -= of;
vec3 bpos = ro + pt * rd;
float rzt = triNoise(bpos.zx, 0.06 + spectrum.y * 0.1);
vec4 c2 = vec4(0.0, 0.0, 0.0, rzt);
c2.rgb = (sin(1.0 - vec3(2.15, -0.5, 1.2) + float(i) * 0.043) * 0.5 + 0.5) * rzt;
avg = mix(avg, c2, 0.5);
col += avg * exp2(-float(i) * 0.065 - 2.5) * smoothstep(0.0, 5.0, float(i));
}
col *= clamp(rd.y * 15.0 + 0.4, 0.0, 1.0);
return col * (1.8 + spectrum.y * 2.0 + beat);
}
vec3 stars(vec3 rd) {
vec2 p = rd.xz / (rd.y + 0.3) * 60.0;
vec2 id = floor(p);
float h = hash21(id);
return vec3(0.9, 0.95, 1.0) * step(0.985, h) * smoothstep(0.25, 0.0, length(fract(p) - 0.5)) * rd.y;
}
void main() {
vec2 uv = (gl_FragCoord.xy - 0.5 * resolution) / resolution.y;
vec3 ro = vec3(0.0, 0.0, -6.7);
vec3 rd = normalize(vec3(uv, 1.3));
rd.yz *= rot(-0.15 - (mouse.y - 0.5) * 0.3);
rd.xz *= rot((mouse.x - 0.5) * 1.5 + sin(time * 0.05) * 0.2);
vec3 col = vec3(0.0);
vec3 brd = rd;
float fade = smoothstep(0.0, 0.01, abs(brd.y)) * 0.1 + 0.9;
col = vec3(0.02, 0.03, 0.08) * (1.0 - abs(rd.y));
if (rd.y > 0.0) {
col += stars(rd);
vec4 aur = smoothstep(0.0, 1.5, aurora(ro, rd)) * fade;
col = col * (1.0 - aur.a) + aur.rgb;
} else {
// The lake: mirror the ray, ripple it, darken it.
rd.y = abs(rd.y);
rd.xz += 0.004 * sin(rd.xz * 200.0 + time);
col += stars(rd) * 0.5;
vec4 aur = smoothstep(0.0, 2.5, aurora(ro, rd));
col = col * (1.0 - aur.a) + aur.rgb;
col *= 0.55;
col += vec3(0.02, 0.03, 0.05);
}
fragColor = vec4(col, 1.0);
}More Showpieces examples
Physarum · SmoothLife · Glitch · Quaternion Julia · Caustics · Glass orbs · Four to the floor