[This is Part One in the Texture
Management series. Part Two will follow
shortly. You can download this article in
Adobe Acrobat PDF format
here. Acknowledgements are due to Scott
Amspoker’s 1994 paper “Managing Textures and
the ‘Unpegged’ Attribute.” ]
Texture Management:
The Unpegged Attribute and Texture Alignment
By John W.
Anderson
Good level
design requires attention to detail. A great
map doesn't have to be wildly original, with
eccentric architecture and clever puzzles. A
great map has to be consistent. It has to be
believable. When a player enters your map,
you're asking him to become part of a
fiction that you've created. The map is a
continuous fictive dream with its own
internal logic. In order for that dream to
be sustained, the player's attention must
not be distracted. The slightest deviation
from logic or consistency in your level may
be a shift in something as seemingly
insignificant as a misaligned texture. For
when the player sees this, he's immediately
awoken from the dream and realizes he's
playing a DOOM level – and a sloppy one, at
that.
You have to keep
the availability and sizes of textures in
mind when laying down the architecture of
your map. Most textures are either 64 or 128
pixels wide by 128 pixels high. The notable
exceptions are the STEP textures, which are
32 or 64 wide by 16 high, and some of the
door textures. These and other textures,
such as switches, are meant to be assigned
to a LineDef whose length matches the
texture map. That is, they're not drawn to
tile seamlessly when placed next to each
other.
Texture
alignment is just as easy to get right as
wrong. All it takes is a little effort and
knowledge of how DOOM maps textures. Let's
explore that topic now.
How DOOM Renders Textures:
The Normal Texture and One-Sided
LineDefs
DOOM maps all
normal
textures from the top down along the
Y-axis, starting in the upper left corner
and tiling to the right horizontally along
the X-axis.
normal
textures are those that are assigned
to one-sided LineDefs on the
first
sidedef. (When a LineDef is
two-sided, the
normal texture is often called the
middle texture because it falls between
upper
and lower textures.)
Many of the
textures are designed so that they tile well
when repeated side by side along a stretch
of wall. Some tile so well that there is no
noticeable separation between textures, such
as some of the DOOM2 BRICK textures.
Figure 1.1.
BRICK6 is 64 pixels wide and 128 pixels
tall.
When mapped horizontally, the textures tile
seamlessly.
These textures
tile well not only horizontally along the
X-axis, but also vertically along the
Y-axis. Note that they're drawn so cleverly,
in fact, that each individual brick is about
8 pixels high and 16 pixels wide. There are
eight rows of these, which separate neatly
into 32-pixel high groups.
This type of
texture is ideal for use in Sectors whose
floor and ceiling heights exceed 128 pixels.
If your level calls for heights above 128
pixels, you should use no less than 8-pixel
increments: 136, 144, 152, 160, and so on.
Figure 1.2 shows
the BRICK6 texture assigned to a wall 128
pixels long and 160 high. The texture starts
at the upper left hand corner and ends 128
pixels down along the Y-axis. The texture
then repeats itself, starting again with the
top of the texture and working its way down
another 32 pixels until the wall ends.

Figure 1.2.
The wall is 160 pixels high by 128 wide. It
is not easy to
tell where the texture starts and ends. DOOM
maps textures
from the top left corner down and to the
right. So the bottom
two rows of bricks are actually identical to
the top two rows,
since the texture map has started over at
the bottom.
As you can see
in Figure 1.2, the bottom two rows of bricks
are identical to the top two. But this is
not something that calls attention to itself
because of the homogenous nature of the
texture. It doesn't repeat noticeably.
There are only a
few groups of textures that show such
homogeneity in their tiling. Most of the
DOOM textures have certain asymmetric design
elements that are noticeable when tiled,
because the elements repeat and call
attention to themselves. Let's look at the
same wall with the BRONZE2 texture in Figure
1.3.

Figure 1.3.
BRONZE2 tiles well along the X-axis, even
though it has
a noticeable design. But along the Y-axis,
the texture
obviously repeats in an asymmetric manner.
Even though
BRONZE2 has a noticeable design element in
the middle, it tiles fairly well from left
to right. Vertically, however, the
crenellations along the top of the texture
don't look quite right when repeated along
the bottom.
If the wall were
shorter than the texture, it would look like
this:

Figure 1.4.
Wall is 96 pixels tall.
The texture starts at the top and works its
way down to the floor. Let's examine how we
could control this by using the unpegged
attribute with
normal
textures.
The Unpegged Attribute
The unpegged
attribute is normally associated with
upper
and
lower textures, which we'll examine
in the next section. It has its uses,
however, with
normal
textures. As stated, DOOM maps
normal
textures from the top down. If
we set the lower unpegged flag for
this LineDef, textures will be drawn from
the bottom up. It would have no
noticeable effect whatsoever if applied to a
wall whose height was the same as the
texture map. If we apply it to our tall
wall, however, you can see the difference it
makes (Figure 1.5).

