A GPU-accelerated path tracer written in C++ using Metal via metal-cpp.
From the directory containing Shaders.metal:
xcrun -sdk macosx metal -c Shaders.metal -o Shaders.air
xcrun -sdk macosx metallib Shaders.air -o default.metallibto compile the Metal shader (Shaders.metal) into a .metallib.
From the build directory:
cmake .. -DBUILD_GPU_PT=ON
maketo build the c++ code.
Move default.metallib to the build directory so the executable can find it and run:
./gpu_pt > output.ppm- GPU Programming with the Metal Shading Language: A very good intro video on GPU programming with Metal
- Accelerated Ray Tracing in One Weekend in CUDA
A CPU-based path tracer written in C++, based on Ray Tracing in One Weekend, and extended with multithreading support.
- Resolution:
1200 × 675 - Samples per Pixel:
500 - Machine: Apple MacBook Pro (M1 chip, 8 cores)
- Render Time:
- Single-threaded: 6h 6m 44s
- Multi-threaded (8 cores): 53m 42s
- Multi-threaded (8 cores) +
BVH: 8m 54s
Leveraging C++17 parallel algorithms (std::execution::par) and Intel TBB, the implementation achieves over 40× speedup in scanline rendering when combined with BVH acceleration.
From the build directory:
cmake .. -DBUILD_CPU_PT=ON -DCMAKE_CXX_COMPILER=g++-15
maketo build the c++ code.
From the build directory:
./cpu_pt > output.ppm