Project 2: A 3D Rendering Engine from Scratch

Build a simple 3D rendering engine that projects and draws wireframes.


Project Overview

Attribute Value
Difficulty Level 2: Intermediate
Time Estimate 2-3 weeks
Main Language Python
Alternative Languages C++, Rust
Knowledge Area Linear algebra and projection
Tools Plotting or raster output
Main Book “Computer Graphics from Scratch” by Gabriel Gambetta

What you’ll build: A renderer that transforms 3D points into 2D screen coordinates and draws lines between them.

Why it teaches math: You must apply vectors, matrices, and projection correctly to get a coherent image.

Core challenges you’ll face:

  • Building rotation and translation matrices
  • Applying perspective projection
  • Handling camera transforms

Real World Outcome

You will render a rotating wireframe cube or model and export frames or a simple animation.

Example Output:

$ python render.py --model cube
Frames: 120
Output: ./frames/

Verification steps:

  • Confirm perspective shrink with distance
  • Verify rotations preserve shape

The Core Question You’re Answering

“How do I map 3D geometry into a 2D image without losing spatial meaning?”

This is the core of computer graphics math.


Concepts You Must Understand First

Stop and research these before coding:

  1. Matrix transformations
    • How does a rotation matrix change coordinates?
    • Book Reference: “Computer Graphics from Scratch” by Gabriel Gambetta, Ch. 1
  2. Perspective projection
    • Why do distant objects appear smaller?
    • Book Reference: “Computer Graphics from Scratch” by Gabriel Gambetta, Ch. 3
  3. Coordinate systems
    • How do world, view, and screen coordinates relate?
    • Book Reference: “3D Math Primer for Graphics and Game Development” by Fletcher Dunn, Ch. 4

Questions to Guide Your Design

  1. Pipeline order
    • In what order should you apply transformations?
    • Where does the camera transform fit?
  2. Rendering output
    • Will you draw just edges or also faces?
    • How will you handle depth ordering?

Thinking Exercise

Rotation Practice

Rotate the point (1,0,0) around the Z-axis by 90 degrees. What is the new coordinate?

Questions while working:

  • Why does rotation preserve distance?
  • How does axis choice change results?

The Interview Questions They’ll Ask

Prepare to answer these:

  1. “What is a projection matrix?”
  2. “Why do we use homogeneous coordinates?”
  3. “What is the difference between world and view space?”
  4. “How do you prevent objects behind the camera from rendering?”
  5. “Why does order of transformations matter?”

Hints in Layers

Hint 1: Starting Point Start by projecting a single point.

Hint 2: Next Level Add rotation matrices and draw a cube.

Hint 3: Technical Details Use a consistent coordinate system and unit scale.

Hint 4: Tools/Debugging Render coordinate axes to confirm orientation.


Books That Will Help

Topic Book Chapter
Projection “Computer Graphics from Scratch” by Gabriel Gambetta Ch. 3
Transforms “Computer Graphics from Scratch” by Gabriel Gambetta Ch. 1
Coordinate systems “3D Math Primer for Graphics and Game Development” by Fletcher Dunn Ch. 4

Implementation Hints

  • Start with wireframes to keep it simple.
  • Keep camera and object transforms separate.
  • Export frames to validate motion.

Learning Milestones

  1. First milestone: You can project 3D points correctly.
  2. Second milestone: You can render a rotating cube.
  3. Final milestone: You can explain the full transform pipeline.