Neat! Thanks for the book recommendation, that was a lot of fun.

I worked through the exercises in Rust, and then did some optimization. The same scene at 1200x800 with x10 sampling takes 8.5 seconds on my 4-core laptop. (I used Rayon to get nearly-free support for multiple cores; with parallelism disabled it takes 31s.)

GitHub cbiffle/rtiow-rust Ray tracer from Peter Shirley's Ray Tracing In One Weekend, but in Rust. - cbiffle/rtiow-rust

Edit: @BlackGoku36, I read through your implementation, and I don’t see a smoking gun to explain the performance difference, except for one thing: I notice that in sphere.rs you clone a Box<Material> inside of hit . That routine is probably the hottest piece of code in the whole program, so it might help to avoid allocating memory there. If you use Rc in place of Box you can return a new pointer to the same Material , avoiding a new allocation.