CUDA Rendering Engine

Spectral PathTracer

A personal and experimental project: a high-performance spectral path tracer implemented with CUDA that accurately simulates light dispersion effects and real-time spectral rendering.

TechnologyCUDA / C++
TypePersonal Project
GoalPhysically-Based Rendering
ToolsCMake, MSVC

Overview

This passion project was created to explore the physics of light and GPU-accelerated rendering techniques. It simulates the behavior of light wavelengths to produce highly realistic dispersion and color effects.

Render of a prism dispersing light in a Cornell Box

Key Features

Physical Spectral Rendering

Simulates wavelengths from 380nm to 780nm for accurate dispersion and color.

CUDA Acceleration

Leverages GPU parallel processing for optimal performance.

Realistic Materials

Supports diffuse, metallic, dielectric (glass), and emissive surfaces.

Geometric Primitives

Supports spheres, triangles, rectangles, prisms, and boxes.

Advanced Camera

Includes depth of field and configurable aperture.

Multiple Scenes

Several configurations to showcase dispersion and materials.

Technical Details

The Physics of Dispersion

The engine simulates how different wavelengths of light travel through materials with varying indices of refraction. This physical phenomenon is what creates rainbows and beautiful caustics through glass prisms.

The implementation uses Cauchy's equation to model dispersion:

$$n(\lambda) = A + \frac{B}{\lambda^2} + \frac{C}{\lambda^4}$$

Render of a glass prism

Spectral to RGB Conversion

To visualize spectral data on traditional screens, the engine implements a physically correct conversion from wavelengths to RGB color space, preserving the visual characteristics of dispersion effects.

Material showcase

Build and Usage

Requirements

CUDA Toolkit 11.0+, CMake 3.18+, a CUDA-compatible GPU (compute capability 7.5+ recommended), and MSVC on Windows.

Build

mkdir build
cd build
cmake ..
cmake --build . --config Release

Usage

Run the compiled binary. You will be prompted to select a scene to render.

./PathtracerSpectralRealtime

Project Status and Disclaimer

This is a personal experimental project I developed to deepen my understanding of spectral rendering and CUDA programming. It is continuously evolving as I explore new techniques and optimizations.

Feel free to use it for learning purposes or as inspiration for your own rendering projects.