Difference between revisions of "FTEX (File Format)"

From MK8
Jump to: navigation, search
m
(Undo revision 4208 by Aboood40091 (talk))
Line 7: Line 7:
 
! Offset !! Size !! Type !! Description
 
! Offset !! Size !! Type !! Description
 
|-
 
|-
| 0x00 || 0x04 || Char[4] || '''File magic'''. Always ''FTEX'' in ASCII.
+
| 0x00 || 4 || Char[4] || '''File magic'''. Always ''FTEX'' in ASCII.
 
|-
 
|-
| 0x04 || 0x9C || Struct || '''[[GTX#GX2 Surface|GX2 Surface]]'''.
+
| 0x04 || 4 || UInt32 || '''Dimension'''. Maps to '''GX2SurfaceDim''' (line 849 [http://pastebin.com/DCrP1w9x here]). Indicates the "shape" of a given surface or texture.
 
|-
 
|-
| 0xA0 || 0x04 || UInt32 || '''Texture handle'''. Set at runtime.
+
| 0x08 || 4 || UInt32 || '''Texture width'''. Width of the texture in pixels.
 
|-
 
|-
| 0xA4 || 0x04 || UInt32 || '''Array length''' (seems to be just a byte in MK8 files, with the remaining 3 bytes being padding?).
+
| 0x0C || 4 || UInt32 || '''Texture height'''. Height of the texture in pixels.
 
|-
 
|-
| 0xA8 || 0x04 || Int32 || '''File name''' offset.
+
| 0x10 || 4 || UInt32 || '''Texture depth'''.
 
|-
 
|-
| 0xAC || 0x04 || Int32 || '''File path''' offset, the path of the file this data was originally created from. Stripped in [[Mario Kart 8]] files, always pointing to an empty string at the end of the BFRES [[BFRES (File Format)#String Table|string table]].
+
| 0x14 || 4 || UInt32 || '''Number of mipmaps'''.
 
|-
 
|-
| 0xB0 || 0x04 || Int32 || '''Data offset'''. Offset to the texture data.
+
| 0x18 || 4 || UInt32 || '''Texture format'''. Maps to '''GX2SurfaceFormat''' (line 589 [http://pastebin.com/DCrP1w9x here] for explanation and format values).
 
|-
 
|-
| 0xB4 || 0x04 || Int32 || '''Mipmap offset'''. Offset to the mipmap texture data.
+
| 0x1C || 4 || UInt32 || '''AA mode'''. Maps to '''GX2AAMode''' (line 865 [http://pastebin.com/DCrP1w9x here]). Indicates the AA mode (number of samples) for the surface.
 
|-
 
|-
| 0xB8 || 0x04 || Int32 || '''[[User Data]] [[Index Group]]''' offset.
+
| 0x20 || 4 || UInt32 || '''Usage'''. Maps to '''GX2SurfaceUse''' (line 823 [http://pastebin.com/DCrP1w9x here]). Indicates how the given surface may be used.
 
|-
 
|-
| 0xBC || 0x02 || UInt16 || '''[[User Data]] entry count'''.
+
| 0x24 || 4 || UInt32 || '''Data length'''. Length of texture data in bytes.
 
|-
 
|-
| 0xBE || 0x02 || — || Padding.
+
| 0x28 || 4 || UInt32 || '''Data pointer'''. Set at runtime.
 +
|-
 +
| 0x2C || 4 || UInt32 || '''Mipmaps data length'''. Length of mipmaps data in bytes.
 +
|-
 +
| 0x30 || 4 || UInt32 || '''Mipmaps pointer'''. Set at runtime.
 +
|-
 +
| 0x34 || 4 || UInt32 || '''Tile mode'''. Maps to '''GX2TileMode''' (line 795 [http://pastebin.com/DCrP1w9x here]). Indicates the desired tiling mode for the surface.
 +
|-
 +
| 0x38 || 4 || UInt32 || '''Swizzle value'''.
 +
|-
 +
| 0x3C || 4 || UInt32 || '''Alignment'''. Always 512 * bytes per pixel.
 +
|-
 +
| 0x40 || 4 || UInt32 || '''Pitch'''.
 +
|-
 +
| 0x44 || 0x34 || UInt32[13] || '''Mipmap offsets'''. An array of 13 offsets for each mipmap, relative to the start of the mipmap data.
 +
|-
 +
| 0x78 || 4 || UInt32 || '''First mipmap'''.
 +
|-
 +
| 0x7C || 4 || UInt32 || '''Number of mipmaps''' (again).
 +
|-
 +
| 0x80 || 4 || UInt32 || '''First slice'''. Always 0.
 +
|-
 +
| 0x84 || 4 || UInt32 || '''Number of slices'''. Always 1.
 +
|-
 +
| 0x88 || 4 || Byte[4] || '''Component Selector''', determines which texture color channels are used for each target channel. The bytes map to the Red, Green, Blue and Alpha channel and can receive one of the following channels.
 +
{| class="wikitable"
 +
! Value !! Name !! Description
 +
|-
 +
| 0 || R || The channel will receive the red values of the texture.
 +
|-
 +
| 1 || G || The channel will receive the green values of the texture.
 +
|-
 +
| 2 || B || The channel will receive the blue values of the texture.
 +
|-
 +
| 3 || A || The channel will receive the alpha values of the texture.
 +
|-
 +
| 4 || 0 || The channel will always have a value 0.
 +
|-
 +
| 5 || 1 || The channel will always have a value 1.
 +
|}
 +
|-
 +
| 0x8C || 0x14 || UInt32[5] || '''Texture registers'''. Array of 5 unsigned integers with unknown purpose.
 +
|-
 +
| 0xA0 || 4 || UInt32 || '''Texture handle'''. Set at runtime.
 +
|-
 +
| 0xA4 || 4 || UInt32 || '''Array length''' (seems to be just a byte in MK8 files, with the remaining 3 bytes being padding?).
 +
|-
 +
| 0xA8 || 4 || Int32 || '''File name''' offset.
 +
|-
 +
| 0xAC || 4 || Int32 || '''File path''' offset, the path of the file this data was originally created from. Stripped in [[Mario Kart 8]] files, always pointing to an empty string at the end of the BFRES [[BFRES (File Format)#String Table|string table]].
 +
|-
 +
| 0xB0 || 4 || Int32 || '''Data offset'''. Offset to the texture data.
 +
|-
 +
| 0xB4 || 4 || Int32 || '''Mipmap offset'''. Offset to the mipmap texture data.
 +
|-
 +
| 0xB8 || 4 || Int32 || '''[[User Data]] [[Index Group]]''' offset.
 +
|-
 +
| 0xBC || 2 || UInt16 || '''[[User Data]] entry count'''.
 +
|-
 +
| 0xBE || 2 || — || Padding.
 
|-
 
|-
 
| 0xC0 || colspan="3" {{Unknown|End of '''FTEX''' header}}
 
| 0xC0 || colspan="3" {{Unknown|End of '''FTEX''' header}}

Revision as of 18:52, 30 January 2018

The FTEX (caFe TEXture) texture format is a format for textures which appears as a subfile of a BFRES file. It appears in the 1:st index group in a BFRES file. Unless otherwise noted, all offsets in the file are relative to themselves.

Header (FTEX)

An FTEX file begins with an 0xC0 byte header that starts with the file identifier, followed by info about the texture and mipmaps.

Offset Size Type Description
0x00 4 Char[4] File magic. Always FTEX in ASCII.
0x04 4 UInt32 Dimension. Maps to GX2SurfaceDim (line 849 here). Indicates the "shape" of a given surface or texture.
0x08 4 UInt32 Texture width. Width of the texture in pixels.
0x0C 4 UInt32 Texture height. Height of the texture in pixels.
0x10 4 UInt32 Texture depth.
0x14 4 UInt32 Number of mipmaps.
0x18 4 UInt32 Texture format. Maps to GX2SurfaceFormat (line 589 here for explanation and format values).
0x1C 4 UInt32 AA mode. Maps to GX2AAMode (line 865 here). Indicates the AA mode (number of samples) for the surface.
0x20 4 UInt32 Usage. Maps to GX2SurfaceUse (line 823 here). Indicates how the given surface may be used.
0x24 4 UInt32 Data length. Length of texture data in bytes.
0x28 4 UInt32 Data pointer. Set at runtime.
0x2C 4 UInt32 Mipmaps data length. Length of mipmaps data in bytes.
0x30 4 UInt32 Mipmaps pointer. Set at runtime.
0x34 4 UInt32 Tile mode. Maps to GX2TileMode (line 795 here). Indicates the desired tiling mode for the surface.
0x38 4 UInt32 Swizzle value.
0x3C 4 UInt32 Alignment. Always 512 * bytes per pixel.
0x40 4 UInt32 Pitch.
0x44 0x34 UInt32[13] Mipmap offsets. An array of 13 offsets for each mipmap, relative to the start of the mipmap data.
0x78 4 UInt32 First mipmap.
0x7C 4 UInt32 Number of mipmaps (again).
0x80 4 UInt32 First slice. Always 0.
0x84 4 UInt32 Number of slices. Always 1.
0x88 4 Byte[4] Component Selector, determines which texture color channels are used for each target channel. The bytes map to the Red, Green, Blue and Alpha channel and can receive one of the following channels.
Value Name Description
0 R The channel will receive the red values of the texture.
1 G The channel will receive the green values of the texture.
2 B The channel will receive the blue values of the texture.
3 A The channel will receive the alpha values of the texture.
4 0 The channel will always have a value 0.
5 1 The channel will always have a value 1.
0x8C 0x14 UInt32[5] Texture registers. Array of 5 unsigned integers with unknown purpose.
0xA0 4 UInt32 Texture handle. Set at runtime.
0xA4 4 UInt32 Array length (seems to be just a byte in MK8 files, with the remaining 3 bytes being padding?).
0xA8 4 Int32 File name offset.
0xAC 4 Int32 File path offset, the path of the file this data was originally created from. Stripped in Mario Kart 8 files, always pointing to an empty string at the end of the BFRES string table.
0xB0 4 Int32 Data offset. Offset to the texture data.
0xB4 4 Int32 Mipmap offset. Offset to the mipmap texture data.
0xB8 4 Int32 User Data Index Group offset.
0xBC 2 UInt16 User Data entry count.
0xBE 2 Padding.
0xC0 End of FTEX header

Image Data

The image and mipmap data is not present after the header. It comes after the BFRES string table instead. This seems to be a caching optimization, since the CPU generally doesn't need to handle the image data. Instead it is sent directly to the GPU.