It started as a little playground to play with raytracing concepts that I found
on Scratchapixel. I then found out about
tray_rust and began refactoring my
code to follow its design, but then eventually bought a copy of
Physically-Based Ray Tracing and decided to follow the
C++ implementation as closely as possible to
make it easier to follow along with the book. Consider this a port of PBRTv3 to
Note: I am very much a beginner in Rust as well as in raytracing and this
project is a way for me to learn about both. If the code is ugly or broken, it
is very much my fault :) This is not helped by the fact that the C++
implementation is very object-oriented, and doesn't always translate cleanly
or idiomatically to Rust... I haven't really paid attention to performance yet,
or number of allocations, so both are probably pretty bad :) That being said,
feedback is more than welcome!
tray_rust: if you want to see a
good physically-based raytracer in Rust written by someone who knows what
they're talking about, you should check this project instead of mine :) It's
got some nice features, like distributed rendering, and the code is
beautifully written and documented.
rs_pbrt: another port of PBRT to Rust.
More examples can be found in the renders/ directory.
How to build
Rustracer depends on Rust nightly, due to some dependencies that require it (in
particular light_arena). The easiest way is to install
rustup, then do
rustup default nightly.
To run the CLI, run
cargo run --release -p rustracer -- scene_file.pbrt.
- Direct Lighting (with "all" or "one" sampling strategies)
- Path Tracing (with "uniform" or "spatial" sampling strategies)
- Normal (for debuging)
- Ambient Occlusion
- Basic shapes: disc, sphere, cylinder
- triangle meshes
- Perspective camera with thin-lens depth-of-field
- Point lights
- distant lights
- diffuse area lights
- infinite area light
- perfect specular reflection / transmission
- microfacet (Oren-Nayar and Torrance-Sparrow models, Beckmann and
Trowbridge-Heitz distributions, Smith masking-shadowing function)
- Metal / RoughMetal
- Glass / RoughGlass
- Substrate (thin-coated)
- Disney (without SSS)
- Textures (imagemaps, UV, CheckerBoard)
- imagemap with mipmapping (with trilinear and EWA filtering)
- BVH acceleration structure (MIDDLE and SAH splitting strategy)
- multi-threaded rendering
- Support for PBRT scene file format (still incomplete)
- Read textures in PNG, TGA, PFM, HDR or EXR (thanks to openexr-rs)
- Write images in PNG or EXR
- Support for PLY meshes (thanks to ply-rs)
- Bump mapping
- Memory arena (thanks to light_arena)
- More CLI parameters (e.g. output file name, thread numbers)
- More camera types (orthographic, realistic, environment)
- More shapes (cone, paraboloid, hyperboloid, NURBs...)
- More samplers (Halton, Sobol...)
- More BxDFs and materials
- Implement subsurface scattering
- Volumetric rendering
- More integrators: bidirectional path tracing, MTL, SPPM
- more light types
- k-d trees?
- Spectral rendering?
- some SIMD optimisation?
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.