GLSL - ASCII Music
Clicca sul link qui sotto e metti le mani davanti alla webcam :
https://www.shadertoy.com/view/WtjGDz
// This is a rework of https://www.shadertoy.com/view/lssGDj,
// created by movAX13h, with sound, by Radical Ed
float character(int n, vec2 p)
{
p = floor(p*vec2(4.0, -4.0) + 2.5);
if (clamp(p.x, 0.0, 4.0) == p.x)
{
if (clamp(p.y, 0.0, 4.0) == p.y)
{
int a = int(round(p.x) + 5.0 * round(p.y));
if (((n >> a) & 1) == 1) return 1.0;
}
}
return 0.0;
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
// create pixel coordinates
vec2 uv = fragCoord.xy / iResolution.xy;
// the sound texture is 512x2
int tx = int(uv.x*512.0);
// second row is the sound wave, one texel is one mono sample
float wave = texelFetch( iChannel0, ivec2(tx,1), 0 ).x;
vec2 pix = fragCoord.xy;
vec3 col = texture(iChannel0, floor(pix/8.0)*8.0/iResolution.xy).rgb;
float gray = 0.3 * col.r + 0.59 * col.g + 0.11 * col.b;
int n = 4096; // .
if (gray > 0.2) n = 65600; // :
if (gray > 0.3) n = 332772; // *
if (gray > 0.4) n = 15255086; // o
if (gray > 0.5) n = 23385164; // &
if (gray > 0.6) n = 15252014; // 8
if (gray > 0.7) n = 13199452; // @
if (gray > 0.8) n = 11512810; // #
vec2 p = mod(pix/4.0, 2.0) - vec2(1.0);
if (iMouse.z > 0.5) col = gray*vec3(character(n, p));
else col = col*character(n, p);
fragColor = vec4(col+ 1.0 - smoothstep( 0.0, 0.15, abs(wave - uv.y) ), 1.0);
}