ray-tracer

The Ray Tracer Challenge in Rust

Stars
37

Ray Tracer Challenge

This is an implementation in Rust of the book The Ray Tracer Challenge . Go get it, it's one of the best book I read!

My main objective is to be fluent in Rust 🗣🦀. So, if some seasoned rustacean comes across this, don't hesitate to pinpoint the problems 😉!

Differences from the book and other points of interest

  • Parallelization with rayon (I can't believe how easy it was!)
  • Matrices inversion are cached (which provides a significant speedup!)
  • Don't explicitly store the w component for tuples. Instead, it's up to the implementation of the Tuple trait to return the correct value (1.0 or 0.0)
  • Avoid creating a new vec for each call to a shape intersects() method using a kind of closure (it provides an interesting speedup as it prevents the dynamic allocation of many temporaries)
  • Use f64 everywhere
  • Naive anti-aliasing
  • Use enums rather than traits to describe polymorphic behaviors (shapes, lights, etc.)

Some samples