Skip to content

Experimental path tracing with C++20 and SYCL

License

Notifications You must be signed in to change notification settings

lforg37/path_tracer

This branch is 35 commits behind triSYCL/path_tracer:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

32baf38 · Feb 10, 2021
Sep 14, 2020
Dec 14, 2020
Dec 5, 2020
Feb 10, 2021
Feb 8, 2021
Feb 1, 2021
Feb 8, 2021
Nov 30, 2020
Feb 2, 2021

Repository files navigation

Path tracer

This is an experimental path tracer using C++20 and SYCL for acceleration.

img

This is using triSYCL for now but it might work even better on some other SYCL implementations. Contributions and optimizations welcome!

The main focus here is to replace classic features like pointers or dynamic polymorphism that does not work (well) on heterogeneous with more modern constructs such as std::variant and std::visit.

Features

  • motion blur;
  • depth of field;
  • materials:
    • smoke;
    • textures;
    • Lambertian material;
    • dielectric material;
    • metallic roughness;
    • light;
  • geometry:
    • spheres;
    • triangles;
    • x/y/z-rectangles;
    • boxes;

Required dependancies

In addition to triSYCL, this project requires the following dependancies:

  • the stb image manipulation library;

On Linux, there's a good chance it can be installed with your package manager :

On Ubuntu/Debian :

sudo apt install libstb-dev

On Archlinux, install the stb package from AUR.

Compiling

Clone the reposity such as with:

git clone [email protected]:triSYCL/path_tracer.git

Create a build directory for example inside the cloned repository and jump into it.

From there, assuming you have the https://github.com/triSYCL/triSYCL repository somewhere, run:

cmake .. -DCMAKE_MODULE_PATH=<absolute_path_to>/triSYCL/cmake

The project defaults to a Release build configuration. If you wish to debug, configure your build settings as follow:

cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MODULE_PATH=<absolute_path_to>/triSYCL/cmake

It is also possible to build with https://github.com/triSYCL/sycl or https://github.com/intel/llvm/tree/sycl

cmake .. -DSYCL_CXX_COMPILER=<path_to_sycl_build>/bin/clang++ -DSYCL_DEVICE_TRIPLE=fpga64_sw_emu
# the triple fpga64_sw_emu is only available with https://github.com/triSYCL/sycl

For FPGA execution you might add -DUSE_SINGLE_TASK=ON on the previous cmake configuration to use a SYCL execution based on a .single_task() instead of .parallel_for(), probably more efficient on FPGA.

Build the project with:

cmake --build . --verbose --parallel `nproc`

This creates the executable.

Running

Now you can run the path tracer with:

time RT_SYCL/sycl-rt >! result.ppm

This results in the image result.ppm produced by the path tracer.

Bibliography

Some references that were tremendously useful in writing this project:

  1. Path tracing

  2. Ray Tracing in One Weekend - Peter Shirley

  3. Ray Tracing: The Next Week - Peter Shirley

  4. Ray-tracing in a Weekend with SYCL: Basic sphere tracing -- Georgi Mirazchiyski

  5. Ray-tracing in a Weekend with SYCL Part 2: Pixel sampling and Material tracing -- Georgi Mirazchiyski

  6. CppCon 2018: Mateusz Pusz, “Effective replacement of dynamic polymorphism with std::variant”

  7. Bartek's coding blog: Runtime Polymorphism with std::variant and std::visit

  8. Intersection of a Ray/Segment with a Triangle

About

Experimental path tracing with C++20 and SYCL

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 76.8%
  • CMake 23.2%