← Doom lesson/Lab: feel it
RU
Lab 03 · hands-on

Feel the Doom renderer

A lab with no code: turn the sliders and move the player — the formulas from the lesson come alive right here, in the browser (and on a phone). Nothing to write, everything is computed on the fly.
🏠 experiment~15 min
How to use this
Three live experiments under the lesson's formulas. Change a parameter and the picture and the numbers recompute instantly. The goal isn't "write a renderer" but to feel why height falls off as 1/z, why BSP gives the right order from any point, and how much front-to-back saves. At the bottom, a notebook for your home machine if you want the same experiments on real numpy.

1 · Projection: height ∝ 1/z

A wall's height on screen is a perspective projection. Turn z (depth) and watch the column grow and shrink:

hscreen=hwall·dprojz,dproj=W/2tan(FOV/2)
What to notice: double z (200→400) — the height drops by exactly half. That is 1/z, the only source of "depth" here. Widen the FOV — d_proj falls and the whole world shrinks (fisheye).

2 · BSP: front-to-back order from any point

The level is split by two cutting lines into 4 subsectors. Drag the player (the red dot) — the traversal order is recomputed from the sign of a cross product at every node:

s=(vx−px)·dy−(vy−py)·dx
What to notice: drag the player across the dashed line — the two near leaves swap places (1↔2). The tree doesn't recompute any geometry, only the sign of s at the nodes — and the order is always right. That is why BSP works from any position.

3 · Overdraw: what front-to-back saves

Five walls in a corridor overlap screen columns. Switch modes and watch the written-pixel counter:

What to notice: with clipping (front-to-back) every column is written once — overdraw ≈ 1.0×. In painter mode (back-to-front) the far walls are drawn for nothing and painted over by the near ones — 2–3× the writes. On a 486 that was the difference between "playable" and "slide show".
🏠 What's next
Go back to the lesson, section "🎮 Play / poke at it" — how to run the real Doom and break it (DSDA-Doom to observe, chocolate-doom + a breakpoint in the BSP traversal, nuts.wad for a visplane overflow).
Connections
from the lesson
Doom and BSP — the theory behind these three experiments: projection, tree traversal, clipping.
next
ECS — that same "hot loop over columns" as an example of a cache-friendly layout.
What to notice afterwards (observation checklist)