Raytracing

Some Background

Raytracing is a method of rendering a virtual scene which is typically used for photorealistic styles. This is because the technique attempts to simulate the paths that light rays take through the scene before entering one's eye (more info here). What this means, practically speaking, is that we can render physically-accurate lighting in exchange for higher computational cost. However, there has been growing interest in raytracing as hardware manufacturers have begun developing graphics cards which optimize basic raytracing computation so, who knows! Maybe in 3 years we'll all be raytracing our apps.

What I did

From scratch, I made:

  1. The physics. This was the really difficult part. We had to model a number of visual phenomena. For example, reflection/refraction through materials, total internal reflection, Fresnel effects, Phong local illumination, or shadows.
  2. An image writer in ASCII .ppm format. Highly inefficient; ridiculously simple (compared to .jpg or .png).
  3. A raycaster. This is a few functions which shoot rays into a scene that return the color of whatever object they hit.
  4. A scene description file reader. Some standard C file parsing used to read the objects (e.g. spheres or .obj triangle meshes) in a scene, as well as parameters like field of view of the camera.
Wow, yeah, I'm so impressive.

I developed in Visual Studio 15 and the project ended up being basically the largest piece I'd written so far. The class hierarchy and such is probably extremely jank—I haven't had other eyes on it—but I am proud of how I dealt with a few weird class interactions. I think it all paid off since I had one of the fastest raytracers in the class :)