This is a simple ray tracer written in C++ using OpenGL's GLUT for creating display. It supports rendering scenes with spheres, pyramids, and checkerboards, and can handle point lights and spotlights with shadows, reflections, and Phong illumination.
Before building and running this project, ensure you have the following installed:
-
g++ (with C++17 support)
-
Make
-
OpenGL development libraries:
libgl1-mesa-devfreeglut3-devlibglu1-mesa-dev
You can install them on Debian/Ubuntu-based systems using:
sudo apt update
sudo apt install g++ make libgl1-mesa-dev freeglut3-dev libglu1-mesa-devTo build the ray tracer:
makeThis will compile the source files and create an executable called raytracer.
To clean up compiled files:
make cleanTo run the ray tracer with a scene description in input.txt and output the image to out.bmp:
make runThis internally runs:
./raytracer --input input.txt --output out.bmpIt is also possible to provide a texturer image for the checker board.
./raytracer --input input.txt --output out.bmp --texture texture.bmpEnsure your input.txt is correctly formatted (see below).
Here's a breakdown of the input file structure:
<near> <far> <fovY> <aspectRatio>
<recursion-level>
<image-resolution>
<checkerboard-width>
<ambientR> <diffuseR> <reflectionR>
<number-of-objects>
<object-type>
<object-parameters...>
...
<object-type>
<object-parameters...>
<number-of-point-lights>
<x> <y> <z> <falloff>
<number-of-spot-lights>
<x> <y> <z> <falloff>
<lookX> <lookY> <lookZ>
<cutoff-angle>
Object types supported:
spherepyramid
Each object and light entry must follow the correct number of parameters as shown in the example.
Here are some sample rendered images from a provided scene.

