Flat

From SRB2 Wiki
Jump to navigation Jump to search
"Flats" redirects here. For a list of flats and textures that are used in SRB2, see Flats and textures.
GFZFLR02, the grass floor that is used in Greenflower Zone, is an example of a flat.

A flat is a graphic that is displayed on the floor or ceiling surfaces of a sector in a map. Like other graphics, flats are stored as lumps in WAD or PK3 files and then referenced by name in the maps that use them. To ensure that flats flow into each other smoothly, the game always aligns them to a fixed grid.[1] In situations where the default alignment is unwanted, sector texture alignment properties or linedef type 7 can be used to displace or rotate the flats of a sector.

Technical specifics

In the original Doom engine, flats are stored as a raw image. Instead of storing the color value of each pixel directly, flats 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 flats. However, SRB2 accepts a patch or a PNG file as a valid flat as well.

Unlike textures, it is not normally possible for flats to have transparent pixels. If this is wanted, the color cyan, which is present at index 255 in SRB2's palette, must be used on the pixels that should turn transparent. Then, if the flat is used on a translucent FOF (such as linedef type 102) with an alpha of #255, these pixels will not be drawn. However, this means the color cyan itself cannot be used as a normal color on flats that are intended to be used with such FOFs, whether or not any pixels on them are meant to be transparent. Otherwise, flats are free to use cyan as a normal color for pixels rather than for transparency.

In PK3 files, flats must be placed in the Flats/ folder in order to be recognized by SRB2. In WAD files, they must be placed between empty marker lumps called F_START and F_END. Alternatively, FF_START and FF_END can also be used, but the former pair is generally favored.

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 floor or ceiling texture, the flat will take priority.

Sizes

The flat format can only have a few specific sizes. In the original Doom engine, only square flats with 4096 bytes (a 64×64-pixel image) were permitted. As such, many WAD editors only support flats of this size and cannot import bigger or smaller images. SRB2, however, supports flat sizes ranging from 1×1 to 2048×2048.

Flat dimensions Lump size (bytes) Lump size (kb)
1×1 1
2×2 4
4×4 16
8×8 64
16×16 256
32×32 1024 1
64×64 4096 4
128×128 16384 16
256×256 65536 64
512×512 262144 256
1024×1024 1048576 1024
2048×2048 4194304 4096

Programs to import flats

Managing flats is a common tool in lump editors. Most of them will convert PNG files to the flat format Doom recognizes. However, some of them only recognize 64×64-pixel flats, while others also support specific additional sizes. Below is a list of common editors along with the image sizes they can import:

Editor Supported sizes
SLADE At least 32×321
SLumpEd 64×64, 128×128
XWE (older versions) 64×64
XWE (newest beta) 64×64, 128×128, 256×256

1 By default, SLADE supports all flat sizes for SRB2 except for 32×32 and lower; flats of those sizes will not be displayed properly. However, this can be fixed manually by opening up slade.pk3 in the folder for SLADE (using SLADE itself), going to the path config/entry_types and modifying the types_gfx_doom.txt file. Here, the lump size in bytes corresponding to the flat size must be added to the list of numbers for the "size" attribute in the gfx_flat section of the file &ndash. After saving the changes and reopening SLADE, flats of sizes smaller than 32×32 will be displayed properly.

References