Shader Examples - notlion/audio-shadertoy GitHub Wiki

Radial Spectrum

#define smoothing .6
#define num_bands 256
#define pixel_scale 2

uniform sampler2D u_frequencies;
uniform float u_aspect;

varying vec2 v_texcoord;

#define PI 3.141592653589793

void main(){
  vec2 pos = vec2((v_texcoord.x * 2. - 1.) * u_aspect, v_texcoord.y * 2. - 1.);

  float theta = abs(atan(pos.x, pos.y)) / PI * .75;
  float amp = texture2D(u_frequencies, vec2(theta, 0.)).x;
  float dist = distance(pos, vec2(0., 0.));
  dist *= dist;

  vec3 c1 = vec3(0., 0., 0.);
  vec3 c2 = vec3(0., .5, .8);

  float fade = float(amp > dist) * (dist / amp);

  gl_FragColor = vec4(mix(c1, c2, fade), 1.);
}

Radial Spectrum Variation 2

#define smoothing .9
#define num_bands 64
#define pixel_scale 2

uniform sampler2D u_frequencies;
uniform float u_aspect, u_time;

varying vec2 v_texcoord;

void main(){
  const float pi = 3.141592653589793;

  vec2 pos = v_texcoord * 2. - 1.;
  pos *= vec2(u_aspect, 1.);
  float theta = (atan(pos.y, pos.x) + pi) / (pi * 2.);
  float dist = length(pos);
  float amp = texture2D(u_frequencies, vec2(dist, 0.)).x;
  amp = sqrt(amp);

  float fade = float(amp > theta) * (theta / amp);

  gl_FragColor = vec4(mix(
    vec3(0., .1, .1),
    vec3(0., 1., .8),
    fade
  ), 1.);
}

Circular Spectrum

#define smoothing .15
#define num_bands 256
#define pixel_scale 1

uniform sampler2D u_frequencies;
uniform float u_aspect, u_time;
uniform vec2 u_mouse; 
varying vec2 v_texcoord;

void main()
{
  vec2 center = vec2(.5, .5); 

  vec2 pos = vec2(v_texcoord.x*u_aspect, v_texcoord.y);
  pos.x-=1.0;

  float freq = texture2D(u_frequencies, v_texcoord).x;

  vec3 color = vec3(freq > v_texcoord.y) * (v_texcoord.y / freq);

  float d = distance(pos, center); 
  float radiusSize = texture2D(u_frequencies, vec2(.1,0)).x; 
  if(d > radiusSize && d < (radiusSize+.1))
  {
    gl_FragColor = vec4(d, 1.0-u_mouse.x, 1.0-u_mouse.y, 1.0);
  }
  else
  {
    d=d*d*d;
    gl_FragColor = vec4((1.0-freq)*d, (1.0-u_mouse.x)*d, (1.0-u_mouse.y)*d, 1.0); 
  }
}

Circular Strip Reactor

#define smoothing .55
#define num_bands 256
#define pixel_scale 1

uniform sampler2D u_frequencies;
uniform float u_aspect, u_time;
uniform vec2 u_mouse; 
varying vec2 v_texcoord;

void main()
{
  vec2 center = vec2(.5, .5); 

  vec2 pos = vec2(v_texcoord.x*u_aspect, v_texcoord.y);
  //  pos.x-=1.0;
  vec2 scaledMouse = vec2(u_mouse.x*u_aspect, u_mouse.y);

  float freq = texture2D(u_frequencies, v_texcoord).x;

  vec3 color = vec3(freq > v_texcoord.y) * (v_texcoord.y / freq);

  float d = distance(pos, scaledMouse); 
  float radiusSize = texture2D(u_frequencies, vec2(.1,0)).x; 
  if(d > radiusSize && d < (radiusSize+abs(sin(u_time))))
  {
     gl_FragColor = vec4(d, 1.0-u_mouse.x, 1.0-u_mouse.y, 1.0);
  }
  else
  {
    d=d*d*d;
    float id = .5*exp(1.-d);
    d = 0.41; 
    gl_FragColor = vec4(id*d, id*d, id*d, 1.0); 
  }
}

Reza Glowies

#define smoothing .1
#define num_bands 256
#define pixel_scale 1

uniform sampler2D u_frequencies;
uniform float u_aspect, u_time;
uniform vec2 u_mouse; 
varying vec2 v_texcoord;

