[][src]Crate tray_rust

tray_rust - A Toy Ray Tracer in Rust

tray_rust is a toy physically based ray tracer built off of the techniques discussed in Physically Based Rendering. It began life as a port of tray to Rust to check out the language. The renderer is currently capable of path tracing, supports triangle meshes (MTL support coming soon), and various physically based material models (including measured data from the MERL BRDF Database). tray_rust also supports rigid body animation along B-spline paths and distributed rendering.

Build Status


Running and passing --help or -h will print out options you can pass to the renderer which are documented in the help. For the more complicated use cases I hope to do some write ups and guides on how to use them (e.g. distributed rendering, animation) but this may take a while. I strongly recommend running the release build as the debug version will be very slow.

Building Your Own Scenes

To position and animate objects, the camera and so on the Blender plugin is the easiest to use. However the plugin is still in development and missing some features like setting materials, changing light properties and such so you'll still currently need to do those by hand in the exported JSON file. For materials take a look at the materials documentation for lights you'll likely just want to change the emission color which is an RGB color plus a strength term.

Start at the documentation for the scene module, there are also a few example scenes included but not all the models are provided. From a clean git clone you should be able to run cornell_box.json and smallpt.json. I plan to add some more simple scenes that show usage of other features like animation to provide examples. The rigid body animation feature is relatively new though so I haven't had time to document it properly yet.


Sample Renders

In the samples the the Buddha, Dragon, Bunny and Lucy statue are from The Stanford Scanning Repository. The Rust logo model was made by Nylithius on BlenderArtists. The Utah teapot used is from Morgan McGuire's page and the monkey head is Blender's Suzanne. I've made minor tweaks to some of the models so for convenience you can find versions that can be easily loaded into the sample scenes here, though the cube model for the Cornell box scene is included. The materials on the Rust logo, Buddha, Dragon and Lucy are from the MERL BRDF Database.

Render times are formatted as hh:mm:ss and were measured using 144 threads on a machine with four Xeon E7-8890 v3 CPUs. The machine is an early/engineering sample from Intel so your results may differ, but massive thanks to Intel for the hardware! Some older renders are shown as well without timing since they were run on a different machine.

Some more sample renders can be found here.

Model gallery

1920x1080, 4096 samples/pixel. Rendering: 00:43:36.45.

Rust Logo with friends, disk

1920x1080, 4096 samples/pixel. Rendering: 00:49:33.514.



Defines the BxDF interface implemented by BRDF/BTDFs to describe material properties. Also provides the BSDF type which composes various BRDF/BTDFs to describe materials


The exec module provides an abstraction of the execution backends used to actually render the image


The film module provides color types and a render target that the image is written too.


The geometry module defines the Geometry trait implemented by the various geometry in the ray tracer and provides some standard geometry for rendering


The integrator module defines the Integrator trait implemented by the various surface integrators used to render the scene with different integration methods, eg. path tracing, photon mapping etc.


Defines the light interface implemented by all lights in tray_rust and the OcclusionTester which provides a convenient interface for doing shadow tests for lights


The linalg module provides some basic linear algebra functionality for transforming 3D geometry


Defines the trait implemented by all materials and exports various supported material types. Materials are used to define how BxDFs are composed to create the desired appearance


Defines various Monte Carlo sampling functions for sampling points/directions on objects and computing the corresponding pdfs


Provides a general partitioning function that implements C++'s std::partition


Provides the Sampler trait which is implemented by the various samplers to provide stratified, low-discrepancy, adaptive sampling methods and so on through a simple trait interface


Defines the scene struct which contains the various objects defining the scene. This includes the geometry, instances of the geometry, the camera and so on.


Defines the trait implemented by all textured values