On this page
What goes into a texture
Almost every texture in the three games is a DirectX DDS file: block-compressed, with its mip chain already in the file, so the loader copies bytes straight to the GPU. Names matter: a suffix tells the loaders what a map is for.
DDS and the mip chain#

bf2-texture reads a DDS the way the two retail loaders see it (lib.rs module doc): dds.rs Dds::parse computes what D3DX reports (format, size, mip count, cube / volume), Dds::surface(face, level) slices one level, and decode.rs decode_rgba8 decodes it on the CPU. RendDX9's TextureManager (manager.rs) never decodes: it asks for the image info, then copies each level's bytes into the texture, after its own mip clamp and quality skip (a lower texture quality setting drops the top levels).
| Format | Bits per texel | Alpha | Seen in (these pages' examples) |
|---|---|---|---|
| DXT1 | 4 | none or 1 bit | the jeep's colour and wreck maps, the house, p_rocks_b.dds (normal), trunk_mt_de.dds (detail) |
| DXT3 | 8 | 4-bit explicit | ch_vehicleglass_b.dds (a vehicle glass normal map) |
| DXT5 | 8 | interpolated 8-bit | sprite_mt_leaftree_03.dds (the leaf sprites) |
| A8R8G8B8, X8R8G8B8, R8G8B8, R5G6B5, A4R4G4B4, P8 | 8-32 | varies | the uncompressed formats of retail files, decoded and checked against D3DX |
| TGA (32-bit) | 32 | 8-bit | Heroes hero item textures (composed into an atlas, below) |
The decoders of the formats retail files use are verified against D3DX (decode.rs decode_rgba8 doc). 2142 and Heroes use the same formats as BF2; the enhanced texture pack's DX10 files (BC4 / BC5 / BC7) are beyond retail (dx10.rs).
Names the loaders act on#

_b.dds: for a bundled mesh, map 1 ending in_b.ddsis the normal map; any other later map that is not aSpecularLUTmarks a GI map (bf2-renderbundledmesh.rs,BundledMeshStateManager::readState).- alpha: the material's alpha mode decides what alpha means: 1 blend, 2 test (cut out at a threshold); with the
ColormapGlosstechnique the colour map's alpha is the gloss. _de.dds: a detail map, tiled over a static mesh's base colour in its own UV set (TEXCOORD1 + the detail index; bf2-meshMeshFile::texcoords)._w.dds: the jeep's wreck geometry (geometry 2) takes the colour map plus this second map (materials shows the slots).
Heroes: the hero atlas and the colour tables#
A hero's look is not stored in one texture. Every worn item adds a TGA that is painted into a 1024 x 1024 atlas at the rectangle of its item type; the item meshes' UVs point into that rectangle (bfh-client hero_mesh.rs compose_atlas).

Skin and hair items are drawn grey. Before they go into the atlas each texel is overlaid with the hero's colour from Colors.xml (9 skin tones, 5 hair colours): s < 128 ? 2cs / 255 : 255 - 2(255 - c)(255 - s) / 255 per channel, then blended by the texel's alpha (bfh-client hero_mesh.rs overlay, RendDX9.dll@bfh!0x1013c43f).

How it is tested#
- Every shipped texture goes through the reader (
crates/bf2-texture/tests/retail.rs); where the reference table exists, the image's info and its decoded top level are compared with what the game's own DirectX helper library gives. - Name resolution (
resolution.rs): every material map of every mesh in the object archives and every atlas texture resolves through the file manager as the original's texture manager would. - Writing (
crates/bf2-gltf/tests/d3dx_parity.rs,nvdxt_parity.rs): the port's DDS encoders against files written by the game's own helper library and by the 2005 editor's converter. Those reference files are small images made for the test.
All of the reading tests need an install and are skipped without one.
Where it is read#
| Step | bf2-rs |
|---|---|
| file detection, image info | bf2-texture info.rs detect, image_info |
| DDS levels | bf2-texture dds.rs Dds::parse, Dds::surface |
| CPU decode (thumbnails, Flash images, tools) | bf2-texture decode.rs decode_rgba8, lib.rs decode_d3dx |
| TextureManager rules (paths, mip clamp) | bf2-texture manager.rs |
texture atlases (.tai) | bf2-texture atlas.rs |
| hero atlas and tints | bfh-client hero_mesh.rs compose_atlas, overlay |
The per-patch colour, detail and light maps of a terrain are on terrain; the animated sprite atlases of particles on effects.
docs/dev/assets/texture.md · built from bf2-rs e3b4f05 · part of the Battlefield 2 / 2142 / Heroes reimplementation. Not affiliated with EA or DICE.