Nodes: Spectrum bars

glint · Examples · Tutorials · Gallery

Visual node mode: a spectrum analyser in four nodes: Spectrum reads the level at this x, Step lights everything below it, a palette colours it across.

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

Nodes: Spectrum bars: 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 (generated from a node graph)

#version 300 es
precision highp float;

// Generated from nodes: edit the graph, or use "Convert to code" to take it from here by hand.
uniform vec2 resolution;
uniform sampler2D fft;

in vec2 v_texcoord;
out vec4 fragColor;

vec3 n_palette(float t, vec3 a, vec3 b, vec3 c, vec3 d) { return a + b * cos(6.2831853 * (c * t + d)); }

void main() {
  // UV
  vec2 nn5dnpcevzy_uv = (v_texcoord * 2.0 - 1.0) * vec2(resolution.x / resolution.y, 1.0);
  vec2 nn5dnpcevzy_st = v_texcoord;
  // Split
  float nn5dnpcflun_x = vec4(nn5dnpcevzy_st, 0.0, 1.0).x;
  float nn5dnpcflun_y = vec4(nn5dnpcevzy_st, 0.0, 1.0).y;
  float nn5dnpcflun_z = vec4(nn5dnpcevzy_st, 0.0, 1.0).z;
  float nn5dnpcflun_w = vec4(nn5dnpcevzy_st, 0.0, 1.0).w;
  // Palette
  vec3 nn5dnpcibz1_rgb = n_palette(nn5dnpcflun_x, vec3(0.5), vec3(0.5), vec3(1.0, 1.0, 0.5), vec3(0.8, 0.9, 0.3));
  // Spectrum
  float nn5dnpcggwa_level = texture(fft, vec2(clamp(nn5dnpcflun_x, 0.0, 1.0), 0.25)).r;
  // Step
  float nn5dnpchlec_out = step(nn5dnpcflun_y, nn5dnpcggwa_level);
  // Multiply
  vec3 nn5dnpcjt8i_out = (nn5dnpcibz1_rgb * vec3(nn5dnpchlec_out));
  fragColor = vec4(nn5dnpcjt8i_out, 1.0);
}

More Nodes & glitch examples

Nodes: Zoom trails · Nodes: Bass twirl · Nodes: Colour drift · Nodes: Crystal · Nodes: Lava · Mosh pit · Corrupt file