Posterous theme by Cory Watilo

using shaders in clojure

The graphics card is a massively parallel processor.  It processes graphics first at the geometry level (per-vertex), and then at the image level (per-pixel).  These two steps are called the vertex shader and fragment shader, respectively.  These are normally specified in a C-like language, but Penumbra uses an intermediate s-expression representation, which is translated into GLSL at runtime.

The above shader, with 'noise' equal to 0, looks like this:

Media_httpdlgetdropboxcomu174179teapotnoturbulencepng_edkjxgbhdykbxdc

But if we use a Perlin noise lookup instead, we get something that looks a little bit like marble:
Media_httpfilesgetdropboxcomu174179teapotwithturbulencepng_fftgphtbsxizjhb

This is not a texture; rather, it is a slice of a large, periodic 3-space.  This becomes obvious when we move the square.

This means that we don't have to use a simple shape like a square.  We can use any shape we like, and the grains will travel a continuous path along the z-axis.

Complete code can be found in the /examples subdirectory of the Penumbra repository.