A sidedef is a map component that represents the front or back side of a linedef and determines the textures that are displayed on this side. A linedef can have either one or two sidedefs: Each linedef must have a front sidedef, which faces the linedef's front sector. On the other hand, the back sidedef, which faces the linedef's back sector, only exists if there is actually a sector behind the linedef. This is not the case for one-sided linedefs, which form the map's boundary – since the back sides of these linedefs face into empty space that the player will never enter, no back sidedefs are needed for them.
The sidedefs of a map are stored in the
SIDEDEFS lump as a list. Each sidedef has a 30-byte entry consisting of the following:
|0–1||Signed 16-bit integer||X texture offset|
|2–3||Signed 16-bit integer||Y texture offset|
|4–11||8-character string||Upper texture|
|12–19||8-character string||Lower texture|
|20–27||8-character string||Middle texture|
|28–29||Signed 16-bit integer||Sector that the sidedef faces|
A sidedef's textures are the images that are drawn by the game on the surfaces corresponding to the sidedef. A sidedef is split vertically into up to three different surfaces at different heights, each of which has its own texture: the upper, middle and lower texture.
On a two-sided linedef, the textures are rendered as follows:
- The upper textures are drawn on the wall connecting the front sector's ceiling to the back sector's ceiling. If the two ceilings have the same height, this wall does not exist and so neither the front upper texture nor the back upper texture is drawn. If the two ceilings have different heights, it depends on which one is lower: If the back sector's ceiling is lower than the front sector's ceiling, the wall will only be visible from the front side, so only the front upper texture is drawn. If it is the other way around, the wall will only be visible from the back side, so only the back upper texture is drawn.
- The lower textures are drawn on the wall connecting the front sector's floor to the back sector's floor. If the two floors have the same height, this wall does not exist and so neither the front lower texture nor the back lower texture is drawn. If the two floors have different heights, it depends on which one is lower: If the back sector's floor is lower than the front sector's floor, the wall will only be visible from the back side, so only the back lower texture is drawn. If it is the other way around, the wall will only be visible from the front side, so only the front lower texture is drawn.
- The middle textures are drawn as a floating texture in the area between the floors and ceilings of the front and back sector. They are typically used to create sector details like grass borders, fencing or windows. Unlike the upper and lower textures, middle textures are only tiled horizontally and not vertically, where they repeat only once. This can be changed by setting the linedef's Repeat Midtexture flag; see Repeating middle textures for details. By default, the middle texture is attached to the lower of the two adjacent ceilings. It can be made to attach to the higher of the two adjacent floors instead via pegging; see Pegging for details. Middle textures are intangible by default, i.e., players can pass through them. However, they can be made solid by setting the linedef's Solid Midtexture flag. Note that the front middle texture is only visible when looking at the linedef from the side, whereas the back middle texture is only visible when looking at it from the back side. If a middle texture should be visible from both sides of a linedef, it must be applied to both sidedefs.
Single-sided linedefs do not have a back sidedef or back sector. Instead, they form a solid wall between the front sector's floor and ceiling, which is covered by the front sidedef's middle texture. The upper and lower texture are unused.
FOFs and PolyObjects both use middle textures to display the textures on their sides. In the case of PolyObjects, each linedef of the PolyObject displays its own front middle texture on its outer side and its back middle texture on its inner side. If a texture is not set, the corresponding side of the PolyObject will be invisible. In the case of FOFs, the control linedef's front middle texture is displayed on all sides. However, if the control linedef's Transfer Line flag is set, each linedef in the control sector instead corresponds to one in-level linedef of the FOF and sets its properties, including the displayed texture.
If a texture is missing that is needed to cover a wall (i.e., an upper or lower texture on a two-sided linedef, a middle texture on a one-sided linedef, or a middle texture on an FOF), the game will not know what to draw in its place. In Software rendering, the game will instead display leftover images from the last tic – this is called the hall of mirrors effect. This behavior can be changed with the
homremoval console variable: If it set to
yes, missing textures will be replaced with a solid black color. If it set to
flash, they will be replaced with a flashing red color, making them easier to spot. In OpenGL rendering, the game will always replace missing textures with the
The alignment of textures on their sidedef is influenced by several factors. For horizontal alignment, the default behavior is simple: The game begins drawing the texture on the left border of the sidedef and then continues repeating it to the right until the entire length of the linedef is filled. If the linedef's length is not a multiple of the texture's width, the last repetition of the texture is cut off at the right border. The behavior for vertical alignment is more complicated since it depends on pegging; depending on the type of texture and the linedef's flag, the texture is either drawn from the bottom up or from the top down. In addition to this default alignment, it is also possible to manually adjust the alignment via offsets.
- See also: Pegging
Each texture is drawn between two surfaces: Upper textures are drawn between two ceilings, lower textures are drawn between two floors, and middle textures are drawn between a floor and a ceiling. Thus, there are two possible ways to draw the texture vertically: One is to begin at the higher surface and then draw from the top down, whereas the other is to begin at the lower surface and draw from the bottom up. A texture is said to be attached or pegged to the surface that the game begins drawing it from. For textures that are repeated to cover a wall, pegging influences where the texture cuts off if the height it covers is not a multiple of the texture's height – if the texture is pegged to the lower surface, it cuts off at the higher surface, and vice versa. For middle textures of two-sided linedefs, which are drawn only once, pegging controls whether the texture is attached to the floor or the ceiling.
Pegging behavior can be controlled via the linedef's flags. The default pegging behavior and the flags used to control it depend on the type of texture:
- Upper textures are pegged to the lower of the two adjacent ceilings by default. If the Upper Unpegged flag is set, they are pegged to the higher ceiling instead.
- Lower textures are pegged to the higher of the two adjacent floors by default. If the Lower Unpegged flag is set, they are pegged to the lower floor instead.
- Middle textures of two-sided linedefs are pegged to the lower of the two adjacent ceilings by default. If either the Lower Unpegged flag or the Peg Midtexture flag is set, they are pegged to the higher of the two adjacent floors instead. The two flags cancel each other out, so if both are set, the middle textures will still be pegged to the ceiling. This combination is useful if the lower textures should be pegged to the lower floor, but the middle textures should be pegged to the ceiling.
- The middle texture of a one-sided linedef is pegged to the ceiling by default. If either the Lower Unpegged flag or the Peg Midtexture flag is set, it is pegged to the floor instead.
- The textures of an FOF are pegged to the FOF's top by default. If the Lower Unpegged flag is set on an in-level linedef, the textures of any FOF appearing on that line will be pegged to the FOF's bottom instead. However, if the Transfer Line flag is set on the FOF's control linedef, pegging is controlled by the linedefs of the control sector instead – if the Lower Unpegged flag is set on a control sector linedef, the texture of the corresponding FOF side will be pegged to the FOF's bottom.
- The textures of a PolyObject are pegged to the PolyObject's top by default. If the Lower Unpegged flag is set on a PolyObject's linedef, its textures are pegged to the PolyObject's bottom instead.
Apart from pegging, texture alignment can also be influenced by texture offsets. Each sidedef has an X (or horizontal) offset and a Y (or vertical) offset that is added to all three textures on the sidedef. The offset value is measured in fracunits and can be positive or negative: A positive X offset shifts the texture to the right, while a negative X offset shifts it to the left. A positive Y offset shifts the texture upwards, while a negative Y offset shifts it downwards. Offsets make it possible to align texture patterns across adjacent linedefs.
FOFs have a special behavior when it comes to offsets: The X offset of an FOF texture is taken from the in-level sidedef on which the FOF appears. The Y offset, however, is taken from the front sidedef of the FOF's control linedef. This makes it possible to control the vertical alignment of an FOF independently of the vertical alignment of the linedef on which the FOF appears. If the Transfer Line flag is set, the Y offset is read from the front side of the corresponding control sector linedef instead (the same one that also sets the texture).
Many map editors offer an auto-alignment tool that automatically sets the offsets of a region of linedefs so that the textures are properly aligned. In Zone Builder, the auto-alignment tool is available in Visual Mode by pointing towards a linedef and pressing A. Note, however, that the auto-alignment tool is not perfect and will not always compute the optimal alignment, so manual adjustments may still be required. In Visual Mode, the offsets of a selected sidedef can be changed with the arrow keys.
- See also: Slope > Texture skewing
If a texture is pegged to a sloped surface, it is possible to skew it towards that surface to match the angle of the slope. Depending on the type of texture, skewing is either enabled by default and can be disabled with a linedef flag, or is it disabled by default and can be enabled with a linedef flag:
- Middle textures are skewed by default; skewing can be disabled by setting the No Midtexture Skew flag.
- The upper and lower texture are not skewed by default, but skewing can be enabled by setting the Slope Skew flag.
- The textures of FOFs are not skewed by default, but skewing can be enabled by setting the Upper Unpegged flag on the FOF's control linedef.
Textures are always skewed towards the surface they are pegged to; see the Pegging section above for information on how to influence pegging.
Repeating middle textures
By default, the middle texture of a sidedef for a two-sided linedef will be drawn only once. However, if the Repeat Midtexture flag is set on the linedef the sidedef belongs to, the middle texture is instead tiled to fill the gap between the floors and ceilings of the adjacent sectors (or, if the linedef belongs to a PolyObject, the PolyObject's top and bottom), similarly to how upper and lower textures are tiled. If the Repeat Midtexture flag is set, it is also possible to specify an exact number of times that the texture should be repeated: For each repetition (in addition to the one time the texture is always drawn), 4096 must be added to the sidedef's X offset. For example, if the X offset is between 4096 and 8191, the texture is stacked twice, whereas if it is between 8192 and 12287, it is stacked three times. If the X offset is between 0 and 4095, the texture is tiled to fill the entire gap as described above.
The sector reference determines which sector the sidedef faces. All sidedefs facing into a closed polygon of linedefs must have the same sector reference. Otherwise, an unclosed sector will result, which may lead to visual glitches or crashes. Map editors set sector references automatically, and so it is not normally necessary to set them manually. However, certain operations can cause the references to become inconsistent and hence cause sectors to become unclosed, in which case they must be corrected by hand.
Thing • Linedef • Sidedef • Vertex • Node • Sector • Reject • Blockmap