Custom textures tutorial - XWE
|This article or section should contain one or more images. Please spruce up the article by adding an image.|
Textures in SRB2 are made up of smaller components called patches. These patches are graphics that are stored in the WAD file in the Doom Graphics Format. In most cases, a texture will simply consist of a single patch, but larger textures or textures that contain multiple layers must be assembled from several patches. For easier navigability and in order to make the lump editor recognize the patches, they are stored between empty marker lumps called
P_END. In order to assemble these patches into textures, two extra data lumps are needed:
PNAMES lists all the patches that are available in the WAD.
TEXTURE2 lists all the textures that are available in the WAD and determines which patches they are made up of and how these patches are assembled together to form the texture. The difference between
TEXTURE2 is that
TEXTURE2 doesn't require the user to copy over all the existing texture entries from the native game. Therefore, it is recommended to use a
TEXTURE2 lump for add-on WADs.
Flats are simpler to make. They are simply graphic lumps that are stored in the Doom Flat Format and put between the marker lumps
F_END for the same reasons are above. No extra lumps are needed. To prevent conflicts, never use a name for a flat, patch or texture that is already in use in SRB2 or you own WAD. Similarly, never use a name for a texture that is already used for a flat, and vice versa.
In order to import your images into the WAD, you need to set up XWE to use SRB2's palette. If you don't do this, the images will be converted into the standard Doom palette, which is different from SRB2's palette, and their colors will be messed up as a result. This article explains how to set up the palette in XWE.
The first thing you need to do is import SRB2's original
PNAMES lump into the WAD. Download it from here by right-clicking on the link and selecting Save As. In XWE, select Entry → Load, navigate to the folder where you saved
PNAMES and import it. Now create a new
TEXTURE1 lump by selecting Entry → New in the menu bar and entering
TEXTURE1 as the name. XWE should now display the lump type as
TEXTURE. If you want to use a
TEXTURE2 lump instead, create
TEXTURE1 for now anyway and rename it later.
Now you can import your images into the WAD as patches. In order to be used as a patch for a texture, the height of the image must be 255 pixels or less and its width must be a power of 2 (such as 32, 64, 128 and so forth). Before you import the patches however, you will need to add the
P_START marker. To do this, click Entry → New in the menu bar and type in
P_START as the name. You should now see a new lump with the file type
MARKER. Now start importing the images. Click Entry → Load in the menu bar, browse to the folder where your images are located, select them and hit enter. The name of a lump must have eight characters or fewer and should be uppercase, so rename the lumps if necessary by right-clicking on them and selecting Rename Entry. XWE will automatically convert the images into the Doom Graphics Format. Now add the
P_END marker just like the
P_START marker above to close off the patch section.
The textures that should only consist of one patch can be added to
TEXTURE1 now. To do this, right-click on the respective patches and click Add to Patch Names and Add to Texture, in that order. Afterwards, you can rename your
TEXTURE1 lump to
TEXTURE2. However, if you want to add more textures later on, you need to rename it back to
If you want to make a texture that consists of multiple patches, you have to add those patches to
PNAMES. Select all relevant patches, right-click on them and select Add to Patch Names. Now click on the
TEXTUREx lump to open the texture editor. The texture editor provides a simple interface for creating textures out of your patches. In the top part of the editor, you will see two tables. The left table lists the textures in the WAD, along with information on each texture such as their height and width. Ignore the fields for X and Y scale, which have no effect in SRB2. Selecting a texture in the table will display it in the bottom part of the window. The table to the right lists all patches that are included in the texture, along with information on each patch, such as their name and position on the texture. The PID is the index number of the patch in the
PNAMES lump, while the UID is used to identify which patches belong to which texture.
For the purposes of this tutorial, we will create a texture out of patches that are already in SRB2. Press the Insert button on your keyboard or select Textures → New in the menu bar. A new entry will appear in the texture list. Change its name to
MARIOVIN and its width and height to 128. Now select Textures→New Patch and enter 106 in the PID field. In the texture display, you will now see that the texture is filled up with the
MARIOW1 patch. Now add another patch to the texture and enter 310 in the PID field. You will see that the
VINE2 patch has been laid on top of the
MARIOW1 patch, but since it is only 64×64 pixels big, it only fills up the top-left quarter of it.
To fill up the rest of the texture, you must add three more
VINE2 patches to the texture. When adding a new patch, the PID of the last one will be duplicated, so you won't need to change it. Now you need to change the position of the patches on the texture. This is done with the xPos and yPos fields in the patch list. Select the first duplicate and change its X position to 64 and its Y position to 0. You can also position the patch by dragging it around in the preview. Move the other two duplicates to positions (0,64) and (64,64), respectively. Now the entire texture is covered with vines.
The same method can be used to create textures that exceed the maximum patch height of 255 pixels. For example, to make a 256×256 texture, split it up into a patch for the upper half and a patch for the lower half and put them together to create the texture.
Skies are created just like any other texture. However, to use them as a sky, name the texture
SKYx, with x being the integer number you want. You can then use the sky for your levels by referencing the sky number in the level headers, using the
To use an image as a flat, it needs to be exactly square. Its height and width also need to be one of the following: 32, 64, 128, 256, 1024 or 2048. Note that as of 2.0, transparency will not work on flats larger than 256×256. Before you import your flats, you will need to add the
F_START marker. To do this, click Entry → New in the menu bar and type in
F_START as the name. You should now see a new lump with the file type
Now you can import the images. Click Entry → Load in the menu bar, browse to the folder where your images are located, select them and hit enter. The name of a lump must have eight characters or fewer and should be uppercase, so rename the lumps if necessary by right-clicking on them and selecting Rename. Now you need to convert the images into the Doom Flat Format. To do this, select each image individually and click Image → Save as Doom Flat in the menu bar. Once you've done this for all images, add the
F_END marker just like the
F_START marker above to close off the flat section. Now you can use the flats in your map.
Note: Flats that have a height and width of 256 will look like they are corrupt when you reload the WAD, but they are not. You will still be able to use them in SRB2.
To create animated textures, you need to download this pack. It contains a command-line program that generates the
ANIMATED lump required for animated textures and flats. The necessary information to create the lump is supplied in the SRB2.DAT file. Without modifications, it will produce the same
ANIMATED lump that is featured in SRB2 itself.
In order to modify it, make a copy of the existing .DAT file and open it with Notepad or a similar text editor. To add a new animated texture or flat, add a new line under the appropriate header and follow the existing format. "Speed" determines how many tics the game will wait before changing to the next frame, "last" determines the last texture in the animation loop, and "first" determines the first. All other lumps that are between those two alphabetically will also be included in the loop.
After saving the file, run "SWANTBLS.exe [filename].DAT" and the program will generate the files "ANIMATED.lmp" and "SWITCHES.lmp". The
SWITCHES lump is only relevant for Doom, so you can delete it. Import "ANIMATED.lmp" into your WAD via Entry → Load in the menu bar and you're done.