Skip to content

A Rust-based ray tracer inspired by "Ray Tracing in One Weekend" by Peter Shirley. This was my first project in Rust, created as a way to learn the language. The ray tracer can render spheres with various materials, including Metal, Dielectric, and Lambertian, while supporting customizable camera angles and positions.

Notifications You must be signed in to change notification settings

L3chuga/rusty-raytracer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rusty Raytracer

Rusty Raytracer is a simple ray tracing project implemented in Rust, inspired by Peter Shirley's "Ray Tracing in One Weekend". This was my first project ever using Rust, I used it as a way to learn the language and explore foundational concepts in computer graphics.

Features

  • Materials: Supports Lambertian (diffuse), Metal (reflective), and Dielectric (refractive) materials.
  • Customizable Camera: Allows for different camera angles, positions, and field of view (FOV).
  • Random Sampling: Implements random sampling for realistic rendering.
  • Scene Composition: Renders scenes with multiple spheres and materials.

Example Output

The raytracer is capable of rendering scenes like this:

Rusty Ray Tracer Output as png

Getting Started

Prerequisites

  • Rust (edition 2021 or later)
  • A basic understanding of Rust and ray tracing concepts is helpful but not required.

Installation

  1. Clone the repository:
git clone https://github.com/L3chuga/rusty-raytracer.git
cd rusty-raytracer
  1. Build the project:
cargo build --release
  1. Run the ray tracer:
cargo run --release

The rendered image will be saved as image.ppm in the project directory. With the default configuration (low resolution and low detail) it takes around 11 seconds to render a full image in my low spec laptob. You can freely change the constants in main.rs to get better images at a larger rendering time cost. You can use online .ppm viewers to see the finished images but I recommend using a vscode .ppm extension as this way you can see the image being generated in real time.

Acknowledgments

  • Inspired by Peter Shirley's "Ray Tracing in One Weekend".

License

This project is licensed under the MIT License.

About

A Rust-based ray tracer inspired by "Ray Tracing in One Weekend" by Peter Shirley. This was my first project in Rust, created as a way to learn the language. The ray tracer can render spheres with various materials, including Metal, Dielectric, and Lambertian, while supporting customizable camera angles and positions.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages