CLANKY,
You think the same as me :-) I almost called it pianobrot. I'd like to say it was designed that way but in truth the shaders are so small that you search for an interesting effect in the 10-15 bytes you have or so left for colour. In writing my glsl 1ks I usually spend half a day just tweaking that one line of colour code!
The truth is doing GLSL shaders in 1k is a bit like having a small suitcase, filling it with everything you need, then discovering your shoes dont fit and no matter how hard you try, you cant close the case. DX is the better choice at 1k :-(. Assembler helps for sure too (~10% which is huge at 1k).
MIX(v1,v2,v3) is a cool glsl command, it smoothly blends one vector (colour) with another, and the blendfactor is the third value. This is how the white is belnded with the inner colours. This I used on its own in mandelflow
http://www.intro-inferno.com/production.php?id=2062The trick with the piano effect was realising suddenly that if I use a discontinuous function as the blend factor (v3) I might get a double of effect of smooth blending then a break to some other look and feel. Hence the piano around the edges.
MIX(v1,v2,max(a,b)) <- max gives a discontinuous function
It was then a matter of putting every variable I had into that equation until something cool popped out (thats the squeezing your shoes in bit ;-)).
Hmmm I just noiticed the last line of code:
gl_FragColor=vec4(mix(p,vec4(t),max(t,v.x)));
Can be written
gl_FragColor=mix(p,vec4(t),max(t,v.x));
so maybe I could squeeze the shoes in too. I hate it when the "obvious" escapes you until *after* release.
Chris