home *** CD-ROM | disk | FTP | other *** search
/ WADS of WADS / WadsOfWads.1994.zip / TEXT / DMTEXT.TXT < prev    next >
Text File  |  1994-09-10  |  20KB  |  439 lines

  1.                    [Included with permission]
  2.  
  3.         MANAGING TEXTURES AND THE "UNPEGGED" ATTRIBUTE
  4.         ----------------------------------------------
  5.  
  6.                 Scott Amspoker   (scott@basis.com)
  7.  
  8. There have been recurring questions regarding the use of "pegged" and
  9. "unpegged" textures on walls as well as the tile rendering of textures
  10. by the Doom engine.  This is not just a beginner's problem.  Even the
  11. more sophisticated and popular PWADs submitted by netters have the
  12. occasional texturing oversight.  Here is an explanation of how textures
  13. are rendered by Doom.  The bulk of the following text deals with wall
  14. textures in particular.
  15.  
  16. As you have already discovered, every section of wall in Doom has three
  17. rectangular areas that must be filled in by the Doom engine - the
  18. upper texture, the normal texture, and the lower texture.  Each area may
  19. have a different texture map assigned to it or no texture at all
  20. inidicated by a texture name of "-".  Any given wall can have all three
  21. areas exposed to the player but most walls will have one of more of these
  22. areas out of view.  When choosing texture maps, the PWAD creator must
  23. consider how Doom will use that texture map to fill in the rectangular wall
  24. areas and understand how Doom's default behaviour can be changed via the
  25. "unpegged" attributes.
  26.  
  27. Doom fills in each wall area by tiling its texture map horizontally
  28. and vertically until the entire area is covered.  The texture map
  29. may be truncated horizontally and/or vertically if the wall area
  30. dimensions are not an even multiple of the dimensions of the texture
  31. map.
  32.  
  33. In all cases, texture maps are placed on the horizonal axis beginning
  34. with the left edge of the wall and working towards the right.  The
  35. placement of textures on the vertical axis is more complicated and differs
  36. depending on various conditions described below.
  37.  
  38. Some of the texture maps found in the standard DOOM.WAD file are have
  39. a homogeneous quality to them.  The effects of tiling/truncating
  40. them are not visible and the PWAD designer need not worry about
  41. unusual wall dimensions.
  42.  
  43. On the other hand, some texture maps have distinct markings that won't
  44. appear correct when tiled/truncated without some intervention by the
  45. PWAD designer.  It is desirable that the texture maps of adjoining
  46. wall segments line up with each other to create a seamless composite
  47. wall.  Sometimes, deliberate texture mis-alignment is used as a hint
  48. to the player of a secret door.  NOTE: some texture maps that
  49. have a height other than 64 or 128 (such as a stair riser) do not
  50. appear to tile very well.  For some reason you might end up with
  51. small pink cracks in the wall texture.  While this can have a really
  52. cool effect, treat it as a bug.
  53.  
  54. Most texture maps found in the standard WAD are 128 units high.  For
  55. most of the following examples, I will use the following texture map:
  56.  
  57.        --------------------
  58.       |TTTTTTTTTTTTTTTTTTTT|
  59.       |                    |
  60.       |                    |
  61.       |                    |
  62.       |                    |
  63.       |                    |
  64.       |                    |
  65.       |                    |
  66.       |                    |
  67.       |BBBBBBBBBBBBBBBBBBBB|
  68.        --------------------
  69.  
  70. For reference, I've labeled the top of the map with T's and the bottom with
  71. B's.
  72.  
  73.  
  74. THE NORMAL TEXTURE
  75. ------------------
  76.  
  77. Single-sided linedefs only require that the normal texture be defined.  In
  78. this case the normal texture is the entire area of wall you see from floor
  79. to ceiling.  By default, Doom will fill the normal texture with the assigned
  80. texture map starting with the top and working down.  If the wall is
  81. somewhat taller than the texture map, it will look like this:
  82.  
  83.        --------------------
  84.       |TTTTTTTTTTTTTTTTTTTT|
  85.       |                    |
  86.       |                    |
  87.       |                    |
  88.       |                    |
  89.       |                    |
  90.       |                    |
  91.       |                    |
  92.       |                    |
  93.       |BBBBBBBBBBBBBBBBBBBB|
  94.       |TTTTTTTTTTTTTTTTTTTT|
  95.       |                    |
  96.       |                    |
  97.        --------------------
  98.  
  99. If the wall is shorter than the texture, the result would be:
  100.  
  101.        --------------------
  102.       |TTTTTTTTTTTTTTTTTTTT|
  103.       |                    |
  104.       |                    |
  105.       |                    |
  106.       |                    |
  107.        --------------------
  108.  
  109. Notice that the top of the texture is always at the top of the wall.
  110. The texture is rendered working down the wall towards the floor and
  111. repeated if necessary.
  112.  
  113. By setting the "lower unpegged" bit in the linedef, the rendering of the
  114. normal texture will be performed from the bottom up instead of the top
  115. down.  (The "lower unpegged" bit is normally associated with the lower
  116. texture but also has an effect on the normal texture.)  Our tall wall
  117. would now look like this:
  118.  
  119.        --------------------
  120.       |                    |
  121.       |                    |
  122.       |BBBBBBBBBBBBBBBBBBBB|
  123.       |TTTTTTTTTTTTTTTTTTTT|
  124.       |                    |
  125.       |                    |
  126.       |                    |
  127.       |                    |
  128.       |                    |
  129.       |                    |
  130.       |                    |
  131.       |                    |
  132.       |BBBBBBBBBBBBBBBBBBBB|
  133.        --------------------
  134.  
  135. Our short wall would be:
  136.  
  137.        --------------------
  138.       |                    |
  139.       |                    |
  140.       |                    |
  141.       |                    |
  142.       |BBBBBBBBBBBBBBBBBBBB|
  143.        --------------------
  144.  
  145. Notice that the bottom of the texture map begins at the bottom of the wall
  146. and works up.
  147.  
  148.  
  149. THE UPPER AND LOWER TEXTURES
  150. ----------------------------
  151.  
  152. A linedef may have sectors on both sides of the line. In such a case, both
  153. sides of the linedef have wall definitions (sidedefs).  If the "2-sided"
  154. attribute is set then Doom considers each of the two sectors to
  155. be exposed to the other sector.  When a 2-sided line is used, the PWAD
  156. designer must always consider what they player should see when facing the
  157. line from both sides.  A 2-sided line is most often used as a see-through
  158. connection between two sectors (such doorways, windows, stairs, and
  159. platforms).  Therefore, the normal texture on both sides would typically
  160. be invisible ("-").  However, since the two sectors could have different
  161. floor and ceiling heights, the dimensions of wall space on either side
  162. of the line could be different.  The "upper texture" is used to handle
  163. the difference (if any) between adjacent ceilings.  The "lower texture"
  164. is similarly used to handle the different floor elevations (if any).
  165.  
  166. In a nutshell, the normal texture is the area of wall that both sectors
  167. have in common.  This would be the portion of the wall above the higher
  168. of the two floors and below the lower of the two ceilings.  (Both sides of
  169. the line will normal textures.)  The upper texture is the area of the
  170. wall between the two ceiling heights.  This area is visible only
  171. on the side of the line with the higher ceiling.  The lower texture
  172. is the wall space between the two floor heights and is only visible
  173. on the side with the lower floor.
  174.  
  175. NOTE: If the ceiling texture of both sectors is F_SKY1 then the upper
  176. texture between them will also be invisible regardless of its assigned
  177. texture map.  See the courtyard in E1M1 for an example of this.
  178.  
  179.  
  180. By default, the upper texture is tiled from the bottom up and the lower
  181. texture is tiled from the top down.
  182.  
  183. Consider a window.  The area above the window opening is the upper texture.
  184. The window opening itself is the normal texture.  The area below the
  185. window opening is the lower texture.  Let's use the following wall
  186. segment with our example texture map assigned to upper and lower areas:
  187.  
  188.        --------------------
  189.       |                    |
  190.       |                    |   <- upper texture
  191.       |BBBBBBBBBBBBBBBBBBBB|
  192.       |--------------------|
  193.       |                    |   <- normal texture ("-")
  194.       |                    |
  195.       |--------------------|
  196.       |TTTTTTTTTTTTTTTTTTTT|
  197.       |                    |   <- lower texture
  198.       |                    |
  199.        --------------------
  200.  
  201. Notice how the bottom of the texture map rests on the bottom of the
  202. upper area whereas the lower area is just the opposite.  If this wall
  203. section were placed adjacent to a regular wall panel, the texture
  204. pattern would not line up:
  205.  
  206.       --------------- --------------------
  207.      |TTTTTTTTTTTTTTT|                    |
  208.      |               |                    |
  209.      |               |BBBBBBBBBBBBBBBBBBBB|
  210.      |               |--------------------|
  211.      |               |                    |
  212.      |               |                    |
  213.      |               |--------------------|
  214.      |               |TTTTTTTTTTTTTTTTTTTT|
  215.      |               |                    |
  216.      |BBBBBBBBBBBBBBB|                    |
  217.       --------------- --------------------
  218.  
  219.  
  220. By setting the "upper unpegged" attribute, the upper texture is rendered
  221. from the top down similar to a normal texture:
  222.  
  223.       --------------- --------------------
  224.      |TTTTTTTTTTTTTTT|TTTTTTTTTTTTTTTTTTTT|
  225.      |               |                    |
  226.      |               |                    |
  227.      |               |--------------------|
  228.      |               |                    |
  229.      |               |                    |
  230.      |               |--------------------|
  231.      |               |TTTTTTTTTTTTTTTTTTTT|
  232.      |               |                    |
  233.      |BBBBBBBBBBBBBBB|                    |
  234.       --------------- --------------------
  235.  
  236. Likewise, by setting the "lower unpegged" attribute, the lower texture
  237. will appear rendered from the bottom up:
  238.  
  239.       --------------- --------------------
  240.      |TTTTTTTTTTTTTTT|TTTTTTTTTTTTTTTTTTTT|
  241.      |               |                    |
  242.      |               |                    |
  243.      |               |--------------------|
  244.      |               |                    |
  245.      |               |                    |
  246.      |               |--------------------|
  247.      |               |                    |
  248.      |               |                    |
  249.      |BBBBBBBBBBBBBBB|BBBBBBBBBBBBBBBBBBBB|
  250.       --------------- --------------------
  251.  
  252. Actually, an unpegged lower texture is a tad more complicated than this.
  253. The bottom starting point on the texture map is not necessarily the
  254. bottom of the map.  Instead, Doom choses the starting point based on
  255. the distance between the ceiling and the floor.  The end result is that
  256. the bottom of the lower texture will line up with the bottom of the
  257. adjacent wall.  If the above example were shorter, both wall sections
  258. would still align:
  259.  
  260.       --------------- --------------------
  261.      |TTTTTTTTTTTTTTT|TTTTTTTTTTTTTTTTTTTT|
  262.      |               |                    |
  263.      |               |                    |
  264.      |               |--------------------|
  265.      |               |                    |
  266.      |               |                    |
  267.      |               |--------------------|
  268.      |               |                    |  <- bottom row cut off both walls
  269.       --------------- --------------------
  270.  
  271. As you can see, unpegged upper and lower textures are used for seamless
  272. windows.
  273.  
  274. NOTE: As mentioned earlier, the effect of "lower unpegged" on normal textures
  275. really does cause a bottom-up rendering of the texture.  If the "lower
  276. unpegged" attribute were set for the adjacent wall in the above example,
  277. it would look like this:
  278.  
  279.       --------------- --------------------
  280.      |               |TTTTTTTTTTTTTTTTTTTT|
  281.      |               |                    |
  282.      |               |                    |
  283.      |               |--------------------|
  284.      |               |                    |
  285.      |               |                    |
  286.      |               |--------------------|
  287.      |BBBBBBBBBBBBBBB|                    |  <- bottom rows don't match
  288.       --------------- --------------------
  289.  
  290.  
  291. APPLICATIONS OF UNPEGGED ATTRIBUTES
  292. -----------------------------------
  293.  
  294. The following are common situations where an understanding of pegged vs.
  295. unpegged textures is important:
  296.  
  297. Windows and fixed doorways:
  298.     As shown in the above example, use unpegged upper and lower textures
  299.     to ensure alignment with surrounding wall sections.
  300.  
  301.  
  302. Doors:
  303.    Doors are usually implemented as a sector where the ceiling height
  304.    is the same as the floor height.  The player will normally see only
  305.    the upper texture which will contain the image of the door.  When the
  306.    door "opens", the ceiling of the door sector rises.  The default
  307.    pegged mode is used to let the door image rise with the ceiling since
  308.    the upper texture is based at the bottom edge of the rising ceiling.
  309.  
  310.    The walls making up the inside tracks of the door are defined as
  311.    normal textures since they are going to be on single-sided lines.
  312.    Since normal textures are rendered from the ceiling down, the
  313.    inside tracks will rise as the door (ceiling) rises.  This is usually
  314.    not the desired behaviour.  By setting the "lower unpegged" bit
  315.    for the inside tracks, they will remain stationary while the
  316.    door opens since they will be based on the non-changing floor.
  317.  
  318.    The rising hallway on the other side of the acid pit in E1M3
  319.    is a classic example of the side walls remaining pegged so that
  320.    they rise with the ceiling.
  321.  
  322.  
  323. Secret doors:
  324.     Secret doors behave the same way as regular doors but add a little
  325.     more complexity to texture decisions if the door is to blend in
  326.     with the surrounding wall.  Normally the door is closed
  327.     so that the player only sees the upper texture from floor to
  328.     ceiling.  Since the upper texture is rendered from the bottom
  329.     up, the bottom of the door (where it meets the floor) will
  330.     show the bottom of the texture map.  If the room has a non-standard
  331.     ceiling clearance, the adjacent wall panel won't meet the floor
  332.     the same way as the closed door.  Rather than make the door
  333.     match the adjacent walls, you can make the adjacent walls match
  334.     the door by unpegging their lower texures (which re-aligns
  335.     the normal textures) so that everybody builds from the floor up.
  336.  
  337.     The "secret" attribute may be set so that the door doesn't show
  338.     up on the map.  However, this will only work if the floor/ceiling
  339.     height of the closed door sector is less than or equal to the floor
  340.     height of the room sector.  In other words, if the doorway is a
  341.     step up from the room, the map will give away the secret by showing
  342.     the lines immediately beyond the door even before the door is first
  343.     opened.
  344.  
  345.  
  346. Switches and other wall decorations:
  347.     The standard textures containing wall switches are 128 units high.
  348.     (This also includes decorations such as "POISON" signs and
  349.     gargoyles).  When using these textures on a wall that is shorter, the
  350.     switch will move down towards the floor since the normal wall
  351.     texture is rendered from the ceiling down.  To keep the switch at
  352.     a reasonable height on the wall, set the "lower unpegged" bit.
  353.     The wall will build up from the floor and the switch will always
  354.     be at a proper height regardless of where the ceiling is.
  355.  
  356.  
  357.  
  358. MANUAL ADJUSTMENT OF TEXTURE OFFSETS
  359. ------------------------------------
  360.  
  361.     There are situations where manipulation of the "unpegged" bits
  362.     will fail to create the desired alignment of wall sections.
  363.     Since the "unpegged" bits only affect the vertical rendering
  364.     of texture maps, they will not help when a horizontal adjustment
  365.     is needed.  Horizontal adjustments might be necessary when wall
  366.     sections with non-standard widths are combined to create a
  367.     single wall.  If the texture map style creates a noticable seam,
  368.     then you may adjust the horizontal and vertical offsets for
  369.     each wall segment.  The "X offset" parameter tells Doom how
  370.     far horizontally into the texture map to begin rendering.  A positive
  371.     value would appear to shift the texture to the left.  Likewise,
  372.     the "Y offset" specifies how far vertically (from the top) to
  373.     begin rendering.  A positive value would appear to shift the
  374.     texture upward.  All three textures (upper, lower, and normal)
  375.     are affected by these values.
  376.  
  377.     At first glance it might appear that these offets are troublesome
  378.     to determine.  In actual practice, it is usually easy to determine
  379.     offsets for any given situation.
  380.  
  381.     Y offsets are the most common since they are necessary to make things
  382.     appear aligned horizontally (by shifting a texture up and down,
  383.     you affect the alignment of horizontal features).  Generally,
  384.     there are 3 values to consider when setting the Y offset:
  385.  
  386.          1) The ceiling height of the current sector.
  387.          2) The ceiling height of a relevant adjoining sector.
  388.          3) The height of the texture map.
  389.  
  390.     Normally, the desired Y offset will turn out to be the difference
  391.     between any 2 of these values.  It is also useful to remember that
  392.     an offset can be negative.  For example instead of an offset of 100
  393.     into a 128-unit texture, an offset of -28 will do the same thing.
  394.     (There's also a good chance that the "28" was easier to determine from
  395.     the circumstances.)
  396.  
  397.     The X offset is less common and is most often used to center textures
  398.     on wall segments that are not the same width as the texture.  This
  399.     happens when creating narrow doorways or placing switches and other
  400.     decorations on short wall segments.  In such cases, simply subtract
  401.     the wall length from the texture length and set the X offset to
  402.     half that value.
  403.  
  404.     A less common situation is when textures for several contiguous wall
  405.     segments must appear as one wall.  Most Doom textures would still appear
  406.     just fine in such situations if the X offset were ignored.  However,
  407.     a few textures (such as computer panels) would look sloppy without
  408.     carefully setting the X offsets.  In such cases, the X offset for
  409.     a wall would be the sum of the X offset and length of the preceeding
  410.     wall (to the left).  If the offset gets too large then wrap it around
  411.     to the negative and continue.
  412.  
  413.  
  414. FLOORS AND CEILINGS
  415. -------------------
  416.  
  417. The textures used for floors and ceilings are all 64 x 64 units.  Unlike
  418. wall textures, floor and ceiling textures are aligned and oriented with
  419. respect to the underlying map coordinate grid.  Since these textures
  420. are tiled globally, they will always create seamless transitions from
  421. one sector to the next (assuming the adjoining sector has similar
  422. floor/ceiling textures).
  423.  
  424. Some floor/ceiling textures have specific markings on them that are
  425. important.  For example, some ceiling textures have a grid of lights.
  426. To ensure that the ceiling lights in a sector tile correctly, not only
  427. must the sector size be a proper multiple of a single light, but the
  428. sector itself must be placed on the map at an appropriate grid line.
  429.  
  430. A transporter pad has a special design.  In order for the image
  431. on the transporter pad to appear correct, the pad must be aligned on
  432. a 64 x 64 map grid.
  433.  
  434. There are some special stair step textures (STEP1 and STEP2).  These could
  435. be used for the top surface of each stair.  If you wish to use these textures
  436. for your stairs, make sure you pick the texure with the proper north/south or
  437. east/west orientation and snap your stairs to a 64-unit width and a
  438. 32-unit depth.
  439.