Skip to content

logancho/CUDA-Path-Tracer

 
 

Repository files navigation

CUDA Path Tracer


Example Render:

2350 x 1000 | CUDA Path Tracer with Intel OIDN Denoiser | BVH | 500 SPP | All assets modelled in Maya


University of Pennsylvania, CIS 565: GPU Programming and Architecture, Project 3


Introduction

This project is a CUDA Path Tracer developed on top of the base code provided by the University of Pennsylvania, CIS 565: GPU Programming and Architecture. Features implemented include:

  • Parallelized Naive Lighting Integrator
  • Parallelized Full Lighting Integrator with MIS
  • Performance Optimizations
    • Sorting Path Segments by material type to reduce divergence and increase warp occupancy
    • Stream Compaction of Path Segments to free up cores from rays that have already terminated
  • Arbitrary .glTF mesh support with materials and textures (albedo and normals)
  • BSDFs (Diffuse, Specular, Microfacet, etc.)
  • Intel OIDN Integration (Denoiser)

Features

BSDFs

  • Diffuse

  • Specular

  • Microfacet

  • Ceramic / Plastic


Integrators

I currently support 3 Lighting Integrator models: Naive, Full Lighting with MIS and Direct Lighting. The following renders are after only a few samples (10.) You can see that the direct lighting and full lighting integrator models are far less noisy than the naive integrator.

Naive Integrator @ 10spp Full Lighting Integrator with MIS @ 10spp Direct Lighting Integrator @ 10spp

Currently, there is a bug which doesn't allow my Full Lighting model to correctly render with more than 1 light source. TBC.


Mesh Loading

This path tracer supports .glTF 3D scene loading and rendering. This was done through wrapping the tinyGLTF library. Here are the supported capabilities:

  • Triangular Mesh Loading
  • Material Loading
  • Albedo Texture Loading and Sampling
  • Pbject Space Normal Map Loading and Sampling

There are a few restrictions however:

  • The mesh must be triangulated. Only triangles are supported currently.
  • Materials must be mapped manually in your Path Tracer .json file. That is, if your glTF file has 4 unique materials, then you must define 4 materials in your .json file accordingly to allow for the 4 materials to appear in the render.

OIDN

This path tracer supports a real-time machine learning denoiser to modify the final render output. (Intel OIDN).

The user can use the UI to configure the strength of denoising they want to apply.

Perf Analysis

BVH

One optimization I implemented was a BVH acceleration structure for storing triangles. This proved to be very useful as it significantly boosted performance for dense .glTF scenes.

Sort by Material and Stream Compaction

Two other optimizations I implemented were Sorting Path/Ray Segments by material at each depth, and also, Stream Compaction to remove rays that have already terminated. Due to the overhead associated with using CUDA's thrust library, these optimizations provided less significant gains in most cases compared to something like BVH.

The following charts are an analysis of average FPS against the inclusion/exclusion of these optimizations on a ~40k triangle scene.

Naive Integrator Full Lighting Integrator

What I have learnt from my long testing of these optimizations is that they are useful only in very specific scenarios. Otherwise, their overhead outweighs any benefit they might be able to provide in regards to increasing warp compaction and reducing warp-divergence related bottlenecks.

Extras and Bloopers

I played around with some other lighting conditions for my hero render:

And here are just a few of the hundreds of bloopers I fought along the way! : )

Credits

  • All scenes modelled, textured and rendered by myself

  • Hero render inspired by Spiderman: Into the Spiderverse (2018):

    • image
  • Base Code: University of Pennsylvania, CIS 5650

  • tinyGLTF Library

  • Intel OIDN

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 86.3%
  • C 10.9%
  • Cuda 2.4%
  • Other 0.4%