Skip to content

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.

License

Notifications You must be signed in to change notification settings

JoeKL/rust_graphics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust Graphics Header

Rust Graphics Engine

Rust License

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.

🖼️ Gallery & Render Modes

Click on any image to view the full-resolution version.

F-16 Render Modes

Comparison of different pipeline stages and rendering modes implemented in the engine.

Wireframe Mode
Wireframe
Vertex Mode
Vertex Plot
Vertex Normal Mode
Vertex Normals
Face Mode
Face Rendering
Z-Buffer Mode
Z-Buffer Visualization

Model Showcase & GUI

Armadillo
Armadillo
Dragon Z-Buffer
Dragon (Z-Buffer)
Suzanne
Suzanne (Face Mode)
Tyra Vertex
Tyra (Vertex Mode)

User Interface

Engine GUI

✨ Features

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

📂 Project Structure

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

🚀 Getting Started

Prerequisites

  • Rust: Ensure you have the latest stable version of Rust and Cargo installed.

Installation

  1. Clone the repository:

    git clone [https://github.com/JoeKL/rust_graphics.git](https://github.com/JoeKL/rust_graphics.git)
    cd rust_graphics
  2. Run the engine:

    cargo run --release

    Note: The --release flag is highly recommended. Since this is a software renderer doing heavy math on the CPU, debug builds may be significantly slower.

🤝 Contributing

This is an educational project, but contributions are welcome!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

Distributed under the MIT License. See LICENSE for more information.

Model Source

https://github.com/alecjacobson/common-3d-test-models

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Languages