Difference between revisions of "FTEX (File Format)"
Jump to navigation
Jump to search
(→Header (FTEX): Confirm array sizes, add enum names.) |
(Why use upper case?) |
||
Line 8: | Line 8: | ||
! Offset !! Size !! Description | ! Offset !! Size !! Description | ||
|- | |- | ||
− | | 0x00 || 4 || '''File | + | | 0x00 || 4 || '''File magic'''. Always ''FTEX'' in ASCII. |
|- | |- | ||
| 0x04 || 4 || '''Dimension'''. Maps to '''GX2SurfaceDim''' (line 849 [http://pastebin.com/DCrP1w9x here]). Indicates the "shape" of a given surface or texture. | | 0x04 || 4 || '''Dimension'''. Maps to '''GX2SurfaceDim''' (line 849 [http://pastebin.com/DCrP1w9x here]). Indicates the "shape" of a given surface or texture. | ||
|- | |- | ||
− | | 0x08 || 4 || '''Texture | + | | 0x08 || 4 || '''Texture width'''. Width of the texture in pixels. |
|- | |- | ||
− | | 0x0C || 4 || '''Texture | + | | 0x0C || 4 || '''Texture height'''. Height of the texture in pixels. |
|- | |- | ||
| 0x10 || 4 || '''Depth'''. | | 0x10 || 4 || '''Depth'''. | ||
|- | |- | ||
− | | 0x14 || 4 || '''Number of | + | | 0x14 || 4 || '''Number of mipmaps'''. |
|- | |- | ||
− | | 0x18 || 4 || '''Texture | + | | 0x18 || 4 || '''Texture format'''. Maps to '''GX2SurfaceFormat''' (line 589 [http://pastebin.com/DCrP1w9x here] for explanation and format values). |
|- | |- | ||
− | | 0x1C || 4 || '''AA | + | | 0x1C || 4 || '''AA mode'''. Maps to '''GX2AAMode''' (line 865 [http://pastebin.com/DCrP1w9x here]). Indicates the AA mode (number of samples) for the surface. |
|- | |- | ||
| 0x20 || 4 || '''Usage'''. Maps to '''GX2SurfaceUse''' (line 823 [http://pastebin.com/DCrP1w9x here]). Indicates how the given surface may be used. | | 0x20 || 4 || '''Usage'''. Maps to '''GX2SurfaceUse''' (line 823 [http://pastebin.com/DCrP1w9x here]). Indicates how the given surface may be used. | ||
|- | |- | ||
− | | 0x24 || 4 || '''Data | + | | 0x24 || 4 || '''Data length'''. Length of texture data in bytes. |
|- | |- | ||
− | | 0x28 || 4 || '''Data | + | | 0x28 || 4 || '''Data pointer'''. Set at runtime. |
|- | |- | ||
− | | 0x2C || 4 || '''Mipmaps | + | | 0x2C || 4 || '''Mipmaps data length'''. Length of mipmaps data in bytes. |
|- | |- | ||
− | | 0x30 || 4 || '''Mipmaps | + | | 0x30 || 4 || '''Mipmaps pointer'''. Set at runtime. |
|- | |- | ||
− | | 0x34 || 4 || '''Tile | + | | 0x34 || 4 || '''Tile mode'''. Maps to '''GX2TileMode''' (line 795 [http://pastebin.com/DCrP1w9x here]). Indicates the desired tiling mode for the surface. |
|- | |- | ||
− | | 0x38 || 4 || '''Swizzle | + | | 0x38 || 4 || '''Swizzle value'''. |
|- | |- | ||
| 0x3C || 4 || '''Alignment'''. Always 512 * bytes per pixel. | | 0x3C || 4 || '''Alignment'''. Always 512 * bytes per pixel. | ||
Line 42: | Line 42: | ||
| 0x40 || 4 || '''Pitch'''. | | 0x40 || 4 || '''Pitch'''. | ||
|- | |- | ||
− | | 0x44 || 0x34 || '''Mipmap | + | | 0x44 || 0x34 || '''Mipmap offsets'''. An array of 13 offsets for each mipmap, relative to the start of the mipmap data. |
|- | |- | ||
− | | 0x78 || 4 || '''First | + | | 0x78 || 4 || '''First mipmap'''. |
|- | |- | ||
− | | 0x7C || 4 || '''Number of | + | | 0x7C || 4 || '''Number of mipmaps''' (again). |
|- | |- | ||
− | | 0x80 || 4 || '''First | + | | 0x80 || 4 || '''First slice'''. Always 0. |
|- | |- | ||
− | | 0x84 || 4 || '''Number of | + | | 0x84 || 4 || '''Number of slices'''. Always 1. |
|- | |- | ||
| 0x88 || 4 || '''GX2CompSel'''. | | 0x88 || 4 || '''GX2CompSel'''. | ||
|- | |- | ||
− | | 0x8C || 0x14 || '''Texture | + | | 0x8C || 0x14 || '''Texture registers'''. Array of 5 unsigned integers with unknown purpose. |
|- | |- | ||
− | | 0xA0 || 4 || '''Texture | + | | 0xA0 || 4 || '''Texture handle'''. Set at runtime. |
|- | |- | ||
− | | 0xA4 || 4 || '''Array | + | | 0xA4 || 4 || '''Array length''' (seems to be just a byte in MK8 files, with the remaining 3 bytes being padding?). |
|- | |- | ||
− | | 0xA8 || 4 || '''File | + | | 0xA8 || 4 || '''File name''' offset. |
|- | |- | ||
− | | 0xAC || 4 || '''End of BFRES | + | | 0xAC || 4 || '''End of BFRES string table''' offset. Points to just after the last string in the string table. Originally pointed to a string being the file path of the file the FTEX data was created from, which has been removed in the released game. |
|- | |- | ||
− | | 0xB0 || 4 || '''Data | + | | 0xB0 || 4 || '''Data offset'''. Offset to the texture data. |
|- | |- | ||
− | | 0xB4 || 4 || '''Mipmap | + | | 0xB4 || 4 || '''Mipmap offset'''. Offset to the mipmap texture data. |
|- | |- | ||
− | | 0xB8 || 4 || '''[[BFRES (File Format)#User Data|User | + | | 0xB8 || 4 || '''[[BFRES (File Format)#User Data|User data]] [[Index Group]]''' offset. |
|- | |- | ||
− | | 0xBC || 2 || '''[[BFRES (File Format)#User Data|User | + | | 0xBC || 2 || '''[[BFRES (File Format)#User Data|User data]] entry count'''. |
|- | |- | ||
| 0xBE || 2 || '''Padding'''. | | 0xBE || 2 || '''Padding'''. |
Revision as of 22:12, 28 May 2017
Under Construction
This article is not finished. Help improve it by adding accurate information or correcting grammar and spelling.
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 | Description |
---|---|---|
0x00 | 4 | File magic. Always FTEX in ASCII. |
0x04 | 4 | Dimension. Maps to GX2SurfaceDim (line 849 here). Indicates the "shape" of a given surface or texture. |
0x08 | 4 | Texture width. Width of the texture in pixels. |
0x0C | 4 | Texture height. Height of the texture in pixels. |
0x10 | 4 | Depth. |
0x14 | 4 | Number of mipmaps. |
0x18 | 4 | Texture format. Maps to GX2SurfaceFormat (line 589 here for explanation and format values). |
0x1C | 4 | AA mode. Maps to GX2AAMode (line 865 here). Indicates the AA mode (number of samples) for the surface. |
0x20 | 4 | Usage. Maps to GX2SurfaceUse (line 823 here). Indicates how the given surface may be used. |
0x24 | 4 | Data length. Length of texture data in bytes. |
0x28 | 4 | Data pointer. Set at runtime. |
0x2C | 4 | Mipmaps data length. Length of mipmaps data in bytes. |
0x30 | 4 | Mipmaps pointer. Set at runtime. |
0x34 | 4 | Tile mode. Maps to GX2TileMode (line 795 here). Indicates the desired tiling mode for the surface. |
0x38 | 4 | Swizzle value. |
0x3C | 4 | Alignment. Always 512 * bytes per pixel. |
0x40 | 4 | Pitch. |
0x44 | 0x34 | Mipmap offsets. An array of 13 offsets for each mipmap, relative to the start of the mipmap data. |
0x78 | 4 | First mipmap. |
0x7C | 4 | Number of mipmaps (again). |
0x80 | 4 | First slice. Always 0. |
0x84 | 4 | Number of slices. Always 1. |
0x88 | 4 | GX2CompSel. |
0x8C | 0x14 | Texture registers. Array of 5 unsigned integers with unknown purpose. |
0xA0 | 4 | Texture handle. Set at runtime. |
0xA4 | 4 | Array length (seems to be just a byte in MK8 files, with the remaining 3 bytes being padding?). |
0xA8 | 4 | File name offset. |
0xAC | 4 | End of BFRES string table offset. Points to just after the last string in the string table. Originally pointed to a string being the file path of the file the FTEX data was created from, which has been removed in the released game. |
0xB0 | 4 | Data offset. Offset to the texture data. |
0xB4 | 4 | Mipmap offset. Offset to the mipmap texture data. |
0xB8 | 4 | User data Index Group offset. |
0xBC | 2 | 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 don't need to handle the image data. Instead it is sent directly to the GPU.