Implementing "Ray Tracing in One Weekend" in Rust

2020-09-20

So this weekend I decided to follow along with the Ray Tracing in One Weekend book, but in Rust because my C++ knowledge is negligible, and because forcing myself to write it in another language would ensure that I understood what I was doing instead of just blindly copying all the code.

I have to say, this has been one of the most fun weekends I've had in a while! The book is very clear, easy to follow, and the results are amazing. It's awesome how you go step by step from generating a blue gradient to having metal and glass spheres. I cannot recommend this enough for anyone who hasn't seen it before and is kind of curious about how this raytracing thing works.

Also, making it in Rust has helped me solidify some concepts that were still a bit shaky (it was my first time using Box, so exciting!).

Here's an image of the final render:

Final render

For my next step, I want to try to get Rayon working, to speed up renders. I've never done anything with multithreading in Rust, so this sound exciting! From the code I've seen it doesn't look that complicated, but it's exciting nonetheless.

I'm also going to get started with Ray Tracing: The Next Week, the next book of the series.

Also, I learned how amazingly slow Rust is in debug mode: The image above took 1 hour and 4 minutes to generate, while the same in release mode took 120 seconds. -_-