Skip to content

About

A simple path tracer built in Rust

Resources

Stars

43 stars

Watchers

0 watching

Forks

Latest commit

 

History

191 Commits

Folders and files

Repository files navigation

Rust Ray Tracing in a Weekend

This is a Rust implementation of the Raytracer described in Peter Shirley's Ray Tracing in One Weekend. It is indended for my own learning purposes. The initial implementation is faithfully following the book implementation. My intention is to use this as a test bed for playing with threading, SIMD and general optimizations in Rust and also to complete follow up books to Ray Tracing in a Weekend.

I found the book via Aras Pranckevičius' blog series on his toy path tracer experiments which was my inspiration for doing this, thanks Aras!

Compiling and running

Requires Rust 1.27 for SIMD support.

The easiest way to build and run the path tracer use the command:

cargo run --release

Using nightly will give slightly better performance due to use of std::intrinsics::cttz. To build with core intrinsics enabled make sure you have a nightly build of rustc installed and use the command:

cargo +nightly run --release --features core_intrinsics

If you build without the --release flag the application will be very slow!

SIMD backends

The sphere collision path can run through several SIMD backends. On x86 the best one is detected at runtime; the PATHTRACE_SIMD environment variable overrides the choice:

Value Backend
scalar / fallback Plain scalar code
sse4_1 SSE4.1 intrinsics
avx2 AVX2 intrinsics
portable / portable_simd / fearless fearless_simd portable SIMD
auto / auto_vectorize fearless_simd #[simd] auto-vectorization

The last two are provided by the fearless_simd cargo feature, which is enabled by default and makes the portable backend the default choice:

cargo run --release
PATHTRACE_SIMD=auto cargo run --release

Disable the feature (and fall back to runtime SSE4.1/AVX2 detection) with --no-default-features.

License

See LICENSE-APACHE and LICENSE-MIT for details.

About

A simple path tracer built in Rust

Resources

Stars

43 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages