Skip to content

A simple command line pathtracer.

License

Notifications You must be signed in to change notification settings

NHollmann/Pathtracer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pathtracer

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.

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

Running

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

Requirements

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).

Compiling

This project uses cmake for cross platform compilation.

Unix

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.

Windows

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.

Debug build

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 ..

Double precision

To compile the project with doubles instead of floats, set the cmake option DOUBLE_AS_FLOAT to ON:

cmake -DDOUBLE_AS_FLOAT ..

Todo

Some features I like to add:

  • More worlds
  • Make drand48 thread safe (maybe erand48?)

About

A simple command line pathtracer.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages