Triangle Ray Tracer

Download the source for my ray tracer

Or view source files online

This was my attempt at the second COSC342 (computer graphics) assignment, which was to write a triangle-mesh ray tracer. A copy of the assignment sheet is here, should you wish to know exactly what we were asked to do. It's written in C by the way. We were allowed to write it in pretty much any language the computer lab supported, but since skeleton code in C was provided, most people went with that.

Extra stuff for the assigment

Assignment readme
Python scene export script - Exports Blender scenes in required format for ray tracer
Circle test - Ray tracer input file 1 - should display a white circle only
Triangle test - Ray tracer input file 2 - expected output - triangle
View plane test - Ray tracer input file 3 - expected output - view plane
Light test - Ray tracer input file 4 - expected output - light test
Complex test - Ray tracer input file 5 - expected output - complex

NOTE that while it does produce pretty good results, (or at least I think so anyway) it's not perfect. I think one value (z?) is incorrectly inverted somewhere, and there are some other problems but I can't remember what they are. If you happen to notice any errors in the source code, please let me know via a text file in my upload facility. I'd really appreciate it, as I probably spent more time on this than any other assignment I've ever done, and it'd be nice to finish it properly.

Mark? 80%. I can't remember what was wrong with it and haven't bothered to fix it up, so watch out for that.

I only made about two decent images with this ray tracer - faces and spiral

By the way...

The document Practical Ray Tracing by Geoff Wyvill* was invaluable while I was writing the raytracer. It is clear and concise, providing an overview of all the basics of ray tracing, but goes into enough depth for anyone with a reasonable level of intelligence to be able to write a ray tracer from scratch.
Part two of the Practical Ray Tracing notes can be found here - Practical Ray Tracing Part 2 - Professional Ray Tracing. This half of the notes is aimed more towards those who have written a ray tracer before and have some more experience creating 3D computer graphics.
*Geoff was one of my computer graphics lecturers, and certainly knows his stuff.