Difference between revisions of "FTEX (File Format)"
Jump to navigation
Jump to search
Aboood40091 (talk | contribs) m |
m (Reverted edits by Aboood40091 (talk) to last revision by Wexos) |
||
(16 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | + | The '''FTEX''' (ca'''F'''e '''TEX'''ture) texture format is a format for textures which appears as a subfile of a '''[[BFRES (File Format)|BFRES file]]'''. It appears in the '''1:st''' [[index group]] in a [[BFRES (File Format)|BFRES file]]. Unless otherwise noted, all offsets in the file are relative to themselves. | |
− | |||
− | |||
== Header (FTEX) == | == 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. | ||
− | |||
{| class="wikitable" | {| class="wikitable" | ||
− | ! Offset | + | ! Offset !! Size !! Type !! Description |
− | ! Size | + | |- |
− | ! Description | + | | 0x00 || 4 || Char[4] || '''File magic'''. Always ''FTEX'' in ASCII. |
+ | |- | ||
+ | | 0x04 || 4 || UInt32 || '''Dimension'''. Maps to '''GX2SurfaceDim''' (line 849 [http://pastebin.com/DCrP1w9x 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 [http://pastebin.com/DCrP1w9x here] for explanation and format values). |
− | | 4 | ||
− | | | ||
|- | |- | ||
− | | | + | | 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. |
− | | 4 | ||
− | | ''' | ||
|- | |- | ||
− | | | + | | 0x20 || 4 || UInt32 || '''Usage'''. Maps to '''GX2SurfaceUse''' (line 823 [http://pastebin.com/DCrP1w9x here]). Indicates how the given surface may be used. |
− | | 4 | ||
− | | ''' | ||
|- | |- | ||
− | | | + | | 0x24 || 4 || UInt32 || '''Data length'''. Length of texture data in bytes. |
− | | 4 | ||
− | | ''' | ||
|- | |- | ||
− | | | + | | 0x28 || 4 || UInt32 || '''Data pointer'''. Set at runtime. |
− | | 4 | ||
− | | ''' | ||
|- | |- | ||
− | | | + | | 0x2C || 4 || UInt32 || '''Mipmaps data length'''. Length of mipmaps data in bytes. |
− | | 4 | ||
− | | ''' | ||
|- | |- | ||
− | | | + | | 0x30 || 4 || UInt32 || '''Mipmaps pointer'''. Set at runtime. |
− | | 4 | ||
− | | ''' | ||
|- | |- | ||
− | | | + | | 0x34 || 4 || UInt32 || '''Tile mode'''. Maps to '''GX2TileMode''' (line 795 [http://pastebin.com/DCrP1w9x here]). Indicates the desired tiling mode for the surface. |
− | | 4 | ||
− | | ''' | ||
|- | |- | ||
− | | | + | | 0x38 || 4 || UInt32 || '''Swizzle value'''. |
− | | 4 | ||
− | | ''' | ||
|- | |- | ||
− | | | + | | 0x3C || 4 || UInt32 || '''Alignment'''. Always 512 * bytes per pixel. |
− | | 4 | ||
− | | ''' | ||
|- | |- | ||
− | | | + | | 0x40 || 4 || UInt32 || '''Pitch'''. |
− | | 4 | ||
− | | ''' | ||
|- | |- | ||
− | | | + | | 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'''. |
− | | 4 | ||
− | | ''' | ||
|- | |- | ||
− | | | + | | 0x7C || 4 || UInt32 || '''Number of mipmaps''' (again). |
− | | 4 | ||
− | | ''' | ||
|- | |- | ||
− | | | + | | 0x80 || 4 || UInt32 || '''First slice'''. Always 0. |
− | | 4 | ||
− | | ''' | ||
|- | |- | ||
− | | | + | | 0x84 || 4 || UInt32 || '''Number of slices'''. Always 1. |
− | | 4 | ||
− | | ''' | ||
|- | |- | ||
− | | | + | | 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. |
− | | 4 | + | {| 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?). |
− | | 4 | ||
− | | ''' | ||
|- | |- | ||
− | | | + | | 0xA8 || 4 || Int32 || '''File name''' offset. |
− | | 4 | ||
− | | | ||
|- | |- | ||
− | | | + | | 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]]. |
− | | 4 | ||
− | | | ||
|- | |- | ||
− | | | + | | 0xB0 || 4 || Int32 || '''Data offset'''. Offset to the texture data. |
− | | 4 | ||
− | | | ||
|- | |- | ||
− | | | + | | 0xB4 || 4 || Int32 || '''Mipmap offset'''. Offset to the mipmap texture data. |
− | | | ||
− | | | ||
|- | |- | ||
− | | | + | | 0xB8 || 4 || Int32 || '''[[User Data]] [[Index Group]]''' offset. |
− | | 4 | ||
− | | '''Data | ||
|- | |- | ||
− | | | + | | 0xBC || 2 || UInt16 || '''[[User Data]] entry count'''. |
− | | | ||
− | | ''' | ||
|- | |- | ||
− | | | + | | 0xBE || 2 || — || Padding. |
− | | | ||
− | | | ||
|- | |- | ||
− | | 0xC0 | + | | 0xC0 || colspan="3" {{Unknown|End of '''FTEX''' header}} |
− | | colspan=" | ||
|} | |} | ||
− | + | == Image Data == | |
+ | The image and mipmap data is not present after the header. It comes after the [[BFRES (File Format)#String Table|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. | ||
[[Category:File Format]] | [[Category:File Format]] |
Latest revision as of 14:17, 19 June 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.
| |||||||||||||||||||||
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.