Difference between revisions of "GTX\GSH (File Format)"
Jump to navigation
Jump to search
Aboood40091 (talk | contribs) |
Aboood40091 (talk | contribs) |
||
Line 1: | Line 1: | ||
− | The '''GTX/GSH''' | + | The '''GTX/GSH''' file formats are used in various Wii U games, including MK8. |
'''GSH''' stands for '''GX2 shader''' file, while '''GTX''' stands for '''GX2 texture''' file. | '''GSH''' stands for '''GX2 shader''' file, while '''GTX''' stands for '''GX2 texture''' file. | ||
Line 47: | Line 47: | ||
|} | |} | ||
− | == Blocks == | + | == Data Blocks == |
− | After the header comes some blocks, blocks contain a 0x20 byte '''BLK{''' header followed by data specified by the block type. | + | After the header comes some data blocks, data blocks contain a 0x20 byte '''BLK{''' block header followed by data specified by the block type. |
=== Block Header === | === Block Header === | ||
Line 103: | Line 103: | ||
|- | |- | ||
| 0x01 | | 0x01 | ||
− | | Follows this block header the | + | | Follows this block header the end of the file. |
|- | |- | ||
| 0x02 | | 0x02 | ||
Line 109: | Line 109: | ||
|- | |- | ||
| 0x03 | | 0x03 | ||
− | | Follows this block header Vertex shader | + | | Follows this block header Vertex shader header. |
|- | |- | ||
| 0x05 | | 0x05 | ||
− | | Follows this block header Vertex shader | + | | Follows this block header Vertex shader data? |
|- | |- | ||
| 0x06 | | 0x06 | ||
− | | Follows this block header Pixel shader | + | | Follows this block header Pixel shader header. |
|- | |- | ||
| 0x07 | | 0x07 | ||
− | | Follows this block header Pixel shader | + | | Follows this block header Pixel shader data? |
+ | |- | ||
+ | | 0x08 | ||
+ | | Follows this block header Geometry shader header. | ||
+ | |- | ||
+ | | 0x09 | ||
+ | | Follows this block header Geometry shader data? | ||
+ | |- | ||
+ | | 0x0A | ||
+ | | Same as 0x09? (Duplicate?) | ||
|- | |- | ||
| 0x0B | | 0x0B | ||
− | | Follows this block header the Image | + | | Follows this block header the Image header. |
|- | |- | ||
| 0x0C | | 0x0C | ||
Line 128: | Line 137: | ||
| 0x0D | | 0x0D | ||
| Follows this block header the Mipmaps data. | | Follows this block header the Mipmaps data. | ||
+ | |- | ||
+ | | 0x0E | ||
+ | | Follows this block header Compute shader header. | ||
+ | |- | ||
+ | | 0x0F | ||
+ | | Follows this block header Compute shader data? | ||
+ | |- | ||
+ | | 0x10 | ||
+ | | Treated like a 0x02 block, users can do what they want with this block. | ||
|} | |} | ||
=== Image info === | === Image info === | ||
− | The image info directly follows the block header that has a block type 0x0B: | + | The image info directly follows the block header that has a block type 0x0B, and should exactly have a size of 0x9C: |
{| class="wikitable" | {| class="wikitable" | ||
! Offset | ! Offset |
Revision as of 10:53, 3 October 2016
The GTX/GSH file formats are used in various Wii U games, including MK8.
GSH stands for GX2 shader file, while GTX stands for GX2 texture file.
Header
Every GTX/GSH file begins with an 0x20 byte Gfx2 header.
Offset | Size | Description |
---|---|---|
0x00 | 4 | "Gfx2" File identifier, ASCII string. |
0x04 | 4 | Size of header in bytes. Must be the real size (0x20), or header (and hence file) is unreadable. |
0x08 | 4 | Major version number. Must be 0x07, or header is unreadable. |
0x0C | 4 | Minor version number. Must be 0x01. |
0x10 | 4 | GPU version for which this file is designed for. |
0x14 | 4 | Align mode. |
0x18 | 4 | Reserved, Always 0x00. |
0x1C | 4 | Reserved, Always 0x00. |
0x20 | End of Gfx2 header. |
Data Blocks
After the header comes some data blocks, data blocks contain a 0x20 byte BLK{ block header followed by data specified by the block type.
Block Header
Offset | Size | Description |
---|---|---|
0x00 | 4 | "BLK{" Header of the block, ASCII string. |
0x04 | 4 | Size of block header in bytes. |
0x08 | 4 | Major version number. Must be 0x01 or header is unreadable. |
0x0C | 4 | Minor version number. Must be 0x00. |
0x10 | 4 | Block type, it determines the type of the following data. |
0x14 | 4 | Size of the following data. In bytes, always 0x9C if the block type is 0x0B. |
0x18 | 4 | A unique identifier for this block, allowing it to be referenced by other blocks |
0x1C | 4 | An incrementing index for each instance of a given type. |
Block types
Block type 0x04 doesn't exist.
Type | Description |
---|---|
0x00 | Not actually a valid Block type. (different magic) |
0x01 | Follows this block header the end of the file. |
0x02 | Follows this block header padding. (Used to align following data) |
0x03 | Follows this block header Vertex shader header. |
0x05 | Follows this block header Vertex shader data? |
0x06 | Follows this block header Pixel shader header. |
0x07 | Follows this block header Pixel shader data? |
0x08 | Follows this block header Geometry shader header. |
0x09 | Follows this block header Geometry shader data? |
0x0A | Same as 0x09? (Duplicate?) |
0x0B | Follows this block header the Image header. |
0x0C | Follows this block header the Image data. |
0x0D | Follows this block header the Mipmaps data. |
0x0E | Follows this block header Compute shader header. |
0x0F | Follows this block header Compute shader data? |
0x10 | Treated like a 0x02 block, users can do what they want with this block. |
Image info
The image info directly follows the block header that has a block type 0x0B, and should exactly have a size of 0x9C:
Offset | Size | Description |
---|---|---|
0x00 | 4 | Dimension. Indicates the "shape" of a given surface or texture (see line 849 here). |
0x04 | 4 | Texture Width. Width of the texture in pixels. |
0x08 | 4 | Texture Height. Height of the texture in pixels. |
0x0C | 4 | Depth. |
0x10 | 4 | Number of Mipmaps. |
0x14 | 4 | Texture Format. Go to line 589 on this page for explanation and format values. |
0x18 | 4 | AA Mode. Indicates the AA mode (number of samples) for the surface (see line 865 here). |
0x1C | 4 | Usage. Indicates how the given surface may be used (see line 823 here). |
0x20 | 4 | Data Length. Length of texture data in bytes. |
0x24 | 4 | Data Pointer?. |
0x28 | 4 | Mipmaps Data Length. Length of mipmaps data in bytes. |
0x2C | 4 | Mipmaps Pointer?. |
0x30 | 4 | Tile Mode. Indicates the desired tiling mode for the surface (see line 795 here). |
0x34 | 4 | Swizzle Value |
0x38 | 4 | Alignment |
0x3C | 4 | Pitch |
0x40 | 0x0D | Unknown. |
0x4D | 0x4F | Unknown. |
Formats
TODO.
Tools
The following tool can extract and generate GTX files:
- GTX Extractor, by AboodXD