Texture

From SRB2 Wiki
Jump to navigation Jump to search
This article or section is outdated and has not been fully updated to reflect the current version of SRB2.

Please help the Wiki by correcting or removing any misinformation, as well as adding any new information to the page.

To do
Document composite texture features added in v2.2: patch flipping, opacity and blend modes.
"Textures" redirects here. For a list of flats and textures that are used in SRB2, see Flats and textures.

A texture is a graphic that is displayed on the wall surfaces of a linedef in a map. A texture can be either a single image or a composite of several smaller images.

Format

Textures are stored as lumps of image data. In the original Doom engine, instead of storing the color value of each pixel directly, textures simply store an index number that corresponds to an entry in the game's palette of 256 colors. Therefore, changing the palette that is used by the game will also change the appearance of all textures. However, SRB2 accepts a PNG file as a valid texture as well.

There are two ways of creating textures out of the stored images: One is to use the images directly as textures. The other is to combine several individual images into a composite texture. In this case, the individual images are called patches. While the direct method is simpler, the composite method is useful for textures in which parts of the texture are repeated multiple times. Since the repeating parts are stored only once as images, the composite version of the texture takes up less space than the direct version would.

Composite textures are defined in special text lump called TEXTURES. The definition of a composite texture consists of its name, its size, and a list of the included patches along with their overall position in the texture. The format of the TEXTURES lump is taken from the Doom source port ZDoom. Some lump editors, such as SLADE, recognize this format and provide a graphical editor for creating composite textures. However, since TEXTURES is a plain text lump, even lump editors that do not recognize it can be used to edit it in text form. See the section below for information on how the contents of the lump are formatted.

In PK3 files, images that are used directly as textures must be placed in the Textures/ folder in order to be recognized by SRB2. In WAD files, they must be placed between empty marker lumps called TX_START and TX_END. Images that are only used as patches in composite textures can be stored anywhere, but for easy navigability they are often placed in the Patches/ folder (in the case of PK3 files) or between empty marker lumps called P_START and P_END (in the case of WAD files).

SRB2 unifies textures and flats into the same namespace. If both a texture and a flat have the same name, and said name is being used as a wall texture, the texture will take priority.

TEXTURES

The general format of a texture defined in the TEXTURES lump is the following:

WallTexture TEXTNAME, width, height
{
	Patch P1NAME, x1, y1
	Patch P2NAME, x2, y2
	...
}

Each texture definition starts with the keyword WallTexture. Following this, TEXTNAME is a name of your choice up to eight characters long that is unique to the texture itself – ideally this should not match the name of any of the patches the texture consists of. width and height determine the dimensions of the full texture in pixels; note that the restrictions given in the section above for widths and heights still apply here.

Within the pair of braces, { and }, is the list of patches the texture consists of. This can be as many patches as necessary for the texture, and can even include multiple copies of the same patch at different positions.

Each line for an individual patch in the texture must start with the keyword Patch. Following this is the name of the patch to use – this can be the name of any existing patch located in the WAD or PK3 file, including single-patch textures already defined in the Textures/ folder or between the TX_START and TX_END markers, respectively. After this are the X and Y coordinates the top-left corner of the patch is located at, relative to the top-left corner of the space within the texture itself. Note that 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.

Example

An example of a composite texture included with SRB2 is GFZROCK. It is 128×128 pixels in size, and is built from four 64×64 patches for each of its four squares within: two GFZTILA1 patches, and two GFZTILA2 patches. Shown below is the texture definition for GFZROCK, taken directly from the TEXTURES.gfz file in srb2.pk3.

WallTexture "GFZROCK", 128, 128
{
	Patch "GFZTILA1", 0, 0
	Patch "GFZTILA2", 64, 0
	Patch "GFZTILA2", 0, 64
	Patch "GFZTILA1", 64, 64
}

Transparency

Textures can contain transparent pixels. SLADE allows the user to pick the color that is converted to transparency, which makes it possible to use non-transparent cyan pixels in a texture – however, this only works for textures that use only a single patch; composite textures will not draw cyan pixels regardless of this. Aside from allowing for partially transparent textures, this also allows for partially transparent patches to be laid on top of entirely opaque patches to create more detailed composite textures.

Partially transparent textures should only be used on middle textures, or any type of FOF that doesn't have the FF_CUTSOLID flag (such as linedef types 220 or 222). Otherwise, the tutti-frutti effect will occur. Textures with multiple patches will never display pixels with palette index 255 on middle textures or FOFs without FF_CUTSOLID, regardless of whether the textures are partially transparent or not, and those pixels will instead be treated as if they were transparent areas. On the other hand, textures with a single patch can display palette index 255 on these same areas of a map only if they are also partially transparent.

See also