CPU/GPU Cuda Raytracer

Spheya

I made a physically-based path tracer called ‘Starlight’ for a school project. In the span of 8 weeks, I developed a path tracer that can run on the CPU using regular C++, and on the GPU using NVIDIA CUDA. Both platforms use the same codebase.

Material System

For the materials, I made something that was mostly inspired by OpenPBR and the Disney BRDF, but its not a direct implementation of either, resulting in a physically based rendering pipeline that mixes different components from both of them together.

Core features of the material system include:

  • A Microfacet BRDF using GGX. Which allows for energy-conserving roughness values and support for anisotropic materials.
  • Support for both metallic and dielectric materials, with the dielectrics (including air) making use of Beer’s Law for accurate light absorption.
  • Because Starlight is a path tracer, it is able to render physically accurate caustics, as seen in the image above.

Sampling Method

For the sampling method, I used Multiple Importance Sampling (MIS) to avoid noise in the image. The implementation of this is based on the Veach 1997 Thesis. This balances direct light sampling and random sampling together, accounting for any bias direct light sampling has, resulting in cleaner images.

There is an option to turn off MIS and use random sampling instead, this is to be able to verify the accuracy of the results.

An example of the difference Multiple Importance Sampling makes.
Top left is accurate, but takes a while for the result to converge.
Bottom left converges quickly, but lacks accuracy.
Top right combines the methods, converging quickly and accurately.
Showcasing Beer’s law on the Blender monkey. Note how thinner areas like the ears absorb less light than where the light has to travel a longer distance through the model.
A gif showing how the rendering looks in real time. (Yes the resolution is very low)
A render of a more complex scene, and what the project looks like at the end.
One of the first images rendered, after about 1 week of progress.