A fully CPU-rendered 3D rasterizer — every pixel computed in plain C++, no GPU involved. The full pipeline (transformations, projection, rasterization, lighting, shadows) is implemented from scratch using only SDL3 for the window.
| Math | Custom Vec2 · Vec3 · Vec4 · Mat4 from scratch |
| Pipeline | Full MVP — Model · View · Projection matrices derived from first principles |
| Rasterization | Barycentric coordinates · perspective-correct interpolation |
| Depth | Z-buffer with per-pixel depth testing |
| Parsing | OBJ + BMP parser — zero external libraries |
| Camera | Free WASD + mouse look · yaw · pitch |
| Textures | UV mapping · perspective-correct sampling |
| Culling | Backface culling · frustum culling (X/Y planes) |
| Lighting | Phong shading · directional + spot lights · toon shading |
| Shadows | Shadow mapping · adaptive bias · spotlight perspective projection |
| Threads | Multithreaded rasterizer across all CPU cores |
- ❌ Triangle clipping not implemented — geometry crossing the near plane will break
- ❌ Z-axis frustum culling not implemented — no clipping for far/near planes
C++17 · SDL3 · CMake · CLion
git clone https://github.com/HambuP/3D-Rasterizer-in-Cpp-using-SDL3.git
cd 3D-Rasterizer-in-Cpp-using-SDL3
mkdir build && cd build
cmake ..
cmake --build .Requires SDL3 installed. Set the working directory to the project root in your run configuration before running.
The full pipeline is documented step by step at hambup.me/rasterizer — every section covers the math, the code, and what broke along the way.
MIT
