Skip to content

CUDA-accelerated path traced Menger sponge using ray marching.

Notifications You must be signed in to change notification settings

nolmoonen/cuda-sdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cuda-sdf performs naive path tracing of a signed distance field (SDF) using ray marching, accelerated with CUDA. The below one-megapixel image displays the Menger sponge, with a thousand samples and up to 80 bounces, generated in about 150 seconds on an RTX 2070. Note that the RTX ray shooting capabilities cannot be not used, as the geometry is implicitly defined.

Performance

A naive implementation (generate_pixel_naive), where each thread is assigned a pixel and computes all samples for that pixel, computes the above image in about 150 seconds. An alternative implementation (generate_pixel_regeneration) spawns a pool of persistent threads that regenerate paths when they terminate, reducing the number of idle threads in a warp. This gives an 4.5% decrease in runtime and a 2% increase in occupancy, as reported by Nsight Compute.

System requirements and dependencies

The following third-party dependencies are included:

  • stb for writing PNG files.
  • sutil from the OptiX SDK samples for random number generation and vector- and matrix math.

Resources

  • Menger Fractal
    Quillez, I. [link]
    This article explains how the Menger fractal can be represented by an SDF.
  • Ray Tracing Gems II: Chapter 14, The Reference Path Tracer
    Boksansky, J. and Marrs, A. [link]
    This chapter explains how to create a simple path tracer.
  • Path Regeneration for Interactive Path Tracing
    Novák J. et al. [link]
    Explains the concept of path regeneration.