Skip to content
⚡ A ray tracer implemented in Rust based on "Ray Tracing in One Weekend"
Rust
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
benches
output
src
.gitignore
.travis.yml
Cargo.lock
Cargo.toml
LICENSE
README.md

README.md

Raytracer.rs

Build Status

"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.

Usage

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)?;

The third parameter indicates that with previous 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

Showcases

Cover Scene

The scene from the cover of "Ray Tracing in One Weekend". It takes ~450 secs to render.

scenes/legacy_scene.rs:legacy_scene

legacy_scene

Sphere Sea

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

complex_scene_2

Textures

Light Scene scenes/legacy_scene.rs:legacy_scene_light
legacy_scene_light

Checker Texture scenes/legacy_scene.rs:legacy_scene_texture
legacy_scene_texture

Perlin Noise scenes/simple_scene.rs:simple_scene_perlin_noise
simple_scene_perlin_noise

Cornell Box

Cornell Box scenes/cornell_box.rs:cornell_box
cornell_box

Run Tests and Benchmarks

cargo bench
cargo test
You can’t perform that action at this time.