Laser show

glint · Examples · Tutorials · Gallery

A fan of additive laser beams through haze, sweeping with the mids; the kick fires a white burst.

Audio-reactive: it moves with music from a microphone, line-in or a file.

Laser show: an audio-reactive GLSL shader

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 vec3 spectrum;
uniform vec3 spectrumIntegrated;
uniform float beat;
uniform int beatCount;
uniform sampler2D fft;

in vec2 v_texcoord;
out vec4 fragColor;

void main() {
    vec2 uv = (gl_FragCoord.xy - vec2(0.5 * resolution.x, 0.0)) / resolution.y;
    vec3 col = vec3(0.0);
    float sweep = sin(time * 0.7 + spectrumIntegrated.y) * 0.6;
    for (int i = 0; i < 9; i++) {
        float fi = float(i) - 4.0;
        float ang = fi * (0.12 + 0.05 * spectrum.y) + sweep;
        vec2 dir = vec2(sin(ang), cos(ang));
        float d = abs(dot(uv, vec2(dir.y, -dir.x)));
        float along = dot(uv, dir);
        float level = texture(fft, vec2(0.02 + float(i) * 0.04, 0.25)).r;
        vec3 c = mod(float(i), 2.0) < 0.5 ? vec3(0.1, 1.0, 0.3) : vec3(1.0, 0.1, 0.6);
        col += c * (0.004 / (d + 0.002)) * step(0.0, along) * (0.6 + level * 2.0) * exp(-along * 0.5);
    }
    // Haze and a kick burst from the source.
    float haze = 0.5 + 0.5 * sin(uv.x * 6.0 + time) * sin(uv.y * 4.0 - time * 0.7);
    col *= 0.6 + 0.4 * haze;
    col += vec3(1.0) * beat * 0.4 * exp(-length(uv) * 4.0);
    fragColor = vec4(1.0 - exp(-col), 1.0);
}

More Starters examples

Bass rings · Radial spectrum · Ridgelines · Kaleido pulse · Metaballs · Oscilloscope trails · Hyperspace · Strobe grid