Home Ruxel - Building a Ray Tracer with Rust (Prelude)
Post
Cancel

Ruxel - Building a Ray Tracer with Rust (Prelude)

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:

GitHubcrates.io
rsdlt/ruxelruxelcrate

Why a Ray Tracer on Rust

  1. 3D graphics processing is intensive on machine resources and greatly benefits from low-level control.
  2. Rust is fast and its speed has been benchmarked against C, C++ and Go with outstanding results.
  3. Rust promises zero cost abstractions
  4. Rust is free of undefined behavior so no dangling pointers, data races, null dereferences or other nasty stuff at runtime.
  5. 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 and doc-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:

And here are some links with useful insights and information:

Next Steps

Well, without further ado let’s start coding!


References and disclaimers:

  1. 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. 

  2. Buck, Jamis. (2019). The ray tracer challenge: A test-driven guide to your first 3D renderer. The Pragmatic Programmers. 

  3. Pharr, M., Jakob, W., Humphreys, G. (2017). Physically based rendering: From theory to implementation (3rd ed.). Morgan Kaufmann 

  4. 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. 

  5. Blandy, J., Orendorff, J, F.S Tindall, L. (2021). Programming Rust: Fast, safe systems development (2nd ed.). O’Reilly 

  6. Gjengset, J. (2022). Rust for rustaceans: idiomatic programming for experienced developers. No Starch Press 

This post is licensed under CC BY 4.0 by the author.
Source code samples licensed under MIT or Apache-2.0