Texture

From SRB2 Wiki
Jump to: navigation, search
This article is about the graphics that are displayed on walls. For the graphics that are displayed on floors and ceilings, see Flat.
"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. 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. If SRB2's palette is applied onto an image using a graphics editing program such as Paint Shop Pro, they will display in the same colors as they do in the game. The width of a texture image must be a power of two, such as 2, 4, 8, 16, 32, 64, 128 and so forth. The height can be anything.

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.

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.

For easy navigability and in order to make lump editors recognize them as such, images that are used directly as textures should be stored between empty marker lumps called TX_START and TX_END. Images that are only used as patches in composite textures should be stored between empty marker lumps called P_START and P_END.

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 matching 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 }, are 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 between the markers P_START and P_END, or any existing single-patch texture located between the markers TX_START and TX_END. 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 GFZTIL01 patches, and two GFZTIL02 patches. The text below is this texture's definition directly taken from srb2.srb's own TEXTURES lump.

walltexture GFZROCK, 128, 128 {
	patch GFZTIL01, 0, 0
	patch GFZTIL02, 64, 0
	patch GFZTIL02, 0, 64
	patch GFZTIL01, 64, 64
}

Transparency

Textures can contain transparent pixels. XWE will automatically convert any pixels with the palette index 247 (cyan) to transparency. 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. However, 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.

See also