Textures in Doom are a notch more complex than sprites: they are compositions of multiple sprites. There are also a couple of additional indirections, one which seems to make more sense than the other.
The first indirection is the TEXTURE1 and TEXTURE2 lumps. While both flats and sprites are lumps in the wad file in their own right, textures are nested one level deeper. You have to read the TEXTURE1 and TEXTURE2 lumps to even find the textures. I haven't been able to make a good guess as to why this indirection exists. I have implemented support for listing the textures in wad-gfx:
wad-gfx doom1.wad TEXTURE1 texture list
Each texture is defined by a name, dimensions and a list of patches. A patch in this case is a sprite and a position on the texture for where to draw the sprite. Rendering a texture is then a relatively simple matter of composing these patches on top of one another, with the notable complexity of retaining the transparency information.1
But there's another surprising layer of indirection! The patches do not reference sprites by name, but by number. Specifically by index into the table in the separate PNAMES lump. This seems to be an extra indirection only causing overhead, but it is possible to eagerly resolve all the names in the PNAMES lump such that finding the sprites while rendering the texture turns into a quick lookup instead of a more elaborate search. Perhaps that's the reason for the PNAMES indirection.
A human readable way to represent such a texture definition is the DeuTex format, which I have implemented in wad-gfx:
wad-gfx doom1.wad TEXTURE1 texture extract -I LITE2
; TextureName Width Height
LITE2 64 128
; PatchName Xoffset Yoffset
* WALL02_2 0 56
* WALL02_2 0 0
* FLAMP 5 0
* FLAMP 35 0
So, LITE2 is a composition of the two sprites WALL02_2 and FLAMP:
WALL02_2 | FLAMP |
Assembled, it looks like this:
|
With a bash "one-liner" we can quickly identify the most complex texture, LITE3, with a whooping 64 patches. That one must surely be interesting!
for TX in $(wad-gfx doom1.wad TEXTURE1 texture list) ; do
echo $(wad-gfx doom1.wad TEXTURE1 texture extract -I $TX | wc -l) $TX
done | sort -n
LITE3
Well, that's a let down. This is just many tiny lighting details repeated 16 times. The reason for this is that the Doom engine tiles textures vertically only at 128 pixel intervals, so usable textures must be 128 pixels tall.
References: GEBBDOOM and the two Doom Wikis doom.fandom.com and doomwiki.org.
Doom does not fully implement this, giving rise to the Medusa effect.