In the last post, we added the last feature of the series – defocus blur or depth of field. In this final post of the series, we’ll render a random scene that fully demonstrates the features of our ray tracer.
Behold! A randomly generated scene of spheres with a variety of sizes and surfaces:
Elderly Tortoise Speed
The only issue I encountered, and it’s a big one, is this took way too long to render. I didn’t precisely time it, but I kicked the execution off, went for a 30-minute walk, came back, and the render wasn’t even half finished!
Rust > C++
I learned a lot about Rust through this project. It has more guardrails than C++. The compiler isn’t afraid to speak up when you’re mishandling pointers or trying to multiply an integer and a float.
I like that the explicit return is optional and traits are an elegant way to incorporate multiple inheritance, which was sort of missing in C#.
The only thing that I’m not liking in Rust is how slow random number generation seems to be. It’s possible I’m doing something wrong, but every time my program execution bogs down, my profiler points to functions that use the rand::Rng library.
There are many things I could do to improve this ray tracer like adding support for other shapes and textures or figuring it why performance is ridiculously slow, however, it’s time for me to pause this project and move on to something else. As always, feel free to peruse the code as well as the online book I followed, Ray Tracing In One Weekend. Thank you for following along.Tags: coding rust software