This project is an implementation of path tracing, utilizing OpenMP, MPI as well as OpenCL for parallel computing.
This is an educational project for the Parallel Computing module at HTWG Konstanz written in C++.
This project is written in C++, built with CMake and documented with LaTex. The latest documenation can be viewed as a compiled pdf in the doc directory.
To get started, follow these steps:
-
Clone the repository:
git clone git@github.com:timomt/path-tracing.git cd path-tracing -
Install CMake: Make sure you have CMake installed on your machine.
-
Install C++ Compiler: Make sure you have a C++ compiler, which supports OpenMP, like GCC installed on your machine.
-
Install MPI: Make sure you have MPI, for example OpenMPI, installed on your machine.
-
Install OpenCL: Make sure you have OpenCL installed on your machine. The installation process of OpenCL varies greatly between operating systems, distributions and vendors.
-
Install OpenCV: Make sure you have OpenCV for C++ installed on your machine.
-
Build the project: Make sure you create a build directory, if not present:
mkdir cmake-build
Configure the project using CMake:
cmake -B cmake-build -S .Build using CMake:
cmake --build cmake-build
Optional: Install pdflatex to build the documentation yourself.
Once installed, the documentation can be compiled by building target doc, while any auxiliary LaTeX files build along the PDF can be cleaned using target doc_clean:
cmake --build cmake-build --target doccmake --build cmake-build --target doc_cleanAfter building successfully, the compiled executable can be launched from the folder specified earlier by the --build flag:
./cmake-build/path_tracingThe entry source file to the project, src/main.cpp, includes usage examples with explanations and different use cases. Feel free to test them out with varying configurations or even write your own rendering setup.
In case the project folder is moved to a different location, the executable has to be rebuilt, since the OpenCL kernels are loaded at runtime.
The following previews showcase example rendering possibilities of this path tracing implementation.
The animation below is a 10-second render produced at 1080p (1920×1080) and
24 FPS using the MPI and OpenCL example setup provided in src/main.cpp. The GitHub version is unfortunately only uploaded in 720p at 12FPS due to the file size.
Render settings:
- Resolution: 1080p (1920x1080)
- Ray samples per pixel: 250
- Maximum ray depth: 250
- Distributed rendering via MPI
- Data parallelization through OpenCL
The example-4k-500spp image is a single 4K frame rendered using OpenCL with
significantly higher quality settings to showcase lighting and material detail.
Render settings:
- Resolution: 4K (3840x2160)
- Ray samples per pixel: 500
- Maximum ray depth: 500
- Data parallelization through OpenCL
This render uses the same configuration as the 4K example above, with the key difference, that the background color is a sky blue and acts as a light source, creating a brighter environment.
The background can currently only be configured directly within the rendering process, specifically inside the
ray_colorfunction of the corresponding implementation. The background used in this example, when rendered using OpenCL, would simply require the following change inkernels/render_kernel.cl:if (!rec.hit) { //color_accum += throughput * (float4)(0.0f, 0.0f, 0.0f, 0.0f); //break; return throughput * (float4)(0.5f, 0.7f, 1.0f, 0.0f); }
This render also uses the same configuration as the 4K example above, however, the scene is now located inside of a closed white box, including orange/red spheres emitting warm light.



