An implementation of Peter Shirley's Ray Tracing in One Weekend in Rust.
This was mostly a way for me to learn about Rust while making some pretty pictures. Definitely has room for improvement.
Added basic Rhai scripting to describe the scenes.
- Install Rust. Works with at least v1.84.0
The project is split into 2 versions: native-rt and wasm-rt. The core is in
rt and is used by both to run the ray tracer.
cd into native-rt and then:
I highly recommend running it in release mode. It's incredibly slow otherwise
cargo build --release
Either run the target directly or do cargo run -- <args>
Usage: native-rt [OPTIONS] --scene <SCENE>
Options:
-s, --scene <SCENE> .rhai file describing the scene to render
-f, --format <FORMAT> The image format to use when writing to file [default: png] [possible values: png, pfm]
-w, --window Output incrementally to window instead
-t, --threads <THREADS> How many threads to use [default: 1]
-h, --help Print help
-V, --version Print versionYou can get very nice results with fewer sample by running the result through a denoiser like OIDN
The PFM output format is helpful for this. To run it through OIDN:
oidnDenoise --hdr render_output.pfm -o denoised.pfm -t float
- Install
wasm-pack(cargo install wasm-pack) cdintowasm-rtand then:
npm run build
npm run dev- Go to
http://localhost:8080 - Hit
run, wait
NOTE: Only one hardcoded script is available at the moment. Full list coming laters
See ./scenes for example scenes. Reference images from these scenes can be
found in ./*.ref.png files.
