A toy ray tracer in Rust

Related tags

Graphics 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 but has surpassed it in a few ways. 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.


Documentation can be found on the project site.


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. Models for running the scenes and links to model sources can be found here.

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. I've also used tray_rust for the past two years at Utah's Teapot Rendering Competition, view my animations for 2015 and 2016. The latter was made using the Blender plugin for modeling and contains more complex motion and sequences.

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.

You might also like...
Kiss3d - Keep it simple, stupid 3d graphics engine for Rust.

Kiss3d - Keep it simple, stupid 3d graphics engine for Rust.

A cool, fast maze generator and solver written in Rust
A cool, fast maze generator and solver written in Rust

MazeCruncher Welcome to maze cruncher! Download Standalone Here Usage To get started, just run the standalone .exe in target/release or compile and ru

A high-performance SVG renderer, powered by Rust based resvg and napi-rs.
A high-performance SVG renderer, powered by Rust based resvg and napi-rs.

resvg-js resvg-js is a high-performance SVG renderer, powered by Rust based resvg and napi-rs. Fast, safe and zero dependencies! No need for node-gyp

A little cross-platform graphics engine written in rust.

Bismuth This is a version of my C++ graphics engine named Bismuth re-written with Rust. My goal is to learn more about the Rust language and make my g

The library provides basic functions to work with Graphviz dot lang from rust code.

Description The library provides the basic access to the graphs in graphviz format with ability to import into or export from it. Base examples: Parse

🦀 Rust Graph Routing runtime for Apollo Federation 🚀

Apollo Router The Apollo Router is a configurable, high-performance graph router for a federated graph. Getting started Follow the quickstart tutorial

Rust bindings to bgfx, a cross-platform, graphics API agnostic

Rust bindings to bgfx, a cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.

Graph API client writen in Rust

graph-rs Now available on stable Rust at crates.io graph-rs-sdk = "0.1.0" 0.1.0 and above use stable Rust. Anything before 0.1.0 uses nightly Rust. M

Rust library for of graph ensembles

Rust library for random graph ensembles Minimal Rust version: 1.55.0 Implements simple sampling and monte carlo (or rather markov-) steps, that can be

Will Usher
Will Usher
A low-overhead Vulkan-like GPU API for Rust.

Getting Started | Documentation | Blog gfx-rs gfx-rs is a low-level, cross-platform graphics and compute abstraction library in Rust. It consists of t

Rust Graphics Mages 5.2k Jan 8, 2023
A complete harfbuzz's shaping algorithm port to Rust

rustybuzz rustybuzz is a complete harfbuzz's shaping algorithm port to Rust. Matches harfbuzz v2.7.0 Why? Because you can add rustybuzz = "*" to your

Evgeniy Reizner 310 Dec 22, 2022
An OpenGL function pointer loader for Rust

gl-rs Overview This repository contains the necessary building blocks for OpenGL wrapper libraries. For more information on each crate, see their resp

Brendan Zabarauskas 621 Dec 17, 2022
Safe OpenGL wrapper for the Rust language.

glium Note to current and future Glium users: Glium is no longer actively developed by its original author. That said, PRs are still welcome and maint

null 3.1k Jan 1, 2023
GLFW3 bindings and idiomatic wrapper for Rust.

glfw-rs GLFW bindings and wrapper for The Rust Programming Language. Example extern crate glfw; use glfw::{Action, Context, Key}; fn main() { le

PistonDevelopers 546 Jan 3, 2023
Safe and rich Rust wrapper around the Vulkan API

Vulkano See also vulkano.rs. Vulkano is a Rust wrapper around the Vulkan graphics API. It follows the Rust philosophy, which is that as long as you do

null 3.6k Jan 3, 2023
A vector graphics renderer using OpenGL with a Rust & C API.

bufro A vector graphics renderer using OpenGL with a Rust & C API. A Rust example can be found in examples/quickstart.rs (using glutin). A C example c

Aspect 9 Dec 15, 2022
Graph data structure library for Rust.

petgraph Graph data structure library. Supports Rust 1.41 and later. Please read the API documentation here Crate feature flags: graphmap (default) en

null 2k Jan 9, 2023
A graph library for Rust.

Gamma A graph library for Rust. Gamma provides primitives and traversals for working with graphs. It is based on ideas presented in A Minimal Graph AP

Metamolecular, LLC 122 Dec 29, 2022
Simple but powerful graph library for Rust

Graphlib Graphlib is a simple and powerful Rust graph library. This library attempts to provide a generic api for building, mutating and iterating ove

Purple Protocol 177 Nov 22, 2022