Nodes: Bass twirl

glint · Examples · Tutorials · Gallery

Visual node mode: a checkerboard twisted into a whirlpool as hard as the bass hits, coloured round the colour wheel.

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

Nodes: Bass twirl: 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 vec3 spectrum;
uniform float beat;
uniform vec3 spectrumIntegrated;
uniform float time;

in vec2 v_texcoord;
out vec4 fragColor;

vec2 n_rotate(vec2 p, float a) { float c = cos(a), s = sin(a); return mat2(c, s, -s, c) * p; }
vec3 n_hsv(vec3 c) { vec3 p = abs(fract(c.xxx + vec3(1.0, 2.0 / 3.0, 1.0 / 3.0)) * 6.0 - 3.0); return c.z * mix(vec3(1.0), clamp(p - 1.0, 0.0, 1.0), c.y); }

void main() {
  // UV
  vec2 nn5dnlbhexr_uv = (v_texcoord * 2.0 - 1.0) * vec2(resolution.x / resolution.y, 1.0);
  vec2 nn5dnlbhexr_st = v_texcoord;
  // Polar
  float nn5dnlbpb9b_angle = (atan(nn5dnlbhexr_uv.y, nn5dnlbhexr_uv.x) / 6.2831853 + 0.5);
  float nn5dnlbpb9b_radius = length(nn5dnlbhexr_uv);
  vec2 nn5dnlbpb9b_uv = vec2(atan(nn5dnlbhexr_uv.y, nn5dnlbhexr_uv.x) / 6.2831853 + 0.5, length(nn5dnlbhexr_uv));
  // HSV
  vec3 nn5dnlbqzux_rgb = n_hsv(vec3(nn5dnlbpb9b_angle, 0.7, 1.0));
  // Audio
  float nn5dnlbifk0_bass = spectrum.x;
  float nn5dnlbifk0_mid = spectrum.y;
  float nn5dnlbifk0_treble = spectrum.z;
  float nn5dnlbifk0_beat = beat;
  float nn5dnlbifk0_flow = spectrumIntegrated.x;
  // Multiply
  float nn5dnlbj4re_out = (nn5dnlbifk0_bass * 8.0);
  // Time
  float nn5dnlbkm2q_t = time * 0.8;
  // Sine
  float nn5dnlbl63l_out = sin(nn5dnlbkm2q_t);
  // Add
  float nn5dnlbmper_out = (nn5dnlbj4re_out + nn5dnlbl63l_out);
  // Twirl
  vec2 nn5dnlbnve9_uv = n_rotate(nn5dnlbhexr_uv, nn5dnlbmper_out / (1.0 + length(nn5dnlbhexr_uv) * 2.0));
  // Checker
  float nn5dnlbo295_out = mod(floor(nn5dnlbnve9_uv.x * 6.0 * 0.5) + floor(nn5dnlbnve9_uv.y * 6.0 * 0.5), 2.0);
  // Multiply
  vec3 nn5dnlbr19e_out = (nn5dnlbqzux_rgb * vec3(nn5dnlbo295_out));
  fragColor = vec4(nn5dnlbr19e_out, 1.0);
}

More Nodes & glitch examples

Nodes: Colour wheel rings · Nodes: Marble · Nodes: Beat circle · Nodes: Zoom trails · Nodes: Colour drift · Nodes: Crystal · Nodes: Spectrum bars · Nodes: Lava