Table of Contents


Name: Raytracing in One Weekend

Description: A project to learn raytracing




Reflection and transparency


Reflection, transparency, and motion blur


Initial motivation: This was my earliest Rust projects. I wanted to have a project to work on, but I didn't really know what to write. I looked it up online and saw that a book called Ray Tracing in One Weekend was a pretty common suggestion. I took through it, and felt like the text was great and that the additional challenge in learning how to translate C code to Rust would be fun!

Further, I've always shied away from graphical programming and so I also thought this would be a great time to learn!

What I've learned: As with almost everything else in computing, graphical programming is an insanely complex field built upon very simple concepts. I was a little surprised at how much I've already learned when it comes to the math and concepts behind rendering. I just didn't know they fit together in that way!

Also, parallelism and how that relates to the problem input space. I noticed very quickly that as my render resolution and effects (motion blur, transparency, etc) increased, so did my render time. It got to a point where it was painful. I then looked into Rayon, which allowed me to introduce parallelism to my code. Since the code calculated the pixels individually, this allowed the integration to be quick and seamless. In fact, I just had to change some normal iters into par_iters. It sped up the code by a lot.

What I'd do differently: Almost everything? I think the biggest downside in my approach is that it was translate C code into Rust, and I think that really influenced some choices that I'm more comfortable with.

Next steps: Revisit and continue with the other books! I ran into an issue with the second book where the documentation wasn't up to date. From what I understand, the authors and maintainers are working on refactoring some of the code. However, that led to some mismatch in terms of code examples. This was a great hindrance as at the time I was not too familiar with any of the topics (Rust, graphics programming, raytracing, etc) and trying to juggle all that AND figure out what the authors really meant proved to be too difficult for me at the time.

That is not a knock on the authors whatsoever. What they do is amazing, and I am big fans of it. I completely understand that open-source projects take time and effort to complete.