Custom textures tutorial (XWE)

From SRB2 Wiki
Jump to navigation Jump to search
This article or section should contain one or more images. Please spruce up the article by adding an image.

This tutorial will teach you how to create custom textures and flats in SRB2 using XWE as a lump editor.

Introduction

There are two ways of creating textures in SRB2: One way is to simply import the image that you want to use as a texture into the WAD file and convert it to Doom's graphics format. To make the game recognize these single-image textures, they must be stored between two marker lumps, TX_START and TX_END.

While this method can generally be used for all textures, it is sometimes useful to combine a texture out of several images, for example if it has repeating patterns or if it shares parts with another texture. Textures that are combined out of several images are called composite textures, and they can be defined in a special text lump called TEXTURES. The individual images in a composite texture are called patches. You can either use already existing single-image textures as patches or place additional patches in the WAD file. It is recommended to store these patches between the marker lumps P_START and P_END for easy navigability, but this is not strictly necessary.

Like single-image textures, flats are simply imported into the WAD files as images, but they are stored in a different graphics format. Flats should be put between F_START and F_END marker lumps.

To prevent conflicts, never use a name for a composite texture that is already in use as a patch or a flat. Likewise, never use a name for a patch, texture or flat that is already used in SRB2 or your own WAD, unless you want to replace an already existing patch/texture/flat.

Palette setup

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.

Single-image textures

To use an image as a texture, its width needs to be a power of 2 (such as 32, 64, 128 and so forth). The height can be anything. Before you start importing your textures, you need to add the TX_START marker. To do this, click Entry → New in the menu bar and type in TX_START as the name. You should now see a new lump with the file type "Marker".

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 Entry. XWE will automatically convert the images into the Doom Graphics Format. Now add the TX_END marker just like the TX_START marker above to close off the texture section. Now you can use the textures in your map.

Skies

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 SkyNum parameter.

Flats

Unlike textures, images that are used for flats must be exactly square. Their height and width must also be one of the following: 32, 64, 128, 256, 512, 1024 or 2048. Importing the flats works just like with textures above, except that the marker lumps are called F_START and F_END, and that you need to convert the images to the Doom Flat Format. To do this, select each image individually and click Image → Save as Doom Flat in the menu bar.

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.

Composite textures

If you want to import additional patches for your composite textures that cannot be used as stand-alone textures, import them just like the single-image textures above, but put them between P_START and P_END marker lumps. Composite textures for SRB2 are defined in a special text lump called TEXTURES. While XWE has a built-in texture editor, it does not support SRB2's texture format, so you must either use SLADE or write the TEXTURES lump yourself.

For the purposes of this tutorial, we will create a texture out of patches that are already included with SRB2. If the WAD file does not already contain a TEXTURES lump, create it yourself via Entry → New in the menu bar and select it to edit its contents. The TEXTURES lump consists of a list of texture definitions, where each texture definition has the following format:

walltexture TEXTNAME, width, height {
	patch P1NAME, x1, y1
	patch P2NAME, x2, y2
	...
}

The keyword walltexture starts the texture definition. Following this, TEXTNAME is the name of the texture, which may have up to eight characters. width and height determine the size of the texture in pixels. Within the pair of braces, the patches that make up the texture are listed. Each patch entry starts with the keyword patch, followed by the name of the patch and its location in the composite texture. The X and Y coordinates determine where the top-left corner of the patch is located, relative to the top-left corner of the composite texture. The X coordinate is measured from the top edge of the texture downwards, and the Y coordinate is measured from the left edge of the texture going to the right.

In this tutorial we will create a texture called MARIOVIN, which consists of the MARIOW1 texture with the vine texture VINE2 laid over it. Since MARIOW1 has the dimensions 128×128, we need to create a composite texture that also has the dimensions 128×128. The outer part of our texture definition is therefore:

walltexture MARIOVIN, 128, 128 {
}

Now we need to add patches. As the basis of our texture we want to use MARIOW1, which should fill up the entire space of the texture. To accomplish this, place MARIOW1 in the upper left corner by adding the line:

patch MARIOW1, 0, 0

Now we will add vines on top of the texture. The problem is that the VINE2 is only 64×64 pixels big, so it will only fill up the top-left quarter of our texture. In order to fill up the entire texture, we must add four VINE2 patches, one to cover each quarter. This is accomplished with the following four lines:

patch VINE2, 0, 0
patch VINE2, 64, 0
patch VINE2, 0, 64
patch VINE2, 64, 64

Now the entire texture is covered with vines. In total, we have the following texture definition:

walltexture MARIOVIN, 128, 128 {
	patch MARIOW1, 0, 0
	patch VINE2, 0, 0
	patch VINE2, 64, 0
	patch VINE2, 0, 64
	patch VINE2, 64, 64
}

Animated textures and flats

Animated textures and flats are textures/flats that cycle through several images at a specified interval to create an animation effect. They are defined in a special text lump called ANIMDEFS. Every line of text in this lump defines one animated texture or flat and has the following format:

Texture/Flat [Texture name] Range [Texture name] Tics [Integer]
  • Texture/Flat [Texture name]: Determines the texture/flat at which the animation loop starts. Use the keyword Texture for animated textures and the keyword Flat for animated flats.
  • Range [Texture name]: Determines the texture/flat at which the animation loop ends. All textures/flats that are between those two alphabetically will also be included in the loop, e.g. if the first texture is SAMPLE1 and the last is SAMPLE4, then SRB2 will cycle through the textures SAMPLE1, SAMPLE2, SAMPLE3, and SAMPLE4 for that animated texture. It is generally a good idea to number textures/flats that are part of an animation loop consecutively like this, to make sure the right images are included in the loop.
  • Tics [Integer]: Determines how long each individual texture/flat will be displayed before changing to the next, in tics.

ANIMDEFS lumps that were automatically converted from the ANIMATED format (which SRB2 used before v2.1) with SLADE will have the keyword Optional between Texture/Flat and the name of the first texture. This keyword has no effect in SRB2 and can be omitted.

Example

Flat LITEY1 Range LITEY3 Tics 4
Texture GFALL1 Range GFALL4 Tics 2

The first line defines an animated flat that cycles from LITEY1 through LITEY3, changing images every four tics. The second line defines an animated texture that cycles from GFALL1 to GFALL4, changing images every two tics.

See also