Monte Carlo Path Tracer
By Fidel Yin🏆
Highlight Submission
Features
- Monte Carlo path tracing. (
path_tracing.cpp)- With Russian Roulette method.
- Multiple importance sampling. (
path_tracing.cpp&brdf.cpp)- Explicit light sampling.
- BSDF importance sampling (Both of cosine-weighted hemisphere distribution and GGX distribution).
- Physically-based BRDF (Cook-Torrance Model). (
brdf.cpp) - BVH Accelerated. (
bvh/AABBTree.cpp&bvh/AABB.cpp) - Texture mapping. (
material/texture.h) - Normal mapping. (
path_tracing.cpp) - Anti-alising by dithering sensor pixels. (
Camera.cpp) - Gamma correction. (
main.cpp&reader/gamma_transform.h) - Loading objects and materials from OBJ and MTL files. (
reader/read_obj.cpp)
Improvements
- Parallelized with OpenMP.
- Better Polymorphism architecture.
- Eliminated all
dynamic_cast.
- Eliminated all
- Performance improvements.
- Optimized ray-object intersection by pre-computing data and Möller–Trumbore intersection algorithm.
- Replaced
std::shared_ptrwithstd::unique_ptror raw pointer where possible. - Replaced 64-bit
doublewith 32-bitfloatfor floating point data. - Utilized Eigen’s vectorized operations and lazy evaluation where possible.
- Modernized the code based on C++20 standard.
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
- Morgan McGuire’s Computer Graphics Archive
- Poly Haven
- Blender
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:
- https://agraphicsguynotes.com/posts/sample_microfacet_brdf/
- https://schuttejoe.github.io/post/ggximportancesamplingpart1/
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


















