Skip to content

Fidelxyz/path-tracer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

98 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Monte Carlo Path Tracer

Modified from Assignment 3: Ray Tracing, but rewrote most of the codes.

Features

Improvements

  • Parallelized with OpenMP.
  • Better Polymorphism architecture.
    • Eliminated all dynamic_cast.
  • Performance improvements.
    • Optimized ray-object intersection by pre-computing data and Möller–Trumbore intersection algorithm.
    • Replaced std::shared_ptr with std::unique_ptr or raw pointer where possible.
    • Replaced 64-bit double with 32-bit float for floating point data.
    • Utilized Eigen's vectorized operations and lazy evaluation where possible.
  • Modernized the code based on C++20 standard.

Instructions

Build

cmake --preset release
cd build
make -j

Usage

./path_tracer <scene.json> [-o <output.png>]

Example scene files can be found in the data/ directory.

If the output file is not specified, the rendered image will be saved as output.png by default.

Rendered Images

Textured Materials

Comparing Parametric Materials

Metallic = 0.0 Metallic = 0.5 Metallic = 1.0
Roughness = 0.1
Roughness = 0.5
Roughness = 1.0

Comparing Samples Per Pixel (SPP)

SPP = 1 SPP = 4 SPP = 16
SPP = 64 SPP = 256 SPP = 1024

Acknowledgements

Libraries

  • Eigen
  • OpenMP: For parallelization.
  • libigl: For loading STL files.
  • tinyobjloader: For loading OBJ and MTL files.
  • stb: For reading and writing images.
  • json: For parsing JSON files.

Assets

Materials

Monte Carlo path tracing: https://sites.cs.ucsb.edu/~lingqi/teaching/resources/GAMES101_Lecture_15.pdf

Multiple Importance Sampling: https://computergraphics.stackexchange.com/questions/5152/progressive-path-tracing-with-explicit-light-sampling

Cook-Torrance BRDF: https://learnopengl.com/PBR/Theory

Cosine-weighted Importance Sampling: https://ameye.dev/notes/sampling-the-hemisphere/

Importance Sampling for GGX Distribution:

Möller–Trumbore intersection algorithm: https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm

Normal Mapping: https://learnopengl.com/Advanced-Lighting/Normal-Mapping

About

A physically-based Monte Carlo path tracer.

Resources

Stars

Watchers

Forks

Contributors