Idea · Oct 11, 2026
Build Your Own BSP Level Renderer
A staged assignment in which students write a browser renderer for real Quake 1 shareware maps: parse the BSP file, walk the tree front to back, cull with the PVS, and texture surfaces with lightmaps, all on a software framebuffer before optionally porting to WebGL.
What it would do
Quake's level format is a compact tour of core CS: binary parsing, binary space partitioning trees, visibility sets compressed with run-length encoding, and perspective-correct texture mapping. Over five milestones students (1) parse the BSP lumps from the freely distributed shareware pak0.pak and draw a wireframe, (2) traverse the BSP tree to find the camera's leaf and render faces front to back, (3) decompress the potentially visible set and measure how much it culls, (4) rasterize textured, lightmapped polygons into a canvas ImageData buffer, and (5) add collision against the clip hulls so a player can walk the level. Each milestone ships with a reference screenshot set and an automated test harness that compares frame hashes and face counts from fixed camera poses, so grading is mostly mechanical. A stretch milestone ports the rasterizer to WebGL and compares frame times.
Key features
- Binary lump parser for vertices, edges, faces, nodes, leaves, textures and lightmaps
- Front-to-back BSP traversal with camera-leaf lookup
- RLE-compressed PVS decoding with a culling statistics overlay
- Software rasterizer with perspective-correct texturing and lightmap blending
- Clip-hull collision and walkable first-person camera, plus an autograder comparing frames from fixed poses