Skip to content

al-ro/path-tracer

Repository files navigation

Path Tracer

This work is in progress.

CUDA / C++ path tracer with bounding volume hierarchy (BVH) based on the tutorial series by jbikker

Pure C++ version for CPU

Test scenes

Scene 0: 3 instances BVH heat map (max 267)
Scene 1: 10,000 instances BVH heat map (max 600)
Scene 2: Model with vertex attributes BVH heat map (max 123)
triangles per mesh BLAS time (s) TLAS total triangles max tests
Scene 0 505,848 792,591 0.88 5 1,517,544 267
Scene 1 505,848 792,591 0.88 19,819 5,058,480,000 600
Scene 2 3,828 4,899 0.0049 1 3,828 123

Performance

  • Resolution: 1500 x 800
  • Samples: 100
  • Max bounces: 6
  • CPU: 13th Gen Intel Core i7-13700H × 20
  • GPU: NVIDIA GeForce RTX 3050 6GB

"Bust of Menelaus" by Scan The World

"Viking room" by nigelgoh (edited)

Environment map from HDR Haven

Features

  • BVH (BLAS + TLAS) construction and traversal
  • Cook-Torrance
  • Trowbridge-Reitz (GGX) specular
  • Lambertian diffuse
  • BRDF importance sampling

Use

Running outputs parameters and progress to the console

Resulting image is output as output.bmp

  • make clean (to remove old executable)
  • make build
  • make run (with default settings)
  • make all (clean, build, run)
  • ./PathTracer [options]
    • -d 0: CUDA (default), 1: CPU
    • -w width of rendered image (e.g. -w 512)
    • -h height of rendered image
    • -s samples per pixel
    • -b maximum bounces per ray per sample
    • -t number of threads (ignored when using CUDA)
    • -p preset scene [0, 2]
    • -a output BVH heatmap (ignores -s and -b)

Dependencies

  • GLM for maths functions and data structures
  • stb for reading and writing images (included in /lib)
  • stl_reader for reading STL files (included in /lib)
  • tinyobjloader for loading OBJ files (included in /lib)
  • C++17
  • make (optional)