[Haskell-cafe] ANN: GlomeTrace raytracing library

Jim Snow jsnow at cs.pdx.edu
Sat Jan 23 21:04:12 EST 2010

I have uploaded to hackage a new version of my ray-tracer, Glome.

In previous releases, Glome was a monolithic application.  In this 
release, the core algorithms have been abstracted out into a pair of 
libraries, GlomeVec and GlomeTrace.

GlomeVec is a vector library.  It's not necessarily any better than any 
of the other vector libraries on Hackage, but it's fairly simple and 
does what I need it to do.  Also included with GlomeVec is a solid 
texture library, which has a perlin noise function that may be useful 
for other projects.

GlomeTrace contains constructors for building scenes out of basic 
primitives like spheres, cones, triangles, and grouping them, moving 
them around, and performing boolean operations on them, and functions to 
test rays for intersection against these objects.  It also has some 
higher-level operations, like tracing a ray corresponding to a certain 
x/y coordinate within the camera's field of view, and returning the 
color by recursively tracing rays against the scene.  (Recursion comes 
into play if the object is reflective.)

GlomeTrace uses a typeclass called Solid for geometric primitives, and 
the composite primitives that are built up from other primitives use an 
existential type SolidItem that is just a container for all types that 
are instances of Solid, so it should be quite easy for an application to 
add new primitives of its own and have them integrate nicely with the 
ones that are already defined, just by making them instances of Solid.

One very useful composite primitive is a BIH (Bounding Interval 
Hierarchy), which is a type of automatically-constructed tree of 
bounding volumes used to speed up the process of tracing a ray against 
many objects.  Constructing a bih is easy: just pass a list of 
SolidItems to the bih constructor, and it returns a "Bih" object that is 
itself a SolidItem, so you can trace rays against it as if it were a 
single primitive.

GlomeTrace and GlomeVec now have (partial) haddock documentation so it 
should be easier to understand the code than it was previously.  There 
is also a (somewhat out of date) tutorial linked to from the Haskell wiki:


Glome the application requires OpenGL for display, but GlomeVec and 
GlomeTrace do not.




More information about the Haskell-Cafe mailing list