← All interactive demos

Skipping What Hides Behind Nearer Walls — Interactive Demo

From the video "How does DOOM avoid drawing what's behind walls?" (How Games Are Made, FPS history 2/3). A simplified model with only walls of the same height that you cannot see through (not a re-implementation of all of DOOM).

Line map (from above) — click two empty spots to place a wall / click a wall to remove it

Screen (front view) — below is the "record of filled columns" (320 columns)

Spans processed - Columns processed - / 320 Columns different from "no skipping" - (Counts for this view and this map. Time is not measured.)
Task: Keep "Skipping" on, open one gap in the near wall, and find which spans of the far wall become necessary. The blue boxes on the record strip (under the screen) are the spans where the far wall was processed. Opening a gap adds more boxes. Also try placing walls yourself and see how the number of processed columns changes.

What it does: it projects each wall onto a span of screen columns (a to b) — the column comes from the ratio of sideways position to depth as seen from the camera — and sets the height of each column in the span from the distance to the wall. "Skipping" walks a BSP tree (a tree that keeps splitting the map in two with lines) starting from the side nearer the viewer, so near walls are processed first. It records "filled columns" in an array of 320, and skips filled columns. "No skipping" walks the same tree from the far side, processes every wall span and draws over it. If the "different columns" count, comparing the two pictures column by column, is 0, the same picture was made with less work. Arrow keys ← → to turn, ↑ ↓ to walk (on a phone, drag the screen).
AI was used to make the diagrams and code. No game footage is used. Sources are in the video description.