TXD
From MultimediaWiki
Renderware TeXture Dictionary. Used by the Renderware Game Engine, which is used by games like Grand Theft Auto: San Andreas, Sonic The Hedgehog and NRL Rugby League. The format has undergone some changes over the years. The one described here is that in use by Grand Theft Auto: San Andreas. Other versions might be slightly different.
Contents |
[edit]
Generic chunk lay-out
TXD files consist of chunks and sub-chunks, which are really just chunks encapsulated in the data field of other chunks. All chunks have the following basic structure:
typedef struct txd_chunk_s {
uint32_t id;
uint32_t chunk_size; // does not include id, chunk_size and marker
uint32_t marker; // 0x1803ffff or 0x1003ffff
uint8_t data[chunk_size];
} txd_chunk_t;
[edit]
Known chunks
typedef struct txd_file_s {
uint32_t id; // 0x16 (22)
uint32_t chunk_size // file_size - 12
uint32_t marker;
uint8_t data[chunk_size];
} txd_file_t;
typedef struct txd_info_s {
uint32_t id; // 0x01 (1)
uint32_t chunk_size; // 0x04 (4)
uint32_t marker;
uint16_t count; // number of textures in the dictionary
uint16_t unknown;
} txd_info_t;
typedef struct txd_texture_s {
uint32_t id; // 0x15 (21)
uint32_t chunk_size;
uint32_t marker;
uint8_t data[chunk_size];
} txd_texture_t;
typedef struct txd_texture_data_s {
uint32_t id; // 0x01 (1)
uint32_t chunk_size;
uint32_t marker;
uint32_t version; // 0x08 (8) or 0x09 (9)
uint32_t filter_flags;
char texture_name[32];
char alpha_name[32];
uint32_t alpha_flags;
uint32_t direct3d_texture_format; // see below
uint16_t width;
uint16_t height;
uint8_t depth;
uint8_t mipmap_count;
uint8_t texcode_type;
uint8_t flags;
uint8_t palette[depth==8 ? 256 * 4 : 0];
uint32_t data_size;
uint8_t data[data_size];
struct mipmaps_s {
uint32_t data_size;
uint8_t data[data_size];
} mipmaps[mipmap_count - 1];
} txd_texture_data_t;
typedef struct txd_extra_info_s {
uint32_t id; // 0x03 (3)
uint32_t chunk_size;
uint32_t marker;
uint8_t data[chunk_size];
} txd_extra_info_t;
direct3d_texture_format can be one of:
- S3TC FourCC
- 0x21 - RGBA32
- 0x22 - RGB32
- 0x00 and flags & 1 is set - S3TC DXT1 compression (used in old version 8 files)
[edit]
Basic file structure
Indentation means the chunks are sub-chunks (see above):
- txd_file_t
- txd_info_t
- txd_texture_t
- txd_texture_data_t
- txd_extra_info_t
- txd_texture_t
- txd_texture_data_t
- txd_extra_info_t
- ...
- txd_extra_info_t
[edit]
Notes
- Chunk id's are scope-dependent. For example, within the txd_file_t chunk, a chunk with id 0x01 is a txd_info_t chunk, but within a txd_texture_t chunk, id 0x01 is used by txd_texture_data_t chunks.
