As far back as I can remember I have always been fascinated by 3D graphics. And building a Ray Tracer and Renderer seems like a fantastic project to sharpen my skills with Rust.
So I have embarked to build one from the ground up and share my experience over a series of posts.
I have decided to name it Ruxel
, which is a portmanteau of Rust + pixel.
My objective is to try to update this series at least on a weekly basis, so here you can expect to find the GitHub and crates.io repositories:
GitHub | crates.io |
---|---|
rsdlt/ruxel | ruxelcrate |
Why a Ray Tracer on Rust
- 3D graphics processing is intensive on machine resources and greatly benefits from low-level control.
- Rust is fast and its speed has been benchmarked against
C
,C++
andGo
with outstanding results. - Rust promises zero cost abstractions
- Rust is free of undefined behavior so no dangling pointers, data races, null dereferences or other nasty stuff at runtime.
- Rust compiler is incredibly clear and verbose.
Goals for Ruxel Version 0.1.0
Functional
Be able to render and ray trace the following:
- Shapes:
- Spheres
- Planes
- Cubes
- Cylinders
- Triangles
- Patterns
- OBJ files
- With these attributes:
- Lights
- Shading
- Shadows
- Patterns
- Reflections
- Refractions
Development
- Idiomatic and ergonomic code:
- Semantic typing
- Semver and features
- Adherence to Rust’s API guidelines
- Thorough documentation (
rustdoc
anddoc-tests
) - Changelog
- Test driven
- Benchmarking and performance testing
- Graceful error handling
- Well-structured
- Single threaded (multithreading for future versions)
Interesting Resources
Here are some of the best books1 on these topics that I’ve come across, and think that can help me with this personal project:
- Rendering and 3D graphics:
- The Ray Tracer Challenge by Jamis Buck.2
- Physically Based Rendering: From Theory to Implementation by Matt Pharr, Wenzel Jakob and Greg Humphreys.3
- Real-Time Rendering by Tomas Kenine-Möller, Eric Haines, Naty Hoffman, Angelo Pesce, Michal Iwanicki and Sébastien Hillaire4
- Rust programming:
- Programming Rust: Fast, Safe Systems Development by Jim Blandy, Jason Orendorff and Leonora F.S. Tindall5
- Rust for Rustaceans by Jon Gjengset6
And here are some links with useful insights and information:
- One Hundred Thousand Lines of Rust by Aleksey Kladov (mtklad)
- Rust Design Patterns found on rust-unofficial/patterns
- Rust API Guidelines found on rust-lang/api-guidelines
Next Steps
Well, without further ado let’s start coding!
References and disclaimers:
Disclaimer: I am not affiliated, associated, endorsed or sponsored by any these authors or publishers. I own physical copies of these books and use them for personal education purposes. ↩
Buck, Jamis. (2019). The ray tracer challenge: A test-driven guide to your first 3D renderer. The Pragmatic Programmers. ↩
Pharr, M., Jakob, W., Humphreys, G. (2017). Physically based rendering: From theory to implementation (3rd ed.). Morgan Kaufmann ↩
Akenine-Möller, T., Haines, E., Hoffman, N., Pesce, A., Iwanicki, M., Hillaire, S. (2018). Real-time rendering (4th ed.). CRC Press, Tailor & Francis Group. ↩
Blandy, J., Orendorff, J, F.S Tindall, L. (2021). Programming Rust: Fast, safe systems development (2nd ed.). O’Reilly ↩
Gjengset, J. (2022). Rust for rustaceans: idiomatic programming for experienced developers. No Starch Press ↩