A ray tracer implemented in Rust, based on Peter Shirley's "Ray Tracing in One Weekend" C++ series. It features depth of field and a basic material system.
- Basic Ray Tracing: Renders scenes with spheres and planes.
- Materials: Supports diffuse, metal, and dielectric materials.
- Depth of Field: Simulates camera blur using a defocus disk.
-
Clone the repository:
git clone https://github.com/yourusername/rust-ray-tracer.git cd rust-ray-tracer
-
Build the project:
cargo build --release
-
Render an image and save it to
output.ppm
:cargo run --release > output.ppm
Then open the output file with your favorite image editor. You can use an online PPM viewer if that doesn't work.
This below image took 5m15s to be rendered on a Ryzen 5600 @ 3.7Ghz 6C12T, using Rayon for multi-threading:
The same image took 38m46s to render using a single thread, and no performance optimizations.
- Performance Profiling, identify chokepoints - Done
- CPU Multithreading - Done
- GPU Multithreading - Probably won't do, not realistically feasible for this
Based on book version:
Ray Tracing in One Weekend
Version 4.0.0-alpha.2, 2024-04-07