A 3D software rendering engine built from scratch in Rust. Implements a custom graphics pipeline, linear algebra library, and scene graph without hardware acceleration APIs.
Based on concepts from Computer Graphics from Scratch by Gabriel Gambetta and university course materials.
Click on any image to view the full-resolution version.
Comparison of different pipeline stages and rendering modes implemented in the engine.
Wireframe |
Vertex Plot |
Vertex Normals |
Face Rendering |
Z-Buffer Visualization |
Armadillo |
Dragon (Z-Buffer) |
Suzanne (Face Mode) |
Tyra (Vertex Mode) |
User Interface
- Software Rasterization: Custom implementation of the graphics pipeline (
src/renderer/rasterizer.rs) handling triangle projection and pixel drawing. - Interactive Scene Graph: Runtime manipulation of objects (Translate, Rotate, Scale) with support for hierarchical selection.
- Dynamic Lighting: Move and rotate light sources in real-time to test shading.
- Custom Math Library: Hand-rolled Vector, Matrix, and Geometry implementations (
src/types/math) to handle 3D transformations. - Robust Input System: Custom state-tracking wrapper around
minifb, enabling distinct checks for Pressed, Held, and Released states.
src/engine.rs: The main game loop and engine lifecycle management.src/renderer/: The core rendering pipeline.rasterizer.rs: Converts projected triangles into pixels (Barycentric/Edge functions).draw_command.rs: Handles the queue of drawing operations.frustum.rs: Handles view culling.
src/types/math/: Linear algebra library (Matrices, Vectors, Points).src/scene/: Manages objects in the world, bounding boxes, and scene nodes.
- Rust: Ensure you have the latest stable version of Rust and Cargo installed.
-
Clone the repository:
git clone [https://github.com/JoeKL/rust_graphics.git](https://github.com/JoeKL/rust_graphics.git) cd rust_graphics -
Run the engine:
cargo run --release
Note: The
--releaseflag is highly recommended. Since this is a software renderer doing heavy math on the CPU, debug builds may be significantly slower.
This is an educational project, but contributions are welcome!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.
