Scott Duckworth
February 12, 2007
CPSC 805
Project 1 - Basic Ray Tracer

REQUIREMENTS

EXTRA FEATURES

Features I implemented which were not required:

TODO LIST

Features I would like to implement in the future:

DISCUSSION

Much of the work on this raytracer was completed before I even began taking this class. I started working on the SSE vector and matrix library as a pet project during last summer so that I could teach myself SSE. I was always needing something to test the library with, so I figured I'd make a simple raytracer, similar to the one I made back in CPSC 215. Over the next few months I worked on the library and the raytracer whenever I was looking for something to do. One thing led to the next, and before I knew it I had a decent raytracer. I only had to add and change a few things, mostly in the lighting model, in order to meet the specifications for this project.

There are still some bugs left in the program. In particular, the CSG does not seem to be functioning correctly in some cases. You can see the problems in the images below. In the scene with the die, look at the top back corner of the die -- it's black where it should be orange. In the chess scene, the tops of the rooks have some black spots where the rays should pass right through.

It's hard to tell where these bugs are coming from. I tried to figure out the problem with the die, and I found that if there is any transformation on the die (even one that does nothing) then this bug appears. If I took off the transformation, the problem went away. The issue was that when the vectors were multiplied by the transformation matrix some computational imprecision occured, and the resulting vectors were off by just a little bit (even though it was an identity matrix). This imprecision was carried down to the CSG objects, which I guess are really sensitive to precision errors.

This problem only occurs when both transformations and CSG are involved. Individually, these objects seem to function correctly.

COMPILING

This project uses the SCons software construction tool (replacement for make and autotools). Edit the SConstruct file and change the CXX and CXXFLAGS to whatever best suits your machine. In particular, make sure the highest possible SSE optimizations are enabled.

Next, edit ./src/config.h and edit the values of the following variables:

USE_THREADS:
Value: 0 or 1
Enables UNIX pthreads. The rendering engines can utilize multiple threads to speed up execution. The number of threads to use is determined at run time by querying the operating system for the number of avaliable processors.
USE_ATOMIC_OPS:
Value: 0 or 1
Enables using atomic operations instead of locking when possible. This uses an extension of GCC 4.1.x, and will most likely result in compilation errors in other compilers.
USE_SSE:
Value: 0, 1, 2, or 3
Enables SSE instructions at the specified level. 0 = no SSE, 1 = SSE, 2 = SSE2, 3 = SSE3. The compiler must have the corresponding SSE instruction set enabled (configured through SConstruct).

To compile, run 'scons'. The resulting executable will be ./build/sdrt

RUNNING

The executable currently takes no command line arguments. The program first renders two high-quality images and saves them out to "die.ppm" and "chess.ppm". It then goes on to render a 360 degree rotation around the chess scene, saved to "frame000.ppm" through "frame359.ppm". This latter part takes A LONG TIME! If you're not interested in the rotation, kill the program after it has rendered the first two images.

RESULTS

Some images that I produced with this program (converted to PNG format to reduce file size):


Click here to download the source code (authentication required)