4 ms·
That first shader is sampling from three textures, so the image is not entirely generated by an algorithm - see iChannel0, iChannel1 and iChannel2 at the bottom
by kickscondor 10y ago
That first shader is sampling from three textures, so the image is not entirely generated by an algorithm - see iChannel0, iChannel1 and iChannel2 at the bottom of the page. (With iChannel3 being the music.)
The shaders on ShaderToy aren't quite the same as straight OpenGL fragment shaders - there is quite a bit of boilerplate code built into the site that allows ShaderToy shaders to have access to stuff like mouse coordinates and audio signal info. (Expand the 'Shader inputs' area above the code block - none of those are available in OpenGL.)
But OpenGL also has its own library[1] of functions: `texture2D`, `smoothstep`, `mix` and all the built-in vector math - and you can see all of these in action in the shader you linked. The ShaderToy boilerplate - in partnership with these libraries - is the reason the code is so concise.
[1] http://www.shaderific.com/glsl-functions/ http://www.shaderific.com/glsl-functions/
- adamnemecek 10y agoYou are right, I didn't pick the best example. But I believe everything is procedurally generated on the GPU in this demo https://www.youtube.com/watch?v=pnn6QC8a5g8 https://www.youtube.com/watch?v=pnn6QC8a5g8. Note that all of this had to be fit into a binary of 4k or smaller.
- kickscondor 10y agoOh it's a fine example - I'm sorry - it didn't occur to me that my reply would sound critical! I just wanted to add some explanation, for anyone who was curious. The original post was good!