22  Rendering: Floor and Ceiling Spans

This tour covers floor and ceiling rendering in Doom, from visplane management in r_plane.h through initialization, span clipping arrays, and the R_DrawPlanes rendering loop.


r_plane.h declarations: - r_plane.h:47–54: declares visplane management functions - r_plane.h:64–68: declares the function responsible for drawing floors and ceilings

r_plane.c initialization: - r_plane.c:97–104: R_InitPlanes is empty since plane rendering uses static globals - r_plane.c:185–190: R_ClearPlanes resets column clipping at frame start - r_plane.c:197–203: resets visplane list and clears cached height values - r_plane.c:203–209: computes X/Y scale factors for texture mapping


Lookup tables: - r_plane.c:85–87: yslope[] stores slope per scanline - r_main.c:730–737: yslope values initialized - r_things.c:80–83: screenheightarray[] stores view height per screen column - r_main.c:725–729: sets each screenheightarray element to viewheight

Data structure: - r_defs.h:458–480: visplane_t represents a visible floor or ceiling section


Rendering logic: - r_plane.c:367–374: R_DrawPlanes renders floor and ceiling planes - r_plane.c:396–404: sky textures rendered fullbright using colormap 0 - r_plane.c:423–431: caches flat texture, computes lighting from plane height and light level - r_plane.c:442–449: R_MakeSpans compares top/bottom bounds across columns to create horizontal spans

Span reconciliation loop (R_MakeSpans): - r_plane.c:338–342: closes completed top spans from previous column - r_plane.c:343–347: closes completed bottom spans - r_plane.c:349–353: opens new top spans - r_plane.c:354–358: opens new bottom spans


And that’s how Doom renders its floors and ceilings!