A rasterizer implementation in Rust
Try it online: Live WebGPU Raytracer
This project includes three different raytracing implementations:
- CPU Raytracer - Software-based raytracing running on the CPU
 - GPU Raytracer - Hardware-accelerated raytracing using GPU compute shaders (offline rendering)
 - Live GPU Raytracer - Real-time interactive GPU raytracer with camera controls
 
The CPU version renders scenes using traditional CPU-based raytracing and outputs to a PPM image file.
# Build and run (outputs to stdout, redirect to file)
cargo run --release > output.ppm
# Or build first, then run
cargo build --release
./target/release/rust-rasterizer > output.ppmFeatures:
- Full path tracing with multiple bounces
 - Direct and indirect lighting
 - Mesh support (.obj files)
 - Sphere primitives
 
The GPU version uses compute shaders to accelerate rendering, outputting to a PPM file.
# Build and run
cargo run --bin gpu_raytracer --release > output.ppm
# Or build separately
cargo build --bin gpu_raytracer --release
./target/release/gpu_raytracer > output.ppmFeatures:
- GPU-accelerated compute shader rendering
 - Same scene quality as CPU version
 - Significantly faster rendering times
 - Hardware-accelerated ray-triangle intersection
 
The live version provides a real-time interactive window where you can navigate the scene.
# Run the live raytracer
cargo run --bin live_raytracer --releaseControls:
- Mouse: Click and drag to rotate the camera
 - SPACE: Toggle between raytracing and normals visualization modes
 - Window Title: Displays current mode and FPS
 
Features:
- Real-time GPU raytracing
 - Interactive camera controls
 - Two rendering modes:
- Raytracing: Full path tracing with lighting and shadows
 - Normals: Fast visualization showing surface normals (useful for debugging)
 
 - Live FPS counter in window title
 
- Rust (latest stable version)
 - For GPU versions: A GPU with compute shader support (Vulkan, Metal, or DirectX 12)
 
            