Walls are not covered with pictures directly. A wall texture is put together from one or
more patches, pictures in the picture format,
each placed at a position in the texture. One patch can appear in many textures, which
saved space in the IWADs. PNAMES lists the patches by name, and
TEXTURE1 (and in Doom and Heretic also TEXTURE2) defines the
textures. Sidedefs name the textures. All numbers are little-endian.
PNAMES
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | i32 | count | The number of names. |
| 4 | 8 each | ASCII | names | The patch lumps’ names, padded with zero bytes. A texture refers to a patch by its place in this list, from 0. |
TEXTURE1 and TEXTURE2
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | i32 | numtextures | The number of textures. |
| 4 | 4 each | i32 | offsets | Where each texture’s definition starts, from the start of the lump. |
| … | varies | maptexture | textures | The definitions, below. |
Each definition, which the Doom source calls maptexture_t:
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 8 | ASCII | name | The texture’s name, as sidedefs give it. |
| 8 | 4 | i32 | masked | Not used by the game. |
| 12 | 2 | i16 | width | Width in pixels. |
| 14 | 2 | i16 | height | Height in pixels. |
| 16 | 4 | i32 | columndirectory | Marked obsolete in the source; 0. |
| 20 | 2 | i16 | patchcount | The number of patches that follow. |
| 22 | 10 each | mappatch | patches | Where each patch goes, below. |
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 2 | i16 | originx | Where the patch’s left edge goes, from the texture’s left edge. Can be negative. |
| 2 | 2 | i16 | originy | Where its top edge goes, from the texture’s top. |
| 4 | 2 | i16 | patch | The patch’s number in PNAMES. |
| 6 | 2 | i16 | stepdir | Not used; 1 in the IWADs. |
| 8 | 2 | i16 | colormap | Not used; 0 in the IWADs. |
0numtextures01 00 00 004 bytes4offset08 00 00 004 bytes8name “TEX1”, masked 0, width 6, height 4, column directory 0, 2 patches22 bytes30patch at 0, 0: patch 010 bytes40patch at 3, 0: patch 0 again10 bytes
Putting a texture together
The game draws each patch in turn, in the order listed, at its origin in a canvas of the texture’s width and height; parts of a patch outside the canvas are cut off, and a later patch covers an earlier one. Pixels no patch covers stay transparent, which only matters for the middle texture of a two-sided line. Doom’s renderer has limits that show in some textures, such as gaps where two patches overlap in a see-through texture; the explorer draws the patches plainly, one over another, with the WAD’s palette. A texture’s width should be a power of two for the walls to repeat properly.
A PWAD that adds textures must carry whole new TEXTURE1 and
PNAMES lumps, since the game takes the last of each name; it often has
textures whose patches are only in the IWAD. The explorer marks those patches as not
found.
Strife’s layout
Strife drops the unused fields. A definition is the name (8 bytes), 4 unused bytes, the
width, the height and the patch count (2 bytes each): 18 bytes. Each patch is
originx, originy and patch: 6 bytes. The lump
does not say which layout it uses; the explorer tries both and takes the one whose
definitions fit the lump and follow one another.