A GPU-accelerated ray tracing engine implementing the Disney Principled BSDF, built with Rust and Vulkan
- Physically-based rendering using path tracing
- Disney Principled BSDF for realistic material rendering
- GPU acceleration through Vulkan compute shaders
- High-performance BVH scene acceleration structure
- Skybox support with HDR image-based lighting
- Multi-bounce light transport for global illumination
- Efficient scene loading from YAML configuration
- AI Denoising from Intel Open Ai Denoising
- Features
- Contents
- Gallery
- Scene Format
- Materials System
- Building and Running
- Technologies
- Architecture
- Performance
- Future Work
- References
Dragon without normal smoothing
camera:
resolution: [900, 900]
focal_length: 2.1
focus_distance: 1
aperture_radius: 0
location: [8, 25, 30]
look_at: [0, 5, 0]
skybox: [
"data/skybox/px.png",
"data/skybox/nx.png",
"data/skybox/py.png",
"data/skybox/ny.png",
"data/skybox/pz.png",
"data/skybox/nz.png",
]
materials:
MetallicMaterial:
base_colour: [0.8, 0.8, 0.9]
metallic: 0.9
roughness: 0.2
specular_tint: 0.5
GlassMaterial:
base_colour: [1.0, 1.0, 1.0]
roughness: 0.05
spec_trans: 0.95
ior: 1.5
surfaces:
- type: "object"
smooth: true
file: "data/models/sphere.obj"
material: "MetallicMaterial"
- type: mesh
material: "GlassMaterial"
vertices:
- [-10, 0, -10]
- [10, 0, -10]
- [10, 0, 10]
- [-10, 0, 10]
triangles:
- [0, 1, 2]
- [0, 2, 3]| Section | Description |
|---|---|
camera |
Camera parameters like position, orientation, and lens settings |
skybox |
Paths to the 6 cubemap faces for environment lighting |
materials |
Named material definitions using the Disney BSDF parameters |
surfaces |
Geometry definitions, either from OBJ files or inline meshes |
Implements the full Disney Principled BSDF with these parameters:
| Parameter | Description | Default |
|---|---|---|
base_colour |
Base surface color (diffuse or metallic) | [0.8, 0.8, 0.8] |
emission |
Light emission (for emissive materials) | [0.0, 0.0, 0.0] |
metallic |
Metallic reflection (0=dielectric, 1=metallic) | 0.0 |
roughness |
Surface microfacet roughness | 0.5 |
subsurface |
Subsurface scattering amount | 0.0 |
anisotropic |
Anisotropic reflection | 0.0 |
specular_tint |
Tints the specular reflection | 0.0 |
sheen |
Sheen for cloth-like materials | 0.0 |
sheen_tint |
Tints the sheen component | 0.5 |
clearcoat |
Clear coat layer | 0.0 |
clearcoat_roughness |
Roughness of clear coat | 0.03 |
spec_trans |
Specular transmission | 0.0 |
ior |
Index of refraction | 1.45 |
- MSRV
- Vulkan SDK 1.2+
- Cargo and standard Rust toolchain
- OIDN 2.2+
# Clone the repository
git clone https://github.com/teehee567/ray-tracer
cd ray-tracer
# Build in release mode
cargo build --release# Run with a default scene
cargo run --release -- scenes/default_scene.yaml
# Or specify a custom scene
cargo run --release -- path/to/your/scene.yaml- Rust: Memory safety and performance for the CPU side
- Vulkan: Low-level GPU access through compute shaders
- GLSL: Shader implementation of the core ray tracing algorithm
- vulkanalia: Rust bindings to Vulkan
- glam: Fast linear algebra library
- serde: Serialization/deserialization for scene loading
The tracer is built on a hybrid CPU/GPU architecture:
- CPU Side: Scene loading, BVH construction, and coordination
- GPU Side: Ray tracing, shading, and image composition
The system consists of these major components:
Scenes are loaded from YAML files that describe:
- Camera parameters
- Material properties and textures
- Geometry (triangles, meshes)
- Light sources
- Environmental lighting
A high-performance BVH (Bounding Volume Hierarchy) is constructed on the CPU and transferred to the GPU for efficient ray traversal:
- Surface area heuristic for optimal splits
- Fast parallel construction
- Compact memory representation
The tracer employs a progressive rendering approach:
- Primary ray generation from camera
- BVH traversal for intersection tests
- Material evaluation using the Disney BSDF
- Direct light sampling with MIS (Multiple Importance Sampling)
- Recursive path tracing for indirect illumination
- Progressive refinement for noise reduction
The Ray Tracer achieves high performance through several optimizations:
- BVH acceleration: Efficiently culls non-intersecting geometry
- Vulkan compute: Utilizes modern GPU hardware
Typical performance on modern hardware (RTX 3080):
- 1080p: 5-10 samples per second (full path tracing)
- 720p: 10-20 samples per second
- Volumetric rendering: Add support for participating media
- Bidirectional path tracing: Improve handling of difficult light paths
- Interactive editing: Real-time material and scene adjustments
- Disney Principled BSDF: Physically-Based Shading at Disney
- Path Tracing: Physically Based Rendering: From Theory To Implementation
- BVH Construction: On fast Construction of SAH-based Bounding Volume Hierarchies
- Blender Cycles ray tracer: Blender Cycles renderer
- GLSL Ray Tracer: GLSL Ray Tracer
- Caldera Ray Tracer: Caldera Ray Tracer
- Ray Tracing in a weekend: Ray Tracing in a weekend
- Graphics Codex: Graphics Codex
- Alexander Veselov's Ray Tracver: Ray Tracer