Figure 1.5.
Wall is 160 pixels high with lower
unpegged flag set.
The texture is
now drawn from the bottom up. Instead
of the top crenellation design being
repeated, the lower molding is repeated at
the top. This doesn't look quite as bad as
in Figure 1.3.
The short wall
shown in Figure 1.4 would now look like
this:

Figure 1.6.
Wall is 96 pixels high with the lower
unpegged flag set.
I think you’d
agree that this looks better, as well.
This
demonstrates not only the properties of the
lower unpegged attribute, but
ways to manipulate
normal textures with asymmetric design elements. The
unpegged attribute has its most powerful
uses with
upper
and
lower textures, which we'll examine
next.
Upper and Lower Textures and Two-Sided
LineDefs
LineDefs are
either one-sided or two-sided. LineDefs must
always have at least one side, which is the
right
side, or
first
sidedef. This is the side visible to
the player and which is assigned
normal
textures. Most DOOM level editors
indicate the
first
sidedef with a
vector,
which is the tiny stick that juts out
perpendicular to the LineDef. A LineDef's
right
side is determined by the start
and end Vertices.
When a LineDef
is shared by two Sectors, it will have a
second or left side, called the
second
sidedef. Not all two-sided LineDefs
are visible. They may be laid down to act as
triggers for
linedef action types, or they may be
used to chop a Sector up into various
sections for lighting purposes. When
adjacent Sectors have varying ceiling and
floor heights, however, the LineDef shared
between them will then have visible
upper
or
lower textures.
-
The
upper texture is used to handle
the difference between adjacent ceilings
from the point of view of one in the
Sector with the higher ceiling.
-
The
lower texture is used to handle
the different floor elevations between
adjacent Sectors from the point of view
of one in the Sector with the lower
floor.
A set of stairs
is a good example. A better, and more
typical, example is a window. A window is
usually made by taking a common wall and
splitting the LineDef a few times to create
an opening into another Sector.
Figure 1.7.
Sector 1 is the window between Sectors 0 and
2.
One-sided LineDefs are drawn in white and
two-
sided LineDefs in gray. The gray LineDefs
between
Sectors 0 and 2 have
upper
and lower
textures visible on their
first sidedef.
Figure 1.7 shows
two Sectors that are 256x256 square, with a
floor height of 0 and a ceiling height of
128, separated by Sector 1, which has a
floor height of 32 and a ceiling height of
96. From the point of view of a player in
Sector 0, therefore, the window Sector has a
higher floor elevation revealing a lower
section of wall between the windowsill and
the floor of Sector 0. Likewise, the ceiling
of Sector 0 is higher than the ceiling of
the window Sector, revealing an upper
section of wall between the two. The window
opening is 64 pixels high with
upper
and
lower textures of 32 pixels each
along the Y-axis. Figure 1.8 shows how DOOM
would map the BRONZE2 texture on these
walls.

Figure 1.8.
DOOM maps
upper
textures from the bottom up
and
lower textures from the top down.
You can see
right away that something is wrong here. The
textures above and below the window do not
align properly with their neighbors. As
we've seen, DOOM maps
normal
textures – the textures on either
side of the window – from the top down.
It does something different with
upper and lower
textures:
The texture
above the window starts from the bottom and
goes up. The texture below the window starts
at the top and goes down. This can be
corrected by setting the upper and
lower unpegged attributes to this
LineDef.
As we saw when
setting the lower unpegged flag on a
LineDef with
normal textures, it caused the textures to be drawn from the
bottom up instead of the top down. Setting
the lower unpegged flag on the
first
sidedef of the window LineDef will
therefore correct the
lower
texture by having it drawn from the
bottom up (see Figure 1.9).

Figure 1.9.
When the lower unpegged flag is set,
the
lower texture is
drawn from the bottom up and now lines up
with its neighbors.
Alternatively,
if we set the upper unpegged
attribute for this LineDef, the
upper
texture will now be drawn from the
top down instead of the bottom up.

Figure 1.10.
When the upper unpegged flag is set,
the
upper texture is
drawn from the top down and now lines up
with its neighbors.
That looks much
better, doesn't it? The problem could also
have been corrected by adjusting the
Y-offset for the
upper and lower
textures by 32 pixels, but it's much
easier to set the unpegged flags.
The lower
unpegged attribute is actually a bit
more complicated than it seems. While it
does indeed draw textures from the bottom up
when set for
lower textures, it doesn't necessarily use the bottom of the
wall according to its height. This is where
talking of "walls" and "rooms" instead of
LineDefs, SideDefs, and Sectors gets us into
trouble. Let's thoroughly confuse you by
showing what our unpegged texture maps would
look like on a shorter "wall."
Let's say that
Sector 0 is 112 pixels high instead of 128.
Our walls are shorter than the texture maps,
in this case. Our window area would look
like this:

