In the summer of 2023, having little knowledge of computer graphics, I set out to create a basic ray-tracing program from scratch in C++. Part of what attracted me to this project was knowing how computation-intensive ray tracing can be and that it would require efficient code to produce good results. In the name of learning for fun, I set out to create this program with minimal information on how modern ray tracing works, so I could challenge myself to figure it out.
The rendering program was written from scratch using only standard C/C++ libraries. I began by designing an environment that could contain cameras or scenery objects in 3D space. To generate animations, I rendered frames individually, either moving the camera or objects between frames. Individual frames were stored in 3-dimensional arrays. Two scripts (created by ChatGPT) were used to convert the 3D arrays to animated GIFs. The first script turned each C++ array into a BMP image to be saved to a drive. The second script turned all the BMP frames into a GIF using Python. A Makefile was used to compile the project and run the scripts.
To test my ray tracer, I began by creating an animation where a camera moves past two spheres, one in front of the other. The rendering began by casting an array for each pixel, then coloring the pixel based on what the ray hit. Render #1 demonstrates that the environment and animation work successfully.