From MultimediaWiki
Jump to navigation Jump to search

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.

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 rw_version;
 uint8_t  data[chunk_size];
} txd_chunk_t;

Known chunks

typedef struct txd_file_s {
 uint32_t id;               // 0x16 (22)
 uint32_t chunk_size        // file_size - 12
 uint32_t rw_version;
 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 rw_version;
 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 rw_version;
 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 rw_version;
 uint32_t version;                    // 0x08 (8) or 0x09 (9)
 uint32_t filter_flags;
 uint8_t  texture_name[32];           // treat as a char array, but make sure 8-bit chars are specified
 uint8_t  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 rw_version;
 uint8_t  data[chunk_size];
} txd_extra_info_t;


This is the format of the texture data found in txd_texture_data_t::data. This value must be known if the textures are to be extracted. It can be one of:

  • 0x21 - RGBA32
  • 0x22 - RGB32
  • 0x00 and flags & 1 is set - S3TC DXT1 compression (used in old version 8 files)

Additionally, direct3d_texture_format may be a four character code ("FourCC") relating to a DXT format. In such cases, the unsigned integer value is actually the concatenated bytes of the FourCC. For example, 0x44585431 is "DXT1" (44 58 54 31).


This is the identifier of the version of the RenderWare engine that the file is for. It can be found in many types of RenderWare binary stream file.

rw_version Hex RenderWare Version
0x0800FFFF 3.?.?.?

Basic file structure

Chunks other than txd_file_t (which has no parent chunk) are nested within the parent chunk's data array. For example, txd_info_t is found within txd_file_t::data.



*txd_texture_t... blocks repeated. The number of repetitions differs between files, and is dictated by the value of txd_info_t::count.


  • Chunk IDs 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.
  • The C structures on this page should be assumed to be packed (as if with #pragma pack or __attribute__((packed))) if they are to be read directly from a file.
  • All values are stored in little endian format for both bits and bytes. (Therefore, for multi-byte values, the least significant byte goes in the lowest addressed memory slot.)