void main()
{
  vec2 center = vec2(.5, .5); 
  vec2 pos = vec2(v_texcoord.x*u_aspect, v_texcoord.y);
  pos.x+=-1.0;
  vec2 scaledMouse = vec2(u_mouse.x*u_aspect, u_mouse.y);

  float freq = texture2D(u_frequencies, v_texcoord).x;
  
  float d = distance(pos, center);  
  d*=1.3*abs(sin(.5));
  d = 1.-d;

  vec3 vignette = vec3(d,d,d);

  float scalar = 10.0*texture2D(u_frequencies, vec2(0,0)).x;; 
  float scalar2 = 10.0*texture2D(u_frequencies, vec2(.1,0)).x;; 
  float scalar3 = 10.0*texture2D(u_frequencies, vec2(.2,0)).x;; 
  float scalar4 = 10.0*texture2D(u_frequencies, vec2(.3,0)).x;; 
  float scalar5 = 10.0*texture2D(u_frequencies, vec2(.4,0)).x;; 
  float scalar6 = 10.0*texture2D(u_frequencies, vec2(.5,0)).x;; 
  float scalar7 = 10.0*texture2D(u_frequencies, vec2(.6,0)).x;; 
  float scalar8 = 10.0*texture2D(u_frequencies, vec2(.7,0)).x;; 
  float scalar9 = 10.0*texture2D(u_frequencies, vec2(.8,0)).x;; 
  float scalar10 = 10.0*texture2D(u_frequencies, vec2(.9,0)).x;; 
  float scalar11 = 10.0*texture2D(u_frequencies, vec2(1.0,0)).x;; 

  vec2 s = vec2(sin(scalar*pos.x+sin(u_time+scalar2)),cos(scalar*pos.y+cos(u_time+scalar3)));
  float amp = distance(s,vec2(0.,0.));

  gl_FragColor = vec4(vignette/amp, 1.0); 
}

Radial Spectrum Variation 2

#define smoothing .75
#define num_bands 64
#define pixel_scale 2

uniform sampler2D u_frequencies;
uniform float u_aspect, u_time;

varying vec2 v_texcoord;

void main(){
  const float pi = 3.141592653589793;

  vec2 pos = v_texcoord * 2. - 1.;
  pos *= vec2(u_aspect, 1.);
  
  float theta = abs(atan(pos.x, pos.y) / pi);

  float dist = length(pos);
  dist -= distance(pos, vec2(-.5, .5));
  dist -= distance(pos, vec2(.5, .5));
  dist += distance(pos, vec2(-.5, -.5));
  dist += distance(pos, vec2(.5, -.5));
  dist = sqrt(dist) / 2.;

  float amp = texture2D(u_frequencies, vec2(dist, 0.)).x;
  amp = sqrt(amp);

  float fade = float(amp > theta && amp < theta * 1.4) * (theta / amp);

  gl_FragColor = vec4(mix(
    vec3(0., .1, .1),
    vec3(0., 1., .8),
    fade
  ), 1.);
}

Reza Glowies 2

#define smoothing .1
#define num_bands 256
#define pixel_scale 1

uniform sampler2D u_frequencies;
uniform float u_aspect, u_time;
uniform vec2 u_mouse; 
varying vec2 v_texcoord;

void main()
{
  vec2 center = vec2(.5, .5); 
  vec2 pos = vec2(v_texcoord.x*u_aspect, v_texcoord.y);
  pos.x+=-1.0;
  vec2 scaledMouse = vec2(u_mouse.x*u_aspect, u_mouse.y);

  float freq = texture2D(u_frequencies, v_texcoord).x;

  float d = distance(pos, center);  
  d*=1.3*abs(sin(.5));
  d = 1.-d;

  vec3 vignette = vec3(d,d,d);

  float scalar = 10.0*texture2D(u_frequencies, vec2(0,0)).x;; 
  float scalar2 = texture2D(u_frequencies, vec2(.1,0)).x;; 
  float scalar3 = texture2D(u_frequencies, vec2(.2,0)).x;; 
  float scalar4 = 10.0*texture2D(u_frequencies, vec2(.3,0)).x;; 
  float scalar5 = 10.0*texture2D(u_frequencies, vec2(.4,0)).x;; 
  float scalar6 = 10.0*texture2D(u_frequencies, vec2(.5,0)).x;; 
  float scalar7 = 10.0*texture2D(u_frequencies, vec2(.6,0)).x;; 
  float scalar8 = 10.0*texture2D(u_frequencies, vec2(.7,0)).x;; 
  float scalar9 = 10.0*texture2D(u_frequencies, vec2(.8,0)).x;; 
  float scalar10 = 10.0*texture2D(u_frequencies, vec2(.9,0)).x;; 
  float scalar11 = 10.0*texture2D(u_frequencies, vec2(1.0,0)).x;; 

  vec2 s = vec2(sin(scalar*pos.x+sin(u_time+scalar4)),cos(scalar*pos.y+cos(u_time+scalar6)));
  vec2 s2 = vec2(sin(s.x), cos(s.y));
  float amp = distance(s2,vec2(scalar8,scalar8));


//  float amp = distance(s,u_mouse);

  gl_FragColor = vec4(vignette/amp, 1.0); 
}

quasicrystal fractal

#define smoothing .89
uniform sampler2D u_frequencies;
uniform float u_aspect, u_time;
uniform vec2 u_mouse;
varying vec2 v_texcoord;

#define PI 3.141592653589793

