|Version 1 (modified by Philip, 3 years ago) (diff)|
Texture file format
- Textures should be in PNG format.
- Textures must be power-of-two sizes (width and height must be 64, 128, 256, 512, etc; non-square sizes like 256x512 are fine too).
- Textures go in an art/textures/ directory (typically binaries/data/mods/public/art/textures/)
PNG files are small on disk, but they expand to 32-bit raw RGBA format in video memory when they're loaded. Reducing video memory usage is important for performance, especially on lower-end hardware. DXTC (also known as S3TC) is a way to store compressed textures in video memory, in three different formats (DXT1, DXT3, DXT5). For example, a 512x512 texture is:
- RGBA: 1024 kB
- DXT1: 128 kB
- DXT3: 256 kB
- DXT5: 256 kB
Compression allows us to increase the number or size of textures by 4x or 8x without hurting performance. The tradeoff is that the compression is lossy, causing ugly artifacts in some textures.
DXT1, DXT3 and DXT5 all store the RGB channels in precisely the same way. The only difference is the alpha channel. The Wolfire Games blog (no relation to Wildfire Games) has some examples.
- DXT1: 1-bit alpha: good for textures that are all solid, or for UI elements with non-antialiased transparency masks. Generally unsuitable for non-solid world textures - even if the texture only needs 1-bit alpha, its mipmaps are likely to need semi-transparent pixels.
- DXT3: 4-bit alpha: good for textures with a wide range of alpha values in a 4x4 block of pixels; bad for smooth alpha gradients.
- DXT5: 3-bit alpha gradient: good for smooth gradients; fine for most of the cases where DXT3 is good. You should generally use this instead of DXT3.