
I'll start the story from the beginning: The project was to create a KD Tree from a triangle-based scene using Surface Area Heuristics to choose the best dividing planes. Then, using my KD Tree, I was to render the scene using ray casting (non-recursive ray tracing). And after that, add phong lighting. What could go wrong, right?
I decided to approach the assignment by ignoring the KD Tree altogether. I attempted ray casting by testing ray intersection against every triangle in the scene. Very, very slow, but at least I could isolate problems more easily.
The first render looked like a pre-school paint smear. After realizing that I was performing an integer division when getting my aspect ratio, I got a slightly more intelligible paint smear. The left side of the picture looked correct, but the right half looked like my program just stopped trying. Then, I considered the merits of resetting my color between casting rays, and got what must be the cheapest version of shadow casting I've ever implemented:

Finally, I thought of also resetting my minimum time of intersection between casting rays. I rendered and waited extremely patiently for the picture to form. It looked correct! The slow speed of ray casting without a KD Tree was getting to me, though, so I decided to cast a ray for only every other pixel to speed it up. So, I got the newsprint version:


Finally, I e-mailed my teacher for a consult. He commented out some functions to isolate the problem. (Why didn't I think of that? Oh well, next time.) It turned out the scene rendered completely correctly if I skipped the function that clips the rays against the AABB's. I looked over my algorithm and couldn't find anything wrong with it, so I scrapped the function and wrote it over again using a similar but slightly simpler algorithm, so I would be able to find problems more easily. And then, of course, because the graphics gods are fickle, it worked:

