This is a simple ray tracer written in Rust, inspired by the "Ray Tracing in One Weekend" series.
cargo build --release
To generate an image and save it to a file:
cargo run --release > image.ppm
- The output will be a PPM image file (
image.ppm) in the project root.
src/main.rs- Entry point, scene setup, and render loopsrc/camera.rs- Camera and ray generationsrc/hittable.rs- Hittable trait and hit recordsrc/hittable_list.rs- List of hittable objectssrc/sphere.rs- Sphere implementationsrc/material.rs- Material trait and implementations (Lambertian, Metal, Dielectric)src/vec3.rs- 3D vector mathsrc/color.rs- Color output and gamma correctionsrc/interval.rs- Utility for value clampingsrc/rtweekend.rs- Math utilities and random number helpers
- Materials and objects are shared using
Rcfor efficient memory usage. - The code is structured to be as close as possible to the C++ "Ray Tracing in One Weekend" book, but idiomatic to Rust.
Adapted from the Ray Tracing in One Weekend book.
