Difference between revisions of "Texture Native Struct"

From GTAMods Wiki
Jump to navigation Jump to search
(Image Data)
m (Image Data)
Line 50: Line 50:
  
 
The header is followed by image data.
 
The header is followed by image data.
 
''- todo (size, palette, pixels, mipmaps) -''
 
  
 
===8 bit per pixel===
 
===8 bit per pixel===

Revision as of 01:11, 22 November 2006

{{{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
 4b - DWORD    - Filter Flags
32b - CHAR[32] - Diffuse Texture Name (null-terminated string)
32b - CHAR[32] - Alpha Texture Name (null-terminated string)
 4b - DWORD    - Image Flags
 4b - DWORD    - Is alpha used? (0: no, 1: yes); Platform 9 uses DXT* codes here
 2b - WORD     - Image Width
 2b - WORD     - Image Height
 1b - BYTE     - Bit Depth
 1b - BYTE     - Mipmap Count
 1b - BYTE     - unknown, always 4
 1b - BYTE     - 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
- todo -
Image Flags
- todo -
// 512 = 16bpp no alpha
// 768 = 16bpp with alpha

// 9728= 8bpp no alpha
// 9472= 8bpp with alpha

// 1536= 32bpp no alpha   < -+- SET IF ANY XBOX
// 1280= 32bpp with alpha < /

// 512? = dxt1 no alpha
// 768 = dxt3 with alpha
// ? = dxt3 no alpha

// 256 = used in generic.txd (first of 2 duplicates in img file)
// and in hud.txd too

// 6 = was used for body in ashdexx's sample
// custom xbox working txd
Bit Depth
8, 16 or 32; 8 comes with palette
Compression Type
- todo -

Image Data

The header is followed by image data.

8 bit per pixel

The 8 bit textures make use of a color palette, so they only support up to 256 different colors. The one byte for each pixel is an index into the palette.

1024 byte  - BYTE[256][4] - palette of RGBA colors
4 byte     - DWORD        - size of pixel data
w*h*1 byte - BYTE[w*h]    - pixels, 1 byte each

16 bit per pixel

- todo -

32 bit per pixel

4 byte     - DWORD        - size of pixel data
w*h*4 byte - BYTE[w*h][4] - pixels, 4 byte each (BGRA colors!)

DXT compressed

- todo (mipmaps!) -