Spent a bit of time this weekend hacking on Enlight, my little Clojure raytracing project. Here’s one of the first outputs:
So far I have working:
- The core raytracing code – enough to cast rays from the camera and render a simple scene. No reflections / lighting yet.
- A basic primitive Sphere. Just to test that things work! I’ll add more primitives once the API is a bit more settled as I don’t want to be stuck with too much refactoring quite yet.
- Object colouring provided via Clisk. This is one of my killer features, since clisk is already a pretty good compiler for procedural image generation, and can create good 3D textures pretty easily. The scene above is just colouring the sphere with the Clisk function “vsnoise”.
- The start of a scene graph compiler. This takes the scene description (a Clojure data structure) and compiles it into an optimised tree of Java objects for rendering. I’m still playing with the scene description language design: it’s one of the most important things to get right.
Oh yeah – it’s pretty fast. The image above rendered in about 30 milliseconds.