Andrew Birkett's nobugs.org
At the end of 2000, I wanted to learn Haskell, a lazy functional programming language. Raytracing is ideally suited to a functional style, so I wrote a raytracer as a way of learning the language. It was written from start to finish in about a day, which is a good indication of a suitable choice of implementation language.
I learned haskell from the excellent book The Haskell School of Expression by Paul Hudak. Unlike many other books, it’s full of useful examples involving graphics and animations. Highly recommended. Real World Haskell is also good – nicely pragmatic.
Here’s a description from the source code comments: “A raytracer written in Haskell for scenes consisting of spheres and planes with procedurally defined 3d textures, and a lighting model consisting of diffuse illumination, shadows and reflections (to a fixed depth). Lights are colored and can be point sources (which cast shadows) or non-occludable directional sources (which don’t). Camera and viewing screen can be placed anywhere in the scene, and parallel and perspective projections are provided.”
This is a simple 100×100 rendering showing a reflective sphere on the left, procedurally textured sphere on the right, reflective floor and two occludable light sources.
The source code is available as raytrace.hs.
It was developed using Hugs, a Haskell interpreter.
Haskell raytracer is released under the GPL.