Figure 1.11.
The wall is 112 pixels high, 16 pixels
shorter than the
BRONZE2 texture.
normal textures are still drawn from
the top down, the unpegged
upper
texture is still drawn from the top
down, so what is the problem with the
unpegged
lower
texture? It is aligned with
its neighbors, which is the desirable state.
But how does it know to do this? Instead of
using the absolute floor height to determine
where to start drawing unpegged
lower
textures from the bottom, DOOM
chooses the starting point based on the
distance between the ceiling and the floor.
This is why the bottom of the
lower
texture lines up with the bottom of
the adjacent textures.
But one more
example for confusion: When the lower
unpegged flag is set for a
normal
texture, it really does draw the
texture from an absolute bottom up. If we
set the lower unpegged flag to the
LineDef on the left, it would look like
this:

Figure 1.12.
When the lower unpegged flag is set
on a LineDef with a
normal texture, rendering is done
from an absolute bottom up.
The unpegged attribute is meant as a
shortcut for correcting the texture map
rendering of
upper
and
lower textures, primarily. Its use is
intended for situations such as those we've
examined for windows and the like. Many
times,
upper and
lower
textures don't need to be corrected
at all. Stairs, for instance, are generally
8 or 16 pixels high, and the texture maps
intended for them are generally the same
height and therefore need no alignment.
Stairs present other alignment problems,
though, for the walls alongside them,
depending on how you've created your stairs.
We'll look at stairs in an upcoming section.
Let's look at another DOOM structure that
calls for application of the unpegged
attribute: doors.
Door Tracks and the
Lower Unpegged Attribute
A door in DOOM
is a Sector whose floor and ceiling usually
have the same height as the floor height of
the adjacent Sectors. That is, it’s a moving
Sector in the down position. When
presented with a door, the Sector's LineDefs
are two-sided, and generally, the
first
sidedef faces the player. Since the
door is actually a moving ceiling, the
visible
first
sidedef has exposed
upper
textures. These are covered with an
appropriate door texture. Since
upper
textures are rendered from the bottom
up, the door texture is aligned properly.
When the door's ceiling rises, the texture
rises with it, constantly being drawn and
redrawn from the bottom up, so it appears
stationary on the SideDef, moving along with
the Sector as it rises. No unpegging or
other alignment is needed for the door
itself.

Figure 1.13.
Sector 3 is the door and the door tracks are
highlighted in orange. Sector 3 has a floor
and
ceiling height of 0, so the door is in the
down
position.
The door tracks,
however, do need adjustment. The door
tracks are the wall space along the "sides"
of the door. The actual LineDefs that form
part of the door Sector are not visible, but
the wall along which they glide are. And
this wall space is a one-sided LineDef whose
first
sidedef naturally has
normal
textures.
normal
textures, you'll recall, are drawn
from the top down. They will be drawn from
the top of the door bottom as it rises. The
bottom of the door is a ceiling, and as it
rises, the
normal
texture below it will be drawn and
redrawn from the top down. So as the door
moves up, the door track appears to rise up
with it. This looks goofy, but can easily be
corrected.
By setting the
lower unpegged flag to the side
LineDefs, the
normal
textures will be drawn from the
bottom up instead of from the top down.
Therefore, as the door rises, the textures
appear stationary as they are revealed,
since they start at the bottom.
Common Situations Using
Upper and Lower Textures
We've covered
windows and doors, which are the most common
design elements involving
upper
and
lower textures, and application of
the unpegged attribute. Stairs will
be addressed in the section on texture
alignment along the X- and Y-axes. Some
other common examples are lifts,
crushing ceilings, pillars,
crates, and secret doors.
lifts
● Lifts are moving Sectors in the up
position. They will have
lower
textures around their base. The
adjacent Sector will have
lower
textures exposed when the lift
lowers.
crushing ceilings
● Crushing
ceilings will have
upper
textures revealed when they descend.
These textures will be drawn from the bottom
up, so you don’t want to unpeg these.
pillars and crates
● Pillars and
crates with two-sided LineDefs will have
lower
textures. True pillars with one-sided
LineDefs are not Sectors at all and will
have
normal textures.
secret
doors
● Secret doors are moving Sectors in
the down position. They have
upper
textures that are drawn from the
bottom up. They are usually flush with their
adjacent walls, and not inset like other
doors. You may want to unpeg the
normal texture on the walls adjacent to the secret
door so that their textures are drawn from
the bottom up. They will then match the
secret door, if you want it perfectly hid.
The unpegged
attribute is handy for correcting certain
alignment issues; but remember that the
unpegged attribute only affects the
vertical rendering of texture maps along the
Y-axis. This may not help when an X-axis
horizontal adjustment is called for.
*
* *
Download this
article in Adobe Acrobat
PDF form, as a Microsoft Word
document, or in
HTML format. |