Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GPU Path Tracer

A GPU-accelerated path tracer written in C++ using Metal via metal-cpp.

Build

From the directory containing Shaders.metal:

xcrun -sdk macosx metal -c Shaders.metal -o Shaders.air
xcrun -sdk macosx metallib Shaders.air -o default.metallib

to compile the Metal shader (Shaders.metal) into a .metallib.

From the build directory:

cmake .. -DBUILD_GPU_PT=ON
make

to build the c++ code.

Run

Move default.metallib to the build directory so the executable can find it and run:

./gpu_pt > output.ppm

References

CPU Path Tracer

A CPU-based path tracer written in C++, based on Ray Tracing in One Weekend, and extended with multithreading support.

final scene

Final Render Statistics

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

Build

From the build directory:

cmake .. -DBUILD_CPU_PT=ON -DCMAKE_CXX_COMPILER=g++-15
make

to build the c++ code.

Run

From the build directory:

./cpu_pt > output.ppm

About

A GPU-accelerated Ray Tracing in One Weekend in Apple Metal via metal-cpp

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages