Skip to content

DanielZhong/CUDA-GPU-Accelerated-Path-Tracer

 
 

Repository files navigation

CUDA GPU-Accelerated Path Tracing

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

  • Ruijun(Daniel) Zhong
  • Tested on: Windows 11 pro, 12th Gen Intel(R) Core(TM) i7-12700K 3.61 GHz 32.0 GB, NVIDIA GeForce RTX 3070 Ti (personal computer)

Abstract

Path tracing is a method used in computer graphics to create realistic images by simulating how light interacts with objects. However, this process can be very demanding on a computer's resources, especially when aiming for high-quality images. Enter NVIDIA's CUDA, a technology that allows for faster computations using graphics processing units (GPUs). In this project, I explore how CUDA can make path tracing faster and more efficient.

Visual Features

GLTF Model & Procedural CheckerBoard Texture & HDR SkyBox

Infinite Procedural Shapes & Procedural Textures


Showing:

  • Material: PBR Diffuse, PBR Glass, PBR Metal, Texture Map, Perlin Noise Texture, Ring Texture
  • Shape: Torus with Displacement, Cylinder, Capsule, Displacement+ SmoothUnion of Bended Cube and Sphere

PBR depth-of-field (by jittering rays within an aperture)

PBR Schlick's approximation of Diffuse, Glass, Metal with random sphere scene

Antialising with random ray(supersampling)

  • Without Antialising

  • With Antialising(50 x more random ray per pixel)

Optimize Feature & Analysis

  • Caching FirstBounces: As we frequently intersect the same primary rays originating from the camera with the scene, we can cache the first bounce. This allows subsequent rays to read from the cache.

  • Compaction: Remove terminated path(ray that hits nothing), and then move the active path to the front of the "array"

  • Material Sorting: When rays bounce and hit materials, the resulting data can be mixed up and out of order. During shading, threads can work on different materials at once, causing inefficiency. To fix this, we sort the data by material type first, so threads work on the same materials together.

  • Denoise: Please check Denoiser Branch!

Based on the provided chart, compaction significantly impacts the open box scene because there are more terminated rays in this setting. Refer to the chart below for a comparison of ray numbers between the closed box and the open scene. Furthermore, as the number of material types increases, the sorting of materials becomes more pronounced.

Bugs

Solution to this bug: make sure z axis is positive for both left and right hand coordinate
AntiAlising isn't correct(Solution: make sure random ray apply to all stages including generate ray, intersection, shading etc.)

Material Sorting will mess up if turn on antialising
Other intersting bugs that can't show directly through picture:

  • Glass material keep showing error(Solution: rewrite sphere intersection)
  • GLTF obj not loading(Solution: reExport from modeling application and make sure the format is match the triangle intersection in accesor, bufferview, mesh etc.)
  • Metal and Glass not reflecting skybox
  • Failed to implement BVH, incorrect normal value
  • etc.

References

Some ideas were inspired by:

Ray Tracing in One Weekend including:

  • Diffuse, Metal, Glass Material
  • Sphere Intersection Test
  • (MSAA) Camera Multisampleing Antialiasing with random ray

Ray Tracing: The Next Week including:

  • Skybox Sphere Texture
  • Procedure Texture(Perlin Noise)

Ray-Tracing: Rendering a Triangle including:

  • Triangle Intersection Test(Moller-Trumbore algorithm)

Inigo Quilez including:

  • SDF Normalize Formula

iquilezles.org including:

  • Procedure Shape Formula

syoyo/tinygltf & Reddit including:

  • Extract GLTF object mesh to triangle index buffer

cgtrader & SolarsSystemScope including:

  • gltf 3d model and textures

Schlick's approximation including:

  • PBR Diffuse, Metal, Glass with Frensel effects using Schlick's approximation

pbrt including:

  • Physically-based depth-of-field (by jittering rays within an aperture)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 88.3%
  • C 10.6%
  • Other 1.1%