Skip to main content

Module render

Module render 

Source
Expand description

Resolution-independent software renderer for Build-style worlds.

Each screen column casts one ray through the sector/portal graph. Walls, sloped floors/ceilings and parallax skies are drawn front to back into a column-major buffer with a per-pixel depth (perpendicular distance in xy units). Sprites and masked walls are drawn afterwards, back to front, with a depth test. Columns are independent, so both passes run in parallel on all CPU cores.

Structsยง

Camera
ColSeg ๐Ÿ”’
Traces one pixelโ€™s ray through sectors starting at (ox, oy, oz) in sector s. dz is z units per xy unit; t_base is the distance already travelled. One stretch of a columnโ€™s 2D ray inside a sector (global ray parameter t).
ColTrace ๐Ÿ”’
Sectors crossed by a columnโ€™s ray (ox, oy) + t (dx, dy), found lazily: only as far along as some pixel of the column actually reaches.
MaskSeg ๐Ÿ”’
PlaneCtx ๐Ÿ”’
Renderer
Ror
RorLink
Room-over-room link: looking through a floor/ceiling continues in sector, offset by (dx, dy, dz) (Bloodโ€™s stack / link markers).
Scene
ShadeLuts
True-colour shade tables, one per palookup (pal), each 64 * 256 entries.
SprProj ๐Ÿ”’
SpriteDraw
A sprite prepared by the game for drawing (picnum already animated/rotated if desired).
View ๐Ÿ”’

Enumsยง

SprKind ๐Ÿ”’

Constantsยง

PLANE_PARALLAX
PLANE_RELATIVE
PLANE_SMOOSH
PLANE_SWAPXY
PLANE_XFLIP
PLANE_YFLIP
SPR_ALIGN_MASK
SPR_BLOCK
SPR_CENTER
SPR_FLOOR
SPR_INVISIBLE
SPR_ONESIDED
SPR_TRANS
SPR_TRANS_REV
SPR_WALL
SPR_XFLIP
SPR_YFLIP
TRANSPARENT
VIS_DIVISOR ๐Ÿ”’
Distance (xy units) times visibility per shade step.
WALL_ALIGN_BOTTOM
WALL_BLOCK
WALL_BOTTOM_SWAP
WALL_MASKED
WALL_ONEWAY
WALL_TRANS
WALL_TRANS_REV
WALL_XFLIP
WALL_YFLIP

Functionsยง

blend ๐Ÿ”’
cast_column ๐Ÿ”’
draw_masked ๐Ÿ”’
draw_plane ๐Ÿ”’
draw_sky ๐Ÿ”’
draw_sprite_column ๐Ÿ”’
draw_wall_span ๐Ÿ”’
linked_room ๐Ÿ”’
Sectors reachable from start through open walls (bounded), i.e. one โ€œroomโ€.
portal_id
Id of the see-through plane of sector s (floor or ceiling) in the portal mask.
project_sprite ๐Ÿ”’
project_voxel ๐Ÿ”’
sample_plane ๐Ÿ”’
Texture colour of a floor or ceiling at world point (px, py), t units away.
sample_wall ๐Ÿ”’
Texture colour of a wall at position s (0..1 along it) and height z.
sector_vis ๐Ÿ”’
Visibility of sector si: the mapโ€™s global value scaled by the sectorโ€™s own, stored as a signed byte offset (0 = use the global value).
shade_index ๐Ÿ”’
sprite_dims ๐Ÿ”’
Sprite world extents: (half width in xy, height in z, left offset texels).
trace_column ๐Ÿ”’
Colour and depth for one pixelโ€™s ray (ox, oy, oz) + t (dx, dy, dz) entering the linked room at t_entry, using the columnโ€™s precomputed sector list. Same result as trace_pixel, which still handles portals nested inside the linked room.
trace_pixel ๐Ÿ”’
wrap ๐Ÿ”’
Euclidean v mod n, using a mask when n is a power of two (almost every Build texture): an integer division per pixel was a large part of the wall/floor cost.

Type Aliasesยง

WallHit ๐Ÿ”’
(wall index, position along the wall, next sectorโ€™s (ceiling, floor) z for a portal).