void main(){

  vec2 pos = vec2((v_texcoord.x * 2. - 1.) * u_aspect, v_texcoord.y * 2. - 1.);

  float theta = abs(atan(pos.x, pos.y)) / PI * .75;
  float amp = texture2D(u_frequencies, vec2(0.5, 0.3)).x;
  float dist = distance(pos, vec2(0., 0.));
  dist *= dist;

  float fade = float(amp > dist) * (dist / amp);

  vec2 resolution = vec2(2.0, 2.0);
  vec2 p = pos * 12.4 * u_mouse.y*4.;
  const float tot = PI * 3.00;
  const float n = 16.0;
  const float df = tot / n;
  float c = 2.0  * 10. * u_mouse.x;
  float t = u_time * 0.232646 * (theta/7. * u_mouse.x) * 1.2234 * (amp * 5.0);

  if (n > 1.0) {
    for (float phi = 0.0; phi < tot; phi += df){
        c += cos(cos(phi) * p.x+ sin(phi) * p.y + t);
    }
  }
  c /= n;
  //c = c > 0.07 ? 0. : 0.9 ;

  gl_FragColor = vec4(c, c, c, 1.);
}

quasi 2

#define smoothing .92
uniform sampler2D u_frequencies;
uniform float u_aspect, u_time;
uniform vec2 u_mouse;
varying vec2 v_texcoord;

#define PI 3.141592653589793

void main(){

  vec2 pos = vec2((v_texcoord.x * 2. - 1.) * u_aspect, v_texcoord.y * 2. - 1.);

  float theta = abs(atan(pos.x, pos.y)) / PI * 1.75;
  float amp = texture2D(u_frequencies, vec2(0.25, 0.2)).x;
  float dist = distance(pos, vec2(0., 0.));
  dist *= dist;

  float fade = float(amp > dist*.210) * (dist);

  vec2 resolution = vec2(2.0, 2.0);
  vec2 p = pos * 12.4 * u_mouse.y*4.;
  const float tot = PI * 3.00;
  const float n = 16.0;
  const float df = tot / n;
  float c = 2.0  * 10.0 * (u_mouse.x/100.0);
  float t = u_time * 0.232646 * (theta/7. * u_mouse.x) * 1.42363* (amp * 5.0);

  if (n > 1.0) {
    for (float phi = 0.0; phi < tot; phi += df){
        c += cos(cos(phi) * p.x+ sin(phi) * p.y + t) * fade;
    }
  }
  c /= n;
  c = c > 0.05 ? 1.0 : 0. ;

  gl_FragColor = vec4(c, c, c, 1.);
}

quasi crystal variable editing

#define smoothing .89
#define pixel_scale 1

uniform sampler2D u_frequencies;
uniform float u_aspect, u_time;
uniform vec2 u_mouse;
varying vec2 v_texcoord;

#define PI 3.141592653589793

void main(){

  vec2 pos = vec2((v_texcoord.x * 2. - 1.) * u_aspect, v_texcoord.y * 2. - 1.);

  float theta = abs(atan(pos.x, pos.y)) / PI * .75;
  float amp = 1.0;

  vec2 resolution = vec2(2.0, 2.0);

  //     this one |
  vec2 p = pos * 20.6 *4.;
  const float tot = PI * 3.00;

  //     this one |
  const float n = 8.0;
  const float df = tot / n;
  float c = 2.0  * 0.2;
  float t = u_time * 0.232646 * 5.0;

  if (n > 1.0) {
    for (float phi = 0.0; phi < tot; phi += df){
        c += cos(cos(phi) * p.x+ sin(phi) * p.y + t);
    }
  }
  c /= n;
  c = c > 0.07 ? 0. : 0.9 ;

  gl_FragColor = vec4(c, c, c, 1.);
}

Smiley!

#define smoothing .85
#define num_bands 64
#define pixel_scale 2

uniform sampler2D u_frequencies;
uniform float u_aspect, u_time;

varying vec2 v_texcoord;

float circle(vec2 px_pos, vec2 pos, float radius){
  return float(distance(px_pos, pos) < radius);
}
float ampAt(float pos){
  return texture2D(u_frequencies, vec2(pos, 0.)).x;
}

void main(){
  vec2 pos = (v_texcoord * 2. - 1.) * vec2(u_aspect, 1.);

  float fade = 0.;
  fade += circle(pos, vec2(0., 0.), .7 + ampAt(.6) * .2);
  fade -= circle(pos, vec2(0., 0.), .5 + ampAt(.5) * .2);
  fade -= float(pos.y > 0.);
  fade = max(fade, circle(pos, vec2(-.5, .5), .1 + ampAt(.2) * .4));
  fade = max(fade, circle(pos, vec2(.5, .5),  .1 + ampAt(.4) * .4));

  gl_FragColor = vec4(mix(
    vec3(0.),
    vec3(1., 1., 0.),
    fade
  ), 1.);
}