|This article or section should contain one or more images. Please spruce up the article by adding an image.|
Pegging refers to the positioning of the textures on a sidedef. Specifically, pegging determines whether the textures are drawn from the bottom up or from the top down. The linedef flags Lower Unpegged, Upper Unpegged and Peg Midtexture are used to determine the pegging behavior.
Pegging is especially important for the middle texture. In SRB2, the middle texture is usually rendered as a "false wall", i.e. the player can pass through it. It is often used to add grass borders to the edges of sectors with a grass flat. To accomplish this, the middle texture must be attached to the sector's floor. However, by default the middle texture is attached to the ceiling. To attach it to the floor, the Lower Unpegged or Peg Midtexture flag (but not both) needs to be checked on the linedef.
Most linedefs are two-sided, which means they constitute a border between two sectors. Which textures are rendered and how they are rendered depends on the height differences between the ceilings and floors of the two sectors:
- The upper texture is drawn as a solid wall between the two ceilings. By default, it attaches to the lower ceiling and is drawn from the bottom up. If the Upper Unpegged flag is checked, it attaches to the higher ceiling instead and is drawn from the top down.
- The lower texture is drawn as a solid wall between the two floors. By default, it attaches to the higher floor and is drawn from the top down. If the Lower Unpegged flag is checked, it attaches to the lower floor instead and is drawn from the bottom up.
- The middle texture is drawn as an intangible wall between the between the lower ceiling and the higher floor. By default, it attaches to the ceiling and is drawn from the top down. If the Lower Unpegged flag is checked, it attaches to the floor instead and is drawn from the bottom up. Checking the Peg Midtexture flag inverts this behavior: If it attached to the ceiling before, it will now attach to the floor, and vice versa. This make it possible to unpeg the lower texture and still attach the middle texture to the ceiling, by checking both the Lower Unpegged and Peg Midtexture flags, or to attach the middle texture to the floor while leaving the lower texture attached to the higher floor, by checking only the Peg Midtexture flag.
For one-sided linedefs, there is only one bordering sector. Therefore, only the middle texture is drawn, as a solid wall between the ceiling and the floor. By default, it attaches to the ceiling and is drawn from the top down. If the Lower Unpegged or Peg Midtexture flag (but not both) is checked, it attaches to the floor instead and is drawn from the bottom up.
Most textures are drawn as solid walls because they constitute the borders between the level space and the outside. Because the outside needs to be concealed entirely from the player, the texture is tiled vertically until it fills the entire height of the wall. The pegging behavior only affects the vertical texture alignment: If the height of the wall is not a multiple of the height of the texture, the texture must be cut off either at the top or the bottom. If the texture is drawn from the top down, the bottom will be cut off. If the texture is drawn from the bottom up, the top will be cut off. Because the same effect can also be achieved with texture offsets, which also control horizontal alignment, pegging is rarely relevant for solid walls.
The middle texture of a two-sided linedef is different, however. Here, both the front and the back of the texture belong to the level space. Neither side must be blocked off or concealed from the player, so no wall is needed. Instead, the middle texture is mostly used for decorations and is thus intangible. By default, it is drawn only once and not tiled. This makes pegging relevant, since it is now important if the texture attaches to the ceiling or the floor. By default, it attaches to the ceiling and is drawn from the top down. This is useful for decorations that hang from the ceiling, such as vines or flags. For decorations that attach to the floor and should be drawn from the bottom up, such as grass borders, the Lower Unpegged or Peg Midtexture flag (but not both) needs to be checked.
|This article or section is badly written and in need of a rewrite. You can help the SRB2 Wiki by Manual of Style.this article to meet with the standards described by the|
Setting up grass borders
In SRB2 Doom Builder, make a map or open an existing one. Select one or more two-sided linedefs and then right-click to bring up the "Edit Linedef" dialog.
Under "Flags", one can check either Lower Unpegged or Upper Unpegged (highlighted in red) to set the effect. Here, we'll be making a tall grass border like the ones seen in Greenflower Zone, so check Lower Unpegged.
Now you need to set the correct textures. Switch to the "Sidedefs" tab. You only need to set certain textures and options for the effect to work; the others have no bearing on how it looks.
As highlighted, only the middle textures and the texture offsets (more on the latter, later) have an effect on pegging. Also, for most cases, one must set both the front and back sidedefs to the same settings, since the middle textures will be seen from both sides.
Because pegging affects middle textures, set both the front and back middle textures to
GFZGRASS. The other textures can be left as they are. For now, leave all texture offsets at
0. Apply the changes by clicking "OK", and then save your map and test it.
One of the screenshots above should show what the result will be. Notice how if you checked Lower Unpegged, the middle
GFZGRASS texture is tacked to the floor, while otherwise, it's tacked to the ceiling.
And that's it. The way to manipulate middle textures is as simple as checking or unchecking "Lower Unpegged". This is a very useful tool in making maps.
Middle textures on FOFs
One quirk of pegging is that it's not obvious how to set it for FOFs. If you try setting the target sector's linedef textures to
GFZGRASS and then check "Lower Unpegged", you're probably going to get this:
GFZGRASS will appear on the target sector's real floor, rather than the FOF. And setting the texture on the control sector itself doesn't work, either (as the control sector actually uses the middle texture for the FOF's walls.) The way to set up
GFZGRASS on FOFs is actually by a trick, or illusion: Set the texture's Y offset to the appropriate height. The
GFZGRASS itself should still be set on the target sector.
The FOF's top height, in the screenshot, is 192 (above the real floor, which is at 0), so set each texture's Y offset to 192 as well. Save your changes and then try it out! The result should be this:
A side effect to this is that the ground's lower texture is shifted too, due to the Y offset. Also, the
GFZGRASS can only be set on the FOF using this method, and a second middle texture can't be set on the ground itself. However, both of these side effects are usually accepted in favor of the FOF effect.
If these side effects are unwanted, there is a slightly more complicated way you can do it, using an intangible FOF without flats. This will create an additional FOF on top of the already existing one, and render only the sides, which are set to a grass border texture. The floor height of this FOF should be the ceiling height of the regular one, and the ceiling height should be 8 fracunits above that (for
GFZGRASS; taller middle textures will need a taller FOF).