Project 6: Software Rasterizer
A 3D software rasterizer from scratch—no GPU, just CPU and math. Transform vertices, rasterize triangles, implement a z-buffer, texture mapping, and basic lighting.
Quick Reference
| Attribute | Value |
|---|---|
| Primary Language | Odin |
| Alternative Languages | C, Rust |
| Difficulty | Level 4: Expert |
| Time Estimate | 3-4 weeks |
| Knowledge Area | Graphics / Rendering / Math |
| Tooling | Custom software renderer |
| Prerequisites | Project 2 (Vector Math), linear algebra, trigonometry |
What You Will Build
A 3D software rasterizer from scratch—no GPU, just CPU and math. Transform vertices, rasterize triangles, implement a z-buffer, texture mapping, and basic lighting.
Why It Matters
This project builds core skills that appear repeatedly in real-world systems and tooling.
Core Challenges
- 3D math pipeline (model→world→view→clip→screen) → maps to matrix operations
- Triangle rasterization → maps to algorithm implementation
- Z-buffer depth testing → maps to memory management
- Texture sampling → maps to array indexing and interpolation
Key Concepts
- Rasterization Pipeline: “Computer Graphics from Scratch” Part II
- 3D Transformations: “3D Math Primer for Graphics and Game Development”
- Barycentric Coordinates: “Fundamentals of Computer Graphics” Ch. 8
- Fixed-Point Math: For performance optimization
Real-World Outcome
$ odin run rasterizer -o:speed
Software Rasterizer Demo
------------------------
Resolution: 800x600
Target FPS: 30
Loading mesh: teapot.obj (6,320 triangles)
Loading texture: checkerboard.png
Rendering pipeline:
1. Vertex Transform (SIMD): 0.8ms
2. Triangle Setup: 0.3ms
3. Rasterization: 12.4ms
4. Fragment Shading: 8.2ms
Total: 21.7ms (46 FPS)
[Window shows rotating 3D teapot with lighting and textures]
Press keys to toggle:
W - Wireframe mode
T - Textured/flat shading
L - Lighting on/off
Z - Show z-buffer
Stats (F1):
Triangles drawn: 4,892
Triangles culled: 1,428
Pixels shaded: 287,432
Cache efficiency: 89%
Implementation Guide
- Reproduce the simplest happy-path scenario.
- Build the smallest working version of the core feature.
- Add input validation and error handling.
- Add instrumentation/logging to confirm behavior.
- Refactor into clean modules with tests.
Milestones
- Milestone 1: Minimal working program that runs end-to-end.
- Milestone 2: Correct outputs for typical inputs.
- Milestone 3: Robust handling of edge cases.
- Milestone 4: Clean structure and documented usage.
Validation Checklist
- Output matches the real-world outcome example
- Handles invalid inputs safely
- Provides clear errors and exit codes
- Repeatable results across runs
References
- Main guide:
LEARN_ODIN_PROGRAMMING_LANGUAGE.md - “Computer Graphics from Scratch” by Gabriel Gambetta