Skip to content

A simple raytracer in Rust, inspired by 'Ray Tracing in One Weekend'

Notifications You must be signed in to change notification settings

stevebest/rust-raytracer-in-one-weekend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Untitled Rust Raytracer

So I've been teaching myself a hard programming language and thought to myself: "How do I make it even harder?" That's when I decided to write this raytracer. And then I did.

It's not perfect by any means, but it's mine, and I like it.

If you want to try it out, here's what you should do.

  1. Install Rust.
  2. Clone this repo.
  3. Run cargo run --release.
  4. There is no step 3.

Wait a few seconds and you should get a PNG file.

Features

  • You can render any scene as long as it's only spheres.
  • Lambertian, metallic and dielectric materials.
  • Automatically uses all CPU cores for rendering.

TODO

  • General code clean up. Eliminate copy pasta and C-isms (return by writing to a parameter).
  • Make pbrt::prelude more useful. Buff Vector and Point with conversions, casting and general.
  • Command-line arguments support: render size, samples per pixel, output file name. Editing the source just to move the camera is silly.
  • More features: emissive materials and lights, more Shape types (quadrics, planes, boxes).
  • Triangle meshes.
  • Transforms and animations.
  • While we're at it, why not throw in full glTF scene support?
  • Non-projective cameras.
  • SIMD/GPGPU support, benchmarks.

Credits

Half of this raytracer was written under inspiration from Physically-Based Rendering: From Theory To Implementation. It's awesome and very well written, but you have to basically copy all of it to get any pixels on the screen.

Another half was hacked together in a few hours, closely following the steps of Ray Tracing in One Weekend. It is the opposite to PBR book in a way that it's hacky, but you get the result right away.

My raytracer borrows from both of these books, and Rust compiler allows it. (Get it? Because borrow checker!)

About

A simple raytracer in Rust, inspired by 'Ray Tracing in One Weekend'

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages