Ray Tracer in C

A simple ray tracer written from scratch.

The first computer graphics course I was enrolled in was mostly focused on using OpenGL to render 3D graphics, with quite a few noteable projects such as: building procedurally generated 3D spaces, creating large scale landscapes using displacement and normal maps, and generating simple particle effects. From my perspective, the most interesting project in the class was building a ray tracer from the ground up.

A ray tracer is a program which attempts to simulate realistic lighting scenarios for a particular 3D scene by simulating many photons being sent out from the light sources and carefully following the path of each to determine the color of every pixel. Ray tracing is normally a very resource intensive process used by modern rendering software, but more recently has entered the popular lexicon due to modern video cards beginning to support real time ray tracing (RTX) in a limited set of circumstances.

To build the ray tracer, we were provided with a single header file from the stb library, which served the purpose of converting a C array into a jpeg file. Beyond stb, an entire ray tracer had to be written that would support shadows and reflections on different surfaces and materials. We were given a description of a reference scene, with coordinates in space where objects were located. This was used to verify the correctness of our solution, by confirming that the reference scene matched what was expected. We were also asked to create a custom scene, to push our ray tracers to their limits, and to further test the correctness of our solution. The output from my custom and reference scenes are pictured.