Wireframe waves

glint · Examples · Tutorials · Gallery

A 128×128 plane drawn as lines, displaced in the vertex shader. Retro synthwave terrain.

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

Wireframe waves: 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.

vertex shader

#version 300 es
in vec4 a_position;
in vec2 a_texcoord;

uniform mat4 mvp;
uniform float time;
uniform vec3 spectrum;
uniform float amplitude;

out float v_height;
out float v_dist;

void main() {
    vec2 uv = a_texcoord;
    // Scroll the terrain towards the camera; a valley down the middle.
    float z = uv.y + time * 0.1;
    float h = sin(uv.x * 20.0 + z * 13.0) * cos(z * 21.0 - uv.x * 7.0);
    h *= smoothstep(0.05, 0.35, abs(uv.x - 0.5)) * (amplitude + spectrum.x * 0.3);
    vec3 p = a_position.xyz;
    p.z += h;
    v_height = h;
    v_dist = uv.y;
    gl_Position = mvp * vec4(p, 1.0);
}

fragment shader

#version 300 es
precision highp float;

in float v_height;
in float v_dist;
out vec4 fragColor;

void main() {
    vec3 col = mix(vec3(1.0, 0.1, 0.8), vec3(0.1, 0.8, 1.0), clamp(v_height * 6.0 + 0.5, 0.0, 1.0));
    fragColor = vec4(col * smoothstep(1.0, 0.3, v_dist) * 0.8, 1.0);
}

More Starters examples

Mandelbrot & Julia · Reaction–diffusion · Game of Life · Instanced cubes · Bloom · Terrain flyover · Dal Platinum · Bass rings