đŸ–Ĩī¸ CPU-Based 3D Renderer in C++

· 2min · Marcus Aas Jensen
3D Renderer project cover

✨ 3D Renderer is a CPU-based 3D renderer written in C++20, supporting simple primitive shapes and built entirely from scratch. It offers both perspective and orthographic projections and supports simple .obj imports.

đŸ’ģ GitHub Repository

3D Renderer Repo

đŸ› ī¸ Features

  • 🧱 Primitive Shapes: Render basic shapes like cubes, spheres, and pyramids.
  • đŸ–ŧī¸ .obj Import: Load and render simple .obj files.
  • 🔄 Projection Modes: Switch between perspective and orthographic projections.
  • đŸ–Ĩī¸ CPU-Based: Built entirely from scratch without relying on external graphics libraries.

đŸ–ŧī¸ Rendering Pipeline

The rendering pipeline transforms 3D objects from their local definitions into 2D rasterized pixels on the screen.

  graph TD;
    A["Object Space<br/>(Local Space)<br/><small>Vertices defined relative to origin</small>"] --> 
    B["World Space<br/><small>Apply transforms (position, rotation, scale)</small>"] --> 
    C["Camera/View Space<br/><small>Relative to camera orientation</small>"] --> 
    D["NDC<br/>(Normalized Device Coordinates)<br/><small>Range [-1, 1]</small>"] --> 
    E["Screen Space<br/><small>Mapped to 2D pixel coords</small>"] --> 
    F["Rasterization<br/><small>Z-Buffer + Triangle Filling</small>"];

Screenshots of the 3D Renderer in action

Shaded ViewZ-Buffer ViewWireframeSuzanne