Skip to content

marcusaasjensen/3d-renderer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🖼️ 3D Renderer in C++

A CPU-based 3D renderer written in C++, supporting simple primitive shapes and built entirely from scratch.

Upload the .ppm image file here to visualize the result: https://www.cs.rhodes.edu/welshc/COMP141_F16/ppmReader.html


Supports both perspective and orthographic projections.

Supports simple .obj imports (assets/teapot.obj).

Work in progress...

Example Scene Render (Perspective View)

shadedzbufferwireframeshaded_wireframe

Rendering Pipeline Stages

  • Object Space (Local Space)

    Vertices are defined relative to each object's origin.

    Example: A unit cube centered at (0,0,0).

  • World Space

    The object's local transform (position, rotation, scale) is applied.

    All objects now share a common 3D world space.

  • Camera (View) Space

    The scene is transformed relative to the camera’s position and orientation.

  • Normalized Device Coordinates (NDC)

    All geometry is normalized into the range [-1, 1].

  • Screen Space

    NDC is mapped to 2D pixel coordinates on the canvas.

  • Rasterization

    Z-Buffer precalculated and used for triangles rasterization.

suzanne_z

Vertices that are outside of the camera's view are ignored.

Wireframe triangles are rasterized onto the canvas.

suzanne_wireframesuzanne

About

CPU-based 3D renderer written in C++ 20

Topics

Resources

Stars

Watchers

Forks