MATTHIEU DELAERE

GRAPHICS PROGRAMMER

email github twitter linkedIn
CUDA Ray Tracer - C++ Graphics Programmer Course

2019 - 2020 • Digital Arts and Entertainment Course

DESCRIPTION:

Since 2019 I am in charge of the Graphics Programming courses, while co-teaching them since 2015. During the Graphics Programming 1 course I teach the basics of Computer Graphics. Before we used DirectX 11 to explain some of the core concepts. When remaking the course, I went back to the roots of Computer Graphics. Now we focus on:

  • visibility determination using both ray tracing and rasterization.
  • intersection algorithms for spheres, planes, triangles and triangle meshes.
  • the Render Equation, focusing on direct lighting and multiple BRDF's (Lambert, Phong and CookTorrance).

Students have to write their own software ray tracer, software rasterizer and a small DirectX 11 render framework from scratch in C++. They only get a few files for window handling and mathematics. While making all the classes, I've created another version of a ray tracer that supports:

  • hardware acceleration using Nvidia's CUDA.
  • progressive indirect lighting, using importance sampling based on the BRDF.

Below you can find some code samples from the project, which is available through the github link . This project is still a work in progress and could be extended with several optimization techniques, transparency, triangle mesh support, etc. Some of the mentioned features are supported in the software version, which I can't share online due to the fact that this is still actively used in classes.


CODE SNIPPETS:

Below are code snippets of some of the most interesting parts of ray tracer. Feel free to analyze the entire github repository as well!

Tracer: part of the heart of the ray tracer, using CUDA to run on the GPU. All data is allocated on the GPU but, due to optimzations performed by the CUDA compiler, virtual functions potentially caused issues. I avoided using virtual functions instead.

Importance Sampling: different sampling methods based on the BRDF's. References are in the code itself. Normalizations happen in the Tracer (see code sample above).

BRDF's: different RDF's (Lambert, Phong and CookTorrance).

Resource Buffer: class to easily transfer memory from GPU to CPU and vice versa. It uses Unified Virtual Addressing to automatically figure out the location (GPU or CPU) of the referenced data. It also make memory management easier.