A physically based path tracing renderer in C++, originally built as a Master 1 team project, now maintained as a personal playground for rendering and performance work (SIMD, profiling, acceleration structures). Path tracing is a physically realistic rendering method that simulates the behavior of light in a 3D scene.
- Rendering of 3D scenes with path tracing
- Support for geometric objects:
- Spheres
- Axis-Aligned Boxes (AABB)
- Diffuse materials (Lambertian)
- Antialiasing by multiple sampling
- Gamma correction
- Export to PPM format
- Parallelized with OpenMp
- Support for different object materials:
- Specular
- Glossy
- Dielectric
- Different rendering methods:
- Path Tracing Monte Carlo
- Metropolis Light Transport
- Light sources
- CMake (version 3.22 minimum)
- C++ compiler supporting C++17 with OpenMP (on macOS:
brew install libomp) - Python 3.x (for the PPM conversion script)
- Clone the repository :
git clone https://github.com/Pleym/path-tracing-cpp.git
cd path-tracing-cpp- Create and navigate to the build directory :
mkdir build
cd build- Generate the build files with CMake :
cmake ..- Compile the project :
makeThe program takes several command line arguments :
./render [width] [height] [samples_per_pixel] [output_path] [max_depth][render_mode]Exemple :
./render 800 600 100 output.ppm 50 0After execution, you will be prompted to enter the camera parameters:
- Camera position (x,y,z)
- Aim point (x,y,z)
- Up vector (x,y,z)
- Vertical field of view (in degrees)
- Number of iterations if you choose the mode MLT
A Python script is provided to convert PPM files to other formats :
python3 convert_ppm.py [outputppm_path] [outputpng_path]src/: Contains source filesrender.h/.cpp: Main rendering functionssphere.h/.cpp: Implementation of spheresobj.h: Base class for objectsmaterial.h: Base class for materialslambertian.h/.cpp: Implementation of the diffuse materialvec3.h/.cpp: Class for 3D vectorsray.h/.cpp: Class for rayscamera.h/.cpp: Camera Managementdielectric.h/.cpp: Implementation of dielectric (transparent) materialglossy.h/.cpp: Implementation of glossy materialspecular.h/.cpp: Implementation of specular reflectionemissive.h/.cpp: Implementation of emissive (light-emitting) materialfirstCollision.h/.cpp: Functions to compute the first ray-object intersectionAABB.h/.cpp: Axis-Aligned Bounding Box for spatial accelerationmlt_path.h/.cpp: Functions related to path tracing using Metropolis Light Transport
script/: Contains shell scripts for renderingrender.sh: Main rendering scriptparameters.txt: Text file containing rendering parametersconvert_ppm.py: Python script to convert PPM files to other formats
The project uses an object-oriented architecture with:
- A hierarchy of geometric objects (Object -> Sphere, AABB)
- A hierarchy of materials (Material -> Lambertian,Specular,Glossy,Dielectric,Emissive)
- A recursive ray tracing system for path tracing
- An integrated MLT rendering engine
