The ray tracer used in this assignment was based on a ray tracer I wrote for a previous class at The Ohio State University. It uses the Coin3D (OpenInventor) file format for describing scenes. It was originally written to run in Unix, but I ported it to Windows because I prefer windowed GUIs to the command line. It is written in C++ and I used Microsoft .NET to make the GUI. It was built in Visual Studio .NET 2003 and VS 2003 should be used to test the code. In all likelihood it will not run in VS 2005 because of the changes to managed C++ in .NET 2.0. However, I have not tested it in 2005.
For this assignment, I attempted two different approaches to global illumination. My first approach involved a hybrid of bi-directional path tracing and photon mapping. As the deadline approached, it became increasingly apparent that I may not have this working in time. While I am confident that with more time I would have gotten this approach to work, I ended up scrapping the idea in lieu of the simpler-to-implement path tracing approach. However, I didn't stick to pure path tracing, which I'm told takes hours or days to create good images. Instead I tried an approach where the ray tracer takes advantage of standard ray tracing techniques to speed up image generation. In this approach, my ray tracer mostly function in the same way it did before, with two exceptions. First, the ray tracer shoots rays from the eye through the image plane and lets them bounce around the scene just as before. The difference is that there is a new type of ray that it creates along with the standard shadow, reflection, and refraction rays - a diffuse ray. This ray is created by every ray-object interaction and works in a very similar way to path tracing. Like path tracing, only one diffuse ray is created for each object intersection. The ray is fired in a random direction on the hemisphere aligned with the normal of the intersection. Since we only fire one per interaction, we need many more initial rays to get a good sampling of the scene. This means that we must fire many more rays for each pixel on the screen than before, sometimes thousands per pixel are required to get a good image. Now that each pixel requires this level of super sampling, my adaptive anti-aliasing technique which accounted for large speed increases is not longer valid. The lack of this and large increase in number of rays significantly hurts the performance compared to earlier versions of this ray tracer. Another thing that slows performance is that we trace these diffuse rays much deeper than any other type of ray. I am not sure if this is necessary and I didn't have time to test different values of this parameter, but I allowed the diffuse rays to bounce around twice as long as other rays because tracing deeper is one of the goals of path tracing. Overall, this technique does make decent globally illuminated images. I compare some of my results below.
|Samples per pixel|
|1||64 (8x8 jittered grid)||900 (30x30 jittered grid)|
I chose a Cornell box scene for this assignment because the enclosed space is ideal for path tracing, and makes the global illumination effects more noticeable. From these images we can see a few things. Most importantly is that the technique does work. If you are willing to devote a lot of time to tracing lots of rays, you can get good images. Some things to notice are the interactions between the colored walls and the ceiling and back wall. Also, the interactions between the sphere and the walls and the box and the walls. We clearly see some diffuse light coming off the box and showing up on the back wall, as light from the green wall illuminating the right side of the box. These types of effects are what we hope to see, and this shows that the technique is successful. Unfortunately, however, the images are very noisy. I have shown what the image looks like with just one sample per pixel. It looks pretty terrible, and thus more samples are needed. Next I show an image with 64 samples per pixel arranged in an 8x8 jittered grid. This looks a lot better but still has some noise in it. Finally I show an image with 900 samples per pixel arranged in a 30x30 jittered grid. This image looks much better but took around 12 hours to create (far longer than my patience.) I have not shown depth of field effects in conjunction with global illumination because it would make the program run a whole order of magnitude slower.
Obviously I had some set backs during this assignment. First, my primary approach wasn't working for me, so I had to try something different. Second, the shear length it takes to generates these images kind of limited my ability to play around with it and find what works best. Although, I think it was pretty successful for switching gears mid way.
Here is a link to the code. This should be opened with Visual Studio 2003.
Grading information and comments can be sent to .