Modified from Assignment 3: Ray Tracing, but rewrote most of the codes.
- 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)
- 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.
cmake --preset release
cd build
make -j./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.
![]() |
![]() |
|---|---|
![]() |
![]() |
| Metallic = 0.0 | Metallic = 0.5 | Metallic = 1.0 | |
|---|---|---|---|
| Roughness = 0.1 | ![]() |
![]() |
![]() |
| Roughness = 0.5 | ![]() |
![]() |
![]() |
| Roughness = 1.0 | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|---|---|---|
| SPP = 1 | SPP = 4 | SPP = 16 |
![]() |
![]() |
![]() |
| SPP = 64 | SPP = 256 | SPP = 1024 |
- 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.
- Morgan McGuire's Computer Graphics Archive
- Poly Haven
- Blender
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


















