This repository contains two implementations of a path tracer: one using CUDA for GPU acceleration and another using CPU multi-threading. The comparison demonstrates the significant performance advantage of GPU-based path tracing for real-time rendering.
CUDA Path Tracer (160 FPS) |
CPU Path Tracer (10~25 FPS) |
.
├── cuda_pathtracer/ # GPU-accelerated implementation
└── cpu_pathtracer/ # CPU-based implementation
[Insert screenshot of your rendered scene here]
The scene features:
- A Cornell box with colored walls (red and green sides)
- Multiple spheres with different materials:
- Glass (refractive)
- Metal (reflective)
- Glossy (mixed specular/diffuse)
- Multiple colored lights for interesting illumination effects
- Real-time camera movement and interaction
- Frame Rate: 160 FPS on 4060 GPU
- Resolution: 1280x720
- Features:
- Real-time rendering
- Interactive camera movement
- Progressive refinement
- Multiple material types (Diffuse, Glossy, Specular, Glass)
- Colored lighting effects
- Monte Carlo path tracing with importance sampling
- Frame Rate: 10~20 FPS
- Resolution: 1280x720
- Features:
- Same features as CUDA version but significantly slower
- Multi-threaded rendering using OpenMP
- Progressive refinement (but much slower accumulation)
- Demonstrates why GPU acceleration is necessary for real-time path tracing
The CPU version demonstrates why GPU acceleration is essential for real-time path tracing:
- Parallelization: Path tracing is inherently parallel - each pixel can be computed independently
- Ray-Object Intersection: GPU can perform thousands of intersection tests simultaneously
- Monte Carlo Sampling: Random sampling and light calculations benefit from massive parallelization
- Memory Access: GPU's high memory bandwidth is crucial for accessing scene data
mkdir build && cd build
cmake ..
make
./cuda_pathtracer/CUDAPathTracer
./cpu_pathtracer/CPUPathTracer
- W/A/S/D: Move camera
- Mouse: Look around
- Tab: Toggle mouse capture
- Escape: Exit
- CUDA Toolkit 11.0 or higher
- NVIDIA GPU with Compute Capability 6.0 or higher
- C++17 compatible compiler
- CMake 3.18 or higher
- X11 development libraries(Linux)
- C++20 compatible compiler
- CMake 3.18 or higher
- OpenMP
- X11 development libraries
Both implementations use:
- Monte Carlo path tracing
- Multiple importance sampling
- Real-time progressive refinement
- Various material types (diffuse, glossy, specular, glass)
- Scene management with implicit objects
- Interactive camera controls(Cuda version has bugs)