Texture alignment



Texture alignment in Doom is perhaps more complicated than in modern true-3D games. A number of factors affect how a texture is aligned.

Wall textures
Alignment of wall textures is a fairly complex subject. The way textures are aligned depends on the type of line (single or two sided line), the linedef flags controlling pegging, and the sidedef offsets.


 * If a linedef is one sided (a solid wall), the texture is "pegged" to the top of the wall. That is to say, the top of the texture is at the ceiling.  The texture continues downward to the floor.
 * If the "lower unpegged" flag is set on the linedef, the texture is instead "pegged" to the bottom of the wall. That is, the bottom of the texture is located at the floor.  The texture is drawn upwards from here.  This is commonly used in the jambs in doors; because by default the texture is attached to the top of the wall, a doorjamb without the lower unpegged flag set will "rise up" with the door.
 * The alignment of the texture can be adjusted using the sidedef X and Y alignment controls. This is applied after the logic controlling pegging.


 * If a linedef is two sided (a bridge between two sectors, like a window or a step), the upper texture is pegged to the lowest ceiling, and the lower texture is pegged to the highest floor.  That is, the bottom of the upper texture will be at the lowest ceiling and drawn upwards, and the top of the lower texture will be at the highest floor and drawn downwards.
 * If the "upper unpegged" flag is set on the linedef, the upper texture will be pegged to the highest ceiling instead. That is, the top of the upper texture will be at the highest ceiling and will be drawn downward.
 * If the "lower unpegged" flag is set on the linedef, the lower texture will be pegged to the lowest floor instead. That is, the bottom of the lower texture will be at the lowest floor and will be drawn upward.
 * The alignment of textures can be adjusted with the sidedef X and Y alignment control. This is applied after the logic controlling pegging and affects all textures.

To put it simply, when a single texture is used repeated on a wall, moving from right to left, the right side of the preceding texture must line up with the left side of the next instance of the texture in such a way that when one is playing a level they cannot tell where one instance of the texture ends and another begins.

Floor and ceiling textures
All floor and ceiling textures are aligned on a 64-unit grid. Because of this, in some cases the only way to align a floor texture is to move the position of the sector which defines the floor itself.

Some ports such as Boom add the ability to change the alignment of floor and ceiling textures, even allowing effects such as moving conveyor belts. These are typically implemented using a separate linedef tagged to the sector.