"Ray Tracing in One Weekend (Amazon)" implemented in Rust 2018
This is the new branch implemented in Rust 2018. For previous version, refer to legacy branch.
UPDATE This project is part of the PPCA 2020 course, where I assisted several students to build their own ray-tracer with the Rust programming language. Here's the showcase.
UPDATE By using static dispatch (generics in Rust) and code generation, we achieved a 2x speedup in rendering most scenes.
Write your specifications in main.rs
:
use self::renderer::utils::render_high_quality as render;
use self::scenes::simple_scene::simple_scene_perlin_noise as scene;
Here you can change render_high_quality
to render_preview
to render faster. And you can select from examples scenes by changing self::scenes::****::****
.
render(hitable_list, camera, "scene.png", true, pdf)?;
The third parameter indicates that with these rendering settings, the image will be rendered to output/scene.png
.
The fourth parameter indicates whether to enable ambient light or not.
Finally run:
cargo run --release
Note that since the latest commit, some functionalities may be broken due to new features.
Cornell Box support mixture pdf for reducing noise scenes/cornell_box.rs:cornell_box
The scene from the cover of "Ray Tracing in One Weekend". It takes ~450 secs to render.
scenes/legacy_scene.rs:legacy_scene
Generate 300 spheres (no overlap) in the space with different materials and settings.
It takes ~560 secs to render.
scenes/complex_scene.rs:complex_scene_2
Light Scene scenes/legacy_scene.rs:legacy_scene_light
Perlin Noise scenes/simple_scene.rs:simple_scene_PERLIN_NOISE
Checker Texture scenes/legacy_scene.rs:legacy_scene_texture
cargo bench
cargo test