Skip to content

timomt/path-tracing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Path-Tracing

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++.

Table of Contents

Introduction

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.

Installation

To get started, follow these steps:

  1. Clone the repository:

    git clone git@github.com:timomt/path-tracing.git
    cd path-tracing
  2. Install CMake: Make sure you have CMake installed on your machine.

  3. Install C++ Compiler: Make sure you have a C++ compiler, which supports OpenMP, like GCC installed on your machine.

  4. Install MPI: Make sure you have MPI, for example OpenMPI, installed on your machine.

  5. Install OpenCL: Make sure you have OpenCL installed on your machine. The installation process of OpenCL varies greatly between operating systems, distributions and vendors.

  6. Install OpenCV: Make sure you have OpenCV for C++ installed on your machine.

  7. 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 doc
cmake --build cmake-build --target doc_clean

Usage

After building successfully, the compiled executable can be launched from the folder specified earlier by the --build flag:

./cmake-build/path_tracing

The 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.

Additional Information

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.

Preview

The following previews showcase example rendering possibilities of this path tracing implementation.


Animated Preview

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

Demo-GIF


High-Resolution Single Image Render

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

Example-4K-500spp


High-Resolution Single Image Render (Bright)

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_color function of the corresponding implementation. The background used in this example, when rendered using OpenCL, would simply require the following change in kernels/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);
}

Example-4K-500spp-bright

High-Resolution Single Image Render (Closed Box)

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.

Example-4K-box

About

Distributed Path Tracing Rendering through OpenMP, OpenCL and OpenMPI

Topics

Resources

Stars

Watchers

Forks

Contributors