https://mk8.tockdom.com/w/api.php?action=feedcontributions&user=Aboood40091&feedformat=atom
MK8 - User contributions [en]
2024-03-29T06:12:11Z
User contributions
MediaWiki 1.35.14
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=4928
GTX\GSH (File Format)
2019-11-12T11:36:32Z
<p>Aboood40091: </p>
<hr />
<div>'''GTX''' and '''GSH''' files are used in various [[Wii U]] games, including [[Mario Kart 8]]. GSH stands for '''G'''X2 '''SH'''ader and GTX stands for '''G'''X2 '''T'''e'''X'''ture'''.<br />
<br />
== Header ==<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be 0x20 bytes long, or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Data Blocks ==<br />
After the header comes some data blocks, data blocks contain a 0x20 byte '''BLK{''' block header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|- bgcolor="#AAFFAA"<br />
| colspan="4" align="center" | '''if Gfx2 version = 6.x'''<br />
|- bgcolor="#DDFFDD"<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x00 or header is unreadable.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|- bgcolor="#FFAAAA"<br />
| colspan="4" align="center" | '''if Gfx2 version = 7.x'''<br />
|- bgcolor="#FFDDDD"<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type.<br />
|-<br />
| 0x01<br />
| Follows this block header the end of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader header.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader program.<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader header.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader program.<br />
|-<br />
| 0x08<br />
| Follows this block header Geometry shader header.<br />
|-<br />
| 0x09<br />
| Follows this block header Geometry shader program.<br />
|- bgcolor="#AAFFAA"<br />
| colspan="4" align="center" | '''if Gfx2 version = 6.x'''<br />
|- bgcolor="#DDFFDD"<br />
| 0x0A<br />
| Follows this block header the GX2 Surface.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0B<br />
| Follows this block header the swizzled image data.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0C<br />
| Follows this block header the swizzled mipmaps data.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0D<br />
| Follows this block header Geometry copy shader program.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0E<br />
| Reserved block.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0F<br />
| Reserved block.<br />
|- bgcolor="#FFAAAA"<br />
| colspan="4" align="center" | '''if Gfx2 version = 7.x'''<br />
|- bgcolor="#FFDDDD"<br />
| 0x0A<br />
| Follows this block header Geometry copy shader program.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0B<br />
| Follows this block header the GX2 Surface.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0C<br />
| Follows this block header the swizzled image data.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0D<br />
| Follows this block header the swizzled mipmaps data.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0E<br />
| Follows this block header Compute shader header.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0F<br />
| Follows this block header Compute shader program.<br />
|-<br />
| 0x10<br />
| Treated like a 0x02 block, users can do what they want with this block.<br />
|}<br />
<br />
=== GX2 Surface ===<br />
The GX2 Surface has an exact size of 0x9C: <br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x00 || 4 || UInt32 || '''Dimension'''. Maps to '''GX2SurfaceDim''' (line 849 [http://pastebin.com/DCrP1w9x here]). Indicates the "shape" of a given surface or texture.<br />
|-<br />
| 0x04 || 4 || UInt32 || '''Texture width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08 || 4 || UInt32 || '''Texture height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C || 4 || UInt32 || '''Texture depth'''.<br />
|-<br />
| 0x10 || 4 || UInt32 || '''Number of mipmaps'''.<br />
|-<br />
| 0x14 || 4 || UInt32 || '''Texture format'''. Maps to '''GX2SurfaceFormat''' (line 589 [http://pastebin.com/DCrP1w9x here] for explanation and format values).<br />
|-<br />
| 0x18 || 4 || UInt32 || '''AA mode'''. Maps to '''GX2AAMode''' (line 865 [http://pastebin.com/DCrP1w9x here]). Indicates the AA mode (number of samples) for the surface.<br />
|-<br />
| 0x1C || 4 || UInt32 || '''Usage'''. Maps to '''GX2SurfaceUse''' (line 823 [http://pastebin.com/DCrP1w9x here]). Indicates how the given surface may be used.<br />
|-<br />
| 0x20 || 4 || UInt32 || '''Data length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24 || 4 || UInt32 || '''Data pointer'''. Set at runtime.<br />
|-<br />
| 0x28 || 4 || UInt32 || '''Mipmaps data length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C || 4 || UInt32 || '''Mipmaps pointer'''. Set at runtime.<br />
|-<br />
| 0x30 || 4 || UInt32 || '''Tile mode'''. Maps to '''GX2TileMode''' (line 795 [http://pastebin.com/DCrP1w9x here]). Indicates the desired tiling mode for the surface.<br />
|-<br />
| 0x34 || 4 || UInt32 || '''Swizzle value'''.<br />
|-<br />
| 0x38 || 4 || UInt32 || '''Alignment'''. Always 512 * bytes per pixel.<br />
|-<br />
| 0x3C || 4 || UInt32 || '''Pitch'''.<br />
|-<br />
| 0x40 || 0x34 || UInt32[13] || '''Mipmap offsets'''. An array of 13 offsets for each mipmap, relative to the start of the mipmap data.<br />
|-<br />
| 0x74 || 4 || UInt32 || '''First mipmap ID'''. (Usually 0, the main map/image)<br />
|-<br />
| 0x78 || 4 || UInt32 || '''Number of available mipmaps'''. ("Number of mipmaps" - "First mipmap ID")<br />
|-<br />
| 0x7C || 4 || UInt32 || '''First slice ID'''. (Usually 0)<br />
|-<br />
| 0x80 || 4 || UInt32 || '''Number of available slices'''. ("Depth" - "First slice ID")<br />
|-<br />
| 0x84 || 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.<br />
{| class="wikitable"<br />
! Value !! Name !! Description<br />
|-<br />
| 0 || R || The channel will receive the red values of the texture.<br />
|-<br />
| 1 || G || The channel will receive the green values of the texture.<br />
|-<br />
| 2 || B || The channel will receive the blue values of the texture.<br />
|-<br />
| 3 || A || The channel will receive the alpha values of the texture.<br />
|-<br />
| 4 || 0 || The channel will always have a value 0.<br />
|-<br />
| 5 || 1 || The channel will always have a value 1.<br />
|}<br />
|-<br />
| 0x88 || 0x14 || UInt32[5] || '''Texture registers'''. 5 registers used to describe the texture.<br />
|}<br />
<br />
== Swizzling ==<br />
[https://pastebin.com/VDvs7q8Y This] code can swizzle image and mipmap data. Call ''swizzle()'' by giving it the width, height, format (in hex), tileMode, swizzle value, pitch and the swizzled data. If you're swizzling then set do_swizzle to ''True''. If you're deswizzling then set do_swizzle to ''False''.<br />
<br />
= Tools =<br />
The following tools can handle GTX/GSH files:<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=BFLYT_(File_Format)&diff=4910
BFLYT (File Format)
2019-04-17T18:06:38Z
<p>Aboood40091: </p>
<hr />
<div>'''BFLYT''' ('''B'''inary ca'''F'''e '''L'''a'''Y'''ou'''T''') is an updated format for [[:mkw:BRLYT (File Format)|BRLYT]] files on the Wii. It contains 2D layout information.<br />
<br />
= Format =<br />
== Header ==<br />
The file starts with a header which is 0x14 bytes long.<br />
<br />
{|class="wikitable"<br />
|-<br />
! Offset !! Type !! Description<br />
|-<br />
| 0x00 || String || '''File magic'''. Always ''FLYT'' in ASCII.<br />
|-<br />
| 0x04 || UInt16 || {{BOM}}<br />
|-<br />
| 0x06 || UInt16 || Header size.<br />
|-<br />
| 0x08 || UInt32 || Version.<br />
|-<br />
| 0x0C || UInt32 || File size.<br />
|-<br />
| 0x10 || UInt16 || Number of sections.<br />
|-<br />
| 0x12 || UInt16 || Padding.<br />
|}<br />
<br />
== Sections ==<br />
After the header comes first 4 sections, where 3 of them are optional. Then comes all the panes and then the groups.<br />
<br />
=== lyt1 ===<br />
The ''lyt1'' section contains general information about the layout.<br />
<br />
{|class="wikitable"<br />
|-<br />
! Offset !! Type !! Description<br />
|-<br />
| 0x00 || String || '''Section magic'''. Always ''lyt1'' in ASCII.<br />
|-<br />
| 0x04 || UInt32 || Section size.<br />
|-<br />
| 0x08 || Byte || Drawn from center. <br />
|-<br />
| 0x09 || Byte[3] || Padding.<br />
|-<br />
| 0x0C || Float || '''Width''' of the layout.<br />
|-<br />
| 0x10 || Float || '''Height''' of the layout.<br />
|-<br />
| 0x14 || Float || ''Max parts height''. '''Unknown meaning'''.<br />
|-<br />
| 0x18 || Float || ''Max parts height''. '''Unknown meaning'''.<br />
|-<br />
| 0x1C || String || Layout name, null terminated.<br />
|}<br />
<br />
=== txl1 ===<br />
The ''txl1'' section is a list of external [[BFLIM]] references.<br />
<br />
{|class="wikitable"<br />
|-<br />
! Offset !! Type !! Description<br />
|-<br />
| 0x00 || String || '''Section magic'''. Always ''txl1'' in ASCII.<br />
|-<br />
| 0x04 || UInt32 || Section size.<br />
|-<br />
| 0x08 || UInt16 || '''N''' = Number of textures.<br />
|-<br />
| 0x0A || UInt16 || Padding.<br />
|-<br />
| 0x0C || UInt32['''N'''] || '''Texture string offsets'''. Links to null-termined strings.<br />
|}<br />
<br />
=== fnl1 ===<br />
The ''fnl'' section is a font list. It links to external [[BFFNT]] files.<br />
<br />
{|class="wikitable"<br />
|-<br />
! Offset !! Type !! Description<br />
|-<br />
| 0x00 || String || '''Section magic'''. Always ''fnl1'' in ASCII.<br />
|-<br />
| 0x04 || UInt32 || Section size.<br />
|-<br />
| 0x08 || UInt16 || '''N''' = Number of fonts.<br />
|-<br />
| 0x0A || UInt16 || Padding.<br />
|-<br />
| 0x0C || UInt32['''N'''] || '''Font string offsets'''. Links to null-termined strings.<br />
|}<br />
<br />
=== mat1 ===<br />
The ''mat1'' section stores materials. It is currently unknown.<br />
<br />
{|class="wikitable"<br />
|-<br />
! Offset !! Type !! Description<br />
|-<br />
| 0x00 || String || '''Section magic'''. Always ''mat1'' in ASCII.<br />
|-<br />
| 0x04 || UInt32 || '''S''' = Section size.<br />
|-<br />
| 0x08 || Byte['''S'''] || {{Unknown-left|Material data.}}<br />
|}<br />
<br />
=== pas1 ===<br />
The ''pas1'' section indicates start of children pane data.<br />
<br />
{|class="wikitable"<br />
|-<br />
! Offset !! Type !! Description<br />
|-<br />
| 0x00 || String || '''Section magic'''. Always ''pas1'' in ASCII.<br />
|-<br />
| 0x04 || UInt32 || Section size.<br />
|}<br />
<br />
=== pae1 ===<br />
The ''pas1'' section indicates end of children pane data.<br />
<br />
{|class="wikitable"<br />
|-<br />
! Offset !! Type !! Description<br />
|-<br />
| 0x00 || String || '''Section magic'''. Always ''pae1'' in ASCII.<br />
|-<br />
| 0x04 || UInt32 || Section size.<br />
|}<br />
<br />
=== pan1 ===<br />
The ''pan1'' section contains information about a null pane, a pane that isn't visible. The root pane is always a pan1 called "RootPane". Other pane sections start with this structure and then has additional data. The only difference is that the magic is changed.<br />
<br />
{|class="wikitable"<br />
|-<br />
! Offset !! Type !! Description<br />
|-<br />
| 0x00 || String || '''Section magic'''. Always ''pan1'' in ASCII.<br />
|-<br />
| 0x04 || UInt32 || Section size.<br />
|-<br />
| 0x08 || Byte || Flag 1. '''xxxx xxAB''':<br />
'''A''' = Influence alpha<br />
'''B''' = Visible<br />
|-<br />
| 0x09 || Byte || Flag 2. '''AABB CCDD''':<br />
'''A''' = Origin X where 0 = center, 1 = left, 2 = right<br><br />
'''B''' = Origin Y where 0 = center, 1 = top, 2 = bottom<br><br />
'''C''' = Parent origin X (same values as '''A''')<br><br />
'''D''' = Parent origin Y (same values as '''B''')<br />
|-<br />
| 0x0A || Byte || Alpha.<br />
|-<br />
| 0x0B || Byte || {{Unknown-left|'''Unknown'''.}}<br />
|-<br />
| 0x0C || String || '''Pane name'''. The string has a fixed length of 0x18, unused characters are set to 0.<br />
|-<br />
| 0x24 || String || '''User information'''. Unknown purpose. The string has a fixed length of 8, unused character are set to 0.<br />
|-<br />
| 0x2C || Float[3] || Pane translation in X, Y and Z directions.<br />
|-<br />
| 0x38 || Float[3] || Pane rotation in X, Y and Z directions.<br />
|-<br />
| 0x44 || Float[2] || Pane scale in X and Y directions.<br />
|-<br />
| 0x4C || Float[2] || Pane size in X and Y directions.<br />
|}<br />
<br />
=== pic1 ===<br />
The ''pic1'' section contains information about a picture pane.<br />
<br />
{|class="wikitable"<br />
|-<br />
! Offset !! Type !! Description<br />
|-<br />
| 0x54 || Byte[4] || '''Top left''' vertex color in RGBA format.<br />
|-<br />
| 0x58 || Byte[4] || '''Top right''' vertex color in RGBA format.<br />
|-<br />
| 0x5C || Byte[4] || '''Bottom left''' vertex color in RGBA format.<br />
|-<br />
| 0x60 || Byte[4] || '''Bottom right''' vertex color in RGBA format.<br />
|-<br />
| 0x64 || UInt16 || '''[[#mat1|Material]]''' index.<br />
|-<br />
| 0x66 || Byte || '''Number of UV coordinates'''.<br />
|-<br />
| 0x67 || Byte || Padding.<br />
|}<br />
<br />
UV coordinates then follows with the following structures.<br />
<br />
{|class="wikitable"<br />
|-<br />
! Offset !! Type !! Description<br />
|-<br />
| 0x00 || Float[2] || '''Top left''' UV coordinates.<br />
|-<br />
| 0x08 || Float[2] || '''Top right''' UV coordinates.<br />
|-<br />
| 0x10 || Float[2] || '''Bottom left''' UV coordinates.<br />
|-<br />
| 0x08 || Float[2] || '''Bottom right''' UV coordinates.<br />
|}<br />
<br />
=== txt1 ===<br />
The ''txt1'' section contains information about a text pane.<br />
<br />
{|class="wikitable"<br />
|-<br />
! Offset !! Type !! Description<br />
|-<br />
| 0x54 || UInt16 || Text length.<br />
|-<br />
| 0x56 || UInt16 || Restricted text length.<br />
|-<br />
| 0x58 || UInt16 || [[#mat1|Material]] index.<br />
|-<br />
| 0x5A || UInt16 || [[#fnl1|Font index]].<br />
|-<br />
| 0x5C || Byte || Text alignment. xxxx AABB<br><br />
'''A''' = Horizontal where 0 = Center, 1 = Left, 2 = Right<br><br />
'''B''' = Vertical where 0 = Center, 1 = Left, 2 = Right<br><br />
|-<br />
| 0x5D || Byte || Line alignment.<br />
'''0''' = Not specified<br><br />
'''1''' = Left<br><br />
'''2''' = Center<br><br />
'''3''' = Right<br />
|-<br />
| 0x5E || Byte || Flag 1. '''xxxA BBCD'''<br />
'''A''' = Per Char Transform enabled<br><br />
'''B''' = Border format where 0 = standart, 1 = Delete Border, 2 = Render in two cycles<br><br />
'''C''' = Restricted text lenght enabled<br><br />
'''D''' = Shadow enabled<br />
|-<br />
| 0x5F || Byte || Padding.<br />
|-<br />
| 0x60 || Float || Italic tilt.<br />
|-<br />
| 0x64 || UInt32 || '''Text offset''', relative to the start of this pane. Links to the pane text which is stored in UTF-16 (big endian) as a null-termined string.<br />
|-<br />
| 0x68 || Byte[4] || Font top color in RGBA format.<br />
|-<br />
| 0x6C || Byte[4] || Font bottom color in RGBA format.<br />
|-<br />
| 0x70 || Float[2] || Font XY size.<br />
|-<br />
| 0x78 || Float || Character space.<br />
|-<br />
| 0x7C || Float || Line space.<br />
|-<br />
| 0x80 || UInt32 || '''Textbox name offset''', relative to the start of this pane. Links to the name of this textbox, stored in ASCII as a null-termined string.<br />
|-<br />
| 0x84 || Float[2] || Shadow XY.<br />
|-<br />
| 0x8C || Float[2] || Shadow XY size.<br />
|-<br />
| 0x94 || Byte[4] || Shadow top color in RGBA format.<br />
|-<br />
| 0x98 || Byte[4] || Shadow bottom color in RGBA format.<br />
|-<br />
| 0x9C || Float || Shadow italic.<br />
|-<br />
| 0xA0 || UInt32 || {{Unknown-left|'''Per character transform offset'''. Links to an unknown structure.}}<br />
|}<br />
<br />
=== wnd1 ===<br />
The ''wnd1'' pane contains information about a window pane. It is unknown how it works.<br />
<br />
{|class="wikitable"<br />
|-<br />
! Offset !! Type !! Description<br />
|-<br />
| 0x54 || Int16 || Inflation left.<br />
|-<br />
| 0x56 || Int16 || Inflation right.<br />
|-<br />
| 0x58 || Int16 || Inflation top.<br />
|-<br />
| 0x5A || Int16 || Inflation bottom.<br />
|-<br />
| 0x5C || Int16 || Frame size left.<br />
|-<br />
| 0x5E || Int16 || Frame size right.<br />
|-<br />
| 0x60 || Int16 || Frame size top.<br />
|-<br />
| 0x62 || Int16 || Frame size bottom.<br />
|-<br />
| 0x64 || Byte || '''N''' = Number of frames.<br />
|-<br />
| 0x65 || Byte || Flags. '''xxAB BBCD'''<br />
'''A''' = Do not draw content.<br><br />
'''B''' = Window kind.<br><br />
'''C''' = Use vertex colors on all materials.<br><br />
'''D''' = Use a single material.<br />
|-<br />
| 0x66 || UInt16 || Padding.<br />
|-<br />
| 0x68 || UInt32 || [[#Window Content|Content]] offset.<br />
|-<br />
| 0x6C || UInt32 || Frame offset table offset. Links to a UInt32['''N'''}] with offsets which links to [[#Window Frame|window frames]]. All offsets are relative to the start of the pane.<br />
|}<br />
<br />
==== Window Content ====<br />
{|class="wikitable"<br />
|-<br />
! Offset !! Type !! Description<br />
|-<br />
| 0x00 || Byte[4] || '''Top left''' vertex color in RGBA format.<br />
|-<br />
| 0x04 || Byte[4] || '''Top right''' vertex color in RGBA format.<br />
|-<br />
| 0x08 || Byte[4] || '''Bottom left''' vertex color in RGBA format.<br />
|-<br />
| 0x0C || Byte[4] || '''Bottom right''' vertex color in RGBA format.<br />
|-<br />
| 0x10 || UInt16 || [[#mat1|Material]] index.<br />
|-<br />
| 0x12 || Byte || '''Number of UV coordinates'''.<br />
|-<br />
| 0x13 || Byte || Padding.<br />
|}<br />
<br />
UV coordinates then follows with the following structures.<br />
<br />
{|class="wikitable"<br />
|-<br />
! Offset !! Type !! Description<br />
|-<br />
| 0x00 || Float[2] || '''Top left''' UV coordinates.<br />
|-<br />
| 0x08 || Float[2] || '''Top right''' UV coordinates.<br />
|-<br />
| 0x10 || Float[2] || '''Bottom left''' UV coordinates.<br />
|-<br />
| 0x08 || Float[2] || '''Bottom right''' UV coordinates.<br />
|}<br />
<br />
==== Window Frame ====<br />
{|class="wikitable"<br />
|-<br />
! Offset !! Type !! Description<br />
|-<br />
| 0x00 || UInt16 || [[#mat1|Material]] index.<br />
|-<br />
| 0x02 || Byte || Texture flip.<br />
|-<br />
| 0x03 || Byte || Padding.<br />
|}<br />
<br />
=== bnd1 ===<br />
The ''bnd1'' section is a boundary pane. It has unknown purpose and no additional data follows the pane.<br />
<br />
=== prt1 ===<br />
The ''prt1'' section is an unknown pane. Unknown additional data follows the pane.<br />
<br />
{|class="wikitable"<br />
|-<br />
! Offset !! Type !! Description<br />
|-<br />
| 0x54 || UInt32 || Property count.<br />
|-<br />
| 0x58 || Float || Magnify X.<br />
|-<br />
| 0x5C || Float || Magnify Y.<br />
|}<br />
<br />
Following this structure are '''N''' amount of properties.<br />
<br />
{|class="wikitable"<br />
|-<br />
! Offset !! Type !! Description<br />
|-<br />
| 0x00 || String || Property Name, 0x18 in length.<br />
|-<br />
| 0x18 || Byte || Usage flag.<br />
|-<br />
| 0x19 || Byte || Basic usage flag.<br />
|-<br />
| 0x1A || UInt16 || Padding.<br />
|-<br />
| 0x1C || UInt32 || Property offset.<br />
|-<br />
| 0x20 || UInt32 || External user data offset.<br />
|-<br />
| 0x24 || UInt32 || Panel information offset.<br />
|}<br />
<br />
The three sections, properties, user data, and panel information are defined below the property.<br />
<br />
=== grs1 ===<br />
The ''grs1'' section indicates start of group children data.<br />
<br />
{|class="wikitable"<br />
|-<br />
! Offset !! Type !! Description<br />
|-<br />
| 0x00 || String || '''Section magic'''. Always ''grs1'' in ASCII.<br />
|-<br />
| 0x04 || UInt32 || Section size.<br />
|}<br />
<br />
=== gre1 ===<br />
The ''gre1'' section indicates end of group children data.<br />
<br />
{|class="wikitable"<br />
|-<br />
! Offset !! Type !! Description<br />
|-<br />
| 0x00 || String || '''Section magic'''. Always ''gre1'' in ASCII.<br />
|-<br />
| 0x04 || UInt32 || Section size.<br />
|}<br />
<br />
=== grp1 ===<br />
The ''grp1'' section contains information about a group.<br />
<br />
{|class="wikitable"<br />
|-<br />
! Offset !! Type !! Description<br />
|-<br />
| 0x00 || String || '''Section magic'''. Always ''grp1'' in ASCII.<br />
|-<br />
| 0x04 || UInt32 || Section size.<br />
|- bgcolor="#AAFFAA"<br />
| colspan="4" align="center" | '''if BFLYT version < 5.0.0.0'''<br />
|- bgcolor="#DDFFDD"<br />
| 0x08 || String || '''Group name'''. The string has a fixed length of 0x18, unused characters are set to 0.<br />
|- bgcolor="#DDFFDD"<br />
| 0x20 || UInt16 || Number of children.<br />
|- bgcolor="#DDFFDD"<br />
| 0x22 || UInt16 || Padding.<br />
|- bgcolor="#FFAAAA"<br />
| 0x08 || String || '''Group name'''. The string has a fixed length of 0x22, unused characters are set to 0.<br />
|- bgcolor="#FFDDDD"<br />
| 0x2A || UInt16 || Number of children.<br />
|}<br />
<br />
The section follows by children names. The amount is given by "Number of children". Each string has a fixed length of 0x18, unused characters are set to 0.<br />
<br />
=== cnt1 ===<br />
''Unknown.''<br />
<br />
{|class="wikitable"<br />
|-<br />
! Offset !! Type !! Description<br />
|-<br />
| 0x00 || String || '''Section magic'''. Always ''cnt1'' in ASCII.<br />
|-<br />
| 0x04 || UInt32 || Section size.<br />
|- bgcolor="#AAFFAA"<br />
| colspan="4" align="center" | '''if BFLYT version < 3.0.0.0'''<br />
|- bgcolor="#DDFFDD"<br />
| 0x08 || UInt32 || Functional panel names offset.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0C || UInt16 || Functional panel count.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0E || UInt16 || Panel animation count.<br />
|- bgcolor="#FFAAAA"<br />
| 0x08 || UInt32 || Control username offset.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0C || UInt32 || Functional panel names offset.<br />
|- bgcolor="#FFDDDD"<br />
| 0x10 || UInt16 || Functional panel count.<br />
|- bgcolor="#FFDDDD"<br />
| 0x12 || UInt16 || Panel animation count.<br />
|- bgcolor="#FFDDDD"<br />
| 0x14 || UInt32 || Panel parameter names offset.<br />
|- bgcolor="#FFDDDD"<br />
| 0x18 || UInt32 || Animation parameter names offset.<br />
|}<br />
<br />
The section follows by children names. The amount is given by "Number of children". Each string has a fixed length of 0x18, unused characters are set to 0.<br />
<br />
=== usd1 ===<br />
The ''usd1'' section contains user data, generic data set by the creator. User data can be attached to any pane section. The section follows directly after the section it is attached to.<br />
<br />
{|class="wikitable"<br />
|-<br />
! Offset !! Type !! Description<br />
|-<br />
| 0x00 || String || '''Section magic'''. Always ''usd1'' in ASCII.<br />
|-<br />
| 0x04 || UInt32 || '''S''' = Section size.<br />
|-<br />
| 0x08 || Byte['''S''' - 8] || {{Unknown-left|'''Unknown data'''}}.<br />
|}<br />
<br />
= Tools =<br />
The following tool can handle BFLYT files:<br />
* [https://www.dropbox.com/s/7ni9vf43e0o7fxz/BenzinU.exe?dl=0 BenzinU], by [[User:diddy81|diddy81]]<br />
* [[Wexos's Toolbox]], by [[Wexos]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=SARC_(File_Format)&diff=4832
SARC (File Format)
2018-07-01T16:29:21Z
<p>Aboood40091: </p>
<hr />
<div>'''SARC Files''' are archive files used in [[Wii U]] and [[3DS]], including [[Mario Kart 8]]. They are similar to the [[:mkw:U8 (File Format)|U8]] files found in GameCube and Wii games. Common extensions are '''.arc''' and '''.sarc''' (general), '''.pack''' (when the archive contains mostly other archive files), '''.bars''' (when it contains audio data), and '''.bgenv/.genvb''' (when it contains aamp/shader files). SARC files are sometimes [[:mkw:Yaz0 (File Format)|Yaz0]] compressed into '''.szs''' files.<br />
<br />
= File Format =<br />
The basic structure of the archive is a '''SARC Header''' followed by a '''File Table''' and a '''File Name Table'''. Finally, the content of all files in the archive is stored directly. The '''File Table''' references the data.<br />
<br />
== Header (SARC) ==<br />
Every SARC file begins with a 0x14 byte '''SARC Header''' structure.<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Description<br />
|-<br />
| 0x00 || 4 || '''Magic''': 0x53415243 ("SARC" in ASCII).<br />
|-<br />
| 0x04 || 2 || '''Header Length''': the length of this header in bytes. Always '''0x14'''.<br />
|-<br />
| 0x06 || 2 || {{BOM}}<br />
|-<br />
| 0x08 || 4 || '''File size''' of the entire archive in bytes.<br />
|-<br />
| 0x0C || 4 || '''Beginning of data''' offset.<br />
|-<br />
| 0x10 || 2 || '''Version number''' of the file format. Always 0x0100.<br />
|-<br />
| 0x12 || 2 || Reserved.<br />
|-<br />
| 0x14 || colspan=2 {{Unknown|End of '''SARC''' header}}<br />
|}<br />
<br />
== File Table ==<br />
Unlike the U8 format, SARC does generally not contain directory nodes (though files may reside inside subfolders).<br />
<br />
=== Header (SFAT) ===<br />
The '''SARC Header''' is immediately followed by 12 byte '''SFAT Header''' structure.<br />
<br />
{| class="wikitable"<br />
! Offset !! Type !! Description<br />
|-<br />
| 0x00 || 4 || '''Magic''': 0x53464154 ("SFAT").<br />
|-<br />
| 0x04 || 2 || '''Header Length''': the length of this header in bytes. Always '''0xC'''.<br />
|-<br />
| 0x06 || 2 || '''Node count'''.<br />
|-<br />
| 0x08 || 4 || '''Hash Key'''. Always '''0x00000065'''.<br />
|-<br />
| 0x0C || colspan=2 {{Unknown|End of '''SFAT''' header}}<br />
|}<br />
<br />
=== Node ===<br />
The '''SFAT Header''' is followed by an array of 16 byte '''SFAT Node''' structures.<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Description<br />
|-<br />
| 0x00 || 4 || '''File Name Hash'''. Look below for the calculation.<br />
|-<br />
| 0x04 || 4 || '''File Attributes''', if flag 0x01000000 is set, bottom half (0xFFFF) is the Name Table offset (after header), divided by 4.<br />
|-<br />
| 0x08 || 4 || '''Beginning of node file data''', relative to the '''Beginning of data''' offset specified in the '''SARC header'''.<br />
|-<br />
| 0x0C || 4 || '''End of node file data''', relative to the '''Beginning of data''' offset specified in the '''SARC header'''.<br />
|-<br />
| 0x10 || colspan=2 {{Unknown|End of node}}<br />
|}<br />
<br />
==== File Name Hash ====<br />
The hash is calculated like this:<br />
<pre><br />
uint GetHash(char* name, int length, uint key)<br />
{<br />
uint result = 0;<br />
for(int i = 0; i < length; i++)<br />
{<br />
result = name[i] + result * key;<br />
}<br />
return result;<br />
}<br />
</pre><br />
<br />
== File Name Table ==<br />
The '''File Name Table''' is a list of null-terminated strings which represent the filenames of the packed files. It is referenced by '''SFAT Node'''s.<br />
<br />
=== Header (SFNT) ===<br />
The '''SFAT Node''' array is immediately followed by an 8 byte '''SFNT Header''' structure.<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Description<br />
|-<br />
| 0x00 || 4 || '''Magic''': 0x53464E54 ("SFNT").<br />
|-<br />
| 0x04 || 2 || '''Header Length''': the length of this header in bytes. Always '''0x8'''.<br />
|-<br />
| 0x06 || 2 || Reserved.<br />
|-<br />
| 0x08 || colspan=2 {{Unknown|End of '''SFNT''' header}}<br />
|}<br />
<br />
=== Strings ===<br />
The '''SFAT Header''' is immediately followed by 4-byte aligned null-terminated strings that represent the filenames of the packed files.<br />
<br />
== File Data ==<br />
The data begins at the '''Beginning of data''' offset specified in the '''SARC Header'''. The alignment of the internal files vary between different files. Some files use 0x4 as the alignment.<br />
<br />
= Tools =<br />
The following tools can handle SARC files:<br />
<br />
* [https://github.com/aboood40091/SARC-Tool/releases/tag/v0.3 SARC Tool], by [[User:Aboood40091|AboodXD]]<br />
* [http://florian.nouwt.com/wiki/index.php/Every_File_Explorer Every File Explorer], by [[Gericom]]<br />
* [https://github.com/NWPlayer123/WiiUTools/tree/master/SARCTools SARCTools], by [[User:NWPlayer123|NwPlayer123]]<br />
* [https://drive.google.com/file/d/0B9ETxoIujjPFLTJOY2pIZ3RfRms/view Uwizard], by [[User:Mr. Mysterio|Mr. Mysterio]]<br />
* [https://github.com/smb123w64gb/Uwizard/releases/tag/1.2.0 Uwizard.Woomy], by [[User:smb123w64gb|smb123w64gb]]<br />
* [[Wexos's Toolbox]], by [[Wexos]]<br />
* [https://www.dropbox.com/sh/tfg2nd6q809oqn3/AADWk3SgQEsqnvlbplcWOfv5a WiiUExplorer], by [[User:Celcodioc|Celcodioc]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=FTEX_(File_Format)&diff=4808
FTEX (File Format)
2018-06-18T01:51:17Z
<p>Aboood40091: Undo revision 4638 by Wexos (talk)</p>
<hr />
<div>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.<br />
<br />
== Header (FTEX) ==<br />
An FTEX file begins with an 0xC0 byte header that starts with the file identifier, followed by info about the texture and mipmaps.<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x00 || 0x04 || Char[4] || '''File magic'''. Always ''FTEX'' in ASCII.<br />
|-<br />
| 0x04 || 0x9C || Struct || '''[[GTX#GX2 Surface|GX2 Surface]]'''.<br />
|-<br />
| 0xA0 || 0x04 || UInt32 || '''Texture handle'''. Set at runtime.<br />
|-<br />
| 0xA4 || 0x04 || UInt32 || '''Array length''' (seems to be just a byte in MK8 files, with the remaining 3 bytes being padding?).<br />
|-<br />
| 0xA8 || 0x04 || Int32 || '''File name''' offset.<br />
|-<br />
| 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]].<br />
|-<br />
| 0xB0 || 0x04 || Int32 || '''Data offset'''. Offset to the texture data.<br />
|-<br />
| 0xB4 || 0x04 || Int32 || '''Mipmap offset'''. Offset to the mipmap texture data.<br />
|-<br />
| 0xB8 || 0x04 || Int32 || '''[[User Data]] [[Index Group]]''' offset.<br />
|-<br />
| 0xBC || 0x02 || UInt16 || '''[[User Data]] entry count'''.<br />
|-<br />
| 0xBE || 0x02 || &mdash; || Padding.<br />
|-<br />
| 0xC0 || colspan="3" {{Unknown|End of '''FTEX''' header}}<br />
|}<br />
<br />
== Image Data ==<br />
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.<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=4805
GTX\GSH (File Format)
2018-06-16T09:25:26Z
<p>Aboood40091: </p>
<hr />
<div>'''GTX''' and '''GSH''' files are used in various [[Wii U]] games, including [[Mario Kart 8]]. GSH stands for '''G'''X2 '''SH'''ader and GTX stands for '''G'''X2 '''T'''e'''X'''ture'''.<br />
<br />
== Header ==<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be 0x20 bytes long, or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Data Blocks ==<br />
After the header comes some data blocks, data blocks contain a 0x20 byte '''BLK{''' block header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|- bgcolor="#AAFFAA"<br />
| colspan="4" align="center" | '''if Gfx2 version = 6.x'''<br />
|- bgcolor="#DDFFDD"<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x00 or header is unreadable.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|- bgcolor="#FFAAAA"<br />
| colspan="4" align="center" | '''if Gfx2 version = 7.x'''<br />
|- bgcolor="#FFDDDD"<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type.<br />
|-<br />
| 0x01<br />
| Follows this block header the end of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader header.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader program.<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader header.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader program.<br />
|-<br />
| 0x08<br />
| Follows this block header Geometry shader header.<br />
|-<br />
| 0x09<br />
| Follows this block header Geometry shader program.<br />
|- bgcolor="#AAFFAA"<br />
| colspan="4" align="center" | '''if Gfx2 version = 6.x'''<br />
|- bgcolor="#DDFFDD"<br />
| 0x0A<br />
| Follows this block header the GX2 Surface.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0B<br />
| Follows this block header the swizzled image data.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0C<br />
| Follows this block header the swizzled mipmaps data.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0D<br />
| Follows this block header Geometry copy shader program.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0E<br />
| Reserved block.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0F<br />
| Reserved block.<br />
|- bgcolor="#FFAAAA"<br />
| colspan="4" align="center" | '''if Gfx2 version = 7.x'''<br />
|- bgcolor="#FFDDDD"<br />
| 0x0A<br />
| Same as 0x09? (Duplicate?)<br />
|- bgcolor="#FFDDDD"<br />
| 0x0B<br />
| Follows this block header the GX2 Surface.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0C<br />
| Follows this block header the swizzled image data.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0D<br />
| Follows this block header the swizzled mipmaps data.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0E<br />
| Follows this block header Compute shader header.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0F<br />
| Follows this block header Compute shader program.<br />
|-<br />
| 0x10<br />
| Treated like a 0x02 block, users can do what they want with this block.<br />
|}<br />
<br />
=== GX2 Surface ===<br />
The GX2 Surface has an exact size of 0x9C: <br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x00 || 4 || UInt32 || '''Dimension'''. Maps to '''GX2SurfaceDim''' (line 849 [http://pastebin.com/DCrP1w9x here]). Indicates the "shape" of a given surface or texture.<br />
|-<br />
| 0x04 || 4 || UInt32 || '''Texture width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08 || 4 || UInt32 || '''Texture height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C || 4 || UInt32 || '''Texture depth'''.<br />
|-<br />
| 0x10 || 4 || UInt32 || '''Number of mipmaps'''.<br />
|-<br />
| 0x14 || 4 || UInt32 || '''Texture format'''. Maps to '''GX2SurfaceFormat''' (line 589 [http://pastebin.com/DCrP1w9x here] for explanation and format values).<br />
|-<br />
| 0x18 || 4 || UInt32 || '''AA mode'''. Maps to '''GX2AAMode''' (line 865 [http://pastebin.com/DCrP1w9x here]). Indicates the AA mode (number of samples) for the surface.<br />
|-<br />
| 0x1C || 4 || UInt32 || '''Usage'''. Maps to '''GX2SurfaceUse''' (line 823 [http://pastebin.com/DCrP1w9x here]). Indicates how the given surface may be used.<br />
|-<br />
| 0x20 || 4 || UInt32 || '''Data length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24 || 4 || UInt32 || '''Data pointer'''. Set at runtime.<br />
|-<br />
| 0x28 || 4 || UInt32 || '''Mipmaps data length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C || 4 || UInt32 || '''Mipmaps pointer'''. Set at runtime.<br />
|-<br />
| 0x30 || 4 || UInt32 || '''Tile mode'''. Maps to '''GX2TileMode''' (line 795 [http://pastebin.com/DCrP1w9x here]). Indicates the desired tiling mode for the surface.<br />
|-<br />
| 0x34 || 4 || UInt32 || '''Swizzle value'''.<br />
|-<br />
| 0x38 || 4 || UInt32 || '''Alignment'''. Always 512 * bytes per pixel.<br />
|-<br />
| 0x3C || 4 || UInt32 || '''Pitch'''.<br />
|-<br />
| 0x40 || 0x34 || UInt32[13] || '''Mipmap offsets'''. An array of 13 offsets for each mipmap, relative to the start of the mipmap data.<br />
|-<br />
| 0x74 || 4 || UInt32 || '''First mipmap ID'''. (Usually 0, the main map/image)<br />
|-<br />
| 0x78 || 4 || UInt32 || '''Number of available mipmaps'''. ("Number of mipmaps" - "First mipmap ID")<br />
|-<br />
| 0x7C || 4 || UInt32 || '''First slice ID'''. (Usually 0)<br />
|-<br />
| 0x80 || 4 || UInt32 || '''Number of available slices'''. ("Depth" - "First slice ID")<br />
|-<br />
| 0x84 || 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.<br />
{| class="wikitable"<br />
! Value !! Name !! Description<br />
|-<br />
| 0 || R || The channel will receive the red values of the texture.<br />
|-<br />
| 1 || G || The channel will receive the green values of the texture.<br />
|-<br />
| 2 || B || The channel will receive the blue values of the texture.<br />
|-<br />
| 3 || A || The channel will receive the alpha values of the texture.<br />
|-<br />
| 4 || 0 || The channel will always have a value 0.<br />
|-<br />
| 5 || 1 || The channel will always have a value 1.<br />
|}<br />
|-<br />
| 0x88 || 0x14 || UInt32[5] || '''Texture registers'''. 5 registers used to describe the texture.<br />
|}<br />
<br />
== Swizzling ==<br />
[https://pastebin.com/VDvs7q8Y This] code can swizzle image and mipmap data. Call ''swizzle()'' by giving it the width, height, format (in hex), tileMode, swizzle value, pitch and the swizzled data. If you're swizzling then set do_swizzle to ''True''. If you're deswizzling then set do_swizzle to ''False''.<br />
<br />
= Tools =<br />
The following tools can handle GTX/GSH files:<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=4804
GTX\GSH (File Format)
2018-06-14T02:40:39Z
<p>Aboood40091: </p>
<hr />
<div>'''GTX''' and '''GSH''' files are used in various [[Wii U]] games, including [[Mario Kart 8]]. GSH stands for '''G'''X2 '''SH'''ader and GTX stands for '''G'''X2 '''T'''e'''X'''ture'''.<br />
<br />
== Header ==<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be 0x20 bytes long, or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Data Blocks ==<br />
After the header comes some data blocks, data blocks contain a 0x20 byte '''BLK{''' block header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|- bgcolor="#AAFFAA"<br />
| colspan="4" align="center" | '''if Gfx2 version = 6.x'''<br />
|- bgcolor="#DDFFDD"<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x00 or header is unreadable.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|- bgcolor="#FFAAAA"<br />
| colspan="4" align="center" | '''if Gfx2 version = 7.x'''<br />
|- bgcolor="#FFDDDD"<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type.<br />
|-<br />
| 0x01<br />
| Follows this block header the end of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader header.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader program.<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader header.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader program.<br />
|-<br />
| 0x08<br />
| Follows this block header Geometry shader header.<br />
|-<br />
| 0x09<br />
| Follows this block header Geometry shader program.<br />
|- bgcolor="#AAFFAA"<br />
| colspan="4" align="center" | '''if Gfx2 version = 6.x'''<br />
|- bgcolor="#DDFFDD"<br />
| 0x0A<br />
| Follows this block header the GX2 Surface.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0B<br />
| Follows this block header the swizzled image data.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0C<br />
| Follows this block header the swizzled mipmaps data.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0D<br />
| Follows this block header Geometry copy shader program.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0E<br />
| Reserved block.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0F<br />
| Reserved block.<br />
|- bgcolor="#FFAAAA"<br />
| colspan="4" align="center" | '''if Gfx2 version = 7.x'''<br />
|- bgcolor="#FFDDDD"<br />
| 0x0A<br />
| Same as 0x09? (Duplicate?)<br />
|- bgcolor="#FFDDDD"<br />
| 0x0B<br />
| Follows this block header the GX2 Surface.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0C<br />
| Follows this block header the swizzled image data.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0D<br />
| Follows this block header the swizzled mipmaps data.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0E<br />
| Follows this block header Compute shader header.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0F<br />
| Follows this block header Compute shader program.<br />
|-<br />
| 0x10<br />
| Treated like a 0x02 block, users can do what they want with this block.<br />
|}<br />
<br />
=== GX2 Surface ===<br />
The GX2 Surface has an exact size of 0x9C: <br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x00 || 4 || UInt32 || '''Dimension'''. Maps to '''GX2SurfaceDim''' (line 849 [http://pastebin.com/DCrP1w9x here]). Indicates the "shape" of a given surface or texture.<br />
|-<br />
| 0x04 || 4 || UInt32 || '''Texture width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08 || 4 || UInt32 || '''Texture height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C || 4 || UInt32 || '''Texture depth'''.<br />
|-<br />
| 0x10 || 4 || UInt32 || '''Number of mipmaps'''.<br />
|-<br />
| 0x14 || 4 || UInt32 || '''Texture format'''. Maps to '''GX2SurfaceFormat''' (line 589 [http://pastebin.com/DCrP1w9x here] for explanation and format values).<br />
|-<br />
| 0x18 || 4 || UInt32 || '''AA mode'''. Maps to '''GX2AAMode''' (line 865 [http://pastebin.com/DCrP1w9x here]). Indicates the AA mode (number of samples) for the surface.<br />
|-<br />
| 0x1C || 4 || UInt32 || '''Usage'''. Maps to '''GX2SurfaceUse''' (line 823 [http://pastebin.com/DCrP1w9x here]). Indicates how the given surface may be used.<br />
|-<br />
| 0x20 || 4 || UInt32 || '''Data length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24 || 4 || UInt32 || '''Data pointer'''. Set at runtime.<br />
|-<br />
| 0x28 || 4 || UInt32 || '''Mipmaps data length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C || 4 || UInt32 || '''Mipmaps pointer'''. Set at runtime.<br />
|-<br />
| 0x30 || 4 || UInt32 || '''Tile mode'''. Maps to '''GX2TileMode''' (line 795 [http://pastebin.com/DCrP1w9x here]). Indicates the desired tiling mode for the surface.<br />
|-<br />
| 0x34 || 4 || UInt32 || '''Swizzle value'''.<br />
|-<br />
| 0x38 || 4 || UInt32 || '''Alignment'''. Always 512 * bytes per pixel.<br />
|-<br />
| 0x3C || 4 || UInt32 || '''Pitch'''.<br />
|-<br />
| 0x40 || 0x34 || UInt32[13] || '''Mipmap offsets'''. An array of 13 offsets for each mipmap, relative to the start of the mipmap data.<br />
|-<br />
| 0x74 || 4 || UInt32 || '''First mipmap'''.<br />
|-<br />
| 0x78 || 4 || UInt32 || '''Number of mipmaps''' (again).<br />
|-<br />
| 0x7C || 4 || UInt32 || '''First slice'''. Always 0.<br />
|-<br />
| 0x80 || 4 || UInt32 || '''Number of slices'''. Always 1.<br />
|-<br />
| 0x84 || 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.<br />
{| class="wikitable"<br />
! Value !! Name !! Description<br />
|-<br />
| 0 || R || The channel will receive the red values of the texture.<br />
|-<br />
| 1 || G || The channel will receive the green values of the texture.<br />
|-<br />
| 2 || B || The channel will receive the blue values of the texture.<br />
|-<br />
| 3 || A || The channel will receive the alpha values of the texture.<br />
|-<br />
| 4 || 0 || The channel will always have a value 0.<br />
|-<br />
| 5 || 1 || The channel will always have a value 1.<br />
|}<br />
|-<br />
| 0x88 || 0x14 || UInt32[5] || '''Texture registers'''. Array of 5 unsigned integers with unknown purpose.<br />
|}<br />
<br />
== Swizzling ==<br />
[https://pastebin.com/VDvs7q8Y This] code can swizzle image and mipmap data. Call ''swizzle()'' by giving it the width, height, format (in hex), tileMode, swizzle value, pitch and the swizzled data. If you're swizzling then set do_swizzle to ''True''. If you're deswizzling then set do_swizzle to ''False''.<br />
<br />
= Tools =<br />
The following tools can handle GTX/GSH files:<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=AAMP_(File_Format)&diff=4684
AAMP (File Format)
2018-04-01T10:19:51Z
<p>Aboood40091: </p>
<hr />
<div>=== Header ===<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
|0x00<br />
|4<br />
|"'''AAMP'''" File Identifier, ASCII string.<br />
|-<br />
|0x04<br />
|4<br />
|'''Unknown1''', always 0x01000000?<br />
|-<br />
|0x08<br />
|4<br />
|'''Unknown2''', always 0x01000000?<br />
|-<br />
|0x0c<br />
|4<br />
|'''File size''', in little endian.<br />
|-<br />
|0x10<br />
|4<br />
|'''Version'''.<br />
|-<br />
|0x14<br />
|4<br />
|'''Type length''', length of the type string.<br />
|-<br />
|0x18<br />
|Type length<br />
|'''Type''', type of this AAMP file, string.<br />
|}<br />
<br />
== Nodes ==<br />
<br />
{| class="wikitable"<br />
|-<br />
! Identifier<br />
! Description<br />
|-<br />
| 0x00<br />
| Boolen (1 byte)<br />
|-<br />
| 0x01<br />
| Float (4 bytes)<br />
|-<br />
| 0x02<br />
| Integer (4 bytes)<br />
|-<br />
| 0x03<br />
| 2 Floats, Coordinates (8 bytes)<br />
|-<br />
| 0x04<br />
| 3 Floats, Coordinates (12 bytes)<br />
|-<br />
| 0x05<br />
| 4 Floats, Coordinates (16 bytes)<br />
|-<br />
| 0x06<br />
| 4 Floats, Colors (16 bytes)<br />
|-<br />
| 0x07<br />
| String (32 bytes)<br />
|-<br />
| 0x08<br />
| String (64 bytes)<br />
|-<br />
| 0x09<br />
| Unknown (128 bytes)<br />
|-<br />
| 0x0c<br />
| ?Array? with floats<br />
|}<br />
<br />
= Tools =<br />
The following tools can handle AAMP files:<br />
<br />
* [https://github.com/jam1garner/aamp2xml/releases AAMP2XML], by [[jam1garner]] (v2 AAMPs only)<br />
<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=4647
GTX\GSH (File Format)
2018-02-06T12:34:36Z
<p>Aboood40091: </p>
<hr />
<div>'''GTX''' and '''GSH''' files are used in various [[Wii U]] games, including [[Mario Kart 8]]. GSH stands for '''G'''X2 '''SH'''ader and GTX stands for '''G'''X2 '''T'''e'''X'''ture'''.<br />
<br />
== Header ==<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be 0x20 bytes long, or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Data Blocks ==<br />
After the header comes some data blocks, data blocks contain a 0x20 byte '''BLK{''' block header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|- bgcolor="#AAFFAA"<br />
| colspan="4" align="center" | '''if Gfx2 version = 6.x'''<br />
|- bgcolor="#DDFFDD"<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x00 or header is unreadable.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|- bgcolor="#FFAAAA"<br />
| colspan="4" align="center" | '''if Gfx2 version = 7.x'''<br />
|- bgcolor="#FFDDDD"<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type.<br />
|-<br />
| 0x01<br />
| Follows this block header the end of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader header.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader program.<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader header.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader program.<br />
|-<br />
| 0x08<br />
| Follows this block header Geometry shader header.<br />
|-<br />
| 0x09<br />
| Follows this block header Geometry shader program.<br />
|- bgcolor="#AAFFAA"<br />
| colspan="4" align="center" | '''if Gfx2 version = 6.x (not confirmed yet)'''<br />
|- bgcolor="#DDFFDD"<br />
| 0x0A<br />
| Follows this block header the GX2 Surface.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0B<br />
| Follows this block header the swizzled image data.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0C<br />
| Follows this block header the swizzled mipmaps data.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0D<br />
| Follows this block header Compute shader header.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0E<br />
| Follows this block header Compute shader program.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0F<br />
| Treated like a 0x02 block, users can do what they want with this block.<br />
|- bgcolor="#FFAAAA"<br />
| colspan="4" align="center" | '''if Gfx2 version = 7.x'''<br />
|- bgcolor="#FFDDDD"<br />
| 0x0A<br />
| Same as 0x09? (Duplicate?)<br />
|- bgcolor="#FFDDDD"<br />
| 0x0B<br />
| Follows this block header the GX2 Surface.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0C<br />
| Follows this block header the swizzled image data.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0D<br />
| Follows this block header the swizzled mipmaps data.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0E<br />
| Follows this block header Compute shader header.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0F<br />
| Follows this block header Compute shader program.<br />
|- bgcolor="#FFDDDD"<br />
| 0x10<br />
| Treated like a 0x02 block, users can do what they want with this block.<br />
|}<br />
<br />
=== GX2 Surface ===<br />
The GX2 Surface has an exact size of 0x9C: <br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x00 || 4 || UInt32 || '''Dimension'''. Maps to '''GX2SurfaceDim''' (line 849 [http://pastebin.com/DCrP1w9x here]). Indicates the "shape" of a given surface or texture.<br />
|-<br />
| 0x04 || 4 || UInt32 || '''Texture width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08 || 4 || UInt32 || '''Texture height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C || 4 || UInt32 || '''Texture depth'''.<br />
|-<br />
| 0x10 || 4 || UInt32 || '''Number of mipmaps'''.<br />
|-<br />
| 0x14 || 4 || UInt32 || '''Texture format'''. Maps to '''GX2SurfaceFormat''' (line 589 [http://pastebin.com/DCrP1w9x here] for explanation and format values).<br />
|-<br />
| 0x18 || 4 || UInt32 || '''AA mode'''. Maps to '''GX2AAMode''' (line 865 [http://pastebin.com/DCrP1w9x here]). Indicates the AA mode (number of samples) for the surface.<br />
|-<br />
| 0x1C || 4 || UInt32 || '''Usage'''. Maps to '''GX2SurfaceUse''' (line 823 [http://pastebin.com/DCrP1w9x here]). Indicates how the given surface may be used.<br />
|-<br />
| 0x20 || 4 || UInt32 || '''Data length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24 || 4 || UInt32 || '''Data pointer'''. Set at runtime.<br />
|-<br />
| 0x28 || 4 || UInt32 || '''Mipmaps data length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C || 4 || UInt32 || '''Mipmaps pointer'''. Set at runtime.<br />
|-<br />
| 0x30 || 4 || UInt32 || '''Tile mode'''. Maps to '''GX2TileMode''' (line 795 [http://pastebin.com/DCrP1w9x here]). Indicates the desired tiling mode for the surface.<br />
|-<br />
| 0x34 || 4 || UInt32 || '''Swizzle value'''.<br />
|-<br />
| 0x38 || 4 || UInt32 || '''Alignment'''. Always 512 * bytes per pixel.<br />
|-<br />
| 0x3C || 4 || UInt32 || '''Pitch'''.<br />
|-<br />
| 0x40 || 0x34 || UInt32[13] || '''Mipmap offsets'''. An array of 13 offsets for each mipmap, relative to the start of the mipmap data.<br />
|-<br />
| 0x74 || 4 || UInt32 || '''First mipmap'''.<br />
|-<br />
| 0x78 || 4 || UInt32 || '''Number of mipmaps''' (again).<br />
|-<br />
| 0x7C || 4 || UInt32 || '''First slice'''. Always 0.<br />
|-<br />
| 0x80 || 4 || UInt32 || '''Number of slices'''. Always 1.<br />
|-<br />
| 0x84 || 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.<br />
{| class="wikitable"<br />
! Value !! Name !! Description<br />
|-<br />
| 0 || R || The channel will receive the red values of the texture.<br />
|-<br />
| 1 || G || The channel will receive the green values of the texture.<br />
|-<br />
| 2 || B || The channel will receive the blue values of the texture.<br />
|-<br />
| 3 || A || The channel will receive the alpha values of the texture.<br />
|-<br />
| 4 || 0 || The channel will always have a value 0.<br />
|-<br />
| 5 || 1 || The channel will always have a value 1.<br />
|}<br />
|-<br />
| 0x88 || 0x14 || UInt32[5] || '''Texture registers'''. Array of 5 unsigned integers with unknown purpose.<br />
|}<br />
<br />
== Swizzling ==<br />
[https://pastebin.com/VDvs7q8Y This] code can swizzle image and mipmap data. Call ''swizzle()'' by giving it the width, height, format (in hex), tileMode, swizzle value, pitch and the swizzled data. If you're swizzling then set do_swizzle to ''True''. If you're deswizzling then set do_swizzle to ''False''.<br />
<br />
= Tools =<br />
The following tools can handle GTX/GSH files:<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=BFSAR_(File_Format)&diff=4391
BFSAR (File Format)
2017-09-23T05:24:04Z
<p>Aboood40091: </p>
<hr />
<div>A '''BFSAR''' file is an archive containing sound effects. In NSMBU, it also contains all music streams, but I don't think this is the case for MK8.<br />
<br />
See the [http://rhcafe.us.to/?page=wiki&id=BFSAR_%28File_Format%29 RHCafe page] for much more detailed documentation of the file format.<br />
<br />
__TOC__<br />
<br />
= Format =<br />
I found this information by reverse engineering NSMBU and analyzing the bfsar files of NSMBU, SM3DW and Splatoon. I think the same applies to MK8, but since I don't have MK8's files, I can't assure this.<br />
<br />
== Header ==<br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x00 || 4 || Char[4] || '''Magic''' ("'''FSAR'''")<br />
|-<br />
| 0x04 || 2 || UInt16 || '''Endianness'''. 0xFEFF is big endian, 0xFFFE is little endian<br />
|-<br />
| 0x06 || 2 || UInt16 || '''Header size'''. Always 0x0040.<br />
|-<br />
| 0x08 || 4 || UInt32 || '''Version number'''<br />
|-<br />
| 0x0C || 4 || UInt32 || '''File size''' of the entire file.<br />
|-<br />
| 0x10 || 2 || UInt16 || '''Section count'''. Always 3.<br />
|-<br />
| 0x12 || 2 || &mdash; || Padding.<br />
|-<br />
| 0x14 || 3 × 12 || [[#Section information|SectionInfo]][3] ||'''Section info'''. 3 structures describing the offsets to and sizes of the bfsar sections.<br />
|-<br />
| 0x38 || 8 || ? || {{Unknown|'''Unknown''', possibly alignment. Always 0.}}<br />
|}<br />
<br />
=== Section information ===<br />
{| class="wikitable"<br />
! Offset !! Size !! Type || Description<br />
|-<br />
| 0 || 2 || UInt16 || '''Identifier'''. Specifies which section it describes. 0x2000 is the STRG section, 0x2001 is INFO and 0x2002 is FILE.<br />
|-<br />
| 2 || 2 || &mdash; || Padding.<br />
|-<br />
| 4 || 4 || UInt32 || '''Offset'''<br />
|-<br />
| 8 || 4 || UInt32 || '''Size'''<br />
|}<br />
<br />
== STRG Section ==<br />
This section contains a string table and data about the string.<br />
{| class="wikitable"<br />
! Offset !! Size !! Description<br />
|-<br />
| 0x00 || 4 || '''ASCII identifier''' ("'''STRG'''")<br />
|-<br />
| 0x04 || 4 || '''Section size'''<br />
|-<br />
| 0x08 || 4 || {{Unknown|'''Unknown'''. Always 0x24000000}}<br />
|-<br />
| 0x0C || 4 || '''String table offset''', relative to field 0x08 of the STRG section.<br />
|-<br />
| 0x10 || 4 || {{Unknown|'''Unknown'''. Always 0x24010000}}<br />
|-<br />
| 0x14 || 4 || '''Offset''' to lookup table, relative to field 0x08 of the STRG section.<br />
|}<br />
<br />
=== String table ===<br />
The string table contains structures that point to null terminated strings. All offsets are relative to the start of the string table. It starts with a string count and then contains:<br />
{| class="wikitable"<br />
! Offset !! Size !! Description<br />
|-<br />
| 0 || 4 || {{Unknown|'''Unknown'''. Always 0x1F010000.}}<br />
|-<br />
| 4 || 4 || '''Offset''' to null terminated string.<br />
|-<br />
| 8 || 4 || '''Size''' of null terminated string.<br />
|}<br />
<br />
=== Lookup table ===<br />
This table is used to get the string table index and other data for a string. It starts with 8 bytes of data:<br />
{| class="wikitable"<br />
! Offset !! Size !! Description<br />
|-<br />
| 0x00 || 4 || '''Index''' of the table entry where it starts.<br />
|-<br />
| 0x04 || 4 || {{Unknown|'''Unknown'''. Seems to be some kind of index too. Must be higher than the other index.}}<br />
|-<br />
| 0x18 || 4 || '''Count''' of audio names.<br />
|}<br />
And is then followed by 0x14 byte structures:<br />
{| class="wikitable"<br />
! Offset !! Size !! Description<br />
|-<br />
| 0x00 || 2 || '''Endpoint'''. 0 if this is an entry that links to another list entry. 1 if the string has been found and the entry contains data about it.<br />
|-<br />
| 0x02 || 2 || '''String bit'''. This bit in the string that's being searched for decides with which entry the search should continue.<br />
|-<br />
| 0x04 || 4 || This is the table index of the next entry if the string bit is 0.<br />
|-<br />
| 0x08 || 4 || This is the index of the next entry if the string bit is 1.<br />
|-<br />
| 0x0C || 4 || '''String table index''' if this structure is an endpoint.<br />
|-<br />
| 0x10 || 1 || '''Data''' about the file. 1 if it's an audio file (SE/WSD/STRM), 2 if it's a WSDSET or SEQSET, 3 is a BANK, 4=PLAYER and 6=GROUP.<br />
|-<br />
| 0x11 || 3 || '''File id'''<br />
|}<br />
<br />
== INFO Section ==<br />
All offsets in this header are relative to the start of the INFO section + 8.<br />
{| class="wikitable"<br />
! Offset !! Size !! Description<br />
|-<br />
| 0x00 || 4 || '''Magic''' ("'''INFO'''")<br />
|-<br />
| 0x04 || 4 || '''Size''' of INFO section.<br />
|-<br />
| 0x08 || 4 || {{Unknown|'''Unknown'''. Always 0x21000000}}<br />
|-<br />
| 0x0C || 4 || Audio list offset (SE/WSD/STRM)<br />
|-<br />
| 0x10 || 4 || {{Unknown|'''Unknown'''. Always 0x21040000}}<br />
|-<br />
| 0x14 || 4 || Audio set list offset (WSDSET/SEQSET)<br />
|-<br />
| 0x18 || 4 || {{Unknown|'''Unknown'''. Always 0x21010000}}<br />
|-<br />
| 0x1C || 4 || Bank list offset<br />
|-<br />
| 0x20 || 4 || {{Unknown|'''Unknown'''. Always 0x21030000}}<br />
|-<br />
| 0x24 || 4 || {{Unknown|'''Unknown''' offset.}}<br />
|-<br />
| 0x28 || 4 || {{Unknown|'''Unknown'''. Always 0x21050000}}<br />
|-<br />
| 0x2C || 4 || Group list offset<br />
|-<br />
| 0x30 || 4 || {{Unknown|'''Unknown'''. Always 0x21020000}}<br />
|-<br />
| 0x34 || 4 || Player list offset<br />
|-<br />
| 0x38 || 4 || {{Unknown|'''Unknown'''. Always 0x21060000}}<br />
|-<br />
| 0x3C || 4 || {{Unknown|'''Unknown''' offset.}}<br />
|-<br />
| 0x40 || 4 || {{Unknown|'''Unknown'''. Always 0x220B0000}}<br />
|-<br />
| 0x44 || 4 || {{Unknown|'''Unknown''' offset.}}<br />
|}<br />
<br />
Each list starts with the amount of list entries and is then followed by these structures:<br />
{| class="wikitable"<br />
! Offset !! Size !! Description<br />
|-<br />
| 0 || 4 || {{Unknown|'''Unknown'''}}<br />
|-<br />
| 4 || 4 || '''Offset'''<br />
|}<br />
<br />
== FILE Section ==<br />
FILE contains all of the audio data in the BFSAR.<br />
{| class="wikitable"<br />
! Offset !! Size !! Description<br />
|-<br />
| 0x00 || 4 || '''Magic''' ("'''FILE'''")<br />
|-<br />
| 0x04 || 4 || '''Size''' of FILE section.<br />
|}<br />
<br />
There isn't a whole lot else to document about the FILE partition, since the data in it will most definitely vary depending on the game.<br />
<br />
There are multiple FILE partitions, but only 1 of them is the 'main' FILE partition (it's the one you get from the BFSAR header). The 'main' FILE partition contains all of the other sub FILE partitions.<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=BFLIM_(File_Format)&diff=4359
BFLIM (File Format)
2017-09-07T10:43:00Z
<p>Aboood40091: </p>
<hr />
<div>The '''BFLIM''' file format ('''B'''inary ca'''F'''e '''L'''ayout '''IM'''age) is used to store layout images.<br />
<br />
== Header ==<br />
The header is at the end of the file (to align the image data without the need for additional padding). It is always 0x14 bytes.<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x00 || 4 || Char[4] || '''File magic'''. Always ''FLIM'' in ASCII.<br />
|-<br />
| 0x04 || 2 || UInt16 || {{BOM}} Not handled on consoles, so the file data must be stored in the endianness of the target console (e.g. big endian for the Wii U).<br />
|-<br />
| 0x06 || 2 || UInt16 || '''Header size''', always 0x14.<br />
|-<br />
| 0x08 || 4 || UInt32 || '''Version''' of this file.<br />
|-<br />
| 0x0C || 4 || UInt32 || '''File size''' in bytes.<br />
|-<br />
| 0x10 || 2 || UInt16 || '''Number of data blocks''', always 0x01.<br />
|-<br />
| 0x12 || 2 || UInt16 || Padding. Seems to reflect upper 2 bytes of filesize (apparently uninitialized memory garbage from file generator).<br />
|-<br />
| 0x14 || colspan="3" {{Unknown|End of '''FLIM''' header}}<br />
|}<br />
<br />
== Image Information ==<br />
A section containing image information comes directly after header. It is always 0x14 bytes long.<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x14 || 4 || Char[4] || '''Section magic'''. Always ''imag'' in ASCII.<br />
|-<br />
| 0x18 || 4 || UInt32 || '''Parse information size''' (total block size), always 0x10 (this and next 0xC bytes).<br />
|-<br />
| 0x1C || 2 || UInt16 || '''Width''' of the texture in pixels.<br />
|-<br />
| 0x1E || 2 || UInt16 || '''Height''' of the texture in pixels.<br />
|-<br />
| 0x20 || 2 || UInt16 || '''File alignment''', always a power of 2.<br />
|-<br />
| 0x22 || 1 || Byte || '''Format''', how the data is stored.<br />
|-<br />
| 0x23 || 1 || Byte || '''Tile mode''' and '''Swizzle''', packed as bits '''SSSTTTTT'''.<br />
* '''TTTTT''' maps to GX2TileMode (line 795 [https://pastebin.com/DCrP1w9x here]). Typically GX2_TILE_MODE_2D_TILED_THIN1 (4).<br />
* '''SSS''' is the initial swizzle value. Could be anything from 0 to 7.<br />
|-<br />
| 0x24 || 4 || UInt32 || '''Raw data size''', always 0xC minus 0x28 (the header).<br />
|-<br />
| 0x28 || colspan="3" {{Unknown|End of '''Image''' header}}<br />
|}<br />
<br />
== Format ==<br />
{| class="wikitable"<br />
! ID<br />
! Name<br />
! Type<br />
! Bits per pixel (bpp)<br />
|-<br />
|0x00<br />
|R8_UNORM / L8<br />
|luminance<br />
|8<br />
|-<br />
|0x01<br />
|R8_UNORM / A8<br />
|alpha<br />
|8<br />
|-<br />
|0x02<br />
|R4G4_UNORM / L4A4<br />
|luminance+alpha<br />
|8<br />
|-<br />
|0x03<br />
|R8G8_UNORM / L8A8<br />
|luminance+alpha<br />
|16<br />
|-<br />
|0x04<br />
|R8G8_UNORM / HILO8<br />
|??<br />
|16<br />
|-<br />
|0x05<br />
|R5G6B5_UNORM / RGB565<br />
|color<br />
|16<br />
|-<br />
|0x06<br />
|RGBA8_UNORM / RGBX8<br />
|color<br />
|32<br />
|-<br />
|0x07<br />
|RGB5A1_UNORM / RGB5A1<br />
|color+alpha <br />
|16<br />
|-<br />
|0x08<br />
|RGBA4_UNORM / RGBA4<br />
|color+alpha <br />
|16<br />
|-<br />
|0x09<br />
|RGBA8_UNORM / RGBA8<br />
|color+alpha <br />
|32<br />
|-<br />
|0x0A<br />
|BC1_UNORM / ETC1<br />
|color<br />
|64<br />
|-<br />
|0x0B<br />
|BC3_UNORM / ETC1A4<br />
|color+alpha<br />
|128<br />
|-<br />
|0x0C<br />
|BC1_UNORM / DXT1<br />
|color+alpha<br />
|64<br />
|-<br />
|0x0D<br />
|BC2_UNORM / DXT3<br />
|color+alpha<br />
|128<br />
|-<br />
|0x0E<br />
|BC3_UNORM / DXT5<br />
|color+alpha<br />
|128<br />
|-<br />
|0x0F<br />
|BC4_UNORM / BC4L / ATI1 (Low-End)<br />
|luminance<br />
|64<br />
|-<br />
|0x10<br />
|BC4_UNORM / BC4A / ATI1 (High-End)<br />
|alpha<br />
|64<br />
|-<br />
|0x11<br />
|BC5_UNORM / ATI2<br />
|luminance+alpha<br />
|128<br />
|-<br />
|0x12<br />
|BC4_UNORM / L4<br />
|luminance<br />
|4<br />
|-<br />
|0x13<br />
|BC4_UNORM / A4<br />
|alpha<br />
|4<br />
|-<br />
|0x14<br />
|RGBA8_SRGB / RGBA8<br />
|color+alpha<br />
|32<br />
|-<br />
|0x15<br />
|BC1_SRGB / DXT1<br />
|color+alpha<br />
|64<br />
|-<br />
|0x16<br />
|BC2_SRGB / DXT3<br />
|color+alpha<br />
|128<br />
|-<br />
|0x17<br />
|BC3_SRGB / DXT5<br />
|color+alpha<br />
|128<br />
|-<br />
|0x18<br />
|RGB10A2_UNORM / RGB10A2<br />
|color+alpha<br />
|32<br />
|-<br />
|0x19<br />
|RGB565_UNORM / RGB565<br />
|color<br />
|16<br />
|-<br />
|}<br />
<br />
= Tools =<br />
The following tools can handle BFLIM files:<br />
<br />
* [https://mega.nz/#!KgRilZAR!qLGAx1yb9KduShuzxwZjd7nuN329nMjDQvrX9sy-CsE BFLIMtoGTX], by [[User:RandomTalkingBush|RandomTalkingBush]]<br />
* [https://github.com/aboood40091/BFLIM-Tool/releases/tag/v1.0 BFLIM Tool], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=4321
GTX\GSH (File Format)
2017-08-14T23:05:59Z
<p>Aboood40091: </p>
<hr />
<div>'''GTX''' and '''GSH''' files are used in various [[Wii U]] games, including [[Mario Kart 8]]. GSH stands for '''G'''X2 '''SH'''ader and GTX stands for '''G'''X2 '''T'''e'''X'''ture'''.<br />
<br />
== Header ==<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be the real size (0x20), or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Data Blocks ==<br />
After the header comes some data blocks, data blocks contain a 0x20 byte '''BLK{''' block header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type.<br />
|-<br />
| 0x01<br />
| Follows this block header the end of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader header.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader program.<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader header.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader program.<br />
|-<br />
| 0x08<br />
| Follows this block header Geometry shader header.<br />
|-<br />
| 0x09<br />
| Follows this block header Geometry shader program.<br />
|- bgcolor="#AAFFAA"<br />
| colspan="4" align="center" | '''if Gfx2 version = 6.x (not confirmed yet)'''<br />
|- bgcolor="#DDFFDD"<br />
| 0x0A<br />
| Follows this block header the GX2 Surface.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0B<br />
| Follows this block header the swizzled image data.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0C<br />
| Follows this block header the swizzled mipmaps data.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0D<br />
| Follows this block header Compute shader header.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0E<br />
| Follows this block header Compute shader program.<br />
|- bgcolor="#DDFFDD"<br />
| 0x0F<br />
| Treated like a 0x02 block, users can do what they want with this block.<br />
|- bgcolor="#FFAAAA"<br />
| colspan="4" align="center" | '''if Gfx2 version = 7.x'''<br />
|- bgcolor="#FFDDDD"<br />
| 0x0A<br />
| Same as 0x09? (Duplicate?)<br />
|- bgcolor="#FFDDDD"<br />
| 0x0B<br />
| Follows this block header the GX2 Surface.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0C<br />
| Follows this block header the swizzled image data.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0D<br />
| Follows this block header the swizzled mipmaps data.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0E<br />
| Follows this block header Compute shader header.<br />
|- bgcolor="#FFDDDD"<br />
| 0x0F<br />
| Follows this block header Compute shader program.<br />
|- bgcolor="#FFDDDD"<br />
| 0x10<br />
| Treated like a 0x02 block, users can do what they want with this block.<br />
|}<br />
<br />
=== GX2 Surface ===<br />
The GX2 Surface has an exact size of 0x9C: <br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x00 || 4 || UInt32 || '''Dimension'''. Maps to '''GX2SurfaceDim''' (line 849 [http://pastebin.com/DCrP1w9x here]). Indicates the "shape" of a given surface or texture.<br />
|-<br />
| 0x04 || 4 || UInt32 || '''Texture width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08 || 4 || UInt32 || '''Texture height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C || 4 || UInt32 || '''Texture depth'''.<br />
|-<br />
| 0x10 || 4 || UInt32 || '''Number of mipmaps'''.<br />
|-<br />
| 0x14 || 4 || UInt32 || '''Texture format'''. Maps to '''GX2SurfaceFormat''' (line 589 [http://pastebin.com/DCrP1w9x here] for explanation and format values).<br />
|-<br />
| 0x18 || 4 || UInt32 || '''AA mode'''. Maps to '''GX2AAMode''' (line 865 [http://pastebin.com/DCrP1w9x here]). Indicates the AA mode (number of samples) for the surface.<br />
|-<br />
| 0x1C || 4 || UInt32 || '''Usage'''. Maps to '''GX2SurfaceUse''' (line 823 [http://pastebin.com/DCrP1w9x here]). Indicates how the given surface may be used.<br />
|-<br />
| 0x20 || 4 || UInt32 || '''Data length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24 || 4 || UInt32 || '''Data pointer'''. Set at runtime.<br />
|-<br />
| 0x28 || 4 || UInt32 || '''Mipmaps data length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C || 4 || UInt32 || '''Mipmaps pointer'''. Set at runtime.<br />
|-<br />
| 0x30 || 4 || UInt32 || '''Tile mode'''. Maps to '''GX2TileMode''' (line 795 [http://pastebin.com/DCrP1w9x here]). Indicates the desired tiling mode for the surface.<br />
|-<br />
| 0x34 || 4 || UInt32 || '''Swizzle value'''.<br />
|-<br />
| 0x38 || 4 || UInt32 || '''Alignment'''. Always 512 * bytes per pixel.<br />
|-<br />
| 0x3C || 4 || UInt32 || '''Pitch'''.<br />
|-<br />
| 0x40 || 0x34 || UInt32[13] || '''Mipmap offsets'''. An array of 13 offsets for each mipmap, relative to the start of the mipmap data.<br />
|-<br />
| 0x74 || 4 || UInt32 || '''First mipmap'''.<br />
|-<br />
| 0x78 || 4 || UInt32 || '''Number of mipmaps''' (again).<br />
|-<br />
| 0x7C || 4 || UInt32 || '''First slice'''. Always 0.<br />
|-<br />
| 0x80 || 4 || UInt32 || '''Number of slices'''. Always 1.<br />
|-<br />
| 0x84 || 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.<br />
{| class="wikitable"<br />
! Value !! Name !! Description<br />
|-<br />
| 0 || R || The channel will receive the red values of the texture.<br />
|-<br />
| 1 || G || The channel will receive the green values of the texture.<br />
|-<br />
| 2 || B || The channel will receive the blue values of the texture.<br />
|-<br />
| 3 || A || The channel will receive the alpha values of the texture.<br />
|-<br />
| 4 || 0 || The channel will always have a value 0.<br />
|-<br />
| 5 || 1 || The channel will always have a value 1.<br />
|}<br />
|-<br />
| 0x88 || 0x14 || UInt32[5] || '''Texture registers'''. Array of 5 unsigned integers with unknown purpose.<br />
|}<br />
<br />
== Swizzling ==<br />
[https://pastebin.com/VDvs7q8Y This] code can swizzle image and mipmap data. Call ''swizzle()'' by giving it the width, height, format (in hex), tileMode, swizzle value, pitch and the swizzled data. If you're swizzling then set do_swizzle to ''True''. If you're deswizzling then set do_swizzle to ''False''.<br />
<br />
= Tools =<br />
The following tools can handle GTX/GSH files:<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=BFLIM_(File_Format)&diff=4290
BFLIM (File Format)
2017-08-01T21:35:33Z
<p>Aboood40091: </p>
<hr />
<div>The '''BFLIM''' file format ('''B'''inary ca'''F'''e '''L'''ayout '''IM'''age) is used to store layout images.<br />
<br />
== Header ==<br />
The header is at the end of the file (to align the image data without the need for additional padding). It is always 0x14 bytes.<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x00 || 4 || Char[4] || '''File magic'''. Always ''FLIM'' in ASCII.<br />
|-<br />
| 0x04 || 2 || UInt16 || {{BOM}} Not handled on consoles, so the file data must be stored in the endianness of the target console (e.g. big endian for the Wii U).<br />
|-<br />
| 0x06 || 2 || UInt16 || '''Header size''', always 0x14.<br />
|-<br />
| 0x08 || 4 || UInt32 || '''Version''' of this file.<br />
|-<br />
| 0x0C || 4 || UInt32 || '''File size''' in bytes.<br />
|-<br />
| 0x10 || 2 || UInt16 || '''Number of data blocks''', always 0x01.<br />
|-<br />
| 0x12 || 2 || UInt16 || Padding. Seems to reflect upper 2 bytes of filesize (apparently uninitialized memory garbage from file generator).<br />
|-<br />
| 0x14 || colspan="3" {{Unknown|End of '''FLIM''' header}}<br />
|}<br />
<br />
== Image Information ==<br />
A section containing image information comes directly after header. It is always 0x14 bytes long.<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x14 || 4 || Char[4] || '''Section magic'''. Always ''imag'' in ASCII.<br />
|-<br />
| 0x18 || 4 || UInt32 || '''Parse information size''' (total block size), always 0x10 (this and next 0xC bytes).<br />
|-<br />
| 0x1C || 2 || UInt16 || '''Width''' of the texture in pixels.<br />
|-<br />
| 0x1E || 2 || UInt16 || '''Height''' of the texture in pixels.<br />
|-<br />
| 0x20 || 2 || UInt16 || '''File alignment''', always a power of 2.<br />
|-<br />
| 0x22 || 1 || Byte || '''Format''', how the data is stored.<br />
|-<br />
| 0x23 || 1 || Byte || '''Tile mode''' and '''Swizzle''', packed as bits '''SSSTTTTT'''.<br />
* '''TTTTT''' maps to GX2TileMode (line 795 [https://pastebin.com/DCrP1w9x here]). Typically GX2_TILE_MODE_2D_TILED_THIN1 (4).<br />
* '''SSS''' is the swizzle value shifted right by 8.<br />
|-<br />
| 0x24 || 4 || UInt32 || '''Raw data size''', always 0xC minus 0x28 (the header).<br />
|-<br />
| 0x28 || colspan="3" {{Unknown|End of '''Image''' header}}<br />
|}<br />
<br />
== Format ==<br />
{| class="wikitable"<br />
! ID<br />
! Name<br />
! Type<br />
! Bits per pixel (bpp)<br />
|-<br />
|0x00<br />
|R8_UNORM / L8<br />
|luminance<br />
|8<br />
|-<br />
|0x01<br />
|R8_UNORM / A8<br />
|alpha<br />
|8<br />
|-<br />
|0x02<br />
|R4G4_UNORM / L4A4<br />
|luminance+alpha<br />
|8<br />
|-<br />
|0x03<br />
|R8G8_UNORM / L8A8<br />
|luminance+alpha<br />
|16<br />
|-<br />
|0x04<br />
|R8G8_UNORM / HILO8<br />
|??<br />
|16<br />
|-<br />
|0x05<br />
|R5G6B5_UNORM / RGB565<br />
|color<br />
|16<br />
|-<br />
|0x06<br />
|RGBA8_UNORM / RGBX8<br />
|color<br />
|32<br />
|-<br />
|0x07<br />
|RGB5A1_UNORM / RGB5A1<br />
|color+alpha <br />
|16<br />
|-<br />
|0x08<br />
|RGBA4_UNORM / RGBA4<br />
|color+alpha <br />
|16<br />
|-<br />
|0x09<br />
|RGBA8_UNORM / RGBA8<br />
|color+alpha <br />
|32<br />
|-<br />
|0x0A<br />
|BC1_UNORM / ETC1<br />
|color<br />
|64<br />
|-<br />
|0x0B<br />
|BC3_UNORM / ETC1A4<br />
|color+alpha<br />
|128<br />
|-<br />
|0x0C<br />
|BC1_UNORM / DXT1<br />
|color<br />
|64<br />
|-<br />
|0x0D<br />
|BC2_UNORM / DXT3<br />
|color+alpha<br />
|128<br />
|-<br />
|0x0E<br />
|BC3_UNORM / DXT5<br />
|color+alpha<br />
|128<br />
|-<br />
|0x0F<br />
|BC4_UNORM / BC4L / ATI1 (Low-End)<br />
|luminance<br />
|64<br />
|-<br />
|0x10<br />
|BC4_UNORM / BC4A / ATI1 (High-End)<br />
|alpha<br />
|64<br />
|-<br />
|0x11<br />
|BC5_UNORM / ATI2<br />
|luminance+alpha<br />
|128<br />
|-<br />
|0x12<br />
|BC4_UNORM / L4<br />
|luminance<br />
|4<br />
|-<br />
|0x13<br />
|BC4_UNORM / A4<br />
|alpha<br />
|4<br />
|-<br />
|0x14<br />
|RGBA8_SRGB / RGBA8<br />
|color+alpha<br />
|32<br />
|-<br />
|0x15<br />
|BC1_SRGB / DXT1<br />
|color<br />
|64<br />
|-<br />
|0x16<br />
|BC2_SRGB / DXT3<br />
|color+alpha<br />
|128<br />
|-<br />
|0x17<br />
|BC3_SRGB / DXT5<br />
|color+alpha<br />
|128<br />
|-<br />
|0x18<br />
|RGB10A2_UNORM / RGB10A2<br />
|color+alpha<br />
|32<br />
|-<br />
|0x19<br />
|RGB565_UNORM / RGB565<br />
|color<br />
|16<br />
|-<br />
|}<br />
<br />
= Tools =<br />
The following tools can handle BFLIM files:<br />
<br />
* [https://mega.nz/#!KgRilZAR!qLGAx1yb9KduShuzxwZjd7nuN329nMjDQvrX9sy-CsE BFLIMtoGTX], by [[User:RandomTalkingBush|RandomTalkingBush]]<br />
* [https://github.com/aboood40091/BFLIM-Tool/releases/tag/v1.0 BFLIM Tool], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=BFLIM_(File_Format)&diff=4222
BFLIM (File Format)
2017-07-24T20:27:44Z
<p>Aboood40091: </p>
<hr />
<div>The '''BFLIM''' file format ('''B'''inary ca'''F'''e '''L'''ayout '''IM'''age) is used to store layout images.<br />
<br />
== Header ==<br />
The header is at the end of the file (to align the image data without the need for additional padding). It is always 0x14 bytes.<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x00 || 4 || Char[4] || '''File magic'''. Always ''FLIM'' in ASCII.<br />
|-<br />
| 0x04 || 2 || UInt16 || {{BOM}} Not handled on consoles, so the file data must be stored in the endianness of the target console (e.g. big endian for the Wii U).<br />
|-<br />
| 0x06 || 2 || UInt16 || '''Header size''', always 0x14.<br />
|-<br />
| 0x08 || 4 || UInt32 || '''Version''' of this file.<br />
|-<br />
| 0x0C || 4 || UInt32 || '''File size''' in bytes.<br />
|-<br />
| 0x10 || 2 || UInt16 || '''Number of data blocks''', always 0x01.<br />
|-<br />
| 0x12 || 2 || UInt16 || Padding. Seems to reflect upper 2 bytes of filesize (apparently uninitialized memory garbage from file generator).<br />
|-<br />
| 0x14 || colspan="3" {{Unknown|End of '''FLIM''' header}}<br />
|}<br />
<br />
== Image Information ==<br />
A section containing image information comes directly after header. It is always 0x14 bytes long.<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x14 || 4 || Char[4] || '''Section magic'''. Always ''imag'' in ASCII.<br />
|-<br />
| 0x18 || 4 || UInt32 || '''Parse information size''' (total block size), always 0x10 (this and next 0xC bytes).<br />
|-<br />
| 0x1C || 2 || UInt16 || '''Width''' of the texture in pixels.<br />
|-<br />
| 0x1E || 2 || UInt16 || '''Height''' of the texture in pixels.<br />
|-<br />
| 0x20 || 2 || UInt16 || '''File alignment''', always a power of 2. Usually 0x800, 0x1000 or 0x2000.<br />
|-<br />
| 0x22 || 1 || Byte || '''Format''', how the data is stored.<br />
|-<br />
| 0x23 || 1 || Byte || '''Tile mode''' and '''Swizzle''', packed as bits '''SSSTTTTT'''.<br />
* '''TTTTT''' maps to GX2TileMode (line 795 [https://pastebin.com/DCrP1w9x here]). Typically GX2_TILE_MODE_2D_TILED_THIN1 (4).<br />
* '''SSS''' is the swizzle value shifted right by 8.<br />
|-<br />
| 0x24 || 4 || UInt32 || '''Raw data size''', always 0xC minus 0x28 (the header).<br />
|-<br />
| 0x28 || colspan="3" {{Unknown|End of '''Image''' header}}<br />
|}<br />
<br />
== Format ==<br />
{| class="wikitable"<br />
! ID<br />
! Name<br />
! Type<br />
! Bits per pixel (bpp)<br />
|-<br />
|0x00<br />
|R8_UNORM / L8<br />
|luminance<br />
|8<br />
|-<br />
|0x01<br />
|R8_UNORM / A8<br />
|alpha<br />
|8<br />
|-<br />
|0x02<br />
|R4G4_UNORM / A4L4<br />
|luminance+alpha<br />
|8<br />
|-<br />
|0x03<br />
|R8G8_UNORM / A8L8<br />
|luminance+alpha<br />
|16<br />
|-<br />
|0x04<br />
|R8G8_UNORM / HILO8<br />
|??<br />
|16<br />
|-<br />
|0x05<br />
|R5G6B5_UNORM / RGB565<br />
|color<br />
|16<br />
|-<br />
|0x06<br />
|RGBA8_UNORM / XBGR8 (BGR8)<br />
|color<br />
|32<br />
|-<br />
|0x07<br />
|RGB5A1_UNORM / A1RGB5<br />
|color+alpha <br />
|16<br />
|-<br />
|0x08<br />
|RGBA4_UNORM / ARGB4<br />
|color+alpha <br />
|16<br />
|-<br />
|0x09<br />
|RGBA8_UNORM / ABGR8<br />
|color+alpha <br />
|32<br />
|-<br />
|0x0A<br />
|BC1_UNORM / ETC1<br />
|color<br />
|64<br />
|-<br />
|0x0B<br />
|BC3_UNORM / ETC1A4<br />
|color+alpha<br />
|128<br />
|-<br />
|0x0C<br />
|BC1_UNORM / DXT1<br />
|color+alpha<br />
|64<br />
|-<br />
|0x0D<br />
|BC2_UNORM / DXT3<br />
|color+alpha<br />
|128<br />
|-<br />
|0x0E<br />
|BC3_UNORM / DXT5<br />
|color+alpha<br />
|128<br />
|-<br />
|0x0F<br />
|BC4_UNORM / BC4L / ATI1 (Low-End)<br />
|luminance<br />
|64<br />
|-<br />
|0x10<br />
|BC4_UNORM / BC4A / ATI1 (High-End)<br />
|alpha<br />
|64<br />
|-<br />
|0x11<br />
|BC5_UNORM / ATI2<br />
|luminance+alpha<br />
|128<br />
|-<br />
|0x12<br />
|BC4_UNORM / L4<br />
|luminance<br />
|4<br />
|-<br />
|0x13<br />
|BC4_UNORM / A4<br />
|alpha<br />
|4<br />
|-<br />
|0x14<br />
|RGBA8_SRGB / ABGR8 (SRGB)<br />
|color+alpha<br />
|32<br />
|-<br />
|0x15<br />
|BC1_SRGB / DXT1 (SRGB)<br />
|color+alpha<br />
|64<br />
|-<br />
|0x16<br />
|BC2_SRGB / DXT3 (SRGB)<br />
|color+alpha<br />
|128<br />
|-<br />
|0x17<br />
|BC3_SRGB / DXT5 (SRGB)<br />
|color+alpha<br />
|128<br />
|-<br />
|0x18<br />
|RGB10A2_UNORM / A2BGR10<br />
|color+alpha<br />
|32<br />
|-<br />
|0x19<br />
|RGB565_UNORM / RGB565<br />
|color<br />
|16<br />
|-<br />
|}<br />
<br />
= Tools =<br />
The following tools can handle BFLIM files:<br />
<br />
* [https://mega.nz/#!KgRilZAR!qLGAx1yb9KduShuzxwZjd7nuN329nMjDQvrX9sy-CsE BFLIMtoGTX], by [[User:RandomTalkingBush|RandomTalkingBush]]<br />
* [https://github.com/aboood40091/BFLIM-Tool/releases/tag/v1.0 BFLIM Tool], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=BFLIM_(File_Format)&diff=4220
BFLIM (File Format)
2017-07-24T10:44:52Z
<p>Aboood40091: </p>
<hr />
<div>The '''BFLIM''' file format ('''B'''inary ca'''F'''e '''L'''ayout '''IM'''age) is used to store layout images.<br />
<br />
== Header ==<br />
The header is at the end of the file (to align the image data without the need for additional padding). It is always 0x14 bytes.<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x00 || 4 || Char[4] || '''File magic'''. Always ''FLIM'' in ASCII.<br />
|-<br />
| 0x04 || 2 || UInt16 || {{BOM}} Not handled on consoles, so the file data must be stored in the endianness of the target console (e.g. big endian for the Wii U).<br />
|-<br />
| 0x06 || 2 || UInt16 || '''Header size''', always 0x14.<br />
|-<br />
| 0x08 || 4 || UInt32 || '''Version''' of this file.<br />
|-<br />
| 0x0C || 4 || UInt32 || '''File size''' in bytes.<br />
|-<br />
| 0x10 || 2 || UInt16 || '''Number of data blocks''', always 0x01.<br />
|-<br />
| 0x12 || 2 || UInt16 || Padding. Seems to reflect upper 2 bytes of filesize (apparently uninitialized memory garbage from file generator).<br />
|-<br />
| 0x14 || colspan="3" {{Unknown|End of '''FLIM''' header}}<br />
|}<br />
<br />
== Image Information ==<br />
A section containing image information comes directly after header. It is always 0x14 bytes long.<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x14 || 4 || Char[4] || '''Section magic'''. Always ''imag'' in ASCII.<br />
|-<br />
| 0x18 || 4 || UInt32 || '''Parse information size''' (total block size), always 0x10 (this and next 0xC bytes).<br />
|-<br />
| 0x1C || 2 || UInt16 || '''Width''' of the texture in pixels.<br />
|-<br />
| 0x1E || 2 || UInt16 || '''Height''' of the texture in pixels.<br />
|-<br />
| 0x20 || 2 || UInt16 || '''File alignment''', always a power of 2. Usually 0x800, 0x1000 or 0x2000.<br />
|-<br />
| 0x22 || 1 || Byte || '''Format''', how the data is stored.<br />
|-<br />
| 0x23 || 1 || Byte || '''Tile mode''' and '''Swizzle''', packed as bits '''SSSTTTTT'''.<br />
* '''TTTTT''' maps to GX2TileMode (line 795 [https://pastebin.com/DCrP1w9x here]). Typically GX2_TILE_MODE_2D_TILED_THIN1 (4).<br />
* '''SSS''' is the swizzle value shifted right by 8.<br />
|-<br />
| 0x24 || 4 || UInt32 || '''Raw data size''', always 0xC minus 0x28 (the header).<br />
|-<br />
| 0x28 || colspan="3" {{Unknown|End of '''Image''' header}}<br />
|}<br />
<br />
== Format ==<br />
{| class="wikitable"<br />
! ID<br />
! Name<br />
! Type<br />
! Bits per pixel (bpp)<br />
|-<br />
|0x00<br />
|R8_UNORM / L8<br />
|luminance<br />
|8<br />
|-<br />
|0x01<br />
|R8_UNORM / A8<br />
|alpha<br />
|8<br />
|-<br />
|0x02<br />
|R4G4_UNORM / L4A4<br />
|luminance+alpha<br />
|8<br />
|-<br />
|0x03<br />
|R8G8_UNORM / L8A8<br />
|luminance+alpha<br />
|16<br />
|-<br />
|0x04<br />
|R8G8_UNORM / HILO8<br />
|??<br />
|16<br />
|-<br />
|0x05<br />
|R5G6B5_UNORM / RGB565<br />
|color<br />
|16<br />
|-<br />
|0x06<br />
|RGBA8_UNORM / RGB888<br />
|color<br />
|32<br />
|-<br />
|0x07<br />
|RGB5A1_UNORM / RGB555A1<br />
|color+alpha <br />
|16<br />
|-<br />
|0x08<br />
|RGBA4_UNORM / RGBA4444<br />
|color+alpha <br />
|16<br />
|-<br />
|0x09<br />
|RGBA8_UNORM / RGBA8888<br />
|color+alpha <br />
|32<br />
|-<br />
|0x0A<br />
|BC1_UNORM / ETC1<br />
|color<br />
|64<br />
|-<br />
|0x0B<br />
|BC3_UNORM / ETC1A4<br />
|color+alpha<br />
|128<br />
|-<br />
|0x0C<br />
|BC1_UNORM / DXT1<br />
|color+alpha<br />
|64<br />
|-<br />
|0x0D<br />
|BC2_UNORM / DXT3<br />
|color+alpha<br />
|128<br />
|-<br />
|0x0E<br />
|BC3_UNORM / DXT5<br />
|color+alpha<br />
|128<br />
|-<br />
|0x0F<br />
|BC4_UNORM / BC4L / ATI1 (Low-End)<br />
|luminance<br />
|64<br />
|-<br />
|0x10<br />
|BC4_UNORM / BC4A / ATI1 (High-End)<br />
|alpha<br />
|64<br />
|-<br />
|0x11<br />
|BC5_UNORM / ATI2<br />
|luminance+alpha<br />
|128<br />
|-<br />
|0x12<br />
|BC4_UNORM / L4<br />
|luminance<br />
|4<br />
|-<br />
|0x13<br />
|BC4_UNORM / A4<br />
|alpha<br />
|4<br />
|-<br />
|0x14<br />
|RGBA8_SRGB / RGBA8888 <br />
|color+alpha<br />
|32<br />
|-<br />
|0x15<br />
|BC1_SRGB / DXT1<br />
|color+alpha<br />
|64<br />
|-<br />
|0x16<br />
|BC2_SRGB / DXT3<br />
|color+alpha<br />
|128<br />
|-<br />
|0x17<br />
|BC3_SRGB / DXT5<br />
|color+alpha<br />
|128<br />
|-<br />
|0x18<br />
|RGB10A2_UNORM / RGB10A2<br />
|color+alpha<br />
|32<br />
|-<br />
|0x19<br />
|RGB565_UNORM / RGB565<br />
|color<br />
|16<br />
|-<br />
|}<br />
<br />
= Tools =<br />
The following tools can handle BFLIM files:<br />
<br />
* [https://mega.nz/#!KgRilZAR!qLGAx1yb9KduShuzxwZjd7nuN329nMjDQvrX9sy-CsE BFLIMtoGTX], by [[User:RandomTalkingBush|RandomTalkingBush]]<br />
* [https://github.com/aboood40091/BFLIM-Tool/releases/tag/v1.0 BFLIM Tool], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=BFLIM_(File_Format)&diff=4219
BFLIM (File Format)
2017-07-24T10:35:58Z
<p>Aboood40091: </p>
<hr />
<div>The '''BFLIM''' file format ('''B'''inary ca'''F'''e '''L'''ayout '''IM'''age) is used to store layout images.<br />
<br />
== Header ==<br />
The header is at the end of the file (to align the image data without the need for additional padding). It is always 0x14 bytes.<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x00 || 4 || Char[4] || '''File magic'''. Always ''FLIM'' in ASCII.<br />
|-<br />
| 0x04 || 2 || UInt16 || {{BOM}} Not handled on consoles, so the file data must be stored in the endianness of the target console (e.g. big endian for the Wii U).<br />
|-<br />
| 0x06 || 2 || UInt16 || '''Header size''', always 0x14.<br />
|-<br />
| 0x08 || 4 || UInt32 || '''Version''' of this file.<br />
|-<br />
| 0x0C || 4 || UInt32 || '''File size''' in bytes.<br />
|-<br />
| 0x10 || 2 || UInt16 || '''Number of data blocks''', always 0x01.<br />
|-<br />
| 0x12 || 2 || UInt16 || Padding. Seems to reflect upper 2 bytes of filesize (apparently uninitialized memory garbage from file generator).<br />
|-<br />
| 0x14 || colspan="3" {{Unknown|End of '''FLIM''' header}}<br />
|}<br />
<br />
== Image Information ==<br />
A section containing image information comes directly after header. It is always 0x14 bytes long.<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x14 || 4 || Char[4] || '''Section magic'''. Always ''imag'' in ASCII.<br />
|-<br />
| 0x18 || 4 || UInt32 || '''Parse information size''' (total block size), always 0x10 (this and next 0xC bytes).<br />
|-<br />
| 0x1C || 2 || UInt16 || '''Width''' of the texture in pixels.<br />
|-<br />
| 0x1E || 2 || UInt16 || '''Height''' of the texture in pixels.<br />
|-<br />
| 0x20 || 2 || UInt16 || '''File alignment''', always a power of 2. Usually 0x800, 0x1000 or 0x2000.<br />
|-<br />
| 0x22 || 1 || Byte || '''Format''', how the data is stored.<br />
|-<br />
| 0x23 || 1 || Byte || '''Tile mode''' and '''Swizzle''', packed as bits '''SSSTTTTT'''.<br />
* '''TTTTT''' maps to GX2TileMode (line 795 [https://pastebin.com/DCrP1w9x here]). Typically GX2_TILE_MODE_2D_TILED_THIN1 (4).<br />
* '''SSS''' is the swizzle value shifted right by 8.<br />
|-<br />
| 0x24 || 4 || UInt32 || '''Raw data size''', always 0xC minus 0x28 (the header).<br />
|-<br />
| 0x28 || colspan="3" {{Unknown|End of '''Image''' header}}<br />
|}<br />
<br />
== Format ==<br />
{| class="wikitable"<br />
! ID<br />
! Name<br />
! Type<br />
! Bits per pixel (bpp)<br />
|-<br />
|0x00<br />
|R8_UNORM / L8<br />
|luminance<br />
|8<br />
|-<br />
|0x01<br />
|R8_UNORM / A8<br />
|alpha<br />
|8<br />
|-<br />
|0x02<br />
|R4G4_UNORM / L4A4<br />
|luminance+alpha<br />
|8<br />
|-<br />
|0x03<br />
|R8G8_UNORM / L8A8<br />
|luminance+alpha<br />
|16<br />
|-<br />
|0x04<br />
|R8G8_UNORM / HILO8<br />
|??<br />
|16<br />
|-<br />
|0x05<br />
|R5G6B5_UNORM / RGB565<br />
|color<br />
|16<br />
|-<br />
|0x06<br />
|RGB8_UNORM / RGB888<br />
|color<br />
|32<br />
|-<br />
|0x07<br />
|RGB5A1_UNORM / RGB555A1<br />
|color+alpha <br />
|16<br />
|-<br />
|0x08<br />
|RGBA4_UNORM / RGBA4444<br />
|color+alpha <br />
|16<br />
|-<br />
|0x09<br />
|RGBA8_UNORM / RGBA8888<br />
|color+alpha <br />
|32<br />
|-<br />
|0x0A<br />
|BC1_UNORM / ETC1<br />
|color<br />
|64<br />
|-<br />
|0x0B<br />
|BC3_UNORM / ETC1A4<br />
|color+alpha<br />
|128<br />
|-<br />
|0x0C<br />
|BC1_UNORM / DXT1<br />
|color+alpha<br />
|64<br />
|-<br />
|0x0D<br />
|BC2_UNORM / DXT3<br />
|color+alpha<br />
|128<br />
|-<br />
|0x0E<br />
|BC3_UNORM / DXT5<br />
|color+alpha<br />
|128<br />
|-<br />
|0x0F<br />
|BC4_UNORM / BC4L / ATI1 (Low-End)<br />
|luminance<br />
|64<br />
|-<br />
|0x10<br />
|BC4_UNORM / BC4A / ATI1 (High-End)<br />
|alpha<br />
|64<br />
|-<br />
|0x11<br />
|BC5_UNORM / ATI2<br />
|luminance+alpha<br />
|128<br />
|-<br />
|0x12<br />
|BC4_UNORM / L4<br />
|luminance<br />
|4<br />
|-<br />
|0x13<br />
|BC4_UNORM / A4<br />
|alpha<br />
|4<br />
|-<br />
|0x14<br />
|RGBA8_SRGB / RGBA8888 <br />
|color+alpha<br />
|32<br />
|-<br />
|0x15<br />
|BC1_SRGB / DXT1<br />
|color+alpha<br />
|64<br />
|-<br />
|0x16<br />
|BC2_SRGB / DXT3<br />
|color+alpha<br />
|128<br />
|-<br />
|0x17<br />
|BC3_SRGB / DXT5<br />
|color+alpha<br />
|128<br />
|-<br />
|0x18<br />
|RGB10A2_UNORM / RGB10A2<br />
|color+alpha<br />
|32<br />
|-<br />
|0x19<br />
|RGB565_UNORM / RGB565<br />
|color<br />
|16<br />
|-<br />
|}<br />
<br />
= Tools =<br />
The following tools can handle BFLIM files:<br />
<br />
* [https://mega.nz/#!KgRilZAR!qLGAx1yb9KduShuzxwZjd7nuN329nMjDQvrX9sy-CsE BFLIMtoGTX], by [[User:RandomTalkingBush|RandomTalkingBush]]<br />
* [https://github.com/aboood40091/BFLIM-Tool/releases/tag/v1.0 BFLIM Tool], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=BFLIM_(File_Format)&diff=4210
BFLIM (File Format)
2017-07-21T22:20:36Z
<p>Aboood40091: Inconsistent and unnecessary.</p>
<hr />
<div>The '''BFLIM''' file format ('''B'''inary ca'''F'''e '''L'''ayout '''IM'''age) is used to store layout images.<br />
<br />
== Header ==<br />
The header is at the end of the file (to align the image data without the need for additional padding). It is always 0x14 bytes.<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x00 || 4 || Char[4] || '''File magic'''. Always ''FLIM'' in ASCII.<br />
|-<br />
| 0x04 || 2 || UInt16 || {{BOM}} Not handled on consoles, so the file data must be stored in the endianness of the target console (e.g. big endian for the Wii U).<br />
|-<br />
| 0x06 || 2 || UInt16 || '''Header size''', always 0x14.<br />
|-<br />
| 0x08 || 4 || UInt32 || '''Version''' of this file.<br />
|-<br />
| 0x0C || 4 || UInt32 || '''File size''' in bytes.<br />
|-<br />
| 0x10 || 2 || UInt16 || '''Number of data blocks''', always 0x01.<br />
|-<br />
| 0x12 || 2 || UInt16 || Padding. Seems to reflect upper 2 bytes of filesize (apparently uninitialized memory garbage from file generator).<br />
|-<br />
| 0x14 || colspan="3" {{Unknown|End of '''FLIM''' header}}<br />
|}<br />
<br />
== Image Information ==<br />
A section containing image information comes directly after header. It is always 0x14 bytes long. The formats are not the same in games like New Super Mario Bros U, be sure to use filename if possible (EG: ^l).<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x14 || 4 || Char[4] || '''Section magic'''. Always ''imag'' in ASCII.<br />
|-<br />
| 0x18 || 4 || UInt32 || '''Parse information size''' (total block size), always 0x10 (this and next 0xC bytes).<br />
|-<br />
| 0x1C || 2 || UInt16 || '''Width''' of the texture in pixels.<br />
|-<br />
| 0x1E || 2 || UInt16 || '''Height''' of the texture in pixels.<br />
|-<br />
| 0x20 || 2 || UInt16 || '''File alignment''', always a power of 2. Usually 0x800, 0x1000 or 0x2000.<br />
|-<br />
| 0x22 || 1 || Byte || '''Format''', how the data is stored.<br />
|-<br />
| 0x23 || 1 || Byte || '''Tile mode''' and '''Swizzle''', packed as bits '''SSSTTTTT'''.<br />
* '''TTTTT''' maps to GX2TileMode (line 795 [https://pastebin.com/DCrP1w9x here]). Typically GX2_TILE_MODE_2D_TILED_THIN1 (4).<br />
* '''SSS''' is the swizzle value shifted right by 8.<br />
|-<br />
| 0x24 || 4 || UInt32 || '''Raw data size''', always 0xC minus 0x28 (the header).<br />
|-<br />
| 0x28 || colspan="3" {{Unknown|End of '''Image''' header}}<br />
|}<br />
<br />
== Format ==<br />
{| class="wikitable"<br />
! ID<br />
! Name<br />
! Type<br />
! Bits per pixel (bpp)<br />
|-<br />
|0x00<br />
|R8_UNORM / L8<br />
|luminance<br />
|8<br />
|-<br />
|0x01<br />
|R8_UNORM / A8<br />
|alpha<br />
|8<br />
|-<br />
|0x02<br />
|R4G4_UNORM / L4A4<br />
|luminance+alpha<br />
|8<br />
|-<br />
|0x03<br />
|R8G8_UNORM / L8A8<br />
|luminance+alpha<br />
|16<br />
|-<br />
|0x04<br />
|R8G8_UNORM / HILO8<br />
|alpha<br />
|16<br />
|-<br />
|0x05<br />
|R5G6B5_UNORM / RGB565<br />
|color<br />
|16<br />
|-<br />
|0x06<br />
|RGB8_UNORM / RGB888<br />
|color<br />
|32<br />
|-<br />
|0x07<br />
|RGB5A1_UNORM / RGB555A1<br />
|color+alpha <br />
|16<br />
|-<br />
|0x08<br />
|RGBA4_UNORM / RGBA4444<br />
|color+alpha <br />
|16<br />
|-<br />
|0x09<br />
|RGBA8_UNORM / RGBA8888<br />
|color+alpha <br />
|32<br />
|-<br />
|0x0A<br />
|BC1_UNORM / ETC1<br />
|color<br />
|64<br />
|-<br />
|0x0B<br />
|BC3_UNORM / ETC1A4<br />
|color+alpha<br />
|128<br />
|-<br />
|0x0C<br />
|BC1_UNORM / DXT1<br />
|color+alpha<br />
|64<br />
|-<br />
|0x0D<br />
|BC2_UNORM / DXT3<br />
|color+alpha<br />
|128<br />
|-<br />
|0x0E<br />
|BC3_UNORM / DXT5<br />
|color+alpha<br />
|128<br />
|-<br />
|0x0F<br />
|BC4_UNORM / BC4L / ATI1 (Low-End)<br />
|luminance<br />
|64<br />
|-<br />
|0x10<br />
|BC4_UNORM / BC4A / ATI1 (High-End)<br />
|alpha<br />
|64<br />
|-<br />
|0x11<br />
|BC5_UNORM / ATI2<br />
|luminance+alpha<br />
|128<br />
|-<br />
|0x12<br />
|BC4_UNORM / L4<br />
|luminance<br />
|4<br />
|-<br />
|0x13<br />
|BC4_UNORM / A4<br />
|alpha<br />
|4<br />
|-<br />
|0x14<br />
|RGBA8_SRGB / RGBA8888 <br />
|color+alpha<br />
|32<br />
|-<br />
|0x15<br />
|BC1_SRGB / DXT1<br />
|color+alpha<br />
|64<br />
|-<br />
|0x16<br />
|BC2_SRGB / DXT3<br />
|color+alpha<br />
|128<br />
|-<br />
|0x17<br />
|BC3_SRGB / DXT5<br />
|color+alpha<br />
|128<br />
|-<br />
|0x18<br />
|RGB10A2_UNORM / RGB10A2<br />
|color+alpha<br />
|32<br />
|-<br />
|0x19<br />
|RGB565_UNORM / RGB565<br />
|color<br />
|16<br />
|-<br />
|}<br />
<br />
= Tools =<br />
The following tools can extract (and generate) BFLIM files:<br />
<br />
* [https://mega.nz/#!KgRilZAR!qLGAx1yb9KduShuzxwZjd7nuN329nMjDQvrX9sy-CsE BFLIMtoGTX], by [[User:RandomTalkingBush|RandomTalkingBush]]<br />
* [https://github.com/aboood40091/BFLIM-Tool/releases/tag/v1.0 BFLIM Tool], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=FTEX_(File_Format)&diff=4208
FTEX (File Format)
2017-07-21T21:49:44Z
<p>Aboood40091: </p>
<hr />
<div>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.<br />
<br />
== Header (FTEX) ==<br />
An FTEX file begins with an 0xC0 byte header that starts with the file identifier, followed by info about the texture and mipmaps.<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x00 || 0x04 || Char[4] || '''File magic'''. Always ''FTEX'' in ASCII.<br />
|-<br />
| 0x04 || 0x9C || Struct || '''[[GTX#GX2 Surface|GX2 Surface]]'''.<br />
|-<br />
| 0xA0 || 0x04 || UInt32 || '''Texture handle'''. Set at runtime.<br />
|-<br />
| 0xA4 || 0x04 || UInt32 || '''Array length''' (seems to be just a byte in MK8 files, with the remaining 3 bytes being padding?).<br />
|-<br />
| 0xA8 || 0x04 || Int32 || '''File name''' offset.<br />
|-<br />
| 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]].<br />
|-<br />
| 0xB0 || 0x04 || Int32 || '''Data offset'''. Offset to the texture data.<br />
|-<br />
| 0xB4 || 0x04 || Int32 || '''Mipmap offset'''. Offset to the mipmap texture data.<br />
|-<br />
| 0xB8 || 0x04 || Int32 || '''[[User Data]] [[Index Group]]''' offset.<br />
|-<br />
| 0xBC || 0x02 || UInt16 || '''[[User Data]] entry count'''.<br />
|-<br />
| 0xBE || 0x02 || &mdash; || Padding.<br />
|-<br />
| 0xC0 || colspan="3" {{Unknown|End of '''FTEX''' header}}<br />
|}<br />
<br />
== Image Data ==<br />
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.<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=4207
GTX\GSH (File Format)
2017-07-21T21:49:01Z
<p>Aboood40091: </p>
<hr />
<div>'''GTX''' and '''GSH''' files are used in various [[Wii U]] games, including [[Mario Kart 8]]. GSH stands for '''G'''X2 '''SH'''ader and GTX stands for '''G'''X2 '''T'''e'''X'''ture'''.<br />
<br />
== Header ==<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be the real size (0x20), or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x07, or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Data Blocks ==<br />
After the header comes some data blocks, data blocks contain a 0x20 byte '''BLK{''' block header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type.<br />
|-<br />
| 0x01<br />
| Follows this block header the end of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader header.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader program.<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader header.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader program.<br />
|-<br />
| 0x08<br />
| Follows this block header Geometry shader header.<br />
|-<br />
| 0x09<br />
| Follows this block header Geometry shader program.<br />
|-<br />
| 0x0A<br />
| Same as 0x09? (Duplicate?)<br />
|-<br />
| 0x0B<br />
| Follows this block header the GX2 Surface.<br />
|-<br />
| 0x0C<br />
| Follows this block header the swizzled image data.<br />
|-<br />
| 0x0D<br />
| Follows this block header the swizzled mipmaps data.<br />
|-<br />
| 0x0E<br />
| Follows this block header Compute shader header.<br />
|-<br />
| 0x0F<br />
| Follows this block header Compute shader program.<br />
|-<br />
| 0x10<br />
| Treated like a 0x02 block, users can do what they want with this block.<br />
|}<br />
<br />
=== GX2 Surface ===<br />
The GX2 Surface has an exact size of 0x9C: <br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x00 || 4 || UInt32 || '''Dimension'''. Maps to '''GX2SurfaceDim''' (line 849 [http://pastebin.com/DCrP1w9x here]). Indicates the "shape" of a given surface or texture.<br />
|-<br />
| 0x04 || 4 || UInt32 || '''Texture width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08 || 4 || UInt32 || '''Texture height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C || 4 || UInt32 || '''Texture depth'''.<br />
|-<br />
| 0x10 || 4 || UInt32 || '''Number of mipmaps'''.<br />
|-<br />
| 0x14 || 4 || UInt32 || '''Texture format'''. Maps to '''GX2SurfaceFormat''' (line 589 [http://pastebin.com/DCrP1w9x here] for explanation and format values).<br />
|-<br />
| 0x18 || 4 || UInt32 || '''AA mode'''. Maps to '''GX2AAMode''' (line 865 [http://pastebin.com/DCrP1w9x here]). Indicates the AA mode (number of samples) for the surface.<br />
|-<br />
| 0x1C || 4 || UInt32 || '''Usage'''. Maps to '''GX2SurfaceUse''' (line 823 [http://pastebin.com/DCrP1w9x here]). Indicates how the given surface may be used.<br />
|-<br />
| 0x20 || 4 || UInt32 || '''Data length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24 || 4 || UInt32 || '''Data pointer'''. Set at runtime.<br />
|-<br />
| 0x28 || 4 || UInt32 || '''Mipmaps data length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C || 4 || UInt32 || '''Mipmaps pointer'''. Set at runtime.<br />
|-<br />
| 0x30 || 4 || UInt32 || '''Tile mode'''. Maps to '''GX2TileMode''' (line 795 [http://pastebin.com/DCrP1w9x here]). Indicates the desired tiling mode for the surface.<br />
|-<br />
| 0x34 || 4 || UInt32 || '''Swizzle value'''.<br />
|-<br />
| 0x38 || 4 || UInt32 || '''Alignment'''. Always 512 * bytes per pixel.<br />
|-<br />
| 0x3C || 4 || UInt32 || '''Pitch'''.<br />
|-<br />
| 0x40 || 0x34 || UInt32[13] || '''Mipmap offsets'''. An array of 13 offsets for each mipmap, relative to the start of the mipmap data.<br />
|-<br />
| 0x74 || 4 || UInt32 || '''First mipmap'''.<br />
|-<br />
| 0x78 || 4 || UInt32 || '''Number of mipmaps''' (again).<br />
|-<br />
| 0x7C || 4 || UInt32 || '''First slice'''. Always 0.<br />
|-<br />
| 0x80 || 4 || UInt32 || '''Number of slices'''. Always 1.<br />
|-<br />
| 0x84 || 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.<br />
{| class="wikitable"<br />
! Value !! Name !! Description<br />
|-<br />
| 0 || R || The channel will receive the red values of the texture.<br />
|-<br />
| 1 || G || The channel will receive the green values of the texture.<br />
|-<br />
| 2 || B || The channel will receive the blue values of the texture.<br />
|-<br />
| 3 || A || The channel will receive the alpha values of the texture.<br />
|-<br />
| 4 || 0 || The channel will always have a value 0.<br />
|-<br />
| 5 || 1 || The channel will always have a value 1.<br />
|}<br />
|-<br />
| 0x88 || 0x14 || UInt32[5] || '''Texture registers'''. Array of 5 unsigned integers with unknown purpose.<br />
|}<br />
<br />
== Swizzling ==<br />
[https://pastebin.com/VDvs7q8Y This] code can swizzle image and mipmap data. Call ''swizzle()'' by giving it the width, height, format (in hex), tileMode, swizzle value, pitch and the swizzled data. If you're swizzling then set do_swizzle to ''True''. If you're deswizzling then set do_swizzle to ''False''.<br />
<br />
= Tools =<br />
The following tools can handle GTX/GSH files:<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=4206
GTX\GSH (File Format)
2017-07-21T21:44:21Z
<p>Aboood40091: </p>
<hr />
<div>'''GTX''' and '''GSH''' files are used in various [[Wii U]] games, including [[Mario Kart 8]]. GSH stands for '''G'''X2 '''SH'''ader and GTX stands for '''G'''X2 '''T'''e'''X'''ture'''.<br />
<br />
== Header ==<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be the real size (0x20), or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x07, or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Data Blocks ==<br />
After the header comes some data blocks, data blocks contain a 0x20 byte '''BLK{''' block header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type.<br />
|-<br />
| 0x01<br />
| Follows this block header the end of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader header.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader program.<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader header.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader program.<br />
|-<br />
| 0x08<br />
| Follows this block header Geometry shader header.<br />
|-<br />
| 0x09<br />
| Follows this block header Geometry shader program.<br />
|-<br />
| 0x0A<br />
| Same as 0x09? (Duplicate?)<br />
|-<br />
| 0x0B<br />
| Follows this block header the GX2 Surface.<br />
|-<br />
| 0x0C<br />
| Follows this block header the swizzled image data.<br />
|-<br />
| 0x0D<br />
| Follows this block header the swizzled mipmaps data.<br />
|-<br />
| 0x0E<br />
| Follows this block header Compute shader header.<br />
|-<br />
| 0x0F<br />
| Follows this block header Compute shader program.<br />
|-<br />
| 0x10<br />
| Treated like a 0x02 block, users can do what they want with this block.<br />
|}<br />
<br />
=== GX2 Surface ===<br />
The GX2 Surface directly follows the block header that has a block type 0x0B, and should exactly have a size of 0x9C: <br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x00 || 4 || UInt32 || '''Dimension'''. Maps to '''GX2SurfaceDim''' (line 849 [http://pastebin.com/DCrP1w9x here]). Indicates the "shape" of a given surface or texture.<br />
|-<br />
| 0x04 || 4 || UInt32 || '''Texture width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08 || 4 || UInt32 || '''Texture height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C || 4 || UInt32 || '''Texture depth'''.<br />
|-<br />
| 0x10 || 4 || UInt32 || '''Number of mipmaps'''.<br />
|-<br />
| 0x14 || 4 || UInt32 || '''Texture format'''. Maps to '''GX2SurfaceFormat''' (line 589 [http://pastebin.com/DCrP1w9x here] for explanation and format values).<br />
|-<br />
| 0x18 || 4 || UInt32 || '''AA mode'''. Maps to '''GX2AAMode''' (line 865 [http://pastebin.com/DCrP1w9x here]). Indicates the AA mode (number of samples) for the surface.<br />
|-<br />
| 0x1C || 4 || UInt32 || '''Usage'''. Maps to '''GX2SurfaceUse''' (line 823 [http://pastebin.com/DCrP1w9x here]). Indicates how the given surface may be used.<br />
|-<br />
| 0x20 || 4 || UInt32 || '''Data length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24 || 4 || UInt32 || '''Data pointer'''. Set at runtime.<br />
|-<br />
| 0x28 || 4 || UInt32 || '''Mipmaps data length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C || 4 || UInt32 || '''Mipmaps pointer'''. Set at runtime.<br />
|-<br />
| 0x30 || 4 || UInt32 || '''Tile mode'''. Maps to '''GX2TileMode''' (line 795 [http://pastebin.com/DCrP1w9x here]). Indicates the desired tiling mode for the surface.<br />
|-<br />
| 0x34 || 4 || UInt32 || '''Swizzle value'''.<br />
|-<br />
| 0x38 || 4 || UInt32 || '''Alignment'''. Always 512 * bytes per pixel.<br />
|-<br />
| 0x3C || 4 || UInt32 || '''Pitch'''.<br />
|-<br />
| 0x40 || 0x34 || UInt32[13] || '''Mipmap offsets'''. An array of 13 offsets for each mipmap, relative to the start of the mipmap data.<br />
|-<br />
| 0x74 || 4 || UInt32 || '''First mipmap'''.<br />
|-<br />
| 0x78 || 4 || UInt32 || '''Number of mipmaps''' (again).<br />
|-<br />
| 0x7C || 4 || UInt32 || '''First slice'''. Always 0.<br />
|-<br />
| 0x80 || 4 || UInt32 || '''Number of slices'''. Always 1.<br />
|-<br />
| 0x84 || 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.<br />
{| class="wikitable"<br />
! Value !! Name !! Description<br />
|-<br />
| 0 || R || The channel will receive the red values of the texture.<br />
|-<br />
| 1 || G || The channel will receive the green values of the texture.<br />
|-<br />
| 2 || B || The channel will receive the blue values of the texture.<br />
|-<br />
| 3 || A || The channel will receive the alpha values of the texture.<br />
|-<br />
| 4 || 0 || The channel will always have a value 0.<br />
|-<br />
| 5 || 1 || The channel will always have a value 1.<br />
|}<br />
|-<br />
| 0x88 || 0x14 || UInt32[5] || '''Texture registers'''. Array of 5 unsigned integers with unknown purpose.<br />
|}<br />
<br />
== Swizzling ==<br />
[https://pastebin.com/VDvs7q8Y This] code can swizzle image and mipmap data. Call ''swizzle()'' by giving it the width, height, format (in hex), tileMode, swizzle value, pitch and the swizzled data. If you're swizzling then set do_swizzle to ''True''. If you're deswizzling then set do_swizzle to ''False''.<br />
<br />
= Tools =<br />
The following tools can handle GTX/GSH files:<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=4205
GTX\GSH (File Format)
2017-07-21T21:43:53Z
<p>Aboood40091: </p>
<hr />
<div>'''GTX''' and '''GSH''' files are used in various [[Wii U]] games, including [[Mario Kart 8]]. GSH stands for '''G'''X2 '''SH'''ader and GTX stands for '''G'''X2 '''T'''e'''X'''ture'''.<br />
<br />
== Header ==<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be the real size (0x20), or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x07, or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Data Blocks ==<br />
After the header comes some data blocks, data blocks contain a 0x20 byte '''BLK{''' block header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type.<br />
|-<br />
| 0x01<br />
| Follows this block header the end of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader header.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader program.<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader header.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader program.<br />
|-<br />
| 0x08<br />
| Follows this block header Geometry shader header.<br />
|-<br />
| 0x09<br />
| Follows this block header Geometry shader program.<br />
|-<br />
| 0x0A<br />
| Same as 0x09? (Duplicate?)<br />
|-<br />
| 0x0B<br />
| Follows this block header the Image header.<br />
|-<br />
| 0x0C<br />
| Follows this block header the swizzled image data.<br />
|-<br />
| 0x0D<br />
| Follows this block header the swizzled mipmaps data.<br />
|-<br />
| 0x0E<br />
| Follows this block header Compute shader header.<br />
|-<br />
| 0x0F<br />
| Follows this block header Compute shader program.<br />
|-<br />
| 0x10<br />
| Treated like a 0x02 block, users can do what they want with this block.<br />
|}<br />
<br />
=== GX2 Surface ===<br />
The GX2 Surface directly follows the block header that has a block type 0x0B, and should exactly have a size of 0x9C: <br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x00 || 4 || UInt32 || '''Dimension'''. Maps to '''GX2SurfaceDim''' (line 849 [http://pastebin.com/DCrP1w9x here]). Indicates the "shape" of a given surface or texture.<br />
|-<br />
| 0x04 || 4 || UInt32 || '''Texture width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08 || 4 || UInt32 || '''Texture height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C || 4 || UInt32 || '''Texture depth'''.<br />
|-<br />
| 0x10 || 4 || UInt32 || '''Number of mipmaps'''.<br />
|-<br />
| 0x14 || 4 || UInt32 || '''Texture format'''. Maps to '''GX2SurfaceFormat''' (line 589 [http://pastebin.com/DCrP1w9x here] for explanation and format values).<br />
|-<br />
| 0x18 || 4 || UInt32 || '''AA mode'''. Maps to '''GX2AAMode''' (line 865 [http://pastebin.com/DCrP1w9x here]). Indicates the AA mode (number of samples) for the surface.<br />
|-<br />
| 0x1C || 4 || UInt32 || '''Usage'''. Maps to '''GX2SurfaceUse''' (line 823 [http://pastebin.com/DCrP1w9x here]). Indicates how the given surface may be used.<br />
|-<br />
| 0x20 || 4 || UInt32 || '''Data length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24 || 4 || UInt32 || '''Data pointer'''. Set at runtime.<br />
|-<br />
| 0x28 || 4 || UInt32 || '''Mipmaps data length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C || 4 || UInt32 || '''Mipmaps pointer'''. Set at runtime.<br />
|-<br />
| 0x30 || 4 || UInt32 || '''Tile mode'''. Maps to '''GX2TileMode''' (line 795 [http://pastebin.com/DCrP1w9x here]). Indicates the desired tiling mode for the surface.<br />
|-<br />
| 0x34 || 4 || UInt32 || '''Swizzle value'''.<br />
|-<br />
| 0x38 || 4 || UInt32 || '''Alignment'''. Always 512 * bytes per pixel.<br />
|-<br />
| 0x3C || 4 || UInt32 || '''Pitch'''.<br />
|-<br />
| 0x40 || 0x34 || UInt32[13] || '''Mipmap offsets'''. An array of 13 offsets for each mipmap, relative to the start of the mipmap data.<br />
|-<br />
| 0x74 || 4 || UInt32 || '''First mipmap'''.<br />
|-<br />
| 0x78 || 4 || UInt32 || '''Number of mipmaps''' (again).<br />
|-<br />
| 0x7C || 4 || UInt32 || '''First slice'''. Always 0.<br />
|-<br />
| 0x80 || 4 || UInt32 || '''Number of slices'''. Always 1.<br />
|-<br />
| 0x84 || 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.<br />
{| class="wikitable"<br />
! Value !! Name !! Description<br />
|-<br />
| 0 || R || The channel will receive the red values of the texture.<br />
|-<br />
| 1 || G || The channel will receive the green values of the texture.<br />
|-<br />
| 2 || B || The channel will receive the blue values of the texture.<br />
|-<br />
| 3 || A || The channel will receive the alpha values of the texture.<br />
|-<br />
| 4 || 0 || The channel will always have a value 0.<br />
|-<br />
| 5 || 1 || The channel will always have a value 1.<br />
|}<br />
|-<br />
| 0x88 || 0x14 || UInt32[5] || '''Texture registers'''. Array of 5 unsigned integers with unknown purpose.<br />
|}<br />
<br />
== Swizzling ==<br />
[https://pastebin.com/VDvs7q8Y This] code can swizzle image and mipmap data. Call ''swizzle()'' by giving it the width, height, format (in hex), tileMode, swizzle value, pitch and the swizzled data. If you're swizzling then set do_swizzle to ''True''. If you're deswizzling then set do_swizzle to ''False''.<br />
<br />
= Tools =<br />
The following tools can handle GTX/GSH files:<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=BFLIM_(File_Format)&diff=4204
BFLIM (File Format)
2017-07-21T21:33:58Z
<p>Aboood40091: </p>
<hr />
<div>The '''BFLIM''' file format ('''B'''inary ca'''F'''e '''L'''ayout '''IM'''age) is used to store layout images.<br />
<br />
== Header ==<br />
The header is at the end of the file (to align the image data without the need for additional padding). It is always 0x14 bytes.<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x00 || 4 || Char[4] || '''File magic'''. Always ''FLIM'' in ASCII.<br />
|-<br />
| 0x04 || 2 || UInt16 || {{BOM}} Not handled on consoles, so the file data must be stored in the endianness of the target console (e.g. big endian for the Wii U).<br />
|-<br />
| 0x06 || 2 || UInt16 || '''Header size''', always 0x14.<br />
|-<br />
| 0x08 || 4 || UInt32 || '''Version''' of this file.<br />
|-<br />
| 0x0C || 4 || UInt32 || '''File size''' in bytes.<br />
|-<br />
| 0x10 || 2 || UInt16 || '''Number of data blocks''', always 0x01.<br />
|-<br />
| 0x12 || 2 || UInt16 || Padding. Seems to reflect upper 2 bytes of filesize (apparently uninitialized memory garbage from file generator).<br />
|-<br />
| 0x14 || colspan="3" {{Unknown|End of '''FLIM''' header}}<br />
|}<br />
<br />
== Image Information ==<br />
A section containing image information comes directly after header. It is always 0x14 bytes long. The formats are not the same in games like New Super Mario Bros U, be sure to use filename if possible (EG: ^l).<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x14 || 4 || Char[4] || '''Section magic'''. Always ''imag'' in ASCII.<br />
|-<br />
| 0x18 || 4 || UInt32 || '''Parse information size''' (total block size), always 0x10 (this and next 0xC bytes).<br />
|-<br />
| 0x1C || 2 || UInt16 || '''Width''' of the texture in pixels.<br />
|-<br />
| 0x1E || 2 || UInt16 || '''Height''' of the texture in pixels.<br />
|-<br />
| 0x20 || 2 || UInt16 || '''File alignment''', always a power of 2. Usually 0x800, 0x1000 or 0x2000.<br />
|-<br />
| 0x22 || 1 || Byte || '''Format''', how the data is stored.<br />
|-<br />
| 0x23 || 1 || Byte || '''Tile mode''' and '''Swizzle''', packed as bits '''SSSTTTTT'''.<br />
* '''TTTTT''' maps to GX2TileMode (line 795 [https://pastebin.com/DCrP1w9x here]). Typically GX2_TILE_MODE_2D_TILED_THIN1 (4).<br />
* '''SSS''' is the swizzle value shifted right by 8.<br />
|-<br />
| 0x24 || 4 || UInt32 || '''Raw data size''', always 0xC minus 0x28 (the header).<br />
|-<br />
| 0x28 || colspan="3" {{Unknown|End of '''Image''' header}}<br />
|}<br />
<br />
== Format ==<br />
Found by reverse engineering. <br />
{| class="wikitable"<br />
! ID<br />
! Name<br />
! Type<br />
! Bits per pixel (bpp)<br />
! Notes<br />
|-<br />
|0x00<br />
|R8_UNORM / L8<br />
|luminance<br />
|8<br />
|^c BFLIM files<br />
|-<br />
|0x01<br />
|R8_UNORM / A8<br />
|alpha<br />
|8<br />
|^d BFLIM files<br />
|-<br />
|0x02<br />
|R4G4_UNORM / L4A4<br />
|luminance+alpha<br />
|8<br />
|^e BFLIM files<br />
|-<br />
|0x03<br />
|R8G8_UNORM / L8A8<br />
|luminance+alpha<br />
|16<br />
|^f BFLIM files<br />
|-<br />
|0x04<br />
|R8G8_UNORM / HILO8<br />
|alpha<br />
|16<br />
|^g BFLIM files<br />
|-<br />
|0x05<br />
|R5G6B5_UNORM / RGB565<br />
|color<br />
|16<br />
|^h BFLIM files<br />
|-<br />
|0x06<br />
|RGB8_UNORM / RGB888<br />
|color<br />
|32<br />
|^i BFLIM files<br />
|-<br />
|0x07<br />
|RGB5A1_UNORM / RGB555A1<br />
|color+alpha <br />
|16<br />
|^j BFLIM files<br />
|-<br />
|0x08<br />
|RGBA4_UNORM / RGBA4444<br />
|color+alpha <br />
|16<br />
|^k BFLIM files<br />
|-<br />
|0x09<br />
|RGBA8_UNORM / RGBA8888<br />
|color+alpha <br />
|32<br />
|^l BFLIM files<br />
|-<br />
|0x0A<br />
|BC1_UNORM / ETC1<br />
|color<br />
|64<br />
|^m BFLIM files<br />
|-<br />
|0x0B<br />
|BC3_UNORM / ETC1A4<br />
|color+alpha<br />
|128<br />
|^n BFLIM files<br />
|-<br />
|0x0C<br />
|BC1_UNORM / DXT1<br />
|color+alpha<br />
|64<br />
|^o BFLIM files<br />
|-<br />
|0x0D<br />
|BC2_UNORM / DXT3<br />
|color+alpha<br />
|128<br />
|^p BFLIM files<br />
|-<br />
|0x0E<br />
|BC3_UNORM / DXT5<br />
|color+alpha<br />
|128<br />
|^q BFLIM files<br />
|-<br />
|0x0F<br />
|BC4_UNORM / BC4L / ATI1 (Low-End)<br />
|luminance<br />
|64<br />
|^r BFLIM files<br />
|-<br />
|0x10<br />
|BC4_UNORM / BC4A / ATI1 (High-End)<br />
|alpha<br />
|64<br />
|^s BFLIM files<br />
|-<br />
|0x11<br />
|BC5_UNORM / ATI2<br />
|luminance+alpha<br />
|128<br />
|^t BFLIM files<br />
|-<br />
|0x12<br />
|BC4_UNORM / L4<br />
|luminance<br />
|4<br />
|^u BFLIM files<br />
|-<br />
|0x13<br />
|BC4_UNORM / A4<br />
|alpha<br />
|4<br />
|^v BFLIM files<br />
|-<br />
|0x14<br />
|RGBA8_SRGB / RGBA8888 <br />
|color+alpha<br />
|32<br />
|^w BFLIM files<br />
|-<br />
|0x15<br />
|BC1_SRGB / DXT1<br />
|color+alpha<br />
|64<br />
|^x BFLIM files<br />
|-<br />
|0x16<br />
|BC2_SRGB / DXT3<br />
|color+alpha<br />
|128<br />
|^y BFLIM files<br />
|-<br />
|0x17<br />
|BC3_SRGB / DXT5<br />
|color+alpha<br />
|128<br />
|^z BFLIM files<br />
|-<br />
|0x18<br />
|RGB10A2_UNORM / RGB10A2<br />
|color+alpha<br />
|32<br />
|??<br />
|-<br />
|0x19<br />
|RGB565_UNORM / RGB565<br />
|color<br />
|16<br />
|??<br />
|-<br />
|}<br />
<br />
= Tools =<br />
The following tools can extract (and generate) BFLIM files:<br />
<br />
* [https://mega.nz/#!KgRilZAR!qLGAx1yb9KduShuzxwZjd7nuN329nMjDQvrX9sy-CsE BFLIMtoGTX], by [[User:RandomTalkingBush|RandomTalkingBush]]<br />
* [https://github.com/aboood40091/BFLIM-Tool/releases/tag/v1.0 BFLIM Tool], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=BFLIM_(File_Format)&diff=4203
BFLIM (File Format)
2017-07-21T21:31:33Z
<p>Aboood40091: </p>
<hr />
<div>The '''BFLIM''' file format ('''B'''inary ca'''F'''e '''L'''ayout '''IM'''age) is used to store layout images.<br />
<br />
== Header ==<br />
The header is at the end of the file (to align the image data without the need for additional padding). It is always 0x14 bytes.<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x00 || 4 || Char[4] || '''File magic'''. Always ''FLIM'' in ASCII.<br />
|-<br />
| 0x04 || 2 || UInt16 || {{BOM}} Not handled on consoles, so the file data must be stored in the endianness of the target console (e.g. big endian for the Wii U).<br />
|-<br />
| 0x06 || 2 || UInt16 || '''Header size''', always 0x14.<br />
|-<br />
| 0x08 || 4 || UInt32 || '''Version''' of this file.<br />
|-<br />
| 0x0C || 4 || UInt32 || '''File size''' in bytes.<br />
|-<br />
| 0x10 || 2 || UInt16 || '''Number of data blocks''', always 0x01.<br />
|-<br />
| 0x12 || 2 || UInt16 || Padding. Seems to reflect upper 2 bytes of filesize (apparently uninitialized memory garbage from file generator).<br />
|-<br />
| 0x14 || colspan="3" {{Unknown|End of '''FLIM''' header}}<br />
|}<br />
<br />
== Image Information ==<br />
A section containing image information comes directly after header. It is always 0x14 bytes long. The formats are not the same in games like New Super Mario Bros U, be sure to use filename if possible (EG: ^l).<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x14 || 4 || Char[4] || '''Section magic'''. Always ''imag'' in ASCII.<br />
|-<br />
| 0x18 || 4 || UInt32 || '''Parse information size''' (total block size), always 0x10 (this and next 0xC bytes).<br />
|-<br />
| 0x1C || 2 || UInt16 || '''Width''' of the texture in pixels.<br />
|-<br />
| 0x1E || 2 || UInt16 || '''Height''' of the texture in pixels.<br />
|-<br />
| 0x20 || 2 || UInt16 || '''File alignment''', always a power of 2. Usually 0x800, 0x1000 or 0x2000.<br />
|-<br />
| 0x22 || 1 || Byte || '''Format''', how the data is stored.<br />
|-<br />
| 0x23 || 1 || Byte || '''Tile mode''' and '''Swizzle''', packed as bits '''SSSTTTTT'''.<br />
* '''TTTTT''' maps to GX2TileMode (line 795 [https://pastebin.com/DCrP1w9x here]). Typically GX2_TILE_MODE_2D_TILED_THIN1 (4).<br />
* '''SSS''' is the swizzle value shifted right by 8.<br />
|-<br />
| 0x24 || 4 || UInt32 || '''Raw data size''', always 0xC minus 0x28 (the header).<br />
|-<br />
| 0x28 || colspan="3" {{Unknown|End of '''Image''' header}}<br />
|}<br />
<br />
== Format ==<br />
{| class="wikitable"<br />
! ID<br />
! Name<br />
! Type<br />
! Bits per pixel<br />
! Notes<br />
|-<br />
|0x00<br />
|R8_UNORM / L8<br />
|luminance<br />
|8<br />
|^c BFLIM files<br />
|-<br />
|0x01<br />
|R8_UNORM / A8<br />
|alpha<br />
|8<br />
|^d BFLIM files<br />
|-<br />
|0x02<br />
|R4G4_UNORM / L4A4<br />
|luminance+alpha<br />
|8<br />
|^e BFLIM files<br />
|-<br />
|0x03<br />
|R8G8_UNORM / L8A8<br />
|luminance+alpha<br />
|16<br />
|^f BFLIM files<br />
|-<br />
|0x04<br />
|R8G8_UNORM / HILO8<br />
|alpha<br />
|16<br />
|^g BFLIM files<br />
|-<br />
|0x05<br />
|R5G6B5_UNORM / RGB565<br />
|color<br />
|16<br />
|^h BFLIM files<br />
|-<br />
|0x06<br />
|RGB8_UNORM / RGB888<br />
|color<br />
|32<br />
|^i BFLIM files<br />
|-<br />
|0x07<br />
|RGB5A1_UNORM / RGB555A1<br />
|color+alpha <br />
|16<br />
|^j BFLIM files<br />
|-<br />
|0x08<br />
|RGBA4_UNORM / RGBA4444<br />
|color+alpha <br />
|16<br />
|^k BFLIM files<br />
|-<br />
|0x09<br />
|RGBA8_UNORM / RGBA8888<br />
|color+alpha <br />
|32<br />
|^l BFLIM files<br />
|-<br />
|0x0A<br />
|BC1_UNORM / ETC1<br />
|color<br />
|64<br />
|^m BFLIM files<br />
|-<br />
|0x0B<br />
|BC3_UNORM / ETC1A4<br />
|color+alpha<br />
|128<br />
|^n BFLIM files<br />
|-<br />
|0x0C<br />
|BC1_UNORM / DXT1<br />
|color+alpha<br />
|64<br />
|^o BFLIM files<br />
|-<br />
|0x0D<br />
|BC2_UNORM / DXT3<br />
|color+alpha<br />
|128<br />
|^p BFLIM files<br />
|-<br />
|0x0E<br />
|BC3_UNORM / DXT5<br />
|color+alpha<br />
|128<br />
|^q BFLIM files<br />
|-<br />
|0x0F<br />
|BC4_UNORM / BC4L / ATI1 (Low-End)<br />
|luminance<br />
|64<br />
|^r BFLIM files<br />
|-<br />
|0x10<br />
|BC4_UNORM / BC4A / ATI1 (High-End)<br />
|alpha<br />
|64<br />
|^s BFLIM files<br />
|-<br />
|0x11<br />
|BC5_UNORM / ATI2<br />
|luminance+alpha<br />
|128<br />
|^t BFLIM files<br />
|-<br />
|0x12<br />
|BC4_UNORM / L4<br />
|luminance<br />
|4<br />
|^u BFLIM files<br />
|-<br />
|0x13<br />
|BC4_UNORM / A4<br />
|alpha<br />
|4<br />
|^v BFLIM files<br />
|-<br />
|0x14<br />
|RGBA8_SRGB / RGBA8888 <br />
|color+alpha<br />
|32<br />
|^w BFLIM files<br />
|-<br />
|0x15<br />
|BC1_SRGB / DXT1<br />
|color+alpha<br />
|64<br />
|^x BFLIM files<br />
|-<br />
|0x16<br />
|BC2_SRGB / DXT3<br />
|color+alpha<br />
|128<br />
|^y BFLIM files<br />
|-<br />
|0x17<br />
|BC3_SRGB / DXT5<br />
|color+alpha<br />
|128<br />
|^z BFLIM files<br />
|-<br />
|0x18<br />
|RGB10A2_UNORM / RGB10A2<br />
|color+alpha<br />
|32<br />
|??<br />
|-<br />
|0x19<br />
|RGB565_UNORM / RGB565<br />
|color<br />
|16<br />
|??<br />
|-<br />
|}<br />
<br />
= Tools =<br />
The following tools can extract (and generate) BFLIM files:<br />
<br />
* [https://mega.nz/#!KgRilZAR!qLGAx1yb9KduShuzxwZjd7nuN329nMjDQvrX9sy-CsE BFLIMtoGTX], by [[User:RandomTalkingBush|RandomTalkingBush]]<br />
* [https://github.com/aboood40091/BFLIM-Tool/releases/tag/v1.0 BFLIM Tool], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=BFLIM_(File_Format)&diff=4114
BFLIM (File Format)
2017-06-23T06:04:16Z
<p>Aboood40091: </p>
<hr />
<div>The '''BFLIM''' file format ('''B'''inary ca'''F'''e '''L'''ayout '''IM'''age) is used to store layout images.<br />
<br />
== Header ==<br />
The header is at the end of the file (to align the image data without the need for additional padding). It is always 0x14 bytes.<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x00 || 4 || Char[4] || '''File magic'''. Always ''FLIM'' in ASCII.<br />
|-<br />
| 0x04 || 2 || UInt16 || '''Byte order mark''' (BOM): 0xFEFF for big endian and 0xFFFE for little endian. Not handled on consoles, so the file data must be stored in the endianness of the target console (e.g. big endian for the Wii U).<br />
|-<br />
| 0x06 || 2 || UInt16 || '''Header size''', always 0x14.<br />
|-<br />
| 0x08 || 4 || UInt32 || '''Version''' of this file.<br />
|-<br />
| 0x0C || 4 || UInt32 || '''File size''' in bytes.<br />
|-<br />
| 0x10 || 2 || UInt16 || '''Number of data blocks''', always 0x01.<br />
|-<br />
| 0x12 || 2 || UInt16 || Padding. Seems to reflect upper 2 bytes of filesize (apparently uninitialized memory garbage from file generator).<br />
|-<br />
| 0x14 || colspan="3" {{Unknown|End of '''FLIM''' header}}<br />
|}<br />
<br />
== Image Information ==<br />
Comes directly after header, always 0x14 bytes. The formats are not the same in games like New Super Mario Bros U, be sure to use filename if possible (EG: ^l).<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Type !! Description<br />
|-<br />
| 0x14 || 4 || Char[4] || '''Section magic'''. Always ''imag'' in ASCII.<br />
|-<br />
| 0x18 || 4 || UInt32 || '''Parse information size''' (total block size), always 0x10 (this and next 0xC bytes).<br />
|-<br />
| 0x1C || 2 || UInt16 || '''Width'''.<br />
|-<br />
| 0x1E || 2 || UInt16 || '''Height'''.<br />
|-<br />
| 0x20 || 2 || UInt16 || '''File alignment''', always a power of 2. Usually 0x800, 0x1000 or 0x2000.<br />
|-<br />
| 0x22 || 1 || Byte || '''Format''', how the data is stored.<br />
|-<br />
| 0x23 || 1 || Byte || '''Tile mode''' and '''Swizzle''', packed as bits '''SSSTTTTT'''.<br />
* '''TTTTT''' maps to GX2TileMode (line 795 [https://pastebin.com/DCrP1w9x here]). Typically GX2_TILE_MODE_2D_TILED_THIN1 (4).<br />
* '''SSS''' is the swizzle value shifted right by 8.<br />
|-<br />
| 0x24 || 4 || UInt32 || '''Raw data size''', always 0xC minus 0x28 (the header).<br />
|-<br />
| 0x28 || colspan="3" {{Unknown|End of '''Image''' header}}<br />
|}<br />
<br />
== Format ==<br />
{| class="wikitable"<br />
! ID<br />
! Name<br />
! Type<br />
! Bits per pixel<br />
! Notes<br />
|-<br />
|0x00<br />
|R8_UNORM / L8<br />
|luminance<br />
|8<br />
|^c BFLIM files<br />
|-<br />
|0x01<br />
|R8_UNORM / A8<br />
|alpha<br />
|8<br />
|^d BFLIM files<br />
|-<br />
|0x02<br />
|R4_G4_UNORM / L4A4<br />
|luminance+alpha<br />
|8<br />
|^e BFLIM files<br />
|-<br />
|0x03<br />
|R8_G8_UNORM / L8A8<br />
|luminance+alpha<br />
|16<br />
|^f BFLIM files<br />
|-<br />
|0x05<br />
|RGB565<br />
|color<br />
|16<br />
|^h BFLIM files<br />
|-<br />
|0x07<br />
|RGB5A1_UNORM / RGB555A1<br />
|color+alpha <br />
|16<br />
|^j BFLIM files<br />
|-<br />
|0x09<br />
|RGBA32_UNORM / RGBA8888<br />
|color+alpha <br />
|32<br />
|^l BFLIM files<br />
|-<br />
|0x0C<br />
|BC1_UNORM / DXT1<br />
|Compressed<br />
|16<br />
|^i / ^o BFLIM files<br />
|-<br />
|0x0D<br />
|BC2_UNORM / DXT3<br />
|Compressed<br />
|<br />
|^p BFLIM files<br />
|-<br />
|0x0E<br />
|BC3_UNORM / DXT5<br />
|Compressed<br />
|16<br />
|^k / ^q BFLIM files<br />
|-<br />
|0x0F<br />
|I4? / BC4_UNORM / ATI1 (Low-End)<br />
|color<br />
|<br />
|^r / +r BFLIM files<br />
|-<br />
|0x10<br />
|IA4? / BC4_UNORM / ATI1 (High-End)<br />
|color+alpha<br />
|<br />
|^s BFLIM files<br />
|-<br />
|0x11<br />
|I8? / BC5_UNORM / ATI2<br />
|color<br />
|<br />
|^t / +t BFLIM files<br />
|-<br />
|0x12<br />
|IA8? / BC1_UNORM / DXT1<br />
|color+alpha<br />
|<br />
|^i BFLIM files<br />
|-<br />
|0x14<br />
|RGBA32_UNORM / RGBA8888 <br />
|color+alpha<br />
|32<br />
|^l BFLIM files<br />
|-<br />
|0x15<br />
|BC1_UNORM / DXT1<br />
|Compressed<br />
|32<br />
|^o BFLIM files<br />
|-<br />
|0x16<br />
|BC2_UNORM / DXT3<br />
|Compressed<br />
|32<br />
|^p BFLIM files<br />
|-<br />
|0x17<br />
|BC3_UNORM / DXT5<br />
|Compressed<br />
|32<br />
|^q BFLIM files<br />
|-<br />
|}<br />
<br />
= Tools =<br />
The following tools can extract (and generate) BFLIM files:<br />
<br />
* [https://mega.nz/#!KgRilZAR!qLGAx1yb9KduShuzxwZjd7nuN329nMjDQvrX9sy-CsE BFLIMtoGTX], by [[User:RandomTalkingBush|RandomTalkingBush]]<br />
* [https://github.com/aboood40091/BFLIM-Tool/releases/tag/v1.0 BFLIM Tool], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=3964
GTX\GSH (File Format)
2017-06-02T19:08:40Z
<p>Aboood40091: </p>
<hr />
<div>'''GTX''' and '''GSH''' files are used in various [[Wii U]] games, including [[Mario Kart 8]]. GSH stands for '''G'''X2 '''SH'''ader and GTX stands for '''G'''X2 '''T'''e'''X'''ture'''.<br />
<br />
== Header ==<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be the real size (0x20), or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x07, or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Data Blocks ==<br />
After the header comes some data blocks, data blocks contain a 0x20 byte '''BLK{''' block header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type.<br />
|-<br />
| 0x01<br />
| Follows this block header the end of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader header.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader program.<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader header.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader program.<br />
|-<br />
| 0x08<br />
| Follows this block header Geometry shader header.<br />
|-<br />
| 0x09<br />
| Follows this block header Geometry shader program.<br />
|-<br />
| 0x0A<br />
| Same as 0x09? (Duplicate?)<br />
|-<br />
| 0x0B<br />
| Follows this block header the Image header.<br />
|-<br />
| 0x0C<br />
| Follows this block header the swizzled image data.<br />
|-<br />
| 0x0D<br />
| Follows this block header the swizzled mipmaps data.<br />
|-<br />
| 0x0E<br />
| Follows this block header Compute shader header.<br />
|-<br />
| 0x0F<br />
| Follows this block header Compute shader program.<br />
|-<br />
| 0x10<br />
| Treated like a 0x02 block, users can do what they want with this block.<br />
|}<br />
<br />
=== Image info ===<br />
The image info directly follows the block header that has a block type 0x0B, and should exactly have a size of 0x9C:<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Description<br />
|-<br />
| 0x00 || 4 || '''Dimension'''. Maps to '''GX2SurfaceDim''' (line 849 [http://pastebin.com/DCrP1w9x here]). Indicates the "shape" of a given surface or texture.<br />
|-<br />
| 0x04 || 4 || '''Texture width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08 || 4 || '''Texture height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C || 4 || '''Depth'''.<br />
|-<br />
| 0x10 || 4 || '''Number of mipmaps'''.<br />
|-<br />
| 0x14 || 4 || '''Texture format'''. Maps to '''GX2SurfaceFormat''' (line 589 [http://pastebin.com/DCrP1w9x here] for explanation and format values).<br />
|-<br />
| 0x18 || 4 || '''AA mode'''. Maps to '''GX2AAMode''' (line 865 [http://pastebin.com/DCrP1w9x here]). Indicates the AA mode (number of samples) for the surface.<br />
|-<br />
| 0x1C || 4 || '''Usage'''. Maps to '''GX2SurfaceUse''' (line 823 [http://pastebin.com/DCrP1w9x here]). Indicates how the given surface may be used.<br />
|-<br />
| 0x20 || 4 || '''Data length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24 || 4 || '''Data pointer'''. Set at runtime.<br />
|-<br />
| 0x28 || 4 || '''Mipmaps data length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C || 4 || '''Mipmaps pointer'''. Set at runtime.<br />
|-<br />
| 0x30 || 4 || '''Tile mode'''. Maps to '''GX2TileMode''' (line 795 [http://pastebin.com/DCrP1w9x here]). Indicates the desired tiling mode for the surface.<br />
|-<br />
| 0x34 || 4 || '''Swizzle value'''.<br />
|-<br />
| 0x38 || 4 || '''Alignment'''. Always 512 * bytes per pixel.<br />
|-<br />
| 0x3C || 4 || '''Pitch'''.<br />
|-<br />
| 0x40 || 0x38 || '''Mipmap offsets'''. An array of 13 offsets for each mipmap, relative to the start of the mipmap data.<br />
|-<br />
| 0x78 || 4 || '''Number of mipmaps''' (again).<br />
|-<br />
| 0x7C || 4 || '''First slice'''. Always 0.<br />
|-<br />
| 0x80 || 4 || '''Number of slices'''. Always 1.<br />
|-<br />
| 0x84 || 4 || '''GX2CompSel'''.<br />
|-<br />
| 0x88 || 0x14 || '''Texture registers'''. Array of 5 unsigned integers with unknown purpose.<br />
|}<br />
<br />
== Swizzling ==<br />
[https://pastebin.com/VDvs7q8Y This] code can swizzle image and mipmap data. Call ''swizzle()'' by giving it the width, height, format (in hex), tileMode, swizzle value, pitch and the swizzled data. If you're swizzling then set do_swizzle to ''True''. If you're deswizzling then set do_swizzle to ''False''.<br />
<br />
= Tools =<br />
The following tools can handle GTX/GSH files:<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=3963
GTX\GSH (File Format)
2017-06-02T19:00:26Z
<p>Aboood40091: </p>
<hr />
<div>'''GTX''' and '''GSH''' files are used in various [[Wii U]] games, including [[Mario Kart 8]]. GSH stands for '''G'''X2 '''SH'''ader and GTX stands for '''G'''X2 '''T'''e'''X'''ture'''.<br />
<br />
== Header ==<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be the real size (0x20), or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x07, or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Data Blocks ==<br />
After the header comes some data blocks, data blocks contain a 0x20 byte '''BLK{''' block header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type.<br />
|-<br />
| 0x01<br />
| Follows this block header the end of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader header.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader program.<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader header.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader program.<br />
|-<br />
| 0x08<br />
| Follows this block header Geometry shader header.<br />
|-<br />
| 0x09<br />
| Follows this block header Geometry shader program.<br />
|-<br />
| 0x0A<br />
| Same as 0x09? (Duplicate?)<br />
|-<br />
| 0x0B<br />
| Follows this block header the Image header.<br />
|-<br />
| 0x0C<br />
| Follows this block header the swizzled image data.<br />
|-<br />
| 0x0D<br />
| Follows this block header the swizzled mipmaps data.<br />
|-<br />
| 0x0E<br />
| Follows this block header Compute shader header.<br />
|-<br />
| 0x0F<br />
| Follows this block header Compute shader program.<br />
|-<br />
| 0x10<br />
| Treated like a 0x02 block, users can do what they want with this block.<br />
|}<br />
<br />
=== Image info ===<br />
The image info directly follows the block header that has a block type 0x0B, and should exactly have a size of 0x9C:<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Dimension'''. Indicates the "shape" of a given surface or texture (see line 849 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Texture Width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Texture Height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Depth'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Number of Mipmaps'''.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Texture Format'''. Go to line 589 on [http://pastebin.com/DCrP1w9x this page] for explanation and format values.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''AA Mode'''. Indicates the AA mode (number of samples) for the surface (see line 865 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Usage'''. Indicates how the given surface may be used (see line 823 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x20<br />
| 4<br />
| '''Data Length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''Data Pointer?'''<br />
|-<br />
| 0x28<br />
| 4<br />
| '''Mipmaps Data Length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C<br />
| 4<br />
| '''Mipmaps Pointer?'''<br />
|-<br />
| 0x30<br />
| 4<br />
| '''Tile Mode'''. Indicates the desired tiling mode for the surface (see line 795 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x34<br />
| 4<br />
| '''Swizzle Value'''.<br />
|-<br />
| 0x38<br />
| 4<br />
| '''Alignment'''. Always 512 * bytes per pixel.<br />
|-<br />
| 0x3C<br />
| 4<br />
| '''Pitch'''.<br />
|-<br />
| 0x40<br />
| 0x38<br />
| '''Mip Offset'''. Offset for each mipmap<br />
|-<br />
| 0x78<br />
| 4<br />
| '''Number of Mipmaps'''. Again...<br />
|-<br />
| 0x7C<br />
| 4<br />
| Unknown. Always 0.<br />
|-<br />
| 0x80<br />
| 4<br />
| Unknown. Always 1.<br />
|-<br />
| 0x84<br />
| 4<br />
| Unknown. Always 0x00010203. (Is this some kind of a pattern? 00->01->02->03)<br />
|-<br />
| 0x88<br />
| 0x14<br />
| Unknown.<br />
|}<br />
<br />
== Swizzling ==<br />
[https://pastebin.com/VDvs7q8Y This] code can swizzle image and mipmap data. Call ''swizzle()'' by giving it the width, height, format (in hex), tileMode, swizzle value, pitch and the swizzled data. If you're swizzling then set do_swizzle to ''True''. If you're deswizzling then set do_swizzle to ''False''.<br />
<br />
= Tools =<br />
The following tools can handle GTX/GSH files:<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=3651
GTX\GSH (File Format)
2017-05-19T16:46:28Z
<p>Aboood40091: </p>
<hr />
<div>The '''GTX/GSH''' file formats are used in various Wii U games, including MK8.<br />
<br />
'''GSH''' stands for '''GX2 shader''' file, while '''GTX''' stands for '''GX2 texture''' file.<br />
<br />
== Header ==<br />
<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be the real size (0x20), or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x07, or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Data Blocks ==<br />
<br />
After the header comes some data blocks, data blocks contain a 0x20 byte '''BLK{''' block header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
IIRC Block type 0x04 doesn't exist, I hope so.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type.<br />
|-<br />
| 0x01<br />
| Follows this block header the end of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader header.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader program.<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader header.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader program.<br />
|-<br />
| 0x08<br />
| Follows this block header Geometry shader header.<br />
|-<br />
| 0x09<br />
| Follows this block header Geometry shader program.<br />
|-<br />
| 0x0A<br />
| Same as 0x09? (Duplicate?)<br />
|-<br />
| 0x0B<br />
| Follows this block header the Image header.<br />
|-<br />
| 0x0C<br />
| Follows this block header the swizzled Image data.<br />
|-<br />
| 0x0D<br />
| Follows this block header the swizzled Mipmaps data.<br />
|-<br />
| 0x0E<br />
| Follows this block header Compute shader header.<br />
|-<br />
| 0x0F<br />
| Follows this block header Compute shader program.<br />
|-<br />
| 0x10<br />
| Treated like a 0x02 block, users can do what they want with this block.<br />
|}<br />
<br />
=== Image info ===<br />
<br />
The image info directly follows the block header that has a block type 0x0B, and should exactly have a size of 0x9C:<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Dimension'''. Indicates the "shape" of a given surface or texture (see line 849 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Texture Width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Texture Height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Depth'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Number of Mipmaps'''.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Texture Format'''. Go to line 589 on [http://pastebin.com/DCrP1w9x this page] for explanation and format values.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''AA Mode'''. Indicates the AA mode (number of samples) for the surface (see line 865 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Usage'''. Indicates how the given surface may be used (see line 823 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x20<br />
| 4<br />
| '''Data Length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''Data Pointer?'''<br />
|-<br />
| 0x28<br />
| 4<br />
| '''Mipmaps Data Length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C<br />
| 4<br />
| '''Mipmaps Pointer?'''<br />
|-<br />
| 0x30<br />
| 4<br />
| '''Tile Mode'''. Indicates the desired tiling mode for the surface (see line 795 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x34<br />
| 4<br />
| '''Swizzle Value'''.<br />
|-<br />
| 0x38<br />
| 4<br />
| '''Alignment'''. Always 512 * bytes per pixel.<br />
|-<br />
| 0x3C<br />
| 4<br />
| '''Pitch'''.<br />
|-<br />
| 0x40<br />
| 0x0D<br />
| '''Mip Offset?'''. Offset for each mipmap?<br />
|-<br />
| 0x4D<br />
| 0x2B<br />
| Unknown. Mipmaps related? (''Almost'' always 0 in textures with no mipmaps)<br />
|-<br />
| 0x78<br />
| 4<br />
| '''Number of Mipmaps'''. Again...<br />
|-<br />
| 0x7C<br />
| 4<br />
| Unknown. Always 0.<br />
|-<br />
| 0x80<br />
| 4<br />
| Unknown. Always 1.<br />
|-<br />
| 0x84<br />
| 4<br />
| Unknown. Always 0x00010203. (Is this some kind of a pattern? 00->01->02->03)<br />
|-<br />
| 0x88<br />
| 0x14<br />
| Unknown.<br />
|}<br />
<br />
== Formats ==<br />
<br />
'''TODO'''.<br />
<br />
== Swizzling ==<br />
<br />
Reverse-engineering the swizzling was a nightmare, so documenting it will be too.<br />
The following code can swizzle/deswizzle data ''if you give it the right values''.<br />
<br />
Basically call swizzle() by giving it the width, height, format (in hex), tileMode, swizzle value, pitch, and the swizzled data.<br />
<br />
If you're swizzling then set do_swizzle to True.<br />
If you're deswizzling then set do_swizzle to False.<br />
<br />
https://pastebin.com/VDvs7q8Y<br />
<br />
= Tools =<br />
<br />
The following tool can extract and generate GTX files:<br />
<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=3650
GTX\GSH (File Format)
2017-05-19T11:39:26Z
<p>Aboood40091: </p>
<hr />
<div>The '''GTX/GSH''' file formats are used in various Wii U games, including MK8.<br />
<br />
'''GSH''' stands for '''GX2 shader''' file, while '''GTX''' stands for '''GX2 texture''' file.<br />
<br />
== Header ==<br />
<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be the real size (0x20), or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x07, or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Data Blocks ==<br />
<br />
After the header comes some data blocks, data blocks contain a 0x20 byte '''BLK{''' block header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
IIRC Block type 0x04 doesn't exist, I hope so.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type.<br />
|-<br />
| 0x01<br />
| Follows this block header the end of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader header.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader program.<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader header.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader program.<br />
|-<br />
| 0x08<br />
| Follows this block header Geometry shader header.<br />
|-<br />
| 0x09<br />
| Follows this block header Geometry shader program.<br />
|-<br />
| 0x0A<br />
| Same as 0x09? (Duplicate?)<br />
|-<br />
| 0x0B<br />
| Follows this block header the Image header.<br />
|-<br />
| 0x0C<br />
| Follows this block header the swizzled Image data.<br />
|-<br />
| 0x0D<br />
| Follows this block header the swizzled Mipmaps data.<br />
|-<br />
| 0x0E<br />
| Follows this block header Compute shader header.<br />
|-<br />
| 0x0F<br />
| Follows this block header Compute shader program.<br />
|-<br />
| 0x10<br />
| Treated like a 0x02 block, users can do what they want with this block.<br />
|}<br />
<br />
=== Image info ===<br />
<br />
The image info directly follows the block header that has a block type 0x0B, and should exactly have a size of 0x9C:<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Dimension'''. Indicates the "shape" of a given surface or texture (see line 849 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Texture Width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Texture Height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Depth'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Number of Mipmaps'''.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Texture Format'''. Go to line 589 on [http://pastebin.com/DCrP1w9x this page] for explanation and format values.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''AA Mode'''. Indicates the AA mode (number of samples) for the surface (see line 865 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Usage'''. Indicates how the given surface may be used (see line 823 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x20<br />
| 4<br />
| '''Data Length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''Data Pointer?'''<br />
|-<br />
| 0x28<br />
| 4<br />
| '''Mipmaps Data Length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C<br />
| 4<br />
| '''Mipmaps Pointer?'''<br />
|-<br />
| 0x30<br />
| 4<br />
| '''Tile Mode'''. Indicates the desired tiling mode for the surface (see line 795 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x34<br />
| 4<br />
| '''Swizzle Value'''.<br />
|-<br />
| 0x38<br />
| 4<br />
| '''Alignment'''. Always 512 * bytes per pixel.<br />
|-<br />
| 0x3C<br />
| 4<br />
| '''Pitch'''.<br />
|-<br />
| 0x40<br />
| 0x0D<br />
| '''Mip Offset?'''. Offset for each mipmap?<br />
|-<br />
| 0x4D<br />
| 0x2B<br />
| Unknown. Mipmaps related? (''Almost'' always 0 in textures with no mipmaps)<br />
|-<br />
| 0x78<br />
| 4<br />
| '''Number of Mipmaps'''. Again...<br />
|-<br />
| 0x7C<br />
| 4<br />
| Unknown. Always 0.<br />
|-<br />
| 0x80<br />
| 4<br />
| Unknown. Always 1.<br />
|-<br />
| 0x84<br />
| 4<br />
| Unknown. Always 0x00010203. (Is this some kind of a pattern? 00->01->02->03)<br />
|-<br />
| 0x88<br />
| 0x14<br />
| Unknown.<br />
|}<br />
<br />
== Formats ==<br />
<br />
'''TODO'''.<br />
<br />
== Swizzling ==<br />
<br />
Reverse-engineering the swizzling was a nightmare, so documenting it will be too.<br />
The following code can swizzle/deswizzle data ''if you give it the right values''.<br />
<br />
Basically call swizzle() by giving it the width, height, depth, format (in hex), tileMode, swizzle value, pitch, and data.<br />
<br />
If you're swizzling then set do_swizzle to True.<br />
If you're deswizzling then set do_swizzle to False.<br />
<br />
https://pastebin.com/VDvs7q8Y<br />
<br />
= Tools =<br />
<br />
The following tool can extract and generate GTX files:<br />
<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=FTEX_(File_Format)&diff=3649
FTEX (File Format)
2017-05-19T11:38:57Z
<p>Aboood40091: </p>
<hr />
<div>{{Under-construction}}<br />
The '''FTEX''' 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.<br />
<br />
== Header (FTEX) ==<br />
A FTEX file begins with an 0xC0 byte header that starts with the file identifier, followed by info about the image.<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Description<br />
|-<br />
| 0x00 || 4 || "'''FTEX'''" File identifier, ASCII string.<br />
|-<br />
| 0x04 || 4 || '''Dimension'''. Indicates the "shape" of a given surface or texture (see line 849 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x08 || 4 || '''Texture Width'''. Width of the texture in pixels.<br />
|-<br />
| 0x0C || 4 || '''Texture Height'''. Height of the texture in pixels.<br />
|-<br />
| 0x10 || 4 || '''Depth'''.<br />
|-<br />
| 0x14 || 4 || '''Number of Mipmaps'''.<br />
|-<br />
| 0x18 || 4 || '''Texture Format'''. Go to line 589 on [http://pastebin.com/DCrP1w9x this page] for explanation and format values.<br />
|-<br />
| 0x1C || 4 || '''AA Mode'''. Indicates the AA mode (number of samples) for the surface (see line 865 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x20 || 4 || '''Usage'''. Indicates how the given surface may be used (see line 823 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x24 || 4 || '''Data Length'''. Length of texture data in bytes.<br />
|-<br />
| 0x28 || 4 || '''Data Pointer?'''<br />
|-<br />
| 0x2C || 4 || '''Mipmaps Data Length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x30 || 4 || '''Mipmaps Pointer?'''<br />
|-<br />
| 0x34 || 4 || '''Tile Mode'''. Indicates the desired tiling mode for the surface (see line 795 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x38 || 4 || '''Swizzle Value'''.<br />
|-<br />
| 0x3C || 4 || '''Alignment'''. Always 512 * bytes per pixel.<br />
|-<br />
| 0x40 || 4 || '''Pitch'''.<br />
|-<br />
| 0x44 || 0x0D || '''Mip Offset?'''. Offset for each mipmap?<br />
|-<br />
| 0x51 || 0x2B || Unknown. Mipmaps related? (''Almost'' always 0 in textures with no mipmaps)<br />
|-<br />
| 0x7C || 4 || '''Number of Mipmaps'''. Again...<br />
|-<br />
| 0x80 || 4 || '''Unknown'''. Always 0.<br />
|-<br />
| 0x84 || 4 || '''Unknown'''. Always 1.<br />
|-<br />
| 0x88 || 4 || '''Unknown'''.<br />
|-<br />
| 0x8C || 0x1C || Unknown.<br />
|-<br />
| 0xA8 || 4 || Offset to the '''name of this file'''.<br />
|-<br />
| 0xAC || 4 || Offset to the '''end of the [[BFRES (File Format)#String Table|string table]]'''.<br />
|-<br />
| 0xB0 || 4 || '''Data Offset'''. Offset to the texture data.<br />
|-<br />
| 0xB4 || 4 || '''Mipmap Offset'''. Offset to the mipmap texture data.<br />
|-<br />
| 0xB8 || 4 || Offset to the '''[[#User Data|user data]]'''.<br />
|-<br />
| 0xBC || 2 || Number of '''[[#User Data|user data]]'''.<br />
|-<br />
| 0xBE || 2 || '''Unknown'''.<br />
|-<br />
| 0xC0 || colspan="2" {{Unknown|End of '''FTEX''' header}}<br />
|}<br />
<br />
== Image Data ==<br />
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 don't need to handle the image data. Instead it is sent directly to the GPU.<br />
<br />
== User Data ==<br />
{{NW4F User Data}}<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=3648
GTX\GSH (File Format)
2017-05-19T11:37:13Z
<p>Aboood40091: </p>
<hr />
<div>The '''GTX/GSH''' file formats are used in various Wii U games, including MK8.<br />
<br />
'''GSH''' stands for '''GX2 shader''' file, while '''GTX''' stands for '''GX2 texture''' file.<br />
<br />
== Header ==<br />
<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be the real size (0x20), or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x07, or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Data Blocks ==<br />
<br />
After the header comes some data blocks, data blocks contain a 0x20 byte '''BLK{''' block header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
IIRC Block type 0x04 doesn't exist, I hope so.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type.<br />
|-<br />
| 0x01<br />
| Follows this block header the end of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader header.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader program.<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader header.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader program.<br />
|-<br />
| 0x08<br />
| Follows this block header Geometry shader header.<br />
|-<br />
| 0x09<br />
| Follows this block header Geometry shader program.<br />
|-<br />
| 0x0A<br />
| Same as 0x09? (Duplicate?)<br />
|-<br />
| 0x0B<br />
| Follows this block header the Image header.<br />
|-<br />
| 0x0C<br />
| Follows this block header the swizzled Image data.<br />
|-<br />
| 0x0D<br />
| Follows this block header the swizzled Mipmaps data.<br />
|-<br />
| 0x0E<br />
| Follows this block header Compute shader header.<br />
|-<br />
| 0x0F<br />
| Follows this block header Compute shader program.<br />
|-<br />
| 0x10<br />
| Treated like a 0x02 block, users can do what they want with this block.<br />
|}<br />
<br />
=== Image info ===<br />
<br />
The image info directly follows the block header that has a block type 0x0B, and should exactly have a size of 0x9C:<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Dimension'''. Indicates the "shape" of a given surface or texture (see line 849 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Texture Width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Texture Height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Depth'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Number of Mipmaps'''.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Texture Format'''. Go to line 589 on [http://pastebin.com/DCrP1w9x this page] for explanation and format values.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''AA Mode'''. Indicates the AA mode (number of samples) for the surface (see line 865 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Usage'''. Indicates how the given surface may be used (see line 823 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x20<br />
| 4<br />
| '''Data Length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''Data Pointer?'''<br />
|-<br />
| 0x28<br />
| 4<br />
| '''Mipmaps Data Length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C<br />
| 4<br />
| '''Mipmaps Pointer?'''<br />
|-<br />
| 0x30<br />
| 4<br />
| '''Tile Mode'''. Indicates the desired tiling mode for the surface (see line 795 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x34<br />
| 4<br />
| '''Swizzle Value'''.<br />
|-<br />
| 0x38<br />
| 4<br />
| '''Alignment'''. Always 512 * bytes per pixel.<br />
|-<br />
| 0x3C<br />
| 4<br />
| '''Pitch'''.<br />
|-<br />
| 0x40<br />
| 0x0D<br />
| '''Mip Offset'''. Offset for each mipmap?<br />
|-<br />
| 0x4D<br />
| 0x2B<br />
| Unknown. Mipmaps related? (''Almost'' always 0 in textures with no mipmaps)<br />
|-<br />
| 0x78<br />
| 4<br />
| '''Number of Mipmaps'''. Again...<br />
|-<br />
| 0x7C<br />
| 4<br />
| Unknown. Always 0.<br />
|-<br />
| 0x80<br />
| 4<br />
| Unknown. Always 1.<br />
|-<br />
| 0x84<br />
| 4<br />
| Unknown. Always 0x00010203. (Is this some kind of a pattern? 00->01->02->03)<br />
|-<br />
| 0x88<br />
| 0x14<br />
| Unknown.<br />
|}<br />
<br />
== Formats ==<br />
<br />
'''TODO'''.<br />
<br />
== Swizzling ==<br />
<br />
Reverse-engineering the swizzling was a nightmare, so documenting it will be too.<br />
The following code can swizzle/deswizzle data ''if you give it the right values''.<br />
<br />
Basically call swizzle() by giving it the width, height, depth, format (in hex), tileMode, swizzle value, pitch, and data.<br />
<br />
If you're swizzling then set do_swizzle to True.<br />
If you're deswizzling then set do_swizzle to False.<br />
<br />
https://pastebin.com/VDvs7q8Y<br />
<br />
= Tools =<br />
<br />
The following tool can extract and generate GTX files:<br />
<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=3647
GTX\GSH (File Format)
2017-05-19T11:17:48Z
<p>Aboood40091: </p>
<hr />
<div>The '''GTX/GSH''' file formats are used in various Wii U games, including MK8.<br />
<br />
'''GSH''' stands for '''GX2 shader''' file, while '''GTX''' stands for '''GX2 texture''' file.<br />
<br />
== Header ==<br />
<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be the real size (0x20), or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x07, or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Data Blocks ==<br />
<br />
After the header comes some data blocks, data blocks contain a 0x20 byte '''BLK{''' block header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
IIRC Block type 0x04 doesn't exist, I hope so.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type.<br />
|-<br />
| 0x01<br />
| Follows this block header the end of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader header.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader program.<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader header.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader program.<br />
|-<br />
| 0x08<br />
| Follows this block header Geometry shader header.<br />
|-<br />
| 0x09<br />
| Follows this block header Geometry shader program.<br />
|-<br />
| 0x0A<br />
| Same as 0x09? (Duplicate?)<br />
|-<br />
| 0x0B<br />
| Follows this block header the Image header.<br />
|-<br />
| 0x0C<br />
| Follows this block header the swizzled Image data.<br />
|-<br />
| 0x0D<br />
| Follows this block header the swizzled Mipmaps data.<br />
|-<br />
| 0x0E<br />
| Follows this block header Compute shader header.<br />
|-<br />
| 0x0F<br />
| Follows this block header Compute shader program.<br />
|-<br />
| 0x10<br />
| Treated like a 0x02 block, users can do what they want with this block.<br />
|}<br />
<br />
=== Image info ===<br />
<br />
The image info directly follows the block header that has a block type 0x0B, and should exactly have a size of 0x9C:<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Dimension'''. Indicates the "shape" of a given surface or texture (see line 849 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Texture Width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Texture Height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Depth'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Number of Mipmaps'''.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Texture Format'''. Go to line 589 on [http://pastebin.com/DCrP1w9x this page] for explanation and format values.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''AA Mode'''. Indicates the AA mode (number of samples) for the surface (see line 865 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Usage'''. Indicates how the given surface may be used (see line 823 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x20<br />
| 4<br />
| '''Data Length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''Data Pointer?'''<br />
|-<br />
| 0x28<br />
| 4<br />
| '''Mipmaps Data Length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C<br />
| 4<br />
| '''Mipmaps Pointer?'''<br />
|-<br />
| 0x30<br />
| 4<br />
| '''Tile Mode'''. Indicates the desired tiling mode for the surface (see line 795 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x34<br />
| 4<br />
| '''Swizzle Value'''.<br />
|-<br />
| 0x38<br />
| 4<br />
| '''Alignment'''. Always 512 * bytes per pixel.<br />
|-<br />
| 0x3C<br />
| 4<br />
| '''Pitch'''.<br />
|-<br />
| 0x40<br />
| 0x0D<br />
| '''Mip Offset'''. Offset for each mipmap?<br />
|-<br />
| 0x4D<br />
| 0x2B<br />
| Unknown. Mipmaps related. (Always 0 in textures with no mipmaps)<br />
|-<br />
| 0x78<br />
| 4<br />
| '''Number of Mipmaps'''. Again...<br />
|-<br />
| 0x7C<br />
| 4<br />
| Unknown. Always 0.<br />
|-<br />
| 0x80<br />
| 4<br />
| Unknown. Always 1.<br />
|-<br />
| 0x84<br />
| 4<br />
| Unknown. Always 0x00010203. (Is this some kind of a pattern? 00->01->02->03)<br />
|-<br />
| 0x88<br />
| 0x14<br />
| Unknown.<br />
|}<br />
<br />
== Formats ==<br />
<br />
'''TODO'''.<br />
<br />
== Swizzling ==<br />
<br />
Reverse-engineering the swizzling was a nightmare, so documenting it will be too.<br />
The following code can swizzle/deswizzle data ''if you give it the right values''.<br />
<br />
Basically call swizzle() by giving it the width, height, depth, format (in hex), tileMode, swizzle value, pitch, and data.<br />
<br />
If you're swizzling then set do_swizzle to True.<br />
If you're deswizzling then set do_swizzle to False.<br />
<br />
https://pastebin.com/VDvs7q8Y<br />
<br />
= Tools =<br />
<br />
The following tool can extract and generate GTX files:<br />
<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=FTEX_(File_Format)&diff=3104
FTEX (File Format)
2017-04-08T08:46:29Z
<p>Aboood40091: Undo revision 3103 by Aboood40091 (talk)</p>
<hr />
<div>{{Under-construction| ''Please do not add speculation here''.}}<br />
<br />
The '''FTEX''' texture format is a format for textures which appears as a subfile of a '''[[BFRES (File Format)|BFRES file]]'''.<br />
<br />
== Header (FTEX) ==<br />
<br />
Every FTEX file begins with an 0xC0 byte '''FTEX''' header that starts with the file identifier, followed by info about the image.<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FTEX'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Dimension'''. Indicates the "shape" of a given surface or texture (see line 849 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Texture Width'''. Width of the texture in pixels.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Texture Height'''. Height of the texture in pixels.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Depth'''.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Number of Mipmaps'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Texture Format'''. Go to line 589 on [http://pastebin.com/DCrP1w9x this page] for explanation and format values.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''AA Mode'''. Indicates the AA mode (number of samples) for the surface (see line 865 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x20<br />
| 4<br />
| '''Usage'''. Indicates how the given surface may be used (see line 823 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x24<br />
| 4<br />
| '''Data Length'''. Length of texture data in bytes.<br />
|-<br />
| 0x28<br />
| 4<br />
| '''Data Pointer?'''<br />
|-<br />
| 0x2C<br />
| 4<br />
| '''Mipmaps Data Length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x30<br />
| 4<br />
| '''Mipmaps Pointer?'''<br />
|-<br />
| 0x34<br />
| 4<br />
| '''Tile Mode'''. Indicates the desired tiling mode for the surface (see line 795 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x38<br />
| 4<br />
| '''Swizzle Value'''.<br />
|-<br />
| 0x3C<br />
| 4<br />
| '''Alignment'''. Always 512 * bytes per pixel.<br />
|-<br />
| 0x40<br />
| 4<br />
| '''Pitch'''.<br />
|-<br />
| 0x44<br />
| 0x0D<br />
| '''Mip Offset'''. Offset for each mipmap?<br />
|-<br />
| 0x51<br />
| 0x2B<br />
| Unknown. Mipmaps related. (Always 0 in textures with no mipmaps)<br />
|-<br />
| 0x7C<br />
| 4<br />
| '''Number of Mipmaps'''. Again...<br />
|-<br />
| 0x80<br />
| 4<br />
| Unknown. Always 0.<br />
|-<br />
| 0x84<br />
| 4<br />
| Unknown. Always 1.<br />
|-<br />
| 0x88<br />
| 4<br />
| Unknown. Always 0x00010203. (Is this some kind of a pattern? 00->01->02->03)<br />
|-<br />
| 0x8C<br />
| 0x24<br />
| Unknown.<br />
|-<br />
| 0xB0<br />
| 4<br />
| '''Data Offset'''. Offset to the texture data. Relative to this field.<br />
|-<br />
| 0xB4<br />
| 4<br />
| '''Mipmap Offset'''. Offset to the mipmap texture data. Relative to this field. '''0''' if not present.<br />
|-<br />
| 0xB8<br />
| 8<br />
| {{Unknown}}<br />
|-<br />
| 0xC0<br />
| colspan="2" {{Unknown|End of '''FTEX''' header}}<br />
|}<br />
<br />
Incomplete header documentation. Last 8 words (32 bytes) seem to change per file. Offset 160 (dec) from FTEX header always seems to be zero, followed by a single byte (value of 1), 3 padding bytes, then a relative offset to the string table, then a relative offset to UnknownDataA, a relative offset to UnknownDataB, a relative offset to unknown DataC, and then two more unknowns (usually zero).<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=FTEX_(File_Format)&diff=3103
FTEX (File Format)
2017-04-08T08:45:33Z
<p>Aboood40091: </p>
<hr />
<div>{{Under-construction| ''Please do not add speculation here''.}}<br />
<br />
The '''FTEX''' texture format is a format for textures which appears as a subfile of a '''[[BFRES (File Format)|BFRES file]]'''.<br />
<br />
== Header (FTEX) ==<br />
<br />
Every FTEX file begins with an 0xC0 byte '''FTEX''' header that starts with the file identifier, followed by info about the image.<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FTEX'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Dimension'''. Indicates the "shape" of a given surface or texture (see line 849 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Texture Width'''. Width of the texture in pixels.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Texture Height'''. Height of the texture in pixels.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Depth'''.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Number of Mipmaps'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Texture Format'''. Go to line 589 on [http://pastebin.com/DCrP1w9x this page] for explanation and format values.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''AA Mode'''. Indicates the AA mode (number of samples) for the surface (see line 865 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x20<br />
| 4<br />
| '''Usage'''. Indicates how the given surface may be used (see line 823 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x24<br />
| 4<br />
| '''Data Length'''. Length of texture data in bytes.<br />
|-<br />
| 0x28<br />
| 4<br />
| '''Data Pointer?'''<br />
|-<br />
| 0x2C<br />
| 4<br />
| '''Mipmaps Data Length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x30<br />
| 4<br />
| '''Mipmaps Pointer?'''<br />
|-<br />
| 0x34<br />
| 4<br />
| '''Tile Mode'''. Indicates the desired tiling mode for the surface (see line 795 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x38<br />
| 4<br />
| '''Swizzle Value'''.<br />
|-<br />
| 0x3C<br />
| 4<br />
| '''Alignment'''. Always 512 * bytes per pixel.<br />
|-<br />
| 0x40<br />
| 4<br />
| '''Pitch'''.<br />
|-<br />
| 0x44<br />
| 0x0D<br />
| '''Mip Offset'''. Offset for each mipmap?<br />
|-<br />
| 0x51<br />
| 0x2B<br />
| Unknown. Mipmaps related. (Always 0 in textures with no mipmaps)<br />
|-<br />
| 0x7C<br />
| 4<br />
| '''Number of Mipmaps'''. Again...<br />
|-<br />
| 0x80<br />
| 4<br />
| Unknown. Always 0.<br />
|-<br />
| 0x84<br />
| 4<br />
| Unknown. Always 1.<br />
|-<br />
| 0x88<br />
| 4<br />
| Unknown. Always 0x00010203. (Is this some kind of a pattern? 00->01->02->03)<br />
|-<br />
| 0x8C<br />
| 0x14<br />
| Unknown.<br />
|-<br />
| 0xB0<br />
| 4<br />
| '''Data Offset'''. Offset to the texture data. Relative to this field.<br />
|-<br />
| 0xB4<br />
| 4<br />
| '''Mipmap Offset'''. Offset to the mipmap texture data. Relative to this field. '''0''' if not present.<br />
|-<br />
| 0xB8<br />
| 8<br />
| {{Unknown}}<br />
|-<br />
| 0xC0<br />
| colspan="2" {{Unknown|End of '''FTEX''' header}}<br />
|}<br />
<br />
Incomplete header documentation. Last 8 words (32 bytes) seem to change per file. Offset 160 (dec) from FTEX header always seems to be zero, followed by a single byte (value of 1), 3 padding bytes, then a relative offset to the string table, then a relative offset to UnknownDataA, a relative offset to UnknownDataB, a relative offset to unknown DataC, and then two more unknowns (usually zero).<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=3102
GTX\GSH (File Format)
2017-04-08T08:45:15Z
<p>Aboood40091: </p>
<hr />
<div>The '''GTX/GSH''' file formats are used in various Wii U games, including MK8.<br />
<br />
'''GSH''' stands for '''GX2 shader''' file, while '''GTX''' stands for '''GX2 texture''' file.<br />
<br />
== Header ==<br />
<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be the real size (0x20), or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x07, or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Data Blocks ==<br />
<br />
After the header comes some data blocks, data blocks contain a 0x20 byte '''BLK{''' block header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
IIRC Block type 0x04 doesn't exist, I hope so.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type.<br />
|-<br />
| 0x01<br />
| Follows this block header the end of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader header.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader program.<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader header.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader program.<br />
|-<br />
| 0x08<br />
| Follows this block header Geometry shader header.<br />
|-<br />
| 0x09<br />
| Follows this block header Geometry shader program.<br />
|-<br />
| 0x0A<br />
| Same as 0x09? (Duplicate?)<br />
|-<br />
| 0x0B<br />
| Follows this block header the Image header.<br />
|-<br />
| 0x0C<br />
| Follows this block header the swizzled Image data.<br />
|-<br />
| 0x0D<br />
| Follows this block header the swizzled Mipmaps data.<br />
|-<br />
| 0x0E<br />
| Follows this block header Compute shader header.<br />
|-<br />
| 0x0F<br />
| Follows this block header Compute shader program.<br />
|-<br />
| 0x10<br />
| Treated like a 0x02 block, users can do what they want with this block.<br />
|}<br />
<br />
=== Image info ===<br />
<br />
The image info directly follows the block header that has a block type 0x0B, and should exactly have a size of 0x9C:<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Dimension'''. Indicates the "shape" of a given surface or texture (see line 849 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Texture Width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Texture Height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Depth'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Number of Mipmaps'''.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Texture Format'''. Go to line 589 on [http://pastebin.com/DCrP1w9x this page] for explanation and format values.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''AA Mode'''. Indicates the AA mode (number of samples) for the surface (see line 865 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Usage'''. Indicates how the given surface may be used (see line 823 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x20<br />
| 4<br />
| '''Data Length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''Data Pointer?'''<br />
|-<br />
| 0x28<br />
| 4<br />
| '''Mipmaps Data Length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C<br />
| 4<br />
| '''Mipmaps Pointer?'''<br />
|-<br />
| 0x30<br />
| 4<br />
| '''Tile Mode'''. Indicates the desired tiling mode for the surface (see line 795 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x34<br />
| 4<br />
| '''Swizzle Value'''.<br />
|-<br />
| 0x38<br />
| 4<br />
| '''Alignment'''. Always 512 * bytes per pixel.<br />
|-<br />
| 0x3C<br />
| 4<br />
| '''Pitch'''.<br />
|-<br />
| 0x40<br />
| 0x0D<br />
| '''Mip Offset'''. Offset for each mipmap?<br />
|-<br />
| 0x4D<br />
| 0x2B<br />
| Unknown. Mipmaps related. (Always 0 in textures with no mipmaps)<br />
|-<br />
| 0x78<br />
| 4<br />
| '''Number of Mipmaps'''. Again...<br />
|-<br />
| 0x7C<br />
| 4<br />
| Unknown. Always 0.<br />
|-<br />
| 0x80<br />
| 4<br />
| Unknown. Always 1.<br />
|-<br />
| 0x84<br />
| 4<br />
| Unknown. Always 0x00010203. (Is this some kind of a pattern? 00->01->02->03)<br />
|-<br />
| 0x88<br />
| 0x14<br />
| Unknown.<br />
|}<br />
<br />
== Formats ==<br />
<br />
'''TODO'''.<br />
<br />
== Swizzling ==<br />
<br />
Reverse-engineering the swizzling was a nightmare, so documenting it will be too.<br />
The following code can swizzle/deswizzle data ''if you give it the right values''.<br />
<br />
Basically call swizzle() (or swizzle_BC() if your data is compressed) by giving it the width, height, depth, format (in hex), tileMode, swizzle value, pitch, and data.<br />
<br />
If you're swizzling then set swizzle to true.<br />
If you're deswizzling then set swizzle to false.<br />
<br />
http://pastebin.com/JA59iT8d<br />
<br />
= Tools =<br />
<br />
The following tool can extract and generate GTX files:<br />
<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=FTEX_(File_Format)&diff=3100
FTEX (File Format)
2017-04-08T07:45:19Z
<p>Aboood40091: </p>
<hr />
<div>{{Under-construction| ''Please do not add speculation here''.}}<br />
<br />
The '''FTEX''' texture format is a format for textures which appears as a subfile of a '''[[BFRES (File Format)|BFRES file]]'''.<br />
<br />
== Header (FTEX) ==<br />
<br />
Every FTEX file begins with an 0xC0 byte '''FTEX''' header that starts with the file identifier, followed by info about the image.<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FTEX'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Dimension'''. Indicates the "shape" of a given surface or texture (see line 849 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Texture Width'''. Width of the texture in pixels.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Texture Height'''. Height of the texture in pixels.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Depth'''.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Number of Mipmaps'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Texture Format'''. Go to line 589 on [http://pastebin.com/DCrP1w9x this page] for explanation and format values.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''AA Mode'''. Indicates the AA mode (number of samples) for the surface (see line 865 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x20<br />
| 4<br />
| '''Usage'''. Indicates how the given surface may be used (see line 823 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x24<br />
| 4<br />
| '''Data Length'''. Length of texture data in bytes.<br />
|-<br />
| 0x28<br />
| 4<br />
| '''Data Pointer?'''<br />
|-<br />
| 0x2C<br />
| 4<br />
| '''Mipmaps Data Length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x30<br />
| 4<br />
| '''Mipmaps Pointer?'''<br />
|-<br />
| 0x34<br />
| 4<br />
| '''Tile Mode'''. Indicates the desired tiling mode for the surface (see line 795 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x38<br />
| 4<br />
| '''Swizzle Value'''.<br />
|-<br />
| 0x3C<br />
| 4<br />
| '''Alignment'''. Always 512 * bytes per pixel.<br />
|-<br />
| 0x40<br />
| 4<br />
| '''Pitch'''.<br />
|-<br />
| 0x44<br />
| 0x0D<br />
| '''Mip Offset'''. Offset for each mipmap?<br />
|-<br />
| 0x51<br />
| 0x2B<br />
| Unknown. Mipmaps related. (Always 0 in textures with no mipmaps)<br />
|-<br />
| 0x7C<br />
| 4<br />
| '''Number of Mipmaps'''. Again...<br />
|-<br />
| 0x80<br />
| 4<br />
| Unknown. Always 0.<br />
|-<br />
| 0x84<br />
| 4<br />
| Unknown. Always 1.<br />
|-<br />
| 0x88<br />
| 4<br />
| Unknown. Always 0x00010203. (Is this some kind of a pattern? 00->01->02->03)<br />
|-<br />
| 0x8C<br />
| 0X24<br />
| Unknown.<br />
|-<br />
| 0xB0<br />
| 4<br />
| '''Data Offset'''. Offset to the texture data. Relative to this field.<br />
|-<br />
| 0xB4<br />
| 4<br />
| '''Mipmap Offset'''. Offset to the mipmap texture data. Relative to this field. '''0''' if not present.<br />
|-<br />
| 0xB8<br />
| 8<br />
| {{Unknown}}<br />
|-<br />
| 0xC0<br />
| colspan="2" {{Unknown|End of '''FTEX''' header}}<br />
|}<br />
<br />
Incomplete header documentation. Last 8 words (32 bytes) seem to change per file. Offset 160 (dec) from FTEX header always seems to be zero, followed by a single byte (value of 1), 3 padding bytes, then a relative offset to the string table, then a relative offset to UnknownDataA, a relative offset to UnknownDataB, a relative offset to unknown DataC, and then two more unknowns (usually zero).<br />
<br />
<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=3099
GTX\GSH (File Format)
2017-04-08T07:33:11Z
<p>Aboood40091: </p>
<hr />
<div>The '''GTX/GSH''' file formats are used in various Wii U games, including MK8.<br />
<br />
'''GSH''' stands for '''GX2 shader''' file, while '''GTX''' stands for '''GX2 texture''' file.<br />
<br />
== Header ==<br />
<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be the real size (0x20), or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x07, or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Data Blocks ==<br />
<br />
After the header comes some data blocks, data blocks contain a 0x20 byte '''BLK{''' block header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
IIRC Block type 0x04 doesn't exist, I hope so.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type.<br />
|-<br />
| 0x01<br />
| Follows this block header the end of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader header.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader program.<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader header.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader program.<br />
|-<br />
| 0x08<br />
| Follows this block header Geometry shader header.<br />
|-<br />
| 0x09<br />
| Follows this block header Geometry shader program.<br />
|-<br />
| 0x0A<br />
| Same as 0x09? (Duplicate?)<br />
|-<br />
| 0x0B<br />
| Follows this block header the Image header.<br />
|-<br />
| 0x0C<br />
| Follows this block header the swizzled Image data.<br />
|-<br />
| 0x0D<br />
| Follows this block header the swizzled Mipmaps data.<br />
|-<br />
| 0x0E<br />
| Follows this block header Compute shader header.<br />
|-<br />
| 0x0F<br />
| Follows this block header Compute shader program.<br />
|-<br />
| 0x10<br />
| Treated like a 0x02 block, users can do what they want with this block.<br />
|}<br />
<br />
=== Image info ===<br />
<br />
The image info directly follows the block header that has a block type 0x0B, and should exactly have a size of 0x9C:<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Dimension'''. Indicates the "shape" of a given surface or texture (see line 849 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Texture Width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Texture Height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Depth'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Number of Mipmaps'''.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Texture Format'''. Go to line 589 on [http://pastebin.com/DCrP1w9x this page] for explanation and format values.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''AA Mode'''. Indicates the AA mode (number of samples) for the surface (see line 865 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Usage'''. Indicates how the given surface may be used (see line 823 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x20<br />
| 4<br />
| '''Data Length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''Data Pointer?'''<br />
|-<br />
| 0x28<br />
| 4<br />
| '''Mipmaps Data Length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C<br />
| 4<br />
| '''Mipmaps Pointer?'''<br />
|-<br />
| 0x30<br />
| 4<br />
| '''Tile Mode'''. Indicates the desired tiling mode for the surface (see line 795 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x34<br />
| 4<br />
| '''Swizzle Value'''.<br />
|-<br />
| 0x38<br />
| 4<br />
| '''Alignment'''. Always 512 * bytes per pixel.<br />
|-<br />
| 0x3C<br />
| 4<br />
| '''Pitch'''.<br />
|-<br />
| 0x40<br />
| 0x0D<br />
| '''Mip Offset'''. Offset for each mipmap?<br />
|-<br />
| 0x4D<br />
| 0x2B<br />
| Unknown. Mipmaps related. (Always 0 in textures with no mipmaps)<br />
|-<br />
| 0x78<br />
| 4<br />
| '''Number of Mipmaps'''. Again...<br />
|-<br />
| 0x7C<br />
| 4<br />
| Unknown. Always 0.<br />
|-<br />
| 0x80<br />
| 4<br />
| Unknown. Always 1.<br />
|-<br />
| 0x84<br />
| 4<br />
| Unknown. Always 0x00010203. (Is this some kind of a pattern? 00->01->02->03)<br />
|-<br />
| 0x88<br />
| 0x2B<br />
| Unknown.<br />
|}<br />
<br />
== Formats ==<br />
<br />
'''TODO'''.<br />
<br />
== Swizzling ==<br />
<br />
Reverse-engineering the swizzling was a nightmare, so documenting it will be too.<br />
The following code can swizzle/deswizzle data ''if you give it the right values''.<br />
<br />
Basically call swizzle() (or swizzle_BC() if your data is compressed) by giving it the width, height, depth, format (in hex), tileMode, swizzle value, pitch, and data.<br />
<br />
If you're swizzling then set swizzle to true.<br />
If you're deswizzling then set swizzle to false.<br />
<br />
http://pastebin.com/JA59iT8d<br />
<br />
= Tools =<br />
<br />
The following tool can extract and generate GTX files:<br />
<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=2841
GTX\GSH (File Format)
2016-12-10T18:08:19Z
<p>Aboood40091: </p>
<hr />
<div>The '''GTX/GSH''' file formats are used in various Wii U games, including MK8.<br />
<br />
'''GSH''' stands for '''GX2 shader''' file, while '''GTX''' stands for '''GX2 texture''' file.<br />
<br />
== Header ==<br />
<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be the real size (0x20), or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x07, or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Data Blocks ==<br />
<br />
After the header comes some data blocks, data blocks contain a 0x20 byte '''BLK{''' block header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
IIRC Block type 0x04 doesn't exist, I hope so.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type. (different magic)<br />
|-<br />
| 0x01<br />
| Follows this block header the end of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader header.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader program.<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader header.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader program.<br />
|-<br />
| 0x08<br />
| Follows this block header Geometry shader header.<br />
|-<br />
| 0x09<br />
| Follows this block header Geometry shader program.<br />
|-<br />
| 0x0A<br />
| Same as 0x09? (Duplicate?)<br />
|-<br />
| 0x0B<br />
| Follows this block header the Image header.<br />
|-<br />
| 0x0C<br />
| Follows this block header the swizzled Image data.<br />
|-<br />
| 0x0D<br />
| Follows this block header the swizzled Mipmaps data.<br />
|-<br />
| 0x0E<br />
| Follows this block header Compute shader header.<br />
|-<br />
| 0x0F<br />
| Follows this block header Compute shader program.<br />
|-<br />
| 0x10<br />
| Treated like a 0x02 block, users can do what they want with this block.<br />
|}<br />
<br />
=== Image info ===<br />
<br />
The image info directly follows the block header that has a block type 0x0B, and should exactly have a size of 0x9C:<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Dimension'''. Indicates the "shape" of a given surface or texture (see line 849 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Texture Width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Texture Height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Depth'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Number of Mipmaps'''.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Texture Format'''. Go to line 589 on [http://pastebin.com/DCrP1w9x this page] for explanation and format values.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''AA Mode'''. Indicates the AA mode (number of samples) for the surface (see line 865 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Usage'''. Indicates how the given surface may be used (see line 823 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x20<br />
| 4<br />
| '''Data Length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''Data Pointer?'''<br />
|-<br />
| 0x28<br />
| 4<br />
| '''Mipmaps Data Length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C<br />
| 4<br />
| '''Mipmaps Pointer?'''<br />
|-<br />
| 0x30<br />
| 4<br />
| '''Tile Mode'''. Indicates the desired tiling mode for the surface (see line 795 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x34<br />
| 4<br />
| '''Swizzle Value'''.<br />
|-<br />
| 0x38<br />
| 4<br />
| '''Alignment'''. Always 512 * bytes per pixel.<br />
|-<br />
| 0x3C<br />
| 4<br />
| '''Pitch'''.<br />
|-<br />
| 0x40<br />
| 0x0D<br />
| '''Mip Offset'''. Offset for each mipmap?<br />
|-<br />
| 0x4D<br />
| 0x4F<br />
| Unknown.<br />
|}<br />
<br />
== Formats ==<br />
<br />
'''TODO'''.<br />
<br />
== Swizzling ==<br />
<br />
Reverse-engineering the swizzling was a nightmare, so documenting it will be too.<br />
The following code can swizzle/deswizzle data ''if you give it the right values''.<br />
<br />
Basically call swizzle() (or swizzle_BC() if your data is compressed) by giving it the width, height, depth, format (in hex), tileMode, swizzle value, pitch, and data.<br />
<br />
If you're swizzling then set swizzle to true.<br />
If you're deswizzling then set swizzle to false.<br />
<br />
http://pastebin.com/JA59iT8d<br />
<br />
= Tools =<br />
<br />
The following tool can extract and generate GTX files:<br />
<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=2641
GTX\GSH (File Format)
2016-10-05T19:13:17Z
<p>Aboood40091: </p>
<hr />
<div>The '''GTX/GSH''' file formats are used in various Wii U games, including MK8.<br />
<br />
'''GSH''' stands for '''GX2 shader''' file, while '''GTX''' stands for '''GX2 texture''' file.<br />
<br />
== Header ==<br />
<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be the real size (0x20), or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x07, or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Data Blocks ==<br />
<br />
After the header comes some data blocks, data blocks contain a 0x20 byte '''BLK{''' block header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
Block type 0x04 doesn't exist.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type. (different magic)<br />
|-<br />
| 0x01<br />
| Follows this block header the end of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader header.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader program.<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader header.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader program.<br />
|-<br />
| 0x08<br />
| Follows this block header Geometry shader header.<br />
|-<br />
| 0x09<br />
| Follows this block header Geometry shader program.<br />
|-<br />
| 0x0A<br />
| Same as 0x09? (Duplicate?)<br />
|-<br />
| 0x0B<br />
| Follows this block header the Image header.<br />
|-<br />
| 0x0C<br />
| Follows this block header the swizzled Image data.<br />
|-<br />
| 0x0D<br />
| Follows this block header the swizzled Mipmaps data.<br />
|-<br />
| 0x0E<br />
| Follows this block header Compute shader header.<br />
|-<br />
| 0x0F<br />
| Follows this block header Compute shader program.<br />
|-<br />
| 0x10<br />
| Treated like a 0x02 block, users can do what they want with this block.<br />
|}<br />
<br />
=== Image info ===<br />
<br />
The image info directly follows the block header that has a block type 0x0B, and should exactly have a size of 0x9C:<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Dimension'''. Indicates the "shape" of a given surface or texture (see line 849 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Texture Width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Texture Height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Depth'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Number of Mipmaps'''.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Texture Format'''. Go to line 589 on [http://pastebin.com/DCrP1w9x this page] for explanation and format values.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''AA Mode'''. Indicates the AA mode (number of samples) for the surface (see line 865 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Usage'''. Indicates how the given surface may be used (see line 823 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x20<br />
| 4<br />
| '''Data Length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''Data Pointer?'''<br />
|-<br />
| 0x28<br />
| 4<br />
| '''Mipmaps Data Length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C<br />
| 4<br />
| '''Mipmaps Pointer?'''<br />
|-<br />
| 0x30<br />
| 4<br />
| '''Tile Mode'''. Indicates the desired tiling mode for the surface (see line 795 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x34<br />
| 4<br />
| '''Swizzle Value'''.<br />
|-<br />
| 0x38<br />
| 4<br />
| '''Alignment'''.<br />
|-<br />
| 0x3C<br />
| 4<br />
| '''Pitch'''.<br />
|-<br />
| 0x40<br />
| 0x0D<br />
| '''Mip Offset'''. Offset for each mipmap?<br />
|-<br />
| 0x4D<br />
| 0x4F<br />
| Unknown.<br />
|}<br />
<br />
== Formats ==<br />
<br />
'''TODO'''.<br />
<br />
== Swizzling ==<br />
<br />
Reverse-engineering the swizzling was a nightmare, so documenting it will be too.<br />
The following code can swizzle/deswizzle data ''if you give it the right values''.<br />
<br />
Basically call swizzle() (or swizzle_BC() if your data is compressed) by giving it the width, height, depth, format (in hex), tileMode, swizzle value, pitch, and data.<br />
<br />
If you're swizzling then set swizzle to true.<br />
If you're deswizzling then set swizzle to false.<br />
<br />
http://pastebin.com/JA59iT8d<br />
<br />
= Tools =<br />
<br />
The following tool can extract and generate GTX files:<br />
<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=2640
GTX\GSH (File Format)
2016-10-05T18:39:26Z
<p>Aboood40091: /* Block types */</p>
<hr />
<div>The '''GTX/GSH''' file formats are used in various Wii U games, including MK8.<br />
<br />
'''GSH''' stands for '''GX2 shader''' file, while '''GTX''' stands for '''GX2 texture''' file.<br />
<br />
== Header ==<br />
<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be the real size (0x20), or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x07, or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Data Blocks ==<br />
<br />
After the header comes some data blocks, data blocks contain a 0x20 byte '''BLK{''' block header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
Block type 0x04 doesn't exist.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type. (different magic)<br />
|-<br />
| 0x01<br />
| Follows this block header the end of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader header.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader program.<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader header.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader program.<br />
|-<br />
| 0x08<br />
| Follows this block header Geometry shader header.<br />
|-<br />
| 0x09<br />
| Follows this block header Geometry shader program.<br />
|-<br />
| 0x0A<br />
| Same as 0x09? (Duplicate?)<br />
|-<br />
| 0x0B<br />
| Follows this block header the Image header.<br />
|-<br />
| 0x0C<br />
| Follows this block header the Image data.<br />
|-<br />
| 0x0D<br />
| Follows this block header the Mipmaps data.<br />
|-<br />
| 0x0E<br />
| Follows this block header Compute shader header.<br />
|-<br />
| 0x0F<br />
| Follows this block header Compute shader program.<br />
|-<br />
| 0x10<br />
| Treated like a 0x02 block, users can do what they want with this block.<br />
|}<br />
<br />
=== Image info ===<br />
<br />
The image info directly follows the block header that has a block type 0x0B, and should exactly have a size of 0x9C:<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Dimension'''. Indicates the "shape" of a given surface or texture (see line 849 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Texture Width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Texture Height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Depth'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Number of Mipmaps'''.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Texture Format'''. Go to line 589 on [http://pastebin.com/DCrP1w9x this page] for explanation and format values.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''AA Mode'''. Indicates the AA mode (number of samples) for the surface (see line 865 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Usage'''. Indicates how the given surface may be used (see line 823 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x20<br />
| 4<br />
| '''Data Length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''Data Pointer?'''<br />
|-<br />
| 0x28<br />
| 4<br />
| '''Mipmaps Data Length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C<br />
| 4<br />
| '''Mipmaps Pointer?'''<br />
|-<br />
| 0x30<br />
| 4<br />
| '''Tile Mode'''. Indicates the desired tiling mode for the surface (see line 795 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x34<br />
| 4<br />
| '''Swizzle Value'''.<br />
|-<br />
| 0x38<br />
| 4<br />
| '''Alignment'''.<br />
|-<br />
| 0x3C<br />
| 4<br />
| '''Pitch'''.<br />
|-<br />
| 0x40<br />
| 0x0D<br />
| '''Mip Offset'''. Offset for each mipmap?<br />
|-<br />
| 0x4D<br />
| 0x4F<br />
| Unknown.<br />
|}<br />
<br />
== Formats ==<br />
<br />
'''TODO'''.<br />
<br />
= Tools =<br />
<br />
The following tool can extract and generate GTX files:<br />
<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=2639
GTX\GSH (File Format)
2016-10-05T09:58:10Z
<p>Aboood40091: /* Image info */</p>
<hr />
<div>The '''GTX/GSH''' file formats are used in various Wii U games, including MK8.<br />
<br />
'''GSH''' stands for '''GX2 shader''' file, while '''GTX''' stands for '''GX2 texture''' file.<br />
<br />
== Header ==<br />
<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be the real size (0x20), or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x07, or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Data Blocks ==<br />
<br />
After the header comes some data blocks, data blocks contain a 0x20 byte '''BLK{''' block header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
Block type 0x04 doesn't exist.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type. (different magic)<br />
|-<br />
| 0x01<br />
| Follows this block header the end of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader header.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader data?<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader header.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader data?<br />
|-<br />
| 0x08<br />
| Follows this block header Geometry shader header.<br />
|-<br />
| 0x09<br />
| Follows this block header Geometry shader data?<br />
|-<br />
| 0x0A<br />
| Same as 0x09? (Duplicate?)<br />
|-<br />
| 0x0B<br />
| Follows this block header the Image header.<br />
|-<br />
| 0x0C<br />
| Follows this block header the Image data.<br />
|-<br />
| 0x0D<br />
| Follows this block header the Mipmaps data.<br />
|-<br />
| 0x0E<br />
| Follows this block header Compute shader header.<br />
|-<br />
| 0x0F<br />
| Follows this block header Compute shader data?<br />
|-<br />
| 0x10<br />
| Treated like a 0x02 block, users can do what they want with this block.<br />
|}<br />
<br />
=== Image info ===<br />
<br />
The image info directly follows the block header that has a block type 0x0B, and should exactly have a size of 0x9C:<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Dimension'''. Indicates the "shape" of a given surface or texture (see line 849 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Texture Width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Texture Height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Depth'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Number of Mipmaps'''.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Texture Format'''. Go to line 589 on [http://pastebin.com/DCrP1w9x this page] for explanation and format values.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''AA Mode'''. Indicates the AA mode (number of samples) for the surface (see line 865 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Usage'''. Indicates how the given surface may be used (see line 823 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x20<br />
| 4<br />
| '''Data Length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''Data Pointer?'''<br />
|-<br />
| 0x28<br />
| 4<br />
| '''Mipmaps Data Length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C<br />
| 4<br />
| '''Mipmaps Pointer?'''<br />
|-<br />
| 0x30<br />
| 4<br />
| '''Tile Mode'''. Indicates the desired tiling mode for the surface (see line 795 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x34<br />
| 4<br />
| '''Swizzle Value'''.<br />
|-<br />
| 0x38<br />
| 4<br />
| '''Alignment'''.<br />
|-<br />
| 0x3C<br />
| 4<br />
| '''Pitch'''.<br />
|-<br />
| 0x40<br />
| 0x0D<br />
| '''Mip Offset'''. Offset for each mipmap?<br />
|-<br />
| 0x4D<br />
| 0x4F<br />
| Unknown.<br />
|}<br />
<br />
== Formats ==<br />
<br />
'''TODO'''.<br />
<br />
= Tools =<br />
<br />
The following tool can extract and generate GTX files:<br />
<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=Main_Page&diff=2638
Main Page
2016-10-05T09:55:01Z
<p>Aboood40091: </p>
<hr />
<div>{{textbox|orange|Welcome to the MK8 Wiki!|<br />
Some notes:<br />
* This wiki is under development. It should look similar to [[:mkw:|CT-Wiiki]].<br />
* Users are shared between [[:mkw:|CT-Wiiki]] and MK8-Wiki. Both wikis share the same session cookies.<br />
* Interwiki is enabled to allow easy cross links. <br />
** Example for MK8 Wiki: '''<tt><nowiki>[[:mkw:Wiimms Mario Kart Fun]]</nowiki></tt>''' &rArr; [[:mkw:Wiimms Mario Kart Fun]]<br />
** Example for MK8 Wiki: '''<tt><nowiki>[[:mkw:User:Wiimm]]</nowiki></tt>''' &rArr; [[:mkw:User:Wiimm]]<br />
** Example for CT-Wiiki: '''<tt><nowiki>[[:mk8:Any Page Name]]</nowiki></tt>'''<br />
* '''We need helpers here to create a basic system similar to [[:mkw:|CT-Wiiki]].'''<br />
}}<br />
<br />
<br />
----<br />
<br />
<br />
{{textbox|center green|Welcome to the Custom Mario Kart 8 Wiki,|<br />
a wiki dedicated to [[Custom Track]]s, [[Texture Hack]]s and [[Custom Character]]s for [[Mario Kart 8]] ([[Wii U]]).<br>We have [[Special:Statistics|{{NUMBEROFARTICLES}}]] articles.<br />
<br />
'''Please read the [[rules]].'''<br />
}}<br />
{{multi-column|<br />
{{textbox||Track Directory|<!-- Enable this only after the first custom track has been released.<br />
[[List of Retro Tracks from Super Mario Kart|SNES Custom Tracks]]<br><br />
[[List of Retro Tracks from Mario Kart 64|N64 Custom Tracks]]<br><br />
[[List of Retro Tracks from Mario Kart: Super Circuit|GBA Custom Tracks]]<br><br />
[[List of Retro Tracks from Mario Kart: Double Dash!!|GCN Custom Tracks]]<br><br />
[[List of Retro Tracks from Mario Kart Arcade GP|Arcade Custom Tracks]]<br><br />
[[List of Retro Tracks from Mario Kart DS|DS Custom Tracks]]<br><br />
[[List of Retro Tracks from Mario Kart Wii|Wii Custom Tracks]]<br><br />
[[List of Retro Tracks from Mario Kart 7|3DS Custom Tracks]]<br><br />
[[List of Retro Tracks from Mario Kart Arcade GP DX|Arcade DX Custom Tracks]]<br><br />
[[List of Retro Tracks from Non-Mario Kart Games|Custom Tracks from Other Games]]<br>--><br />
[[List of Unfinished Tracks|Unfinished Custom Tracks]]<br><br />
[[List of Texture Hacked Tracks|Texture Hacked Tracks]]<br><br />
[[List of Edited Tracks|Edited Tracks]]<br><br />
}}<br />
<br />
{{textbox||Character Directory|<!-- Enable this only after the first custom track has been released.<br />
[[List of Custom Characters/Karts|Custom Characters/Karts]]<br><br />
[[List of Retro Characters/Karts|Retro Characters/Karts]]<br>--><br />
[[List of Texture Hacked Characters/Karts|Texture Hacked Characters / Karts]]<br><br />
}}<br />
<br />
{{textbox||File Formats|<br />
<!-- BYAML is more than just the new KMP, it also does things like objflow.byaml --><br />
[[BYAML (File Format)|BYAML - Game information file]]<br><br />
[[KCL (File Format)|KCL - Collision data]]<br><br />
[[BFRES (File Format)|BFRES - Model data]]<br><br />
[[BFLIM (File Format)|BFLIM - Layout Image file]]<br><br />
[[GTX (File Format)|GTX/GSH - Image/shader file]]<br><br />
[[BFSTM (File Format)|BFSTM - Music File]]<br><br />
[[BFSAR (File Format)|BFSAR - Sound Archive]]<br><br />
[[SARC (File Format)|SARC - File Archive]]<br><br />
[[YAZ0 (File Format)|YAZ0 - File Compression]]<br />
}}<br />
<br />
{{textbox||Reference|<br />
[[Author Reference|Author Directory (User Links)]]<br><br />
[[Filesystem]]<br><br />
[[List of File Formats| File Formats]]<br><br />
[[:Category:Software|Software]]<br><br />
[[Version Number|Version Number Usage]]<br><br />
}}<br />
|<br />
{{textbox|news|Latest Wiiki News|<br />
; New MK8 Wiki<br />
* We created this MK8-Wiki as twin of the [[:mkw:|CT-Wiiki]]. The users and session cookies will be shared between both wikis. If you have problems to login, please remove or clean the old wiki cookies and login again.<br />
}}<br />
<br />
{{textbox|red|Getting Started|<br />
[http://meta.wikimedia.org/wiki/Help:Contents Wiki User's Guide]<br><br />
[http://www.mediawiki.org/wiki/Manual:FAQ MediaWiki FAQ]<br><br />
[[Help:FAQ|Wiki FAQ]]<br />
<br />
'''Try wiki-editing in the [[sandbox]]'''<br />
}}<br />
<br />
{{New Page Templates}}<br />
|{{textbox|news|Latest Releases|<br />
{{Main-news}}<br />
<br />
'''All News: [[News 2014|2014]] • [[News 2015|2015]] • [[News 2016|2016]]'''<br />
}}<br />
}}<br />
<br />
[[Category:General Information]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=List_of_File_Formats&diff=2637
List of File Formats
2016-10-05T09:51:44Z
<p>Aboood40091: </p>
<hr />
<div>This article contains a list of '''file formats''' in [[Mario Kart 8]]. For a comparison with [[Mario Kart Wii]] see [[Comparison of Mario Kart 8 and Mario Kart Wii File Formats]].<br />
<br />
__TOC__<br />
<br />
== Mario Kart 8 file formats ==<br />
<br />
This table contains a list of file formats found in [[Mario Kart 8]]:<br />
{| class="wikitable"<br />
|-<br />
! Name<br />
! Description<br />
<br />
|-<br />
| align=center | [[AAMP (File Format)|AAMP]]<br />
| Compressed files.<br />
|-<br />
| align=center | [[BARS (File Format)|BARS]]<br />
| Sound files archive.<br />
|-<br />
| align=center | [[BAGLCUBE (File Format)|BAGLCUBE]]<br />
| {{Unknown|Unknown.}} [[AAMP (File Format)|AAMP]] compressed file.<br />
|-<br />
| align=center | [[BFFNT (File Format)|BFFNT]]<br />
| Font files used to display text.<br />
|-<br />
| align=center | [[BFLIM (File Format)|BFLIM]]<br />
| Layout images.<br />
|-<br />
| align=center | [[BFRES (File Format)|BFRES]]<br />
| Object files, containing model, animation, and texture information on an object, such as an itembox, a character or a course.<br />
|-<br />
| align=center | [[BFSAR (File Format)|BFSAR]]<br />
| Sound archive file for small sound effects.<br />
|-<br />
| align=center | [[BFSHA (File Format)|BFSHA]]<br />
| Shader files.<br />
|-<br />
| align=center | [[BFSTM (File Format)|BFSTM]]<br />
| Music files used by Mario Kart 8.<br />
|-<br />
| align=center | [[BGENV (File Format)|BGENV]]<br />
| Posteffect information.<br />
|-<br />
| align=center | [[BGLPBD (File Format)|BGLPBD]]<br />
| {{Unknown|Probably Baked Textures related data.}}<br />
|-<br />
| align=center | [[BSIS (File Format)|BSIS]]<br />
| audio database<br />
|-<br />
| align=center | [[BYAML (File Format)|BYAML]]<br />
| A generic data container format, like a binary version of XML.<br />
|-<br />
| align=center | [[CPSD (File Format)|CPSD]]<br />
| {{Unknown|Probably Mii related data.}}<br />
|-<br />
| align=center | [[FMDL (File Format)|FMDL]]<br />
| Model data and usually a sub file of [[BFRES (File Format)|BFRES archives]].<br />
|-<br />
| align=center | [[FTEX (File Format)|FTEX]]<br />
| FTEX files are [[Image Formats|texture files]] and usually a sub file of [[BFRES (File Format)|BFRES archives]].<br />
|-<br />
| align=center | [[GTX (File Format)|GTX/GSH]]<br />
| Texture/Shader file.<br />
|-<br />
| align=center | [[KCL (File Format)|KCL]]<br />
| Collision information files containing information about when and how objects collide with a course or object.<br />
|-<br />
| align=center | [[MSBT (File Format)|MSBT]]<br />
| Message files containing localized text for use in game screens and menus.<br />
|-<br />
| align=center | [[PTCL (File Format)|PTCL]]<br />
| Graphic particle file.<br />
|-<br />
| align=center | [[SARC (File Format)|SARC]]<br />
| File archive with a hierarchical file system. Most used together with [[Yaz0]] compression and stored as SZS file. Otherwise often seen with the BARS extension.<br />
|-<br />
| align=center | [[YAZ0 (File Format)|YAZ0]]<br />
| Compressed files with any data. [[SZS]] files are mostly [[YAZ0]] files.<br />
|}<br />
<br />
[[Category:File Format|!]]<br />
[[Category:List]]<br />
[[mkw:List of File Formats]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX_(File_Format)&diff=2636
GTX (File Format)
2016-10-05T09:05:47Z
<p>Aboood40091: Aboood40091 moved page GTX (File Format) to GTX/GSH (File Format): It's not only gtx.</p>
<hr />
<div>#REDIRECT [[GTX/GSH (File Format)]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=2635
GTX\GSH (File Format)
2016-10-05T09:05:46Z
<p>Aboood40091: Aboood40091 moved page GTX (File Format) to GTX/GSH (File Format): It's not only gtx.</p>
<hr />
<div>The '''GTX/GSH''' file formats are used in various Wii U games, including MK8.<br />
<br />
'''GSH''' stands for '''GX2 shader''' file, while '''GTX''' stands for '''GX2 texture''' file.<br />
<br />
== Header ==<br />
<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be the real size (0x20), or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x07, or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Data Blocks ==<br />
<br />
After the header comes some data blocks, data blocks contain a 0x20 byte '''BLK{''' block header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
Block type 0x04 doesn't exist.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type. (different magic)<br />
|-<br />
| 0x01<br />
| Follows this block header the end of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader header.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader data?<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader header.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader data?<br />
|-<br />
| 0x08<br />
| Follows this block header Geometry shader header.<br />
|-<br />
| 0x09<br />
| Follows this block header Geometry shader data?<br />
|-<br />
| 0x0A<br />
| Same as 0x09? (Duplicate?)<br />
|-<br />
| 0x0B<br />
| Follows this block header the Image header.<br />
|-<br />
| 0x0C<br />
| Follows this block header the Image data.<br />
|-<br />
| 0x0D<br />
| Follows this block header the Mipmaps data.<br />
|-<br />
| 0x0E<br />
| Follows this block header Compute shader header.<br />
|-<br />
| 0x0F<br />
| Follows this block header Compute shader data?<br />
|-<br />
| 0x10<br />
| Treated like a 0x02 block, users can do what they want with this block.<br />
|}<br />
<br />
=== Image info ===<br />
<br />
The image info directly follows the block header that has a block type 0x0B, and should exactly have a size of 0x9C:<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Dimension'''. Indicates the "shape" of a given surface or texture (see line 849 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Texture Width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Texture Height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Depth'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Number of Mipmaps'''.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Texture Format'''. Go to line 589 on [http://pastebin.com/DCrP1w9x this page] for explanation and format values.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''AA Mode'''. Indicates the AA mode (number of samples) for the surface (see line 865 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Usage'''. Indicates how the given surface may be used (see line 823 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x20<br />
| 4<br />
| '''Data Length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''Data Pointer?'''.<br />
|-<br />
| 0x28<br />
| 4<br />
| '''Mipmaps Data Length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C<br />
| 4<br />
| '''Mipmaps Pointer?'''.<br />
|-<br />
| 0x30<br />
| 4<br />
| '''Tile Mode'''. Indicates the desired tiling mode for the surface (see line 795 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x34<br />
| 4<br />
| '''Swizzle Value'''<br />
|-<br />
| 0x38<br />
| 4<br />
| '''Alignment'''<br />
|-<br />
| 0x3C<br />
| 4<br />
| '''Pitch'''<br />
|-<br />
| 0x40<br />
| 0x0D<br />
| Unknown.<br />
|-<br />
| 0x4D<br />
| 0x4F<br />
| Unknown.<br />
|}<br />
<br />
== Formats ==<br />
<br />
'''TODO'''.<br />
<br />
= Tools =<br />
<br />
The following tool can extract and generate GTX files:<br />
<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=List_of_File_Formats&diff=2634
List of File Formats
2016-10-05T08:56:10Z
<p>Aboood40091: </p>
<hr />
<div>This article contains a list of '''file formats''' in [[Mario Kart 8]]. For a comparison with [[Mario Kart Wii]] see [[Comparison of Mario Kart 8 and Mario Kart Wii File Formats]].<br />
<br />
__TOC__<br />
<br />
== Mario Kart 8 file formats ==<br />
<br />
This table contains a list of file formats found in [[Mario Kart 8]]:<br />
{| class="wikitable"<br />
|-<br />
! Name<br />
! Description<br />
<br />
|-<br />
| align=center | [[AAMP (File Format)|AAMP]]<br />
| Compressed files.<br />
|-<br />
| align=center | [[BARS (File Format)|BARS]]<br />
| Sound files archive.<br />
|-<br />
| align=center | [[BAGLCUBE (File Format)|BAGLCUBE]]<br />
| {{Unknown|Unknown.}} [[AAMP (File Format)|AAMP]] compressed file.<br />
|-<br />
| align=center | [[BFFNT (File Format)|BFFNT]]<br />
| Font files used to display text.<br />
|-<br />
| align=center | [[BFLIM (File Format)|BFLIM]]<br />
| BFLIM is an [[Image Formats|image file format]] used for menus.<br />
|-<br />
| align=center | [[BFRES (File Format)|BFRES]]<br />
| Object files, containing model, animation, and texture information on an object, such as an itembox, a character or a course.<br />
|-<br />
| align=center | [[BFSAR (File Format)|BFSAR]]<br />
| Sound archive file for small sound effects.<br />
|-<br />
| align=center | [[BFSHA (File Format)|BFSHA]]<br />
| Shader files.<br />
|-<br />
| align=center | [[BFSTM (File Format)|BFSTM]]<br />
| Music files used by Mario Kart 8.<br />
|-<br />
| align=center | [[BGENV (File Format)|BGENV]]<br />
| Posteffect information.<br />
|-<br />
| align=center | [[BGLPBD (File Format)|BGLPBD]]<br />
| {{Unknown|Probably Baked Textures related data.}}<br />
|-<br />
| align=center | [[BSIS (File Format)|BSIS]]<br />
| audio database<br />
|-<br />
| align=center | [[BYAML (File Format)|BYAML]]<br />
| A generic data container format, like a binary version of XML.<br />
|-<br />
| align=center | [[CPSD (File Format)|CPSD]]<br />
| {{Unknown|Probably Mii related data.}}<br />
|-<br />
| align=center | [[FMDL (File Format)|FMDL]]<br />
| Model data and usually a sub file of [[BFRES (File Format)|BFRES archives]].<br />
|-<br />
| align=center | [[FTEX (File Format)|FTEX]]<br />
| FTEX files are [[Image Formats|texture files]] and usually a sub file of [[BFRES (File Format)|BFRES archives]].<br />
|-<br />
| align=center | [[GTX (File Format)|GTX/GSH]]<br />
| Texture/Shader file.<br />
|-<br />
| align=center | [[KCL (File Format)|KCL]]<br />
| Collision information files containing information about when and how objects collide with a course or object.<br />
|-<br />
| align=center | [[MSBT (File Format)|MSBT]]<br />
| Message files containing localized text for use in game screens and menus.<br />
|-<br />
| align=center | [[PTCL (File Format)|PTCL]]<br />
| Graphic particle file.<br />
|-<br />
| align=center | [[SARC (File Format)|SARC]]<br />
| File archive with a hierarchical file system. Most used together with [[Yaz0]] compression and stored as SZS file. Otherwise often seen with the BARS extension.<br />
|-<br />
| align=center | [[YAZ0 (File Format)|YAZ0]]<br />
| Compressed files with any data. [[SZS]] files are mostly [[YAZ0]] files.<br />
|}<br />
<br />
[[Category:File Format|!]]<br />
[[Category:List]]<br />
[[mkw:List of File Formats]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=2633
GTX\GSH (File Format)
2016-10-03T10:53:13Z
<p>Aboood40091: </p>
<hr />
<div>The '''GTX/GSH''' file formats are used in various Wii U games, including MK8.<br />
<br />
'''GSH''' stands for '''GX2 shader''' file, while '''GTX''' stands for '''GX2 texture''' file.<br />
<br />
== Header ==<br />
<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be the real size (0x20), or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x07, or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Data Blocks ==<br />
<br />
After the header comes some data blocks, data blocks contain a 0x20 byte '''BLK{''' block header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
Block type 0x04 doesn't exist.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type. (different magic)<br />
|-<br />
| 0x01<br />
| Follows this block header the end of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader header.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader data?<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader header.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader data?<br />
|-<br />
| 0x08<br />
| Follows this block header Geometry shader header.<br />
|-<br />
| 0x09<br />
| Follows this block header Geometry shader data?<br />
|-<br />
| 0x0A<br />
| Same as 0x09? (Duplicate?)<br />
|-<br />
| 0x0B<br />
| Follows this block header the Image header.<br />
|-<br />
| 0x0C<br />
| Follows this block header the Image data.<br />
|-<br />
| 0x0D<br />
| Follows this block header the Mipmaps data.<br />
|-<br />
| 0x0E<br />
| Follows this block header Compute shader header.<br />
|-<br />
| 0x0F<br />
| Follows this block header Compute shader data?<br />
|-<br />
| 0x10<br />
| Treated like a 0x02 block, users can do what they want with this block.<br />
|}<br />
<br />
=== Image info ===<br />
<br />
The image info directly follows the block header that has a block type 0x0B, and should exactly have a size of 0x9C:<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Dimension'''. Indicates the "shape" of a given surface or texture (see line 849 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Texture Width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Texture Height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Depth'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Number of Mipmaps'''.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Texture Format'''. Go to line 589 on [http://pastebin.com/DCrP1w9x this page] for explanation and format values.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''AA Mode'''. Indicates the AA mode (number of samples) for the surface (see line 865 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Usage'''. Indicates how the given surface may be used (see line 823 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x20<br />
| 4<br />
| '''Data Length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''Data Pointer?'''.<br />
|-<br />
| 0x28<br />
| 4<br />
| '''Mipmaps Data Length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C<br />
| 4<br />
| '''Mipmaps Pointer?'''.<br />
|-<br />
| 0x30<br />
| 4<br />
| '''Tile Mode'''. Indicates the desired tiling mode for the surface (see line 795 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x34<br />
| 4<br />
| '''Swizzle Value'''<br />
|-<br />
| 0x38<br />
| 4<br />
| '''Alignment'''<br />
|-<br />
| 0x3C<br />
| 4<br />
| '''Pitch'''<br />
|-<br />
| 0x40<br />
| 0x0D<br />
| Unknown.<br />
|-<br />
| 0x4D<br />
| 0x4F<br />
| Unknown.<br />
|}<br />
<br />
== Formats ==<br />
<br />
'''TODO'''.<br />
<br />
= Tools =<br />
<br />
The following tool can extract and generate GTX files:<br />
<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=2625
GTX\GSH (File Format)
2016-10-01T13:04:00Z
<p>Aboood40091: /* Image info */</p>
<hr />
<div>The '''GTX/GSH''' texture formats are used in various Wii U games, including MK8.<br />
<br />
'''GSH''' stands for '''GX2 shader''' file, while '''GTX''' stands for '''GX2 texture''' file.<br />
<br />
== Header ==<br />
<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be the real size (0x20), or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x07, or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Blocks ==<br />
<br />
After the header comes some blocks, blocks contain a 0x20 byte '''BLK{''' header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
Block type 0x04 doesn't exist.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type. (different magic)<br />
|-<br />
| 0x01<br />
| Follows this block header the End of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader info.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader program.<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader info.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader program.<br />
|-<br />
| 0x0B<br />
| Follows this block header the Image info.<br />
|-<br />
| 0x0C<br />
| Follows this block header the Image data.<br />
|-<br />
| 0x0D<br />
| Follows this block header the Mipmaps data.<br />
|}<br />
<br />
=== Image info ===<br />
<br />
The image info directly follows the block header that has a block type 0x0B:<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Dimension'''. Indicates the "shape" of a given surface or texture (see line 849 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Texture Width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Texture Height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Depth'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Number of Mipmaps'''.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Texture Format'''. Go to line 589 on [http://pastebin.com/DCrP1w9x this page] for explanation and format values.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''AA Mode'''. Indicates the AA mode (number of samples) for the surface (see line 865 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Usage'''. Indicates how the given surface may be used (see line 823 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x20<br />
| 4<br />
| '''Data Length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''Data Pointer?'''.<br />
|-<br />
| 0x28<br />
| 4<br />
| '''Mipmaps Data Length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C<br />
| 4<br />
| '''Mipmaps Pointer?'''.<br />
|-<br />
| 0x30<br />
| 4<br />
| '''Tile Mode'''. Indicates the desired tiling mode for the surface (see line 795 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x34<br />
| 4<br />
| '''Swizzle Value'''<br />
|-<br />
| 0x38<br />
| 4<br />
| '''Alignment'''<br />
|-<br />
| 0x3C<br />
| 4<br />
| '''Pitch'''<br />
|-<br />
| 0x40<br />
| 0x0D<br />
| Unknown.<br />
|-<br />
| 0x4D<br />
| 0x4F<br />
| Unknown.<br />
|}<br />
<br />
== Formats ==<br />
<br />
'''TODO'''.<br />
<br />
= Tools =<br />
<br />
The following tool can extract and generate GTX files:<br />
<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=2624
GTX\GSH (File Format)
2016-10-01T13:01:26Z
<p>Aboood40091: </p>
<hr />
<div>The '''GTX/GSH''' texture formats are used in various Wii U games, including MK8.<br />
<br />
'''GSH''' stands for '''GX2 shader''' file, while '''GTX''' stands for '''GX2 texture''' file.<br />
<br />
== Header ==<br />
<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be the real size (0x20), or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x07, or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Blocks ==<br />
<br />
After the header comes some blocks, blocks contain a 0x20 byte '''BLK{''' header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
Block type 0x04 doesn't exist.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type. (different magic)<br />
|-<br />
| 0x01<br />
| Follows this block header the End of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader info.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader program.<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader info.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader program.<br />
|-<br />
| 0x0B<br />
| Follows this block header the Image info.<br />
|-<br />
| 0x0C<br />
| Follows this block header the Image data.<br />
|-<br />
| 0x0D<br />
| Follows this block header the Mipmaps data.<br />
|}<br />
<br />
=== Image info ===<br />
<br />
The image info directly follows the block header that has a block type 0x0B:<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Dimension'''. Indicates the "shape" of a given surface or texture (see line 849 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Texture Width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Texture Height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Depth'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Number of Mipmaps'''.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Texture Format'''. Go to line 589 on [http://pastebin.com/DCrP1w9x this page] for explanation and format values.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''AA Mode'''. Indicates the AA mode (number of samples) for the surface (see line 865 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Usage'''. Indicates how the given surface may be used (see line 823 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x20<br />
| 4<br />
| '''Data Length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''Data Pointer?'''.<br />
|-<br />
| 0x28<br />
| 4<br />
| '''Mipmaps Data Length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C<br />
| 4<br />
| '''Mipmaps Pointer?'''.<br />
|-<br />
| 0x30<br />
| 4<br />
| '''Tile Mode'''. Indicates the desired tiling mode for the surface (see line 795 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x34<br />
| 4<br />
| '''Swizzle Value'''<br />
|-<br />
| 0x38<br />
| 4<br />
| '''Alignment'''<br />
|-<br />
| 0x3C<br />
| 4<br />
| '''Pitch'''<br />
|-<br />
| 0x40<br />
| 0x5C<br />
| Unknown.<br />
|}<br />
<br />
== Formats ==<br />
<br />
'''TODO'''.<br />
<br />
= Tools =<br />
<br />
The following tool can extract and generate GTX files:<br />
<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=2623
GTX\GSH (File Format)
2016-10-01T13:00:57Z
<p>Aboood40091: </p>
<hr />
<div>The '''GTX/GSH''' texture formats are used in various Wii U games, including MK8.<br />
<br />
'''GSH''' stands for '''GX2 shader''' file. <br />
'''GTX''' stands for '''GX2 texture''' file.<br />
<br />
== Header ==<br />
<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be the real size (0x20), or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x07, or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Blocks ==<br />
<br />
After the header comes some blocks, blocks contain a 0x20 byte '''BLK{''' header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
Block type 0x04 doesn't exist.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type. (different magic)<br />
|-<br />
| 0x01<br />
| Follows this block header the End of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader info.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader program.<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader info.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader program.<br />
|-<br />
| 0x0B<br />
| Follows this block header the Image info.<br />
|-<br />
| 0x0C<br />
| Follows this block header the Image data.<br />
|-<br />
| 0x0D<br />
| Follows this block header the Mipmaps data.<br />
|}<br />
<br />
=== Image info ===<br />
<br />
The image info directly follows the block header that has a block type 0x0B:<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Dimension'''. Indicates the "shape" of a given surface or texture (see line 849 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Texture Width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Texture Height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Depth'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Number of Mipmaps'''.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Texture Format'''. Go to line 589 on [http://pastebin.com/DCrP1w9x this page] for explanation and format values.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''AA Mode'''. Indicates the AA mode (number of samples) for the surface (see line 865 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Usage'''. Indicates how the given surface may be used (see line 823 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x20<br />
| 4<br />
| '''Data Length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''Data Pointer?'''.<br />
|-<br />
| 0x28<br />
| 4<br />
| '''Mipmaps Data Length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C<br />
| 4<br />
| '''Mipmaps Pointer?'''.<br />
|-<br />
| 0x30<br />
| 4<br />
| '''Tile Mode'''. Indicates the desired tiling mode for the surface (see line 795 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x34<br />
| 4<br />
| '''Swizzle Value'''<br />
|-<br />
| 0x38<br />
| 4<br />
| '''Alignment'''<br />
|-<br />
| 0x3C<br />
| 4<br />
| '''Pitch'''<br />
|-<br />
| 0x40<br />
| 0x5C<br />
| Unknown.<br />
|}<br />
<br />
== Formats ==<br />
<br />
'''TODO'''.<br />
<br />
= Tools =<br />
<br />
The following tool can extract and generate GTX files:<br />
<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=2622
GTX\GSH (File Format)
2016-10-01T13:00:15Z
<p>Aboood40091: </p>
<hr />
<div>The '''GTX/GSH''' texture formats are used in various Wii U games, including MK8.<br />
<br />
'''GSH''' stands for '''GX2 shader''' file. <br />
'''GTX''' stands for '''GX2 texture''' file. <br />
<br />
== Header ==<br />
<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be the real size (0x20), or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x07, or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Blocks ==<br />
<br />
After the header comes some blocks, blocks contain a 0x20 byte '''BLK{''' header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
Block type 0x04 doesn't exist.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type. (different magic)<br />
|-<br />
| 0x01<br />
| Follows this block header the End of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader info.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader program.<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader info.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader program.<br />
|-<br />
| 0x0B<br />
| Follows this block header the Image info.<br />
|-<br />
| 0x0C<br />
| Follows this block header the Image data.<br />
|-<br />
| 0x0D<br />
| Follows this block header the Mipmaps data.<br />
|}<br />
<br />
=== Image info ===<br />
<br />
The image info directly follows the block header that has a block type 0x0B:<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Dimension'''. Indicates the "shape" of a given surface or texture (see line 849 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Texture Width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Texture Height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Depth'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Number of Mipmaps'''.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Texture Format'''. Go to line 589 on [http://pastebin.com/DCrP1w9x this page] for explanation and format values.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''AA Mode'''. Indicates the AA mode (number of samples) for the surface (see line 865 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Usage'''. Indicates how the given surface may be used (see line 823 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x20<br />
| 4<br />
| '''Data Length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''Data Pointer?'''.<br />
|-<br />
| 0x28<br />
| 4<br />
| '''Mipmaps Data Length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C<br />
| 4<br />
| '''Mipmaps Pointer?'''.<br />
|-<br />
| 0x30<br />
| 4<br />
| '''Tile Mode'''. Indicates the desired tiling mode for the surface (see line 795 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x34<br />
| 4<br />
| '''Swizzle Value'''<br />
|-<br />
| 0x38<br />
| 4<br />
| '''Alignment'''<br />
|-<br />
| 0x3C<br />
| 4<br />
| '''Pitch'''<br />
|-<br />
| 0x40<br />
| 0x5C<br />
| Unknown.<br />
|}<br />
<br />
== Formats ==<br />
<br />
'''TODO'''.<br />
<br />
= Tools =<br />
<br />
The following tool can extract and generate GTX files:<br />
<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091
https://mk8.tockdom.com/w/index.php?title=GTX%5CGSH_(File_Format)&diff=2621
GTX\GSH (File Format)
2016-10-01T12:59:31Z
<p>Aboood40091: </p>
<hr />
<div>The '''GTX/GSH''' texture formats are used in various Wii U games, including MK8.<br />
<br />
'''GSH''' stands for '''GX2 shader''' file.<br />
'''GTX''' stands for '''GX2 texture''' file.<br />
<br />
== Header ==<br />
<br />
Every GTX/GSH file begins with an 0x20 byte '''Gfx2''' header.<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''Gfx2'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of header in bytes'''. Must be the real size (0x20), or header (and hence file) is unreadable.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x07, or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x01.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''GPU version''' for which this file is designed for.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Align mode'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Reserved''', Always 0x00.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of '''Gfx2''' header.}}<br />
|}<br />
<br />
== Blocks ==<br />
<br />
After the header comes some blocks, blocks contain a 0x20 byte '''BLK{''' header followed by data specified by the block type.<br />
<br />
=== Block Header ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''BLK{'''" Header of the block, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size of block header in bytes'''.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Major version number'''. Must be 0x01 or header is unreadable.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Minor version number'''. Must be 0x00.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Block type''', it determines the type of the following data.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Size of the following data'''. In bytes, always 0x9C if the block type is 0x0B.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''A unique identifier for this block''', allowing it to be referenced by other blocks<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''An incrementing index''' for each instance of a given type.<br />
|}<br />
<br />
=== Block types ===<br />
<br />
Block type 0x04 doesn't exist.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| Not actually a valid Block type. (different magic)<br />
|-<br />
| 0x01<br />
| Follows this block header the End of the file.<br />
|-<br />
| 0x02<br />
| Follows this block header padding. (Used to align following data)<br />
|-<br />
| 0x03<br />
| Follows this block header Vertex shader info.<br />
|-<br />
| 0x05<br />
| Follows this block header Vertex shader program.<br />
|-<br />
| 0x06<br />
| Follows this block header Pixel shader info.<br />
|-<br />
| 0x07<br />
| Follows this block header Pixel shader program.<br />
|-<br />
| 0x0B<br />
| Follows this block header the Image info.<br />
|-<br />
| 0x0C<br />
| Follows this block header the Image data.<br />
|-<br />
| 0x0D<br />
| Follows this block header the Mipmaps data.<br />
|}<br />
<br />
=== Image info ===<br />
<br />
The image info directly follows the block header that has a block type 0x0B:<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Dimension'''. Indicates the "shape" of a given surface or texture (see line 849 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Texture Width'''. Width of the texture in pixels.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Texture Height'''. Height of the texture in pixels.<br />
|-<br />
| 0x0C<br />
| 4<br />
| '''Depth'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Number of Mipmaps'''.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Texture Format'''. Go to line 589 on [http://pastebin.com/DCrP1w9x this page] for explanation and format values.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''AA Mode'''. Indicates the AA mode (number of samples) for the surface (see line 865 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x1C<br />
| 4<br />
| '''Usage'''. Indicates how the given surface may be used (see line 823 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x20<br />
| 4<br />
| '''Data Length'''. Length of texture data in bytes.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''Data Pointer?'''.<br />
|-<br />
| 0x28<br />
| 4<br />
| '''Mipmaps Data Length'''. Length of mipmaps data in bytes.<br />
|-<br />
| 0x2C<br />
| 4<br />
| '''Mipmaps Pointer?'''.<br />
|-<br />
| 0x30<br />
| 4<br />
| '''Tile Mode'''. Indicates the desired tiling mode for the surface (see line 795 [http://pastebin.com/DCrP1w9x here]).<br />
|-<br />
| 0x34<br />
| 4<br />
| '''Swizzle Value'''<br />
|-<br />
| 0x38<br />
| 4<br />
| '''Alignment'''<br />
|-<br />
| 0x3C<br />
| 4<br />
| '''Pitch'''<br />
|-<br />
| 0x40<br />
| 0x5C<br />
| Unknown.<br />
|}<br />
<br />
== Formats ==<br />
<br />
'''TODO'''.<br />
<br />
= Tools =<br />
<br />
The following tool can extract and generate GTX files:<br />
<br />
* [https://github.com/aboood40091/GTX-Extractor GTX Extractor], by [[User:Aboood40091|AboodXD]]<br />
<br />
[[Category:File Format]]</div>
Aboood40091