Skip to content

bomanviktor/rt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rt

Completed during grit:lab full-stack development course.

Project Description: here

closeup

Table of Contents

About

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.

System requirements

Unix based OS such as Linux or Mac OS

Dependencies

Installation/Running Instructions

  1. Clone the repo
  2. Install brew
    • /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  3. Install Rust
    • brew install rust
  4. Install gtk-rs dependencies
    • brew install gtk+3
  5. Run in repo root
    • cargo run --release

or

  1. Run ./install.sh

Features

  • Four shapes: Cube, Sphere, Flat plane and Cylinder.
  • Four materials: Diffusive, Glossy, Reflective and Light.
  • Ability to change ambient brightness by changing the brightness value.
  • Rayon multithreading for faster rendering 🚀

Run without GUI

To run program without launching the GUI: cargo run --release no-gui

Camera Settings

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();

Brightness

 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.

Objects

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);

Textures

Diffusive(color)
Light(color)
Reflective

Colors

There 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()

Finalize the scene

// 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
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors