Authored by: Viktor Boman, Johannes Eckerman, Salam Foon, Ville Patjas, and André Teetor
Completed during grit:lab full-stack development course.
Project Description: here
This is a Monte Carlo based ray tracer with a GUI written from scratch, entirely in Rust. For the GUI the GTK3 library for rust was used.
Unix based OS such as Linux or Mac OS
- Clone the repo
- Install brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Install Rust
brew install rust
- Install gtk-rs dependencies
brew install gtk+3
- Run in repo root
cargo run --release
or
- Run
./install.sh
- Four shapes:
Cube,Sphere,Flat planeandCylinder. - Four materials:
Diffusive,Glossy,ReflectiveandLight. - Ability to change ambient brightness by changing the
brightnessvalue. - Rayon multithreading for faster rendering 🚀
To run program without launching the GUI:
cargo run --release no-gui
To change the sample size, camera position, focal length, looking at and resolution, change the following in main.rs:
let mut camera = CameraBuilder::new()
.sample_size(20)
.position_by_coordinates(Point::new(-6.0, 4.0, 15.0))
.focal_length(1.0)
.look_at(Point::new(0.0, 0.0, 0.0))
.resolution(1920, 1080)
.build(); let scene = Arc::new(Scene::init(0.01)); // Change the 0.01 to a value between 0.0 and 1.0. 1.0 being max, 0.0 being min.To create the objects, go to scene.rs to initialize the objects, and add them to the objects vector using Arc::new():
To create a objects, use the below, e.g. Sphere struct from sphere.rs in scene.rs. Here's an example:
let sphere = Sphere::new(position, radius, texture);
let cube = Cube::new(position, side_length, texture);
let plane = FlatPlane::new(position, radius, texture);
let cylinder = Cylinder::new(position, radius, height, texture);Diffusive(color)
Light(color)
ReflectiveThere are a wide range of colors to choose from. These are just a small sample of all the available colors.
RGB::new() // Custom color in 255,255,255 format
RGB::random()
RGB::red()
RGB::green()
RGB::blue()// Initialize an object
let sphere = Sphere::new(
Point::new(0.0, 1.0, 0.0),
1.0,
Textures::Diffusive(RGB::red())
);
// more objects here...
// Add the objects to the scene in this vector
let objects: Objects = vec![
Arc::new(sphere),
Arc::(object2),
// More objects here...
];
// Return the scene
Scene {
objects, brightness
}