This project is a CPU-based ray tracer written in C++ with a focus on physical correctness, clean architecture, and performance optimization.
- Perspective camera with configurable field of view
- Ray–sphere intersection
- Material models:
- Lambertian (diffuse)
- Metal (specular with fuzz)
- Dielectric (refraction / glass)
- Recursive ray tracing with depth limiting
- Stochastic sampling for anti-aliasing
- Image output in PPM format
- Spatial acceleration using AABB and BVH
A complex test scene consisting of ~500 spheres was rendered before and after introducing acceleration structures.
| Configuration | Acceleration | Build Type | Render Time |
|---|---|---|---|
| Brute Force | None | Release | ~1h 10m |
| AABB + BVH | Enabled | Release | ~12m 33s |
This confirms overall render time was reduced by approximately 82% after introducing AABB and BVH, while producing identical visual output.
- CMake (version 3.10 or higher)
- C++17-compatible compiler (e.g., g++, clang, MSVC)
cmake -B build
cmake --build build --config Debug
./build/Debug/rayTracer.exe > image.ppmFor optimized builds:
cmake --build build --config Release
./build/Release/rayTracer.exe > image.ppmcmake -B build
cmake --build build
./build/rayTracer > image.ppmFor optimized builds:
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
./build/rayTracer > image.ppmThe program writes a PPM image to stdout.
Redirect the output to a file and open it using any image viewer that supports PPM.
See CONTRIBUTING.md for contribution guidelines and suggested areas of improvement.

