Raytracer.rs Save

⚡ A high-performance path tracer implemented in Rust based on "Ray Tracing in One Weekend" featuring static dispatch, multi-threaded rendering and a variety of preset scenes.

Project README

Raytracer.rs

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

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

Showcases

Cornell Box

Cornell Box support mixture pdf for reducing noise scenes/cornell_box.rs:cornell_box

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

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

Textures

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

Run Tests and Benchmarks

cargo bench
cargo test
Open Source Agenda is not affiliated with "Raytracer.rs" Project. README Source: skyzh/raytracer.rs
Stars
97
Open Issues
0
Last Commit
3 years ago
Repository
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating