This repository contains a raytracer built following Peter Shirley's Raytracing in One Weekend guide. On top of the base code from that guide, I've also added some custom functionality:
- Multithreading support to speed up render times on CPU
- Video frames rendering (movable camera that can pan, spin, etc. as well as shift focus)
- Render time measurement & percentage progress indicator
- Live rendering into a desktop window, rather than just a headless render into a file (although that is supported too)
Here's a demo of the video frames rendering and live rendering:
Video Frames Rendering | Live Rendering |
---|---|
![]() |
![]() |
This was the first serious software project I did, and the purpose was to teach myself OOP concepts and C++. It was a great first project in that sense, with a very cool and gratifying visual result at the end.
Have SDL2, CMake
and ninja
installed. Then, after cloning this repo, from the root of the repo, run the following:
mkdir build
cd build
cmake -G Ninja ..
ninja
./rt-weekend
Single image renders should produce a .ppm
file in the same directory as the executable.
You can also use the render_to_window()
function in the renderer class to see the image get rendered live into a desktop window.
For rendering videos, make a subfolder called output
, and the video frames will be rendered into there. To combine the video frames into a video, run the following ffmpeg command:
ffmpeg -framerate 30 -i "output/%01d.ppm" output.mp4
I've used 30 fps in the code, and thus the number must be the same in this command.
- Use a video encoding library to stitch the frames into a video from within the program instead of rendering frames as seperate files and having to stitch later through an ffmpeg command
- Add camera movement of a spiral and helix
- Add a proper progress bar for video rendering
- Implement graphics acceleration using Metal/Vulkan/DirectX (aspirational)