A 3D rendering engine written from scratch in Rust. This project parses and renders .obj 3D model files using a custom software rasterizer, outputting the final image as a .ppm bitmap.
- Renders 3D
.objmodels to.ppmimages. - Custom implementation of:
- Vector math (
Vec2,Vec3) - Line drawing and triangle rasterization
- Back-face culling
- Z-buffering (optional)
- Vector math (
- Basic lighting with diffuse shading
src/
├── main.rs # Entry point
├── graphics_api.rs # Core image buffer, color representation, and file output
├── two_dimensional_draw_api.rs # 2D primitives (lines, fills)
├── three_dimensional_draw_api.rs # 3D triangle drawing and z-buffering
├── wireframe_rendering.rs # Loads and renders an example OBJ model
├── vectors.rs # Vec2/Vec3 implementations with vector math
├── helper_functions.rs # Utility functions
cargo build --releasecargo run --releaseBy default, this renders the model african_head.obj and outputs the image to out.ppm.
You can open .ppm files using image viewers like:
- ImageGlass
- GIMP
- ImageMagick
- Or convert to PNG/JPEG
- Input:
.objmodel (default:african_head.obj) - Output:
.ppmimage (default:out.ppm)
Each triangle is:
- Lit using a hard-coded light vector and Lambertian shading
- Back-face culled
- Converted to screen space
- Drawn using a scanline rasterizer
This project was created as a Rust-based implementation of the Tiny Renderer tutorial by ssloy, following its lessons to build a 3D software rasterizer from scratch.
- Support more complex shading (Phong, Gouraud)
- Texture mapping support
- Camera transformations
- Scene file input
- Parallel rendering
