Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

3D Software Rasterizer

3D Software Rasterizer

Built from scratch in C++ using SDL3 — no engines, no graphics APIs, no shortcuts.

   

What it is

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.

Features

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

Known limitations

  • ❌ Triangle clipping not implemented — geometry crossing the near plane will break
  • ❌ Z-axis frustum culling not implemented — no clipping for far/near planes

Stack

C++17 · SDL3 · CMake · CLion

Build

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.

Documentation

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.

License

MIT

About

A 3D software rasterizer built from scratch in C++ using SDL3 — no graphics APIs, no GPU. Full MVP pipeline, Phong lighting, shadow mapping, and multithreaded rendering, all documented at hambup.me .

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Contributors

Languages