Texture Native Struct
{{{NAME}}} | |
---|---|
RenderWare Stream Section | |
Vendor | {{{VENDORNAME}}} |
Module | {{{MODULENAME}}} |
Module ID | 0x{{{MODULEID}}}
|
Identifier | 0x{{{IDENTIFIER}}}
|
Chunk ID | 0x{{{MODULEID}}}{{{IDENTIFIER}}}
|
Versions | All |
Hierarchy | |
Parents: None | |
Children: None | |
Extensions: None | |
File Format |
This article is about the Struct section accompanied by a Texture Native parent section.
The Texture Native Struct section can usually be found in texture archives used by the PC and XBOX versions of the GTA III game trilogy. They are the most important sections inside a
.txd
file since they contain the names, dimensions and the actual image data for textures. The typical location in the file's section hierarchy is Texture Dictionary > Texture Native > Struct.
Header
There is a 88 byte header with general image information:
4b - DWORD - Platform ID 2b - WORD - Filter Flags 1b - BYTE - Texture Wrap V 1b - BYTE - Texture Wrap U 32b - CHAR[32] - Diffuse Texture Name (null-terminated string) 32b - CHAR[32] - Alpha Texture Name (null-terminated string) 4b - DWORD - Raster Format 4b - DWORD - Alpha/FOURCC 2b - WORD - Image Width 2b - WORD - Image Height 1b - BYTE - Bits Per Pixel (BPP) 1b - BYTE - Mipmap Count 1b - BYTE - Raster Type, always 0x04 ("Texture") 1b - BYTE - DXT Compression Type
- Platform ID
- This is 8 for GTA3 and VC on the PC, 9 for GTA SA on the PC, and 5 for GTA3/VC/SA on the XBOX.
- Filter Flags
FILTER_NONE 0x00 FILTER_NEAREST 0x01 FILTER_LINEAR 0x02 FILTER_MIP_NEAREST 0x03 FILTER_MIP_LINEAR 0x04 FILTER_LINEAR_MIP_NEAREST 0x05 FILTER_LINEAR_MIP_LINEAR 0x06
- Texture Wrap
WRAP_NONE 0x00 WRAP_WRAP 0x01 WRAP_MIRROR 0x02 WRAP_CLAMP 0x03
- Raster Format
FORMAT_DEFAULT 0x0000 FORMAT_1555 0x0100 (1 bit alpha) FORMAT_565 0x0200 FORMAT_4444 0x0300 FORMAT_LUM8 0x0400 (gray scale) FORMAT_8888 0x0500 FORMAT_888 0x0600 FORMAT_555 0x0A00 FORMAT_EXT_AUTO_MIPMAP 0x1000 (RW generates mipmaps) FORMAT_EXT_PAL8 0x2000 (2^8 = 256 palette colors) FORMAT_EXT_PAL4 0x4000 (2^4 = 16 palette colors) FORMAT_EXT_MIPMAP 0x8000 (mipmaps included)
- Alpha/FOURCC
- Usually this defines if the alpha channel is used (0: no, 1: yes), but for platform 9 this is the FOURCC of the used DXTn compression type or something else for other formats (currently unknown).
- BPP
- 8, 16 or 32; 8 usually comes with palette
- DXT Compression Type
- If greater than 0 the raster data is DXT compressed. This value directly defines the DXT compression (e.g. 3 means DXT3). For more information, refer to S3 Texture Compression.
Raster Data
The header is followed by an optional palette and the raster data (pixels), according to the Raster Format flags.
If Raster Format is FORMAT_EXT_PAL8 | FORMAT_8888
or FORMAT_EXT_PAL8 | FORMAT_888
, then a color palette of (up to) 256 RGBA colors is included. This is used in GTA3 quite often. The raster's one byte for each pixel is an index into the palette.
1024 byte - BYTE[256][4] - palette of RGBA colors 4 byte - DWORD - raster size w*h*1 byte - BYTE[w*h] - pixels, 1 byte each
If no palette is included, the header is followed by raster size and data. If mipmaps are included (FORMAT_EXT_MIPMAP
) then this is repeated for each mipmap. With increasing mipmap levels the raster size is decreased by the factor 4 (side lengths halved). Small initial textures can result in mipmaps of the size 0. For uncompressed images:
4 byte - DWORD - raster size w*h*bpp/8 byte - BYTE[w*h][bpp/8] - pixels
Note: FORMAT_888(8) rasters use BGRA colors!
If DXT compression is used, blocks of 4x4 pixels occupy only 8 or 16 bytes (depending on the type).