A simple pathtracer running from the commandline for Linux, macOS and Windows
This is strongly based on the book Ray Tracing in a Weekend by Peter Shirley. The code follows the one from the book, but I've changed a lot of the code structure and added some extra features.
- Runs from the command line with options
- Multithreaded
- PPM Output
- BMP Output
- TGA Output
- Antialiasing
- Diffuse, Metal and Dielectric Materials
- Positionable camera
- Defocus blur
- Motion blur
The usage is relly simple. For a complete overview of all options, enter ./raytracer --help
. Here are some examples:
./raytracer --help # Print help with all options
./raytracer # Start raytracing of the default world with default settings
./raytracer --world random # Random Scene (from the book)
./raytracer --world demo # Demo Scene (from the book)
./raytracer --width 1280 --height 640 # Output image with size 1280x640
The final binary has no requirements.
To compile this project you need cmake
>= 3.2 and a C++ compiler with support for C++14. There aren't any other dependencies.
It was tested on Linux (Ubuntu, with gcc), macOS Mojave (clang) and Windows 10 (MSVC).
This project uses cmake for cross platform compilation.
Use the default cmake workflow:
# Assuming you are already in the project directory
mkdir build # Out of source build
cd build
cmake ..
make
./raytracer --help # Show help to check if compilation was successfull.
Use cmake for windows to create a Visual Studio project. Open this project and make sure you have Release selected, then compile the complete project. This was tested with VS 2017.
The project will be builded as Release by default. If you need a debug build, set CMAKE_BUILD_TYPE
to Debug
:
cmake -DCMAKE_BUILD_TYPE=Debug ..
To compile the project with doubles instead of floats, set the cmake option DOUBLE_AS_FLOAT
to ON
:
cmake -DDOUBLE_AS_FLOAT ..
Some features I like to add:
- More worlds
- Make drand48 thread safe (maybe erand48?)