https://mk8.tockdom.com/w/api.php?action=feedcontributions&user=Chadderz&feedformat=atomMK8 - User contributions [en]2024-03-28T20:46:04ZUser contributionsMediaWiki 1.35.14https://mk8.tockdom.com/w/index.php?title=Fire_Luigi_(Luigi_Texture)&diff=1262Fire Luigi (Luigi Texture)2015-10-09T16:21:26Z<p>Chadderz: I didn't actually do anything towards GCN Dry Dry Grassland.</p>
<hr />
<div><div class="float-right"><br />
{{Text-Info<br />
|texture hack name= Fire Luigi<br />
|author= [[MrBean35000vr]]<br />
|type= Fire, Texture<br />
|version=<br />
|date of released= 2014-09-25<br />
|download=<br />
}}<br />
</div><br />
<br />
==Overview==<br />
'''Fire Luigi''' a [[Texture Hack]] of Luigi. It makes Luigi look like he has a fire suit on.<br />
==Media==<br />
{{youtube-box||j3AgUN7hQK4|Preview}}<br />
<br />
==Version History==<br />
{| class="wikitable"<br />
|-<br />
! align=left| Version<br />
! align=left| Date of release<br />
! align=left| Information<br />
|-<br />
|<br />
| 2014-09-25<br />
| Preview Video Showing off [[GCN Dry Dry Grassland (GCN Dry Dry Desert Texture)|GCN Dry Dry Grassland]] and [[Fire Luigi (Luigi Texture)|Fire Luigi]]<br />
|}<br />
<br />
{{User-MrBean35000vr-Link}}<br />
[[Category:Track/Texture]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=GCN_Dry_Dry_Grassland_(GCN_Dry_Dry_Desert_Texture)_(MrBean35000vr)&diff=1261GCN Dry Dry Grassland (GCN Dry Dry Desert Texture) (MrBean35000vr)2015-10-09T16:20:50Z<p>Chadderz: I didn't actually do anything towards GCN Dry Dry Grassland.</p>
<hr />
<div><div class="float-right"><br />
{{Text-Info<br />
|texture hack name= GCN Dry Dry Grassland<br />
|author= [[MrBean35000vr]]<br />
|type= Grass, Dry, Texture<br />
|version=<br />
|date of released= 2014-09-25<br />
|download=<br />
}}<br />
</div><br />
<br />
==Overview==<br />
'''GCN Dry Dry Grassland''' a [[Texture Hack]] of GCN Dry Dry Desert. It gives GCN Dry Dry Desert an impression of a dry grassland. It was made using textures from Thwomp Ruins, some original textures slightly recoloured and some custom textures.<br />
==Media==<br />
{{youtube-box||j3AgUN7hQK4|Preview}}<br />
<br />
==Version History==<br />
{| class="wikitable"<br />
|-<br />
! align=left| Version<br />
! align=left| Date of release<br />
! align=left| Information<br />
|-<br />
|<br />
| 2014-09-25<br />
| Preview Video Showing off [[GCN Dry Dry Grassland (GCN Dry Dry Desert Texture)|GCN Dry Dry Grassland]] and [[Fire Luigi (Luigi Texture)|Fire Luigi]]<br />
|}<br />
<br />
{{User-MrBean35000vr-Link}}<br />
[[Category:Track/Texture]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=News_2014&diff=1260News 20142015-10-09T16:19:57Z<p>Chadderz: I didn't actually do anything towards GCN Dry Dry Grassland.</p>
<hr />
<div>{{News Attention}}<br />
<!-- WARNING: Newer entries within the same date must be put below older entries. --><br />
{{textbox|news|September 2015|<br />
;2015-09-25<br />
* '''[[MrBean35000vr]]''' released a video showing off '''[[GCN Dry Dry Grassland (GCN Dry Dry Desert Texture)|GCN Dry Dry Grassland]]''' and '''[[Fire Luigi (Luigi Texture)|Fire Luigi]]'''.<br />
}}<br />
{{textbox|news|May 2015|<br />
;2015-05-29<br />
* '''Congratulations Mario Kart 8, you are now 1 year old.'''<br />
}}<br />
{{textbox|news|August 2014|<br />
;2014-08-15<br />
*'''[[MrBean35000vr]]''' and '''[[Chadderz]]''' interviewed on Kotaku about [http://kotaku.com/the-men-who-hacked-mario-kart-8-1622076182 Mario Kart 8 modding.]<br />
<br />
;2014-08-04<br />
* This MK8-Wiki was founded.<br />
}}<br />
{{textbox|news|July 2014|<br />
;2014-07-21<br />
* '''[[MrBean35000vr]]''' and '''[[Chadderz]]''' created the first [[Mario Kart 8]] [[Texture Hack]]; '''[[Icy Thwomp Ruins (Thwomp Ruins Texture)|Icy Thwomp Ruins]]'''.<br />
<br />
;2014-07-05<br />
* '''[[MrBean35000vr]]''' and '''[[Chadderz]]''' created the first '''[[Mario Kart 8]] mods''' on a [http://www.twitch.tv/mrbean35000vr/b/544826295 twitch.tv livestream].<br />
}}<br />
<br />
{{News Links}}<br />
[[Category:History]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=BFSTM_(File_Format)&diff=1177BFSTM (File Format)2015-03-14T09:09:53Z<p>Chadderz: Added category and improved formatting.</p>
<hr />
<div>The '''BFSTM''' file format is an updated spec from its predecessor, [[:mkw:BRSTM (File Format)|BRSTM]]. It contains audio streams in uncompressed ADPCM.<br />
<br />
There is a header section along with an INFO, SEEK, and DATA section.<br />
<br />
== File Header ==<br />
<br />
The file starts with a typical header structure.<br />
<br />
{| class="wikitable"<br />
|-<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| Magic Bytes (FSTM)<br />
|-<br />
| 0x04<br />
| 2<br />
| Byte Order Mark (0xFEFF for Big Endian)<br />
|-<br />
| 0x06<br />
| 2<br />
| Header Size (always 0x40)<br />
|-<br />
| 0x08<br />
| 4<br />
| Unknown Constant (always 0x30000)<br />
|-<br />
| 0x0C<br />
| 4<br />
| Size of Entire File<br />
|-<br />
| 0x10<br />
| 4<br />
| Unknown Constant (always 0x30000)<br />
|-<br />
| 0x14<br />
| 4<br />
| Section 0 Flag (0x40000000)<br />
|-<br />
| 0x18<br />
| 4<br />
| INFO Offset (always 0x40)<br />
|-<br />
| 0x1C<br />
| 4<br />
| INFO Size (always 0x100)<br />
|-<br />
| 0x20<br />
| 4<br />
| Section 1 Flag (0x40010000)<br />
|-<br />
| 0x24<br />
| 4<br />
| SEEK Offset (always 0x140)<br />
|-<br />
| 0x28<br />
| 4<br />
| SEEK Size<br />
|-<br />
| 0x2C<br />
| 4<br />
| Section 2 Flag (0x40020000)<br />
|-<br />
| 0x30<br />
| 4<br />
| DATA Offset<br />
|-<br />
| 0x34<br />
| 4<br />
| DATA Size<br />
|-<br />
| 0x38<br />
| 8<br />
| Padding<br />
|-<br />
| 0x40<br />
| colspan=2 {{unknown|End of file header}}<br />
|}<br />
<br />
[[Category:File Format]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=BYAML_(File_Format)&diff=1172BYAML (File Format)2015-02-27T17:55:53Z<p>Chadderz: /* Tools */ Replaced tools section with link to yamlconv article.</p>
<hr />
<div>The '''BYAML''' file format is a generic data container format used in [[Mario Kart 8]]. It is similar in some ways to [http://en.wikipedia.org/wiki/Xml XML], but it is a binary data format. Like XML files, BYAML files are somewhat self describing making it easier to understand and edit them than unformated binary data. In Mario Kart 8 they're used to describe course control information such as layout and checkpointing, as well as describing game-wide settings such as objects and AIs.<br />
<br />
__TOC__<br />
<br />
= Format =<br />
<br />
The file is broken up into a node structure, with possible interlinking between the nodes. Each node has a one byte format identifier. The file begins with a header which points to up to four special nodes: the node name table node; the string value table node; the path value node and finally the root node.<br />
<br />
== Header ==<br />
<br />
The BYAML file format starts with a 0x14 byte header structure.<br />
<br />
{| class="wikitable"<br />
|-<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 2<br />
| '''String "BY" in ASCII''' (file identifier).<br />
|-<br />
| 0x02<br />
| 2<br />
| '''Version''' 0x0001 in [[Mario Kart 8]].<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Node name table node''' Offset to the node name table node, relative to start (usually 0x014). Unknown if this can ever be 0. Must be a '''string value node''' (0xc2).<br />
|-<br />
| 0x08<br />
| 4<br />
| '''String value table node''' Offset to the string value table node, relative to start. May be '''0''' if string values unused. Must be a '''string value node''' (0xc2).<br />
|-<br />
| 0x0c<br />
| 4<br />
| '''Path value table node''' Offset to the path value table node, relative to start. May be '''0''' if path values unused. Must be a '''path value node''' (0xc3).<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Root node''' Offset to the root node, relative to start. Must be either an '''array node''' (0xc0) or a '''dictionary node''' (0xc1).<br />
|-<br />
| 0x14<br />
| colspan=2 {{unknown|End of file header}}<br />
|}<br />
<br />
== Nodes ==<br />
<br />
Every node format has a unique one byte identifier as follows. Some nodes are considered value nodes as indicated below. The full nodes have a longer encoding in the file, which must be four byte aligned. The order of encoding full nodes within the file does not seem to matter.<br />
<br />
{| class="wikitable"<br />
|-<br />
! Identifier<br />
! Type<br />
! Description<br />
|-<br />
| 0xa0<br />
| '''Value''' (Index)<br />
| String. Value is an index into the string value table.<br />
|-<br />
| 0xa1<br />
| '''Value''' (Index)<br />
| Path. Value is an index into the path value table.<br />
|-<br />
| 0xc0<br />
| '''Full'''<br />
| Array. Node is an array of nodes, typically, though not necessarily, all of the same format.<br />
|-<br />
| 0xc1<br />
| '''Full'''<br />
| Dictionary. Node is a mapping from strings in the node name table to other nodes.<br />
|-<br />
| 0xc2<br />
| '''Full''' (Special Purpose)<br />
| String table. Special purpose node type only seen in the node name table and the string value table.<br />
|-<br />
| 0xc3<br />
| '''Full''' (Special Purpose)<br />
| Path table. Special purpose node type only seen in the path value table.<br />
|-<br />
| 0xd0<br />
| '''Value'''<br />
| Boolean. Node is '''1''' or '''0''' representing '''true''' or '''false''' respectively.<br />
|-<br />
| 0xd1<br />
| '''Value'''<br />
| Integer. Node is a signed integer value.<br />
|-<br />
| 0xd2<br />
| '''Value'''<br />
| Float. Node is a 32 bit floating point value.<br />
|}<br />
<br />
=== Value Nodes ===<br />
<br />
Value nodes can only be encoded as children of other nodes. Each value node has a direct four byte encoding. For string and path values, this encoding is simply a four byte index into the string or path tables respectively.<br />
<br />
=== 0xc0 - Array Node ===<br />
<br />
An array node begins with the following header.<br />
<br />
{| class="wikitable"<br />
|-<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 1<br />
| '''0xc0''' node type.<br />
|-<br />
| 0x01<br />
| 3<br />
| '''N'''= '''Count''' number of entries in array.<br />
|-<br />
| 0x04<br />
| '''N'''<br />
| Variable length array of node types; the type of each element in the array.<br />
|-<br />
| 0x04+'''N'''<br />
| colspan=2 {{unknown|End of node header}}<br />
|}<br />
<br />
There then follows padding bytes up to the nearest 4 bytes. After the padding is the variable length array of '''N''' node values. For '''value''' nodes this is the four byte node value. For '''full''' nodes this is an offset to the node relative to the start of the file.<br />
<br />
=== 0xc1 - Dictionary Node ===<br />
<br />
Dictionary nodes are used to encode name value collections. The order of entries in the dictionary does not seem to matter. A dictionary node begins with the following header.<br />
<br />
{| class="wikitable"<br />
|-<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 1<br />
| '''0xc1''' node type.<br />
|-<br />
| 0x01<br />
| 3<br />
| '''N'''= '''Count''' number of entries in dictionary.<br />
|-<br />
| 0x04<br />
| colspan=2 {{unknown|End of node header}}<br />
|}<br />
<br />
What then follows is a variable length array of '''N''' dictionary entries. Each entry has the following structure.<br />
<br />
{| class="wikitable"<br />
|-<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 1<br />
| '''Node type'''. One of the node type constants.<br />
|-<br />
| 0x01<br />
| 3<br />
| '''Name'''. Index into the node name value table for the name of this entry.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Value'''. For '''value''' nodes this is the four byte node value. For '''full''' nodes this is an offset to the node relative to the start of the file.<br />
|-<br />
| 0x08<br />
| colspan=2 {{unknown|End of entry}}<br />
|}<br />
<br />
=== 0xc2 - String Table Node ===<br />
<br />
A string table node begins with the following header.<br />
<br />
{| class="wikitable"<br />
|-<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 1<br />
| '''0xc2''' node type.<br />
|-<br />
| 0x01<br />
| 3<br />
| '''N'''= '''Count''' number of entries in string value table.<br />
|-<br />
| 0x04<br />
| 4*('''N'''+1)<br />
| '''Offsets'''. Variable length array of offsets to each string relative to the start of the node. The last entry is an offset to the end of the last string.<br />
|-<br />
| 0x04+4*('''N'''+1)<br />
| colspan=2 {{unknown|End of node header}}<br />
|}<br />
<br />
Immediately following the node header are the string values at the positions indicated by the offsets. Despite the length being clear from the table, the string values are null terminated, perhaps for ease of decoding. The are always stored in alphabetical order.<br />
<br />
=== 0xc3 - Path Table Node ===<br />
<br />
A path table node begins with the following header.<br />
<br />
{| class="wikitable"<br />
|-<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 1<br />
| '''0xc3''' node type.<br />
|-<br />
| 0x01<br />
| 3<br />
| '''N'''= '''Count''' number of entries in path value table.<br />
|-<br />
| 0x04<br />
| 4*('''N'''+1)<br />
| '''Offsets'''. Variable length array of offsets to each path relative to the start of the node. The last entry is an offset to the end of the last path.<br />
|-<br />
| 0x04+4*('''N'''+1)<br />
| colspan=2 {{unknown|End of node header}}<br />
|}<br />
<br />
Immediately following the header are the paths at the positions indicated by the offsets. The length of each path is implicit; subtract the offset to the next path from the offset to this path. Each path consists of multiple points. Each point is a structure as follows.<br />
<br />
{| class="wikitable"<br />
|-<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 12<br />
| '''Posiition''' three floating point values, '''x''', '''y''' and '''z'''.<br />
|-<br />
| 0x0c<br />
| 12<br />
| '''Normal''' three floating point values, '''x''', '''y''' and '''z'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Unknown'''.<br />
|-<br />
| 0x1c<br />
| colspan=2 {{unknown|End of point}}<br />
|}<br />
<br />
= Uses =<br />
<br />
Since the BYAML format is a generic data container, this format specification cannot detail what structure a particular BYAML file ought to have. The following table links to articles on specific instances of BYAML files.<br />
<br />
{| class="wikitable"<br />
|-<br />
! File(s)<br />
! Description<br />
|-<br />
| [[Filesystem/content/ai#Files|/content/ai/AIRivalTable.byaml]]<br />
| {{Unknown}}<br />
|-<br />
| [[Filesystem/content/race_common/ai#Files|/content/race_common/ai/AIConfuseTable.byaml]]<br />
| {{Unknown}}<br />
|-<br />
| [[Filesystem/content/race_common/ai#Files|/content/race_common/ai/AICourseTable_GP.byaml]]<br />
| {{Unknown}}<br />
|-<br />
| [[Filesystem/content/race_common/ai#Files|/content/race_common/ai/AICourseTable_VS.byaml]]<br />
| {{Unknown}}<br />
|-<br />
| [[Filesystem/content/race_common/ai#Files|/content/race_common/ai/AIItemTable.byaml]]<br />
| {{Unknown}}<br />
|-<br />
| [[Filesystem/content/race_common/ai#Files|/content/race_common/ai/AILevelTable.byaml]]<br />
| {{Unknown}}<br />
|-<br />
| [[Filesystem/content/race_common/ai#Files|/content/race_common/ai/AIProbability_Drift_Table.byaml]]<br />
| {{Unknown}}<br />
|-<br />
| [[Filesystem/content/race_common/ai#Files|/content/race_common/ai/AIProbability_JumpAction_Table.byaml]]<br />
| {{Unknown}}<br />
|-<br />
| [[Filesystem/content/race_common/ai#Files|/content/race_common/ai/AIProbability_RocketStart_Table.byaml]]<br />
| {{Unknown}}<br />
|-<br />
| [[Filesystem/content/race_common/ai#Files|/content/race_common/ai/AIProbability_WheelSpin_Table.byaml]]<br />
| {{Unknown}}<br />
|-<br />
| [[Filesystem/content/race_common/ai#Files|/content/race_common/ai/AIItemTable.byaml]]<br />
| {{Unknown}}<br />
|-<br />
| [[Filesystem/content/race_common/item#Files|/content/race_common/item/ItemSlotTable.byaml]]<br />
| {{Unknown}}<br />
|-<br />
| /content/course/*/[[battle_muunt.byaml]]<br />
| Parameters for the battle such as spawn location.<br />
|-<br />
| /content/course/*/[[course_muunt.byaml]]<br />
| Parameters for the course such as lap path, gravity and object placement.<br />
|-<br />
| [[Filesystem/content/data|/content/data]]/[[objflow.byaml]]<br />
| Object paramters such as hit box, resource list, animation, id.<br />
|-<br />
|}<br />
<br />
= Tools =<br />
<br />
The following tools can handle BYAML files.<br />
* [[yamlconv]] by [[Chadderz]].<br />
<br />
[[Category:File Format]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=Yamlconv&diff=1171Yamlconv2015-02-27T17:53:23Z<p>Chadderz: Created page for the released software.</p>
<hr />
<div>{{Software-Info<br />
|name=yamlconv<br />
|creator=[[Chadderz]]<br />
|fileformat1=BYAML<br />
|fileformat2=<br />
|fileformat3=<br />
|fileformat4=<br />
|fileformat5=<br />
|fileformat6=<br />
|fileformat7=<br />
|fileformat8=<br />
|fileformat9=<br />
|fileformat10=<br />
|version=v1.0.0.0<br />
|date of release=2015-02-26<br />
|download=https://github.com/Chadderz121/yamlconv/releases<br />
}}<br />
'''yamlconv''' is a program to convert '''[[BYAML (File Format)|BYAML]]''' files to '''XML'''. It was developed in C# by [[Chadderz]] as part of the initial investigations into the [[BYAML (File Format)|BYAML]] file format. This was to aid understanding and make editing easier than binary. The program can be used by dragging and dropping BYAML or XML files onto the executable, or invoking the program from the command line with the file name(s) to convert.<br />
<br />
Since it was only designed as a temporary solution to the problem of editing BYAML files, it was coded quickly and may contain bugs. It may be possible to compile non-Windows versions of the software, as it should only use a small subset of the C# language.<br />
<br />
== Conversion ==<br />
<br />
The conversion procedure begins at the root node. It is encoded as the root XML node with name "yaml". Every sub-node is then recursively converted. Value nodes may either be converted to XML attributes or XML elements. Integers are encoded directly, booleans are encoded as "true" or "false" and floats are encoded as the numeric representation followed by an "f". A string is encoded as the inner text of an XML element with the attribute "type" set to "string". A path is encoded as a series of "point" elements with attributes "x", "y", "z", "nx", "ny", "nz" and "val". The container element of the path has attribute "type" equal to "path". Finally, arrays are encoded as a series of "value" elements with the container having attribute "type" equal to "array" and dictionaries are encoded as a series of named elements or attributes.<br />
<br />
== Examples ==<br />
<br />
The following is an example of the output of yamlconv showing all features mentioned above.<br />
<br />
<?xml version="1.0" encoding="utf-8"?><br />
<yaml float_field_example="1.0f" int_field_example="0" bool_field_example="true"><br />
<string_field_example type="string">Hello!</string_field_example><br />
<path_example type="path"><br />
<point x="0f" y="0f" z="0f" nx="0f" ny="1f" nz="0f" val="0" /><br />
<point x="1f" y="0f" z="0f" nx="0f" ny="1f" nz="0f" val="0" /><br />
</path_example><br />
<array_example type="array"><br />
<value sample_int="0" /><br />
<value sample_int="1" /><br />
</array_example><br />
<empty_array type="array" /><br />
<dictionary_example><br />
<attr type="string">Hi!</attr><br />
</dictionary_example><br />
<empty_dictionary /><br />
</yaml><br />
<br />
[[Category:Software]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=Talk:BYAML_(File_Format)&diff=1170Talk:BYAML (File Format)2015-02-26T20:16:39Z<p>Chadderz: Reply to download link.</p>
<hr />
<div>Is there any download link to "yamlconv"? -- [[User:Leseratte|Leseratte]] ([[User talk:Leseratte|talk]]) 06:15, 26 February 2015 (UTC)<br />
: There wasn't, so I've just released it (with source https://github.com/Chadderz121/yamlconv/releases/tag/v1.0.0).<br />
: [[User:Chadderz|Chadderz]] ([[User talk:Chadderz|talk]]) 20:16, 26 February 2015 (UTC)</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=BFRES_(File_Format)&diff=1156BFRES (File Format)2015-01-28T17:56:51Z<p>Chadderz: /* Sub Files */ Added note about continuity.</p>
<hr />
<div>'''BFRES''' is an archive format used on [[Wii U]] and in [[Mario Kart 8]] to store graphics data. Typically, a BFRES file will contain information for one model including textures and animations, but this is not necessarily the case. BFRES seems to be a direct upgrade of the [[:mkw:BRRES (File Format)|BRRES]] format used on [[Wii]]. Due to their vast size, large BFRES files are often compressed using [[YAZ0 (File Format)|YAZ0 compression]].<br />
<br />
__TOC__<br />
<br />
= Format =<br />
<br />
This article describes the '''BFRES''' file format seen in [[Mario Kart 8]]. It is unknown if the file format differs between games like the [[:mkw:BRRES (File Format)|BRRES]] format does. The basic architecture of a '''BFRES''' file is any number of subfiles each in one of 12 groups governing format and purpose. Each subfile is something like a model or a texture. Unless otherwise noted, all offsets in BFRES files are relative to themselves, not the beginning of the file which is more common in other formats.<br />
<br />
== Header (FRES) ==<br />
<br />
Every BFRES file begins with an 0x6c byte '''FRES''' header.<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FRES'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 1<br />
| {{Unknown|'''Unknown''' has value '''0x03''' in [[Mario Kart 8]] files.}}<ref group="FRES">Almost certainly 4 separate bytes as have not yet read BOM.</ref><br />
|-<br />
| 0x05<br />
| 1<br />
| {{Unknown|'''Unknown''' has value '''0x00, 0x03 or 0x04''' in [[Mario Kart 8]] files.}}<br />
|-<br />
| 0x06<br />
| 1<br />
| {{Unknown|'''Unknown''' has value '''0x00''' in [[Mario Kart 8]] files.}}<br />
|-<br />
| 0x07<br />
| 1<br />
| {{Unknown|'''Unknown''' has value '''0x01, 0x02 or 0x04''' in [[Mario Kart 8]] files.}}<br />
|-<br />
| 0x08<br />
| 2<br />
| '''Byte order mark''' (BOM): 0xFE,0xFF for big endian and 0xFF,0xFE for little endian. Seems to indicate endian-ness of embedded files.<br />
|-<br />
| 0x0a<br />
| 2<br />
| {{Unknown|'''Unknown''' Probably a version number<ref group="FRES">This is an assumption because of the parallel with BRRES.</ref>, always has value '''0x0010''' in [[Mario Kart 8]] files.}}<br />
|-<br />
| 0x0c<br />
| 4<br />
| '''File length''' including all headers, in bytes.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''File alignment''' a power of 2. Most specific data alignment required in the file. The graphics card often requires data to be aligned to specific power of 2 boundaries. If the file is loaded into memory aligned to this value<ref group="FRES">That is to say, the address of the data is a multiple of this value.</ref>, then all addresses will be correct for the graphics card.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''File name''' offset (without file extension).<br />
|-<br />
| 0x18<br />
| 4<br />
| '''String table Length'''. Length in bytes of the String Table.<br />
|-<br />
| 0x1c<br />
| 4<br />
| '''String table''' offset.<br />
|-<br />
| 0x20<br />
| 4 &times; 12<br />
| '''File offsets'''. Offsets to [[#Index Group|index groups]] for each of the 12 subfile types. '''0''' indicates that a particular subfile type is not present.<br />
|-<br />
| 0x50<br />
| 2 &times; 12<br />
| '''File counts'''. Numer of files in the [[#Index Group|index groups]] for each of the 12 subfile types. '''0''' for subfile types which are not present.<br />
|-<br />
| 0x68<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0''' in [[Mario Kart 8]] files.}}<br />
|-<br />
| 0x6c<br />
| colspan="2" {{Unknown|End of '''FRES''' header}}<br />
|}<br />
<references group="FRES"/><br />
<br />
== Index Group ==<br />
<br />
The '''BFRES Index Group''' is a data structure that occurs very often within BFRES files and subfiles. It is a binary search tree in which a series of named data pointers are stored which are used to represent subfiles. It has a 0x08 byte header, as follows.<br />
{| class="wikitable"<br />
|-<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Length''' of group in bytes.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Number''' in group (excluding the root entry).<br />
|-<br />
| 0x08<br />
| colspan="2" {{Unknown|End of index group header}}<br />
|}<br />
This is then followed by a number of entries equal to the number in the header. The first entry is never an actual data entry, but instead a reference point. Each entry is a 0x10 byte structure as follows.<br />
{| class="wikitable"<br />
|-<br />
! Offset<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Search value''' a value used in the binary search tree traversal algorithm.<br />
|-<br />
| 0x04<br />
| 2<br />
| '''Left index''' used in binary search tree traversal algorithm.<br />
|-<br />
| 0x06<br />
| 2<br />
| '''Right index''' used in binary search tree traversal algorithm.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Name pointer'''. Offset to the name of this entry.<br />
|-<br />
| 0x0c<br />
| 4<br />
| '''Data pointer'''. Offset to the data of this entry.<br />
|-<br />
| 0x10<br />
| colspan="2" {{Unknown|End of entry}}<br />
|}<br />
<br />
It is unknown how the binary search tree algorithm works but it may be similar to the [[:mkw:BRRES Index Group (File Format)|BRRES Index Group]].<br />
<br />
== String Table ==<br />
<br />
The '''BFRES String Table''' is a table that occurs near the end of the BFRES file. There is no header information for the table. References to the table are stored as offsets to stored to strings directly. The strings are stored in ASCII order (so Z comes before a). The length of each string is stored in the 4 bytes before that string and the strings are also null terminated. Each length is 4 byte aligned. The pointer in the [[#Header|FRES header]] points to the length of the first string.<br />
<br />
== Sub Files ==<br />
<br />
The format and purpose of subfiles is determined entirely by the index group they're in of the 12 main index groups references by the FRES header. Note that these subfiles are not necessarily continuous. Typically, all the headers for all subfiles occur at the start of the BFRES, followed by all the data. This is probably a caching optimisation, as the CPU generally only deals with the headers of each format, and the GPU deals with the data. Grouping together the headers makes them all more likely to fit in the CPU's cache, speeding up file access.<br />
<br />
{| class="wikitable"<br />
! Index<br />
! Format<br />
|-<br />
| 0<br />
| [[FMDL (File Format)|FMDL model]].<br />
|-<br />
| 1<br />
| [[FTEX (File Format)|FTEX texture]].<br />
|-<br />
| 2<br />
| [[FSKA (File Format)|FSKA data]].<br />
|-<br />
| 3<br />
| rowspan="3"| [[FSHU (File Format)|FSHU data]]. '''Unknown''' why 3 indices all use the same format.<br />
|-<br />
| 4<br />
|-<br />
| 5<br />
|-<br />
| 6<br />
| [[FTXP (File Format)|FTXP data]].<br />
|-<br />
| 7<br />
| '''Unknown''' not seen in Mario Kart 8.<br />
|-<br />
| 8<br />
| [[FVIS (File Format)|FVIS bone visibility]].<br />
|-<br />
| 9<br />
| [[FSHA (File Format)|FSHA data]].<br />
|-<br />
| 10<br />
| [[FSCN (File Format)|FSCN scene data]].<br />
|-<br />
| 11<br />
| '''Embedded file'''. The data offset points to a offset &amp; length pair which describe the embedded file. The embedded files always seem to be placed at the end of the BFRES fille. Shader source code has been seen in embedded files, though this is not typically the case.<br />
|}<br />
<br />
= Tools =<br />
<br />
The following tool can operate on BFRES files:<br />
<br />
* [https://github.com/LordNed/BFRES-Extractor BFRES Extractor], by [[User:LordNed|LordNed]]<br />
<br />
[[Category:File Format]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=FTEX_(File_Format)&diff=1155FTEX (File Format)2015-01-28T17:50:26Z<p>Chadderz: /* Header (FTEX) */ I don't have time to do a proper analysis now, but I've added the infomation I could glean from my notes.</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.<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 />
| {{Unknown|'''Unknown''' has value '''0x01''' in examined files. May be version number.}}<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 />
| {{Unknown|'''Unknown''' has value '''0x01''' in examined files. May be a count of some form.}}<br />
|-<br />
| 0x14<br />
| 6<br />
| {{Unknown}}<br />
|-<br />
| 0x1A<br />
| 1<br />
| {{Unknown|'''Unknown''' seems related to the format.}}<br />
|-<br />
| 0x1B<br />
| 1<br />
| '''Texture Format'''. Values unknown.<br />
|-<br />
| 0x1C<br />
| 8<br />
| {{Unknown}}<br />
|-<br />
| 0x24<br />
| 4<br />
| '''Data Length'''. Length of texture data in bytes.<br />
|-<br />
| 0x28<br />
| 0x88<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>Chadderzhttps://mk8.tockdom.com/w/index.php?title=User_talk:LordNed&diff=1152User talk:LordNed2015-01-24T21:59:53Z<p>Chadderz: /* BFRES-Extractor Tool */</p>
<hr />
<div>== BFRES-Extractor Tool ==<br />
<br />
Hi LordNed, welcome to the wiki. I couldn't help but notice your tool for dealing with BFRES files, very nice to see the research being applied! Having read your Readme on GitHub, I had a few comments. Do you think the name 'sub file' is misleading on this wiki? This is a throwback to the BRRES format on the Wii (which had contiguous sub files), and our documentation of that. Topologically, it is an archive. No data overlaps between two FMDLs or an FSHP and an FVTX say, so each bit of data belongs to exactly one sub file. As with BRRES on the Wii, you can't simply extract these anyway as the string table offsets would be wrong. For BRRES, we chose not to preserve the string table offsets, so that the files could be extracted. This meant each sub file had it's own string table when extracted. I think a similar scheme could be used here; when you extract the data you regroup it into a contiguous file, with the understanding that a BFRES creator would rearange the data again. It's helpful for understanding, but splitting the BFRES up may not be the best plan anyway. Perhaps a tool to convert a BFRES to other formats and back again makes more sense; the BFRES is designed to be an end use format, not an editing and viewing format. Good luck with the program!<br />
<br />
[[User:Chadderz|Chadderz]] ([[User talk:Chadderz|talk]]) 08:01, 20 January 2015 (UTC)<br />
<br />
<br />
: With regard to sub-file naming: I'm not sure. They're definitely specific types of data, but yeah they're not individual files (for the most part that we could tell, not entirely sure without all of the formats being better reverse engineered). I'm not sure what you'd call it instead, though in contrast to "Embedded File" (which is a whole complete linear file) sub-file does sound out of place. I don't think the data is ever shared here either - it's just not written linearly in the file (ie: you do not have a full FMDL in the space between two FMDL headers in the file). <br />
<br />
: I think a BFRES file does need to be split out into individual files (with possible repeat data) - it's just not clear where exactly yet. Obviously embedded files work fine as is, but it'll become a game of "Can you have X type of sub-file alone in an archive?" ie: Can skeletal animations be included in archives with nothing else? If so they could stand alone as a file. What about FTEX headers, is there anything there that we can use the FTEX for or is it just meta data for the actual binary data that actually contains the texture data. <br />
<br />
: [[User:LordNed|LordNed]] ([[User talk:LordNed|talk]]) 00:35, 24 January 2015 (UTC)<br />
:: Perhaps we should choose a name like section then, but I would argue even that implies linearity. In truth, I'm not sure we have a good word for it. Perhaps we should edit the article just to make explicit that the files are not continuous.<br />
<br />
:: On the topic of splitting, the trurth is that NO files other than embedded files can be split simply. ALL formats reference the string table (if nothing else). You will never be able to split the file and preserve the original format, some conversion will be required. Since conversion is required, data must be rearranged regardless. It's just a difficulty in BFRES software implementation really. What we have done in our work is write programs to convert the BFRES to a .obj model (FMDLs) and a series of .png images (FTEX) and also tools to replace a given FTEX or FMDL with a .png or .obj, which allows us editing. This allows us to avoid these issues as we never export a FMDL as a standalone file.<br />
:: [[User:Chadderz|Chadderz]] ([[User talk:Chadderz|talk]]) 21:59, 24 January 2015 (UTC)</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=User_talk:LordNed&diff=1150User talk:LordNed2015-01-20T08:01:19Z<p>Chadderz: /* BFRES-Extractor Tool */ new section</p>
<hr />
<div>== BFRES-Extractor Tool ==<br />
<br />
Hi LordNed, welcome to the wiki. I couldn't help but notice your tool for dealing with BFRES files, very nice to see the research being applied! Having read your Readme on GitHub, I had a few comments. Do you think the name 'sub file' is misleading on this wiki? This is a throwback to the BRRES format on the Wii (which had contiguous sub files), and our documentation of that. Topologically, it is an archive. No data overlaps between two FMDLs or an FSHP and an FVTX say, so each bit of data belongs to exactly one sub file. As with BRRES on the Wii, you can't simply extract these anyway as the string table offsets would be wrong. For BRRES, we chose not to preserve the string table offsets, so that the files could be extracted. This meant each sub file had it's own string table when extracted. I think a similar scheme could be used here; when you extract the data you regroup it into a contiguous file, with the understanding that a BFRES creator would rearange the data again. It's helpful for understanding, but splitting the BFRES up may not be the best plan anyway. Perhaps a tool to convert a BFRES to other formats and back again makes more sense; the BFRES is designed to be an end use format, not an editing and viewing format. Good luck with the program!<br />
<br />
[[User:Chadderz|Chadderz]] ([[User talk:Chadderz|talk]]) 08:01, 20 January 2015 (UTC)</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=FMDL_(File_Format)&diff=1038FMDL (File Format)2014-09-13T08:03:53Z<p>Chadderz: /* FSHP */ Information from latest experiments with generating models.</p>
<hr />
<div>The '''FMDL''' model format is a format for models which appears as a subfile of a '''[[BFRES (File Format)|BFRES file]]''' in the '''0'''th file group. Typically a BFRES file has one FMDL but some have none and some have more than one.<br />
<br />
__TOC__<br />
<br />
= Format =<br />
<br />
An '''FMDL file''' begins with an '''FMDL header'''. This is then followed by a number of sections pointed to by the header, many of which can occur multiple times. The purpose of these sections is described in the table below. Unless otherwise noted, all offsets in BFRES files are relative to themselves, not the beginning of the file which is more common in other formats.<br />
<br />
{| class="wikitable"<br />
! Section<br />
! Purpose<br />
|-<br />
| [[#FVTX|FVTX]]<br />
| Describes an array of array of vertices which can have a number of attributes including position, normal, colour and texture coordinates.<br />
|-<br />
| [[#FMAT|FMAT]]<br />
| Describes the properties of a surface necessary to draw it including texture information.<br />
|-<br />
| [[#FSKL|FSKL]]<br />
| Describes a skeleton for the model which may be used in animations.<br />
|-<br />
| [[#FSHP|FSHP]]<br />
| Selects triples of vertices from one [[#FVTX|FVTX]] section to draw triangles between. Also specifies the [[#FMAT|FMAT]] material and the [[#FSKL|FSKL]] attachment of the triangles.<br />
|-<br />
| [[#Parameter|Parameter]]<br />
| Sets a named paramter for the model.<br />
|}<br />
<br />
== Header (FMDL) ==<br />
<br />
Every FMDL begins with an 0x2c byte '''FMDL header'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FMDL'''" file identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''File name''' offset (without file extension).<br />
|-<br />
| 0x08<br />
| 4<br />
| '''End of BFRES string table''' offset. Points to just after the last string in the string table.<br />
|-<br />
| 0x0c<br />
| 4<br />
| '''[[#FSKL|FSKL]]''' offset. Offset to the '''FSKL Header'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''[[#FVTX|FVTX]] array''' offset. Offset to the first element in an array of '''FVTX Header'''s.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''[[#FSHP|FSHP]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to an index group which contains named pointers to '''FSHP Header'''s.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''[[#FMAT|FMAT]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to an index group which contains named pointers to '''FMAT Header'''s.<br />
|-<br />
| 0x1c<br />
| 4<br />
| '''[[#Parameter|Parameter]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to an index group which contains named pointers to parameter values. May be '''0''' if no parameters exist (common).<br />
|-<br />
| 0x20<br />
| 2<br />
| '''[[#FVTX|FVTX]] count''': number of FVTX sections in the '''FVTX array'''.<br />
|-<br />
| 0x22<br />
| 2<br />
| '''[[#FSHP|FSHP]] count''': number of FSHP sections in the the '''FSHP index group'''.<br />
|-<br />
| 0x24<br />
| 2<br />
| '''[[#FMAT|FMAT]] count''': number of FMAT sections in the the '''FMAT index group'''.<br />
|-<br />
| 0x26<br />
| 2<br />
| '''[[#Parameter|Parameter]] count''': number of parameters in the '''Parameter index group'''.<br />
|-<br />
| 0x28<br />
| 4<br />
| {{Unknown|'''Unknown''' possibly something like an unused face count.}}<br />
|-<br />
| 0x2c<br />
| colspan="2" {{Unknown|End of FMDL header}}<br />
|}<br />
<br />
== FVTX ==<br />
<br />
The model may have one or more '''FVTX''' sections which describe the vertices for one polygon (e.g. the road of a track). The section describes a series of buffers and attributes. Buffers are arrays of arbitrary elements which contain the actual values of the vertices and are passed directly to the graphics card. Attributes are properties of vertices (e.g. position, texture coordinate, vertex colours) and they describe the format and layout of the elements in the buffers.<br />
<br />
=== Header (FVTX) ===<br />
<br />
Each FVTX section has a 0x20 byte header. These headers are stored sequentially in an array at the offset given in the '''FMDL header'''. The length of this array is also given in that header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FVTX'''" section identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 1<br />
| '''[[#Attributes|Attribute]] count''': number of different attributes (position, normal, colour, etc) in the attribute array.<br />
|-<br />
| 0x05<br />
| 1<br />
| '''[[#Buffers|Buffer]] count''': number of attribute buffers in the buffer array.<br />
|-<br />
| 0x06<br />
| 2<br />
| '''Section index''': index into FVTX array of this entry.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Number of vertices'''. This is also the number of elements in each buffer.<br />
|-<br />
| 0x0c<br />
| 1<br />
| {{Unknown|'''Unknown'''; values seen are between '''0''' and '''4''' (normally '''0''').}}<br />
|-<br />
| 0x0d<br />
| 3<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| '''[[#Attributes|Attribute]] array''' offset. Offset to the first element in the Attribute array.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''[[#Attributes|Attribute]] [[BFRES (File Format)#Index Group|index group]]''' offset. Named pointers to the members of the '''Attribute array''' to allow named lookups.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''[[#Buffers|Buffer]] array''' offset. Offset to the first element in the Buffer array.<br />
|-<br />
| 0x1c<br />
| 4<br />
| Padding, always '''0'''.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of FVTX header}}<br />
|}<br />
<br />
=== Attributes ===<br />
<br />
The '''attributes''' of each '''FVTX''' section are stored as a simple repeating 0xc byte structure. These are stored in an array with location and length specified by the FVTX header. They are also referenced by the attribute index group, presumably to allow both index and name based lookup of attributes.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Attribute name''' offset.<br />
|-<br />
| 0x04<br />
| 1<br />
| '''Buffer index''' of the buffer containing this attribute.<br />
|-<br />
| 0x05<br />
| 3<br />
| '''Buffer offset''' of the attribute in each element in the buffer.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Format''' of the attribute's data in the buffer.<br />
|-<br />
| 0xc<br />
| colspan="2" {{Unknown|End of attribute}}<br />
|}<br />
<br />
The following values have been seen for the '''Format''' field. This list is not exhaustive.<br />
<br />
{| class="wikitable"<br />
! Format<br />
! Data Size<br />
! Description<br />
|-<br />
| 0x00000004<br />
| 2<br />
| Two 8 bit values representing numbers between 0 and 1.<br />
|-<br />
| 0x00000007<br />
| 4<br />
| Two 16 bit values representing numbers between 0 and 1.<br />
|-<br />
| 0x0000020a<br />
| 4<br />
| Four signed 8 bit values.<br />
|-<br />
| 0x0000020b<br />
| 4<br />
| Three signed 10 bit values. Divide by 511 to get decimal value. Top 2 bits are always 0b01.<br />
|-<br />
| 0x0000080d<br />
| 8<br />
| Two 32 bit floating point values.<br />
|-<br />
| 0x0000080f<br />
| 8<br />
| Four [http://en.wikipedia.org/wiki/Half_precision 16 bit floating point] values.<br />
|-<br />
| 0x00000811<br />
| 12<br />
| Three 32 bit floating point values.<br />
|}<br />
<br />
Based on the some of the shader code in [[Filesystem/content/mapobj/PackunMusic#Files|/vol/content/mapobj/PackunMusic/PackunMusic.bfres]] the following naming convention seems to be used for attributes.<br />
<br />
{| class="wikitable"<br />
! Attribute Name<br />
! Friendly Name<br />
! Description<br />
|-<br />
| _p0<br />
| position0<br />
| The position of the vertex.<br />
|-<br />
| _n0<br />
| normal0<br />
| The normal of the vertex as used in lighting calculations.<br />
|-<br />
| _t0<br />
| tangent0<br />
| The tangent of the vertex as used in advanced lighting calculations.<br />
|-<br />
| _b0<br />
| binormal0<br />
| The binormal of the vertex as used in advanced lighting calculations.<br />
|-<br />
| _w0<br />
| blendweight0<br />
| {{Unknown}}<br />
|-<br />
| _i0<br />
| blendindex0<br />
| {{Unknown}}<br />
|-<br />
| _u0<br />
| uv0<br />
| rowspan="4" | Texture coordinates used for texture mapping.<br />
|-<br />
| _u1<br />
| uv1<br />
|-<br />
| _u2<br />
| uv2<br />
|-<br />
| _u3<br />
| uv3<br />
|-<br />
| _c0<br />
| color0<br />
| rowspan="2" | Vertex colours used for simple shadow mapping.<br />
|-<br />
| _c1<br />
| color1<br />
|}<br />
<br />
=== Buffers ===<br />
<br />
The '''buffers''' of each '''FVTX''' section are stored as a repeating 0x18 byte header structure which references the actual data stored later in the BFRES file. The headers are stored in an array with location and length specified by the FVTX header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size''' of the buffer in bytes.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Stride''': the size of each element in the buffer.<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''1'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Data offset'''.<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of buffer}}<br />
|}<br />
<br />
== FMAT ==<br />
<br />
The model may have one or more '''FMAT''' sections which describe surface properties of a polygon such as textures. Every polygon is rendered using a vertex shader and a pixel shader. These are pieces of code which run on the graphics card. Like any code, these have parameters which is principally what the '''FMAT''' section controls. There are many different ways for the '''FMAT''' section to set variables in the shader code, but it remains '''unknown''' what the reason for this is. All shader parameters are either uniform or attributes. Attribute parameters vary per vertex or pixel, whereas uniform parameters are global. The '''FMAT''' must specify values for all uniform parameters, and specifies a mapping between vertex attributes in the corresponding '''[[#FVTX|FVTX]] sections''' and attribute parameters for both the pixel and vertex shader. In [[Mario Kart 8]] most models reference the same pixel shader and the same vertex shader, both called Turbo_UBER. Turbo_UBER is totally generic and has hundreds of parameters to configure the rendering. The source code for Turbo_UBER seems to be available in [[Filesystem/content/mapobj/PackunMusic#Files|/vol/content/mapobj/PackunMusic/PackunMusic.bfres]].<br />
<br />
=== Header (FMAT) ===<br />
<br />
Every FMAT begins with an 0x48 byte header structure. This references the other structures documented here to describe the material.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FMAT'''" section identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Material name''' offset.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''1'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Section Index''' of this material.<br />
|-<br />
| 0x0e<br />
| 2<br />
| '''[[#Render Info Parameter|Render Info Parameter]] Count'''. Number of elements in the Render Info Parameter index group.<br />
|-<br />
| 0x10<br />
| 1<br />
| '''[[#Texture Selector|Texture Selector]] Count'''. Number of elements in the Texture Selector array.<br />
|-<br />
| 0x11<br />
| 1<br />
| '''[[#Texture Attribute Selector|Texture Attribute Selector]] Count'''. Number of elements in the Texture Attribute Selector array. Always equal to the number of elements in the Texture Selector array.<br />
|-<br />
| 0x12<br />
| 2<br />
| '''[[#Material Parameter|Material Parameter]] Count'''. Number of elements in the Material Parameter array.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''[[#Material Parameter|Material Parameter]] Data Size''' in bytes. The size of the Material Parameter Data section.<br />
|-<br />
| 0x18<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0''', '''1''' or '''2'''.}}<br />
|-<br />
| 0x1c<br />
| 4<br />
| '''[[#Render Info Parameter|Render Info Parameter]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to the index group defining render info parameters.<br />
|-<br />
| 0x20<br />
| 4<br />
| '''[[#Unknown Material Structure|Unknown Material Structure]] offset'''. Offset to the unknown material structure.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''[[#Shader Control|Shader Control]]''' offset. Offset to the shader control structure.<br />
|-<br />
| 0x28<br />
| 4<br />
| '''[[#Texture Selector|Texture Selector]]''' offset. Offset to the first element in the Texture Selector array.<br />
|-<br />
| 0x2c<br />
| 4<br />
| '''[[#Texture Attribute Selector|Texture Attribute Selector]]''' offset. Offset to the first element in the Texture Attribute Selector array.<br />
|-<br />
| 0x30<br />
| 4<br />
| '''[[#Texture Attribute Selector|Texture Attribute Selector]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to an index group which references the Texture Attribute Selector array, to allow named value lookups.<br />
|-<br />
| 0x34<br />
| 4<br />
| '''[[#Material Parameter|Material Parameter]]''' array offset. Offset to the first element in the Material Parameter array.<br />
|-<br />
| 0x38<br />
| 4<br />
| '''[[#Material Parameter|Material Parameter]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to an index group which references the Material Parameter array, to allow named value lookups.<br />
|-<br />
| 0x3c<br />
| 4<br />
| '''[[#Material Parameter|Material Parameter]] Data''' offset. Offset to the beggining of the values for Material Parameters. The '''Material Parameter array''' references this data.<br />
|-<br />
| 0x40<br />
| 4<br />
| '''[[#Shadow Parameter|Shadow Parameter]] [[BFRES (File Format)#Index Group|index group]]''' offset. May be '''0''' if not needed.<br />
|-<br />
| 0x44<br />
| 4<br />
| {{Unknown|'''Unknown''' offset. Always points to 12 bytes, all 0. Offset may be '''0''' if not needed.}}<br />
|-<br />
| 0x48<br />
| colspan="2" {{Unknown|End of FMAT Header}}<br />
|}<br />
<br />
=== Render Info Parameter ===<br />
<br />
A '''Render Info Parameter''' is a repeating structure of at least 0x8 bytes, each of which describes the value to assign to a render info variable in the shader code. Render info variables are always uniform variables. The '''Render Info Parameter''' structures are referenced by the '''Render Info Parameter index group''' in the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0''' or '''1'''.}}<br />
|-<br />
| 0x02<br />
| 1<br />
| '''Type''' of the variable.<br />
|-<br />
| 0x03<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Variable Name''' offset.<br />
|-<br />
| 0x08<br />
| Varies<br />
| '''Value''' of the variable.<br />
|-<br />
| Varies<br />
| colspan="2" {{Unknown|End of Render Info Parameter}}<br />
|}<br />
<br />
The '''Type''' field has values as follows.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Value Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 8<br />
| {{Unknown|'''Unknown''' data always '''0'''?}}<br />
|-<br />
| 0x01<br />
| 8<br />
| {{Unknown|'''Unknown''' vector of 2 floats?}}<br />
|-<br />
| 0x02<br />
| 4<br />
| Offset to a string.<br />
|}<br />
<br />
=== Texture Selector ===<br />
<br />
A '''Texture Selector''' is a repeating 0x8 byte structure each of which references a single '''[[FTEX (File Format)|FTEX texture]]'''. The length and position of the '''Texture Selector''' array is specified by the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Texture Name''' offset. The same as the '''FTEX''' name.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''[[FTEX (File Format)|FTEX]]''' offset. Points to the header of the '''FTEX'''.<br />
|-<br />
| 0x08<br />
| colspan="2" {{Unknown|End of Texture Selector}}<br />
|}<br />
<br />
=== Texture Attribute Selector ===<br />
<br />
An '''Texture Attribute Selector''' is a repeating 0x18 byte structure each of which describes one of the inputs to the pixel shader from the selected textures. The length and position of the '''Texture Attribute Selector''' array is specified by the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''2'''.}}<br />
|-<br />
| 0x01<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''0x00''', '''0x02''', '''0x04''' or '''0x12'''.}}<br />
|-<br />
| 0x02<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''0x00''', '''0x10''', '''0x12''' or '''0x5a'''.}}<br />
|-<br />
| 0x03<br />
| 1<br />
| {{Unknown|'''Unknown''' usually either near '''0''' or near '''0x80'''. Could be flags?}}<br />
|-<br />
| 0x04<br />
| 1<br />
| {{Unknown|'''Unknown''' signed integer normally close to 0.}}<br />
|-<br />
| 0x05<br />
| 1<br />
| {{Unknown|'''Unknown''' typically small value.}}<br />
|-<br />
| 0x06<br />
| 2<br />
| {{Unknown|'''Unknown''' probably flags.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0x80000000'''.}}<br />
|-<br />
| 0x0c<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Attribute Name''' offset.<br />
|-<br />
| 0x14<br />
| 1<br />
| '''Index''' of this element.<br />
|-<br />
| 0x15<br />
| 3<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of Texture Attribtue Selector}}<br />
|}<br />
<br />
Based on the some of the shader code in [[Filesystem/content/mapobj/PackunMusic#Files|/vol/content/mapobj/PackunMusic/PackunMusic.bfres]] the following naming convention seems to be used for texture attributes.<br />
<br />
{| class="wikitable"<br />
! Attribute Name<br />
! Friendly Name<br />
! Description<br />
|-<br />
| _a0<br />
| albedo0<br />
| rowspan="4" | Ordinary colour textures for surface albedo.<br />
|-<br />
| _a1<br />
| albedo1<br />
|-<br />
| _a2<br />
| albedo2<br />
|-<br />
| _a3<br />
| albedo3<br />
|-<br />
| _s0<br />
| specular0<br />
| Specular highlight texture.<br />
|-<br />
| _n0<br />
| normal0<br />
| rowspan="2" | Normal map texture for altering surface normals.<br />
|-<br />
| _n1<br />
| normal1<br />
|-<br />
| _e0<br />
| emission0<br />
| Emissive lighting texture.<br />
|-<br />
| _b0<br />
| bake0<br />
| rowspan="2" | Shadow textures.<br />
|-<br />
| _b1<br />
| bake1<br />
|}<br />
<br />
=== Material Parameter ===<br />
<br />
A '''Material Parameter''' is a repeating 0x14 byte structure each of which describes the value to assign to a material variable in the shader code. Material variables are always uniform variables. The length and position of the '''Material Parameter''' array is controlled by the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
In some '''BFRES Files''' which do not have 0x03040004 after the '''FRES''' identifier, the '''Material Parameter''' structure is shorter or longer than 0x14 bytes. This seems to be consistent across entire model files. This is presumably a different verson of the '''FMDL''' format. It is rare in [[Mario Kart 8]] (affecting only 6 models).<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 1<br />
| '''Type''' of the variable.<br />
|-<br />
| 0x01<br />
| 1<br />
| '''Size''' of the value in bytes.<br />
|-<br />
| 0x02<br />
| 2<br />
| '''Offset''' relative to the start of the '''Material Parameter Data''' section to the value.<br />
|-<br />
| 0x04<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0xffffffff'''.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Parameter Index''' into the Material Parameter array.<br />
|-<br />
| 0x0e<br />
| 2<br />
| Same value as '''Parameter Index''' again.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Variable Name''' offset.<br />
|-<br />
| 0x14<br />
| colspan="2" {{Unknown|End of Material Parameter}}<br />
|}<br />
<br />
The '''Type''' field has values as follows.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Size<br />
! Description<br />
|-<br />
| 0x04<br />
| 4<br />
| Signed Integer.<br />
|-<br />
| 0x0c<br />
| 4<br />
| Floating point value.<br />
|-<br />
| 0x0d<br />
| 8<br />
| Vector of 2 floats.<br />
|-<br />
| 0x0e<br />
| 12<br />
| Vector of 3 floats.<br />
|-<br />
| 0x0f<br />
| 16<br />
| Vector of 4 floats.<br />
|-<br />
| 0x1e<br />
| 24<br />
| 2&times;3 Texutre Matrix. Encoded down columns then along rows, so the identity matrix would be encoded '''1, 0, 0, 1, 0, 0'''.<br />
|}<br />
<br />
=== Unknown Material Structure ===<br />
<br />
A '''Unknown Material''' structure is a 0x30 byte structure with unknown purpose. A '''Unknown Material''' structure is referenced by the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' always less than '''0x14'''.}}<br />
|-<br />
| 0x04<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x0028'''.}}<br />
|-<br />
| 0x06<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x0240''', '''0x0242''' or '''0x0243'''.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0x49749732''' or '''0x49749736'''.}}<br />
|-<br />
| 0x0c<br />
| 4<br />
| {{Unknown|'''Unknown''' always less than '''0xe'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| {{Unknown|'''Unknown''' floating point always less than '''1.0'''.}}<br />
|-<br />
| 0x14<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x00cc'''.}}<br />
|-<br />
| 0x16<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x0000''' or '''0x0100'''.}}<br />
|-<br />
| 0x18<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x1c<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x2001'''.}}<br />
|-<br />
| 0x1e<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''1''' or '''5'''.}}<br />
|-<br />
| 0x1f<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''1''' or '''4'''.}}<br />
|-<br />
| 0x20<br />
| 16<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x30<br />
| colspan="2" {{Unknown|End of Unknown Material Structure}}<br />
|}<br />
<br />
=== Shader Control ===<br />
<br />
A '''Shader Control''' structure is a 0x1c byte structure which describe the shader to be used by a material. A '''Shader Control''' structure is referenced by the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Shader Name 1''' offset?<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Shader Name 2''' offset?<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0''' or '''1'''.}}<br />
|-<br />
| 0x0c<br />
| 1<br />
| '''Vertex Shader Input Count'''. Number of elements in the Vertex Shader Input index group.<br />
|-<br />
| 0x0d<br />
| 1<br />
| '''Pixel Shader Input Count'''. Number of elements in the Pixel Shader Input index group.<br />
|-<br />
| 0x0e<br />
| 2<br />
| '''Parameter Count'''. Number of elements in the Parameter index group.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Vertex Shader Input [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to the index group which forms a mapping between strings, mapping an '''FVTX''' attribute to a vertex shader variable. The names are always the same in [[Mario Kart 8]], so this mapping is just ["_p0": "_p0", "_n0": "_n0", ...]?<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Pixel Shader Input [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to the index group which forms a mapping between strings, mapping an '''FVTX''' attribute to a pixel shader variable. The names are always the same in [[Mario Kart 8]], so this mapping is just ["_p0": "_p0", "_n0": "_n0", ...]?<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Parameter [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to the index group which forms a mapping between strings, mapping a uniform shader variable to a value. The values are always strings, even for numeric parameters.<br />
|-<br />
| 0x1c<br />
| colspan="2" {{Unknown|End of Material Parameter}}<br />
|}<br />
<br />
=== Shadow Parameter ===<br />
<br />
A '''Shadow Parameter''' is a repeating 0xc byte structure, each of which describes the value to assign to a shadow variable in the shader code. Shadow variables are always uniform variables. The '''Shadow Parameter''' structures are referenced by the '''Shadow Parameter index group''' in the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Variable Name''' offset.<br />
|-<br />
| 0x04<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''1'''.}}<br />
|-<br />
| 0x06<br />
| 1<br />
| {{Unknown|'''Type''' or '''Index'''?}}<br />
|-<br />
| 0x07<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Value''' of the variable.<br />
|-<br />
| 0xc<br />
| colspan="2" {{Unknown|End of Shadow Parameter}}<br />
|}<br />
<br />
== FSKL ==<br />
<br />
Each model has one '''FSKL''' section which describes one or more bones. The bones form a skeleton and give a transformation to apply to any attached polygon. Every '''[[#FSHP|FSHP polygon]]''' is attached to at least one bone. The '''FSKL''' format is somewhat different in '''BFRES''' files with values other than 0x03040004 after the '''FRES''' identifier, which may indicate an alternative version of the format. These are rare in [[Mario Kart 8]] and not documented here.<br />
<br />
=== Header (FSKL) ===<br />
<br />
The FSKL section always starts with an 0x24 byte header. The location of this header is given by the offset in the '''FMDL header'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FSKL'''" section identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x06<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x1100''' or '''0x1200'''.}}<br />
|-<br />
| 0x08<br />
| 2<br />
| '''[[#Bone|Bone]] array count'''. Number of elements in the Bone array.<br />
|-<br />
| 0x0a<br />
| 2<br />
| '''[[#Inverse Matrix|Inverse Index]] array count'''. Number of elements in the Inverse Matrix array.<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Extra Index count'''. Count of the number of extra indices at the end of the '''[[#Inverse Matrix|Inverse Index]] array'''. These serve '''unknown''' purpose.<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| '''[[#Bone|Bone]] [[BFRES (File Format)#Index Group|index group]]''' offset. Named pointers to the members of the '''Bone array''' to allow named lookups.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''[[#Bone|Bone]] array''' offset. Offset to the first element in the Bone array.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''[[#Inverse Matrix|Inverse Index]] array''' offset. Offset to the first element in the Inverse Index array. Always given even if the array is empty.<br />
|-<br />
| 0x1c<br />
| 4<br />
| '''[[#Inverse Matrix|Inverse Matrix]] array''' offset. Offset to the first element in the Inverse Matrix array. Always given even if the array is empty.<br />
|-<br />
| 0x20<br />
| 4<br />
| Padding, always '''0'''.<br />
|-<br />
| 0x24<br />
| colspan="2" {{Unknown|End of FSKL header}}<br />
|}<br />
<br />
=== Bone ===<br />
<br />
A '''Bone''' is a repeating 0x30 byte structure which descibes a transformation to apply to a polygon. Each bone has up to four parents, which form a tree called a skeleton. To compute the final transformation of a point, apply the transformation required by the bone it is attached to, then that bone's parent recursively up until no parents remain. The '''Bone''' tree is stored as an array with offset and length specified by the '''[[#Header (FSKL)|FSKL header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Name offset''' for this bone.<br />
|-<br />
| 0x04<br />
| 2<br />
| '''Bone index''' of this bone into the bone array.<br />
|-<br />
| 0x06<br />
| 8<br />
| '''Parent indices''' of up to four parents for this bone. '''0xffff''' for no parent.<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 2<br />
| '''Flags''' controlling this bone. '''Unknown''' purpose.<br />
|-<br />
| 0x12<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x1001'''.}}<br />
|-<br />
| 0x14<br />
| 12<br />
| '''Scale Vector''' 3 floats. The amount to scale the vertices by.<br />
|-<br />
| 0x20<br />
| 12<br />
| '''Rotation Vector''' 3 floats. The amount of rotation to apply to x, y and z axis in Radians.<br />
|-<br />
| 0x2c<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''1.0f'''.}}<br />
|-<br />
| 0x30<br />
| 12<br />
| '''Translation Vector''' 3 floats. The amount to translate the vertices by.<br />
|-<br />
| 0x3c<br />
| 4<br />
| Padding, always '''0'''.<br />
|-<br />
| 0x40<br />
| colspan="2" {{Unknown|End of Bone}}<br />
|}<br />
<br />
=== Inverse Matrix ===<br />
<br />
The '''FSKL''' may specify an '''Inverse Matrix''' for any '''[[#Bone|Bone]]'''. It does this by creating an entry in the '''Invese Index''' array which is the index of the bone, and in the corresponding place in the '''Inverse Matrix array''' it places a 4&times;3 transformation matrix which reverses the full transformation of the bone and all its parents. Inverse Matricies are optional, it is '''Unknown''' if they are ever referenced. The position of and number of elements in the '''Inverse Matrix array''' and the '''Inverse Index array''' are given in the [[#Header (FSKL)|FSKL Header]]. At the end of the '''Inverse Index array''' are a number of extra indices, which have '''Unkonwn''' purpose. The number of such extra indices is also present in the [[#Header (FSKL)|FSKL Header]].<br />
<br />
== FSHP ==<br />
<br />
The model may have one or more '''FSHP''' sections which describe the one polygon (e.g. the road of a track). The FSHP section consists of an 0x40 byte header, which references an '''[[#FVTX|FVTX]]''' section and indices of the polygons to draw. A basic '''FSHP''' amounts to a list of indices into the corresponding '''FVTX''' indicating which points to draw triangles between. The '''FSHP''' also references an '''[[#FMAT|FMAT]]''' to describe the material of the triangles, and an '''[[#FSKL|FSKL]]''' to indicate the bone structure of the model used in animation.<br />
<br />
The triangles in an '''FSHP''' are organised by two systems; [[#LoD Model|LoD Models]] and [[#Visibility Group|Visibility Groups]]. No model in Mario Kart 8 uses both of these features non-trivially simultaneously. LoD stands for Level of Detail, which is a standard performance technique used across many 3d rendering systems. Each LoD model is a simpler version of the one before it, with extraneous triangles removed, and finer detail simplified. As the camera in the game moves away from a polygon, the simpler version of the model is rendered instead, which should look the same as the fine detailed version at a distance. A trivial polygon will only have one LoD model, which will be rendered no matter what distance the camera is. Separately, the Visibility Group system allows parts of the model to not be rendered if they are off-screen. This allows an polygon which is partially off-screen to be rendered faster, by skipping the off-screen components. A trivial polygon will only have one Visibility Group, which will always be rendered.<br />
<br />
=== Header (FSHP) ===<br />
<br />
Every '''FSHP''' begins with an 0x40 byte header. This references other data structures which describe the polygon.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FSHP'''" section identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Polygon name''' offset.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''2'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Section Index''' or '''[[#FVTX|FVTX]] Index'''. In every [[Mario Kart 8]] model these numbers are the same.<br />
|-<br />
| 0x0e<br />
| 2<br />
| '''[[#FMAT|FMAT]] Index'''. Index of the material for this polygon.<br />
|-<br />
| 0x10<br />
| 2<br />
| '''[[#FSKL|FSKL]] Index''' of the bone for this polygon.<br />
|-<br />
| 0x12<br />
| 2<br />
| '''Section Index''' or '''[[#FVTX|FVTX]] Index'''. In every [[Mario Kart 8]] model these numbers are the same.<br />
|-<br />
| 0x14<br />
| 2<br />
| '''FSKL Index Array Count'''. Often zero, '''Unknown''' purpose but seems to be related to '''FSKL'''.<br />
|-<br />
| 0x16<br />
| 1<br />
| {{Unknown|'''Unknown''': If '''FSKL Index Array''' is present this tends to be non-zero. Zero otherwise.}}<br />
|-<br />
| 0x17<br />
| 1<br />
| '''[[#LoD Model|LoD Model]] count'''. Number of elements in the array.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''[[#Visibility Group Tree|Visibility Group Tree Node]] count'''.<br />
|-<br />
| 0x1c<br />
| 4<br />
| {{Unknown|'''Unknown''' floating point.}}<br />
|-<br />
| 0x20<br />
| 4<br />
| '''[[#FVTX|FVTX]] offset''' to the vertex buffer for this polygon.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''[[#LoD Model|LoD Model]] offset'''. Offset to the first element in the array.<br />
|-<br />
| 0x28<br />
| 4<br />
| '''FSKL Index Array Offset'''. Each element of this array is a 16 bit index.<br />
|-<br />
| 0x2c<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x30<br />
| 4<br />
| '''[[#Visibility Group Tree|Visibility Group Tree Nodes]] offset'''.<br />
|-<br />
| 0x34<br />
| 4<br />
| '''[[#Visibility Group Tree|Visibility Group Tree Ranges]] offset'''.<br />
|-<br />
| 0x38<br />
| 4<br />
| '''[[#Visibility Group Tree|Visibility Group Tree Indices]] offset'''.<br />
|-<br />
| 0x3c<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x40<br />
| colspan="2" {{Unknown|End of FSHP header}}<br />
|}<br />
<br />
=== LoD Model ===<br />
<br />
An '''LoD Model''' is a repeating 0x1c byte structure which are stored in a sequential array with location and size specified by the '''[[#Header (FSHP)|FSHP Header]]'''. Their purpose is described at the beginning of this section.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''4'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''4'''.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Count''' of points drawn in all [[#Visibility Group|Visibility Group]]s, thus the maximum number of points drawn at this LoD.<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''[[#Visibility Group|Visibility Group]] count'''. The number of elements in the array.<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| '''[[#Visibility Group|Visibility Group]] offset'''. Offset to the first element in the array.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''[[#Index Buffer|Index Buffer]] offset'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Skip Vertices''': the number of elements to skip in the corresponding '''FVTX''' buffer.<br />
|-<br />
| 0x1c<br />
| colspan="2" {{Unknown|End of LoD Model}}<br />
|}<br />
<br />
=== Visibility Group ===<br />
<br />
A '''Visibility Group''' is a repeating 0x8 byte structure describing an offset and a count in the corresponding [[#Index Buffer|Index Buffer]]. Visibility Groups are stored in a sequential array with location and count indicated by the corresponding [[#LoD Model|LoD Model]]. This allows multiple visibility groups to use the same Index Buffer. In many cases, a single group is used which simply draws the entire Index Buffer.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Offset''' into index buffer in bytes.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Count''' of the points to draw.<br />
|-<br />
| 0x08<br />
| colspan="2" {{Unknown|End of Visibility Group}}<br />
|}<br />
<br />
=== Index Buffer ===<br />
<br />
An '''Index Buffer''' is an 0x18 byte structure which describes a list of 16 bit values which are used to index the '''FVTX''' section when drawing the polygon. Index Buffers are referenced by [[#LoD Model|LoD Model]]s. The format is very similar to the [[#Buffers|FVTX Buffer]] format, which may indicate they are instances of the same structure.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size''' of index data in bytes.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' Always '''1'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Index data offset'''.<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of Index Buffer}}<br />
|}<br />
<br />
=== Visibility Group Tree ===<br />
<br />
The '''Visibility Group Tree''' is some sort of tree structure that occurs in all FSHP sections. In all [[Mario Kart 8]] files, when the '''FSHP''' has multiple [[#LoD Model|LoD Model]]s, the Visibility Group Tree is a trivial one node tree. The Visibility Group Tree is used to control which [[#Visibility Group|Visibility Group]]s need to be drawn as described at the beginning of this section. The workings of the structure are however unknown.<br />
<br />
==== Nodes ====<br />
<br />
The '''Visibility Group Tree Node''' is a repeating 0xc byte structure. The nodes form a binary tree. The [[#FSHP|FSHP header]] contains a pointer to node array, as well as specifying its length. The root node is the first node in this array. Each node specifies a range of Visibility Groups, with the root node always covering all nodes, and the children of each node always selecting disjoint subsets of that node's range.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 2<br />
| '''Left Child''' index. The current node's index if it has no left child.<br />
|-<br />
| 0x02<br />
| 2<br />
| '''Right Child''' index. The current node's index if it has no right child.<br />
|-<br />
| 0x04<br />
| 2<br />
| '''Unknown''' always the same as '''Left Child''' index.<br />
|-<br />
| 0x06<br />
| 2<br />
| '''Next Sibling''' index. For left children, always the current node's parent's right child (the current node's index if it has no right child).<br />
|-<br />
| 0x08<br />
| 2<br />
| '''[[#Visibility Group|Visibility Group]] Index''' selects a range of Visibility Groups along with the count.<br />
|-<br />
| 0x0a<br />
| 2<br />
| '''[[#Visibility Group|Visibility Group]] Count''' selects a range of Visibility Groups along with the index.<br />
|-<br />
| 0x0c<br />
| colspan="2" {{Unknown|End of Node}}<br />
|}<br />
<br />
==== Ranges ====<br />
<br />
The '''Visibility Group Tree Range''' is a repeating 0x18 byte structure. The meaning is unknown. There are exactly as many Ranges as Nodes. The range appears to contain two 3D positions, which are not necessarily distinct.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 12<br />
| {{Unknown|'''Unknown''' 3D position (x,y,z float).}}<br />
|-<br />
| 0x0c<br />
| 12<br />
| {{Unknown|'''Unknown''' 3D position (x,y,z float).}}<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of Range}}<br />
|}<br />
<br />
==== Indices ====<br />
<br />
The '''Visibility Group Tree Index''' array is an array of 16 bit values which appear to be the index of the leaf node of the '''Visibility Group Tree''' which contains the corresponding '''[[#Visibility Group|Visibility Group]]'''. Therefore this array has length equal to the number of [[#Visibility Group|Visibility Group]]s in the '''FSHP''' section.<br />
<br />
== Parameter ==<br />
<br />
A '''Parameter''' is an 0xc byte structure which describes the value of some model parameter. It is only used in a handful of [[Mario Kart 8]] models to set the value of "ParticleLimit". A '''Parameter''' structure is referenced by the '''Parameter index group''' in the '''[[#Header (FMDL)|FMDL Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Variable Name''' offset.<br />
|-<br />
| 0x04<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''1'''.}}<br />
|-<br />
| 0x06<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Value''' of the variable (floating point).<br />
|-<br />
| 0xc<br />
| colspan="2" {{Unknown|End of Parameter}}<br />
|}<br />
<br />
[[Category:File Format]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=Talk:SARC_(File_Format)&diff=1036Talk:SARC (File Format)2014-09-13T07:13:19Z<p>Chadderz: /* SFAT node filenames */ My two cents.</p>
<hr />
<div>== Node Hash ==<br />
<br />
I'm pretty sure that the value at offset 0x00 in the node structure is a hash of the filename or an ID, because I have found a stripped archive; one in which the SFNT table is empty. The only plausible way to index the files would therefore be to use this value, the values being sorted supports this hypothesis.<br />
[[User:Chadderz|Chadderz]] ([[User talk:Chadderz|talk]]) 06:12, 20 August 2014 (UTC)<br />
<br />
: That makes much more sense than my "percentage" theory. Then the files would be sorted by this hash. --[[User:Celcodioc|Celcodioc]] ([[User talk:Celcodioc|talk]]) 18:35, 20 August 2014 (UTC)<br />
<br />
:: Yup. Just checked it by comparing 2 different archives that contain an identical file. Definitely a hash, sorry for entering the wrong info. --[[User:Celcodioc|Celcodioc]] ([[User talk:Celcodioc|talk]]) 18:41, 20 August 2014 (UTC)<br />
<br />
::: Ah good, nice to have some sort of proof. Don't worry, better to submit a theory that leads to the correct answer than to do nothing :)<br />
::: [[User:Chadderz|Chadderz]] ([[User talk:Chadderz|talk]]) 06:00, 21 August 2014 (UTC)<br />
<br />
: Yea, I also thought that. This format is used in mk7 aswell, and there are no filenames in the file name table. In the ram there are paths to files (with subdirs), so this got to be a hash. --[[User:Gericom|Gericom]] ([[User talk:Gericom|talk]]) 08:57, 24 August 2014 (UTC)<br />
<br />
== SFAT node filenames ==<br />
<br />
Hi, I just wanted to let you guys know about something I've found. I'm currently exploring A Link Between World's files, and it has a number of Yaz0-compressed SARC archives. What's interesting is that for the most part, the filename table is completely missing on the compressed archives. In addition, on those files the "unknown" 8-bit value at 0x4 in the node structure is set to 0 instead of 1. So it seems to me that that value indicates whether or not the given node has a filename at all. I'm also gonna hazard a guess and say that the unknown 16-bit value at 0x6 in the SFNT header is just padding, considering all the strings are padded to multiple-of-4 offsets and the header would be 6 bytes without it.<br />
<br />
Really useful page, thanks for all the work.<br />
--[[User:Parax0|Parax0]] ([[User talk:Parax0|talk]]) 16:23, 12 September 2014 (UTC)<br />
<br />
: Probably should have read this page a little closer, I see you guys have already run into a bunch of archives with empty SFNT tables. :P Ah well. --[[User:Parax0|Parax0]] ([[User talk:Parax0|talk]]) 16:34, 12 September 2014 (UTC)<br />
:: Yes. Mario Kart 7 for example has no single file using filenames. Only hashes. (I found the way of generating the hash in mk7 aswell by the way) --[[User:Gericom|Gericom]] ([[User talk:Gericom|talk]]) 19:57, 12 September 2014 (UTC)<br />
: '''"In addition, on those files the "unknown" 8-bit value at 0x4 in the node structure is set to 0 instead of 1."''' This matches my observation as well, so it could well be correct. Can you confirm Gericom?<br />
: '''"I'm also gonna hazard a guess and say that the unknown 16-bit value at 0x6 in the SFNT header is just padding"''' Yes this is always the problem with padding, it's hard to say for sure. Until someone has a look at some parsing code or w/e to confirm the value is ignored, it's best to leave it as unknown on the wiki imo, then developers know they should use some caution.<br />
: [[User:Chadderz|Chadderz]] ([[User talk:Chadderz|talk]]) 07:13, 13 September 2014 (UTC)</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=Talk:SARC_(File_Format)&diff=991Talk:SARC (File Format)2014-08-21T06:00:42Z<p>Chadderz: /* Node Hash */</p>
<hr />
<div>== Node Hash ==<br />
<br />
I'm pretty sure that the value at offset 0x00 in the node structure is a hash of the filename or an ID, because I have found a stripped archive; one in which the SFNT table is empty. The only plausible way to index the files would therefore be to use this value, the values being sorted supports this hypothesis.<br />
[[User:Chadderz|Chadderz]] ([[User talk:Chadderz|talk]]) 06:12, 20 August 2014 (UTC)<br />
<br />
: That makes much more sense than my "percentage" theory. Then the files would be sorted by this hash. --[[User:Celcodioc|Celcodioc]] ([[User talk:Celcodioc|talk]]) 18:35, 20 August 2014 (UTC)<br />
<br />
:: Yup. Just checked it by comparing 2 different archives that contain an identical file. Definitely a hash, sorry for entering the wrong info. --[[User:Celcodioc|Celcodioc]] ([[User talk:Celcodioc|talk]]) 18:41, 20 August 2014 (UTC)<br />
<br />
::: Ah good, nice to have some sort of proof. Don't worry, better to submit a theory that leads to the correct answer than to do nothing :)<br />
::: [[User:Chadderz|Chadderz]] ([[User talk:Chadderz|talk]]) 06:00, 21 August 2014 (UTC)</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=SARC_(File_Format)&diff=987SARC (File Format)2014-08-20T06:14:59Z<p>Chadderz: Undo revision 985 by Celcodioc (talk). I think the old version is right, see Talk:SARC (File Format)#Node Hash</p>
<hr />
<div>'''SARC Files''' are archive files used in [[Wii U]] software, 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''' (when it contains 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 archive beings 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 || '''Byte order mark''' (BOM): 0xFE,0xFF for big endian and 0xFF,0xFE for little endian.<br />
|-<br />
| 0x08 || 4 || '''File size''' of the entire archive in bytes.<br />
|-<br />
| 0x0c || 4 || '''Beginning of data''' offset.<br />
|-<br />
| 0x10 || 4 || {{Unknown|'''Unknown'''. Always '''0x01000000'''?}}<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). It is currently unknown if it is able to.<br />
<br />
=== Header (SFAT) ===<br />
The '''SARC Header''' is immediately followed by 0xc 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 || {{Unknown|'''Unknown.''' 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 0x10 byte '''SFAT Node''' structures.<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Description<br />
|-<br />
| 0x00 || 4 || {{Unknown|'''Unknown.''' Could plausibly be an ID of some sort, the files are encoded sorted by this value, so perhaps even a hash of the name.}}<br />
|-<br />
| 0x04 || 1 || {{Unknown|'''Unknown.''' Always '''0x01'''? Comparable to the file/folder flag from U8?}}<br />
|-<br />
| 0x05 || 3 || '''File name table entry''' offset, relative to the end of the file name table 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 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 0x8 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 || {{Unknown|'''Unknown.''' Always '''0'''?}}<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'''. There is padding between the files for 256-byte (0x100) alignment.<br />
<br />
= Tools =<br />
<br />
The following tool can extract SARC files:<br />
<br />
* [https://www.dropbox.com/sh/tfg2nd6q809oqn3/AADWk3SgQEsqnvlbplcWOfv5a WiiUExplorer], by [[User:Celcodioc|Celcodioc]]<br />
<br />
[[Category:File Format]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=Talk:SARC_(File_Format)&diff=986Talk:SARC (File Format)2014-08-20T06:13:00Z<p>Chadderz: /* Node Hash */ new section</p>
<hr />
<div>== Node Hash ==<br />
<br />
I'm pretty sure that the value at offset 0x00 in the node structure is a hash of the filename or an ID, because I have found a stripped archive; one in which the SFNT table is empty. The only plausible way to index the files would therefore be to use this value, the values being sorted supports this hypothesis.<br />
[[User:Chadderz|Chadderz]] ([[User talk:Chadderz|talk]]) 06:12, 20 August 2014 (UTC)</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=Template:User-MrBean35000vr-Link&diff=971Template:User-MrBean35000vr-Link2014-08-16T08:21:38Z<p>Chadderz: Added mention of Incendia.</p>
<hr />
<div>{{Author-Link|[[User:MrBean35000vr|MrBean35000vr]]|<br />
[http://www.chadsoft.co.uk/ Website]<br />
<br />
'''Custom Tracks:'''<br/><br />
[[Incendia Castle]] <br/><br />
'''Texture Hacks:'''<br/><br />
[[Icy Thwomp Ruins (Thwomp Ruins Texture)|Icy Thwomp Ruins]] <br/><br />
}}<br />
<noinclude>[[Category:Template/User]]</noinclude></div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=Template:User-Chadderz-Link&diff=970Template:User-Chadderz-Link2014-08-16T08:21:10Z<p>Chadderz: Added mention of Incendia.</p>
<hr />
<div>{{Author-Link|[[User:Chadderz|Chadderz]]|<br />
[http://www.chadsoft.co.uk/ Website]<br />
<br />
'''Custom Tracks:'''<br/><br />
[[Incendia Castle]] <br/><br />
'''Texture Hacks:'''<br/><br />
[[Icy Thwomp Ruins (Thwomp Ruins Texture)|Icy Thwomp Ruins]] <br/><br />
}}<br />
<noinclude>[[Category:Template/User]]</noinclude></div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=FMDL_(File_Format)&diff=928FMDL (File Format)2014-08-11T18:54:01Z<p>Chadderz: /* FMAT */ Had a revelation on the meaning of attribute selectors.</p>
<hr />
<div>The '''FMDL''' model format is a format for models which appears as a subfile of a '''[[BFRES (File Format)|BFRES file]]''' in the '''0'''th file group. Typically a BFRES file has one FMDL but some have none and some have more than one.<br />
<br />
__TOC__<br />
<br />
= Format =<br />
<br />
An '''FMDL file''' begins with an '''FMDL header'''. This is then followed by a number of sections pointed to by the header, many of which can occur multiple times. The purpose of these sections is described in the table below. Unless otherwise noted, all offsets in BFRES files are relative to themselves, not the beginning of the file which is more common in other formats.<br />
<br />
{| class="wikitable"<br />
! Section<br />
! Purpose<br />
|-<br />
| [[#FVTX|FVTX]]<br />
| Describes an array of array of vertices which can have a number of attributes including position, normal, colour and texture coordinates.<br />
|-<br />
| [[#FMAT|FMAT]]<br />
| Describes the properties of a surface necessary to draw it including texture information.<br />
|-<br />
| [[#FSKL|FSKL]]<br />
| Describes a skeleton for the model which may be used in animations.<br />
|-<br />
| [[#FSHP|FSHP]]<br />
| Selects triples of vertices from one [[#FVTX|FVTX]] section to draw triangles between. Also specifies the [[#FMAT|FMAT]] material and the [[#FSKL|FSKL]] attachment of the triangles.<br />
|-<br />
| [[#Parameter|Parameter]]<br />
| Sets a named paramter for the model.<br />
|}<br />
<br />
== Header (FMDL) ==<br />
<br />
Every FMDL begins with an 0x2c byte '''FMDL header'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FMDL'''" file identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''File name''' offset (without file extension).<br />
|-<br />
| 0x08<br />
| 4<br />
| '''End of BFRES string table''' offset. Points to just after the last string in the string table.<br />
|-<br />
| 0x0c<br />
| 4<br />
| '''[[#FSKL|FSKL]]''' offset. Offset to the '''FSKL Header'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''[[#FVTX|FVTX]] array''' offset. Offset to the first element in an array of '''FVTX Header'''s.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''[[#FSHP|FSHP]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to an index group which contains named pointers to '''FSHP Header'''s.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''[[#FMAT|FMAT]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to an index group which contains named pointers to '''FMAT Header'''s.<br />
|-<br />
| 0x1c<br />
| 4<br />
| '''[[#Parameter|Parameter]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to an index group which contains named pointers to parameter values. May be '''0''' if no parameters exist (common).<br />
|-<br />
| 0x20<br />
| 2<br />
| '''[[#FVTX|FVTX]] count''': number of FVTX sections in the '''FVTX array'''.<br />
|-<br />
| 0x22<br />
| 2<br />
| '''[[#FSHP|FSHP]] count''': number of FSHP sections in the the '''FSHP index group'''.<br />
|-<br />
| 0x24<br />
| 2<br />
| '''[[#FMAT|FMAT]] count''': number of FMAT sections in the the '''FMAT index group'''.<br />
|-<br />
| 0x26<br />
| 2<br />
| '''[[#Parameter|Parameter]] count''': number of parameters in the '''Parameter index group'''.<br />
|-<br />
| 0x28<br />
| 4<br />
| {{Unknown|'''Unknown''' possibly something like an unused face count.}}<br />
|-<br />
| 0x2c<br />
| colspan="2" {{Unknown|End of FMDL header}}<br />
|}<br />
<br />
== FVTX ==<br />
<br />
The model may have one or more '''FVTX''' sections which describe the vertices for one polygon (e.g. the road of a track). The section describes a series of buffers and attributes. Buffers are arrays of arbitrary elements which contain the actual values of the vertices and are passed directly to the graphics card. Attributes are properties of vertices (e.g. position, texture coordinate, vertex colours) and they describe the format and layout of the elements in the buffers.<br />
<br />
=== Header (FVTX) ===<br />
<br />
Each FVTX section has a 0x20 byte header. These headers are stored sequentially in an array at the offset given in the '''FMDL header'''. The length of this array is also given in that header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FVTX'''" section identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 1<br />
| '''[[#Attributes|Attribute]] count''': number of different attributes (position, normal, colour, etc) in the attribute array.<br />
|-<br />
| 0x05<br />
| 1<br />
| '''[[#Buffers|Buffer]] count''': number of attribute buffers in the buffer array.<br />
|-<br />
| 0x06<br />
| 2<br />
| '''Section index''': index into FVTX array of this entry.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Number of vertices'''. This is also the number of elements in each buffer.<br />
|-<br />
| 0x0c<br />
| 1<br />
| {{Unknown|'''Unknown'''; values seen are between '''0''' and '''4''' (normally '''0''').}}<br />
|-<br />
| 0x0d<br />
| 3<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| '''[[#Attributes|Attribute]] array''' offset. Offset to the first element in the Attribute array.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''[[#Attributes|Attribute]] [[BFRES (File Format)#Index Group|index group]]''' offset. Named pointers to the members of the '''Attribute array''' to allow named lookups.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''[[#Buffers|Buffer]] array''' offset. Offset to the first element in the Buffer array.<br />
|-<br />
| 0x1c<br />
| 4<br />
| Padding, always '''0'''.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of FVTX header}}<br />
|}<br />
<br />
=== Attributes ===<br />
<br />
The '''attributes''' of each '''FVTX''' section are stored as a simple repeating 0xc byte structure. These are stored in an array with location and length specified by the FVTX header. They are also referenced by the attribute index group, presumably to allow both index and name based lookup of attributes.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Attribute name''' offset.<br />
|-<br />
| 0x04<br />
| 1<br />
| '''Buffer index''' of the buffer containing this attribute.<br />
|-<br />
| 0x05<br />
| 3<br />
| '''Buffer offset''' of the attribute in each element in the buffer.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Format''' of the attribute's data in the buffer.<br />
|-<br />
| 0xc<br />
| colspan="2" {{Unknown|End of attribute}}<br />
|}<br />
<br />
The following values have been seen for the '''Format''' field. This list is not exhaustive.<br />
<br />
{| class="wikitable"<br />
! Format<br />
! Data Size<br />
! Description<br />
|-<br />
| 0x00000004<br />
| 2<br />
| Two 8 bit values representing numbers between 0 and 1.<br />
|-<br />
| 0x00000007<br />
| 4<br />
| Two 16 bit values representing numbers between 0 and 1.<br />
|-<br />
| 0x0000020a<br />
| 4<br />
| Four signed 8 bit values.<br />
|-<br />
| 0x0000020b<br />
| 4<br />
| Three signed 10 bit values. Divide by 511 to get decimal value. Top 2 bits are always 0b01.<br />
|-<br />
| 0x0000080d<br />
| 8<br />
| Two 32 bit floating point values.<br />
|-<br />
| 0x0000080f<br />
| 8<br />
| Four [http://en.wikipedia.org/wiki/Half_precision 16 bit floating point] values.<br />
|-<br />
| 0x00000811<br />
| 12<br />
| Three 32 bit floating point values.<br />
|}<br />
<br />
Based on the some of the shader code in [[Filesystem/content/mapobj/PackunMusic#Files|/vol/content/mapobj/PackunMusic/PackunMusic.bfres]] the following naming convention seems to be used for attributes.<br />
<br />
{| class="wikitable"<br />
! Attribute Name<br />
! Friendly Name<br />
! Description<br />
|-<br />
| _p0<br />
| position0<br />
| The position of the vertex.<br />
|-<br />
| _n0<br />
| normal0<br />
| The normal of the vertex as used in lighting calculations.<br />
|-<br />
| _t0<br />
| tangent0<br />
| The tangent of the vertex as used in advanced lighting calculations.<br />
|-<br />
| _b0<br />
| binormal0<br />
| The binormal of the vertex as used in advanced lighting calculations.<br />
|-<br />
| _w0<br />
| blendweight0<br />
| {{Unknown}}<br />
|-<br />
| _i0<br />
| blendindex0<br />
| {{Unknown}}<br />
|-<br />
| _u0<br />
| uv0<br />
| rowspan="4" | Texture coordinates used for texture mapping.<br />
|-<br />
| _u1<br />
| uv1<br />
|-<br />
| _u2<br />
| uv2<br />
|-<br />
| _u3<br />
| uv3<br />
|-<br />
| _c0<br />
| color0<br />
| rowspan="2" | Vertex colours used for simple shadow mapping.<br />
|-<br />
| _c1<br />
| color1<br />
|}<br />
<br />
=== Buffers ===<br />
<br />
The '''buffers''' of each '''FVTX''' section are stored as a repeating 0x18 byte header structure which references the actual data stored later in the BFRES file. The headers are stored in an array with location and length specified by the FVTX header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size''' of the buffer in bytes.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Stride''': the size of each element in the buffer.<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''1'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Data offset'''.<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of buffer}}<br />
|}<br />
<br />
== FMAT ==<br />
<br />
The model may have one or more '''FMAT''' sections which describe surface properties of a polygon such as textures. Every polygon is rendered using a vertex shader and a pixel shader. These are pieces of code which run on the graphics card. Like any code, these have parameters which is principally what the '''FMAT''' section controls. There are many different ways for the '''FMAT''' section to set variables in the shader code, but it remains '''unknown''' what the reason for this is. All shader parameters are either uniform or attributes. Attribute parameters vary per vertex or pixel, whereas uniform parameters are global. The '''FMAT''' must specify values for all uniform parameters, and specifies a mapping between vertex attributes in the corresponding '''[[#FVTX|FVTX]] sections''' and attribute parameters for both the pixel and vertex shader. In [[Mario Kart 8]] most models reference the same pixel shader and the same vertex shader, both called Turbo_UBER. Turbo_UBER is totally generic and has hundreds of parameters to configure the rendering. The source code for Turbo_UBER seems to be available in [[Filesystem/content/mapobj/PackunMusic#Files|/vol/content/mapobj/PackunMusic/PackunMusic.bfres]].<br />
<br />
=== Header (FMAT) ===<br />
<br />
Every FMAT begins with an 0x48 byte header structure. This references the other structures documented here to describe the material.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FMAT'''" section identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Material name''' offset.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''1'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Section Index''' of this material.<br />
|-<br />
| 0x0e<br />
| 2<br />
| '''[[#Render Info Parameter|Render Info Parameter]] Count'''. Number of elements in the Render Info Parameter index group.<br />
|-<br />
| 0x10<br />
| 1<br />
| '''[[#Texture Selector|Texture Selector]] Count'''. Number of elements in the Texture Selector array.<br />
|-<br />
| 0x11<br />
| 1<br />
| '''[[#Texture Attribute Selector|Texture Attribute Selector]] Count'''. Number of elements in the Texture Attribute Selector array. Always equal to the number of elements in the Texture Selector array.<br />
|-<br />
| 0x12<br />
| 2<br />
| '''[[#Material Parameter|Material Parameter]] Count'''. Number of elements in the Material Parameter array.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''[[#Material Parameter|Material Parameter]] Data Size''' in bytes. The size of the Material Parameter Data section.<br />
|-<br />
| 0x18<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0''', '''1''' or '''2'''.}}<br />
|-<br />
| 0x1c<br />
| 4<br />
| '''[[#Render Info Parameter|Render Info Parameter]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to the index group defining render info parameters.<br />
|-<br />
| 0x20<br />
| 4<br />
| '''[[#Unknown Material Structure|Unknown Material Structure]] offset'''. Offset to the unknown material structure.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''[[#Shader Control|Shader Control]]''' offset. Offset to the shader control structure.<br />
|-<br />
| 0x28<br />
| 4<br />
| '''[[#Texture Selector|Texture Selector]]''' offset. Offset to the first element in the Texture Selector array.<br />
|-<br />
| 0x2c<br />
| 4<br />
| '''[[#Texture Attribute Selector|Texture Attribute Selector]]''' offset. Offset to the first element in the Texture Attribute Selector array.<br />
|-<br />
| 0x30<br />
| 4<br />
| '''[[#Texture Attribute Selector|Texture Attribute Selector]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to an index group which references the Texture Attribute Selector array, to allow named value lookups.<br />
|-<br />
| 0x34<br />
| 4<br />
| '''[[#Material Parameter|Material Parameter]]''' array offset. Offset to the first element in the Material Parameter array.<br />
|-<br />
| 0x38<br />
| 4<br />
| '''[[#Material Parameter|Material Parameter]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to an index group which references the Material Parameter array, to allow named value lookups.<br />
|-<br />
| 0x3c<br />
| 4<br />
| '''[[#Material Parameter|Material Parameter]] Data''' offset. Offset to the beggining of the values for Material Parameters. The '''Material Parameter array''' references this data.<br />
|-<br />
| 0x40<br />
| 4<br />
| '''[[#Shadow Parameter|Shadow Parameter]] [[BFRES (File Format)#Index Group|index group]]''' offset. May be '''0''' if not needed.<br />
|-<br />
| 0x44<br />
| 4<br />
| {{Unknown|'''Unknown''' offset. Always points to 12 bytes, all 0. Offset may be '''0''' if not needed.}}<br />
|-<br />
| 0x48<br />
| colspan="2" {{Unknown|End of FMAT Header}}<br />
|}<br />
<br />
=== Render Info Parameter ===<br />
<br />
A '''Render Info Parameter''' is a repeating structure of at least 0x8 bytes, each of which describes the value to assign to a render info variable in the shader code. Render info variables are always uniform variables. The '''Render Info Parameter''' structures are referenced by the '''Render Info Parameter index group''' in the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0''' or '''1'''.}}<br />
|-<br />
| 0x02<br />
| 1<br />
| '''Type''' of the variable.<br />
|-<br />
| 0x03<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Variable Name''' offset.<br />
|-<br />
| 0x08<br />
| Varies<br />
| '''Value''' of the variable.<br />
|-<br />
| Varies<br />
| colspan="2" {{Unknown|End of Render Info Parameter}}<br />
|}<br />
<br />
The '''Type''' field has values as follows.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Value Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 8<br />
| {{Unknown|'''Unknown''' data always '''0'''?}}<br />
|-<br />
| 0x01<br />
| 8<br />
| {{Unknown|'''Unknown''' vector of 2 floats?}}<br />
|-<br />
| 0x02<br />
| 4<br />
| Offset to a string.<br />
|}<br />
<br />
=== Texture Selector ===<br />
<br />
A '''Texture Selector''' is a repeating 0x8 byte structure each of which references a single '''[[FTEX (File Format)|FTEX texture]]'''. The length and position of the '''Texture Selector''' array is specified by the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Texture Name''' offset. The same as the '''FTEX''' name.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''[[FTEX (File Format)|FTEX]]''' offset. Points to the header of the '''FTEX'''.<br />
|-<br />
| 0x08<br />
| colspan="2" {{Unknown|End of Texture Selector}}<br />
|}<br />
<br />
=== Texture Attribute Selector ===<br />
<br />
An '''Texture Attribute Selector''' is a repeating 0x18 byte structure each of which describes one of the inputs to the pixel shader from the selected textures. The length and position of the '''Texture Attribute Selector''' array is specified by the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''2'''.}}<br />
|-<br />
| 0x01<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''0x00''', '''0x02''', '''0x04''' or '''0x12'''.}}<br />
|-<br />
| 0x02<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''0x00''', '''0x10''', '''0x12''' or '''0x5a'''.}}<br />
|-<br />
| 0x03<br />
| 1<br />
| {{Unknown|'''Unknown''' usually either near '''0''' or near '''0x80'''. Could be flags?}}<br />
|-<br />
| 0x04<br />
| 1<br />
| {{Unknown|'''Unknown''' signed integer normally close to 0.}}<br />
|-<br />
| 0x05<br />
| 1<br />
| {{Unknown|'''Unknown''' typically small value.}}<br />
|-<br />
| 0x06<br />
| 2<br />
| {{Unknown|'''Unknown''' probably flags.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0x80000000'''.}}<br />
|-<br />
| 0x0c<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Attribute Name''' offset.<br />
|-<br />
| 0x14<br />
| 1<br />
| '''Index''' of this element.<br />
|-<br />
| 0x15<br />
| 3<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of Texture Attribtue Selector}}<br />
|}<br />
<br />
Based on the some of the shader code in [[Filesystem/content/mapobj/PackunMusic#Files|/vol/content/mapobj/PackunMusic/PackunMusic.bfres]] the following naming convention seems to be used for texture attributes.<br />
<br />
{| class="wikitable"<br />
! Attribute Name<br />
! Friendly Name<br />
! Description<br />
|-<br />
| _a0<br />
| albedo0<br />
| rowspan="4" | Ordinary colour textures for surface albedo.<br />
|-<br />
| _a1<br />
| albedo1<br />
|-<br />
| _a2<br />
| albedo2<br />
|-<br />
| _a3<br />
| albedo3<br />
|-<br />
| _s0<br />
| specular0<br />
| Specular highlight texture.<br />
|-<br />
| _n0<br />
| normal0<br />
| rowspan="2" | Normal map texture for altering surface normals.<br />
|-<br />
| _n1<br />
| normal1<br />
|-<br />
| _e0<br />
| emission0<br />
| Emissive lighting texture.<br />
|-<br />
| _b0<br />
| bake0<br />
| rowspan="2" | Shadow textures.<br />
|-<br />
| _b1<br />
| bake1<br />
|}<br />
<br />
=== Material Parameter ===<br />
<br />
A '''Material Parameter''' is a repeating 0x14 byte structure each of which describes the value to assign to a material variable in the shader code. Material variables are always uniform variables. The length and position of the '''Material Parameter''' array is controlled by the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
In some '''BFRES Files''' which do not have 0x03040004 after the '''FRES''' identifier, the '''Material Parameter''' structure is shorter or longer than 0x14 bytes. This seems to be consistent across entire model files. This is presumably a different verson of the '''FMDL''' format. It is rare in [[Mario Kart 8]] (affecting only 6 models).<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 1<br />
| '''Type''' of the variable.<br />
|-<br />
| 0x01<br />
| 1<br />
| '''Size''' of the value in bytes.<br />
|-<br />
| 0x02<br />
| 2<br />
| '''Offset''' relative to the start of the '''Material Parameter Data''' section to the value.<br />
|-<br />
| 0x04<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0xffffffff'''.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Parameter Index''' into the Material Parameter array.<br />
|-<br />
| 0x0e<br />
| 2<br />
| Same value as '''Parameter Index''' again.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Variable Name''' offset.<br />
|-<br />
| 0x14<br />
| colspan="2" {{Unknown|End of Material Parameter}}<br />
|}<br />
<br />
The '''Type''' field has values as follows.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Size<br />
! Description<br />
|-<br />
| 0x04<br />
| 4<br />
| Signed Integer.<br />
|-<br />
| 0x0c<br />
| 4<br />
| Floating point value.<br />
|-<br />
| 0x0d<br />
| 8<br />
| Vector of 2 floats.<br />
|-<br />
| 0x0e<br />
| 12<br />
| Vector of 3 floats.<br />
|-<br />
| 0x0f<br />
| 16<br />
| Vector of 4 floats.<br />
|-<br />
| 0x1e<br />
| 24<br />
| 2&times;3 Texutre Matrix. Encoded down columns then along rows, so the identity matrix would be encoded '''1, 0, 0, 1, 0, 0'''.<br />
|}<br />
<br />
=== Unknown Material Structure ===<br />
<br />
A '''Unknown Material''' structure is a 0x30 byte structure with unknown purpose. A '''Unknown Material''' structure is referenced by the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' always less than '''0x14'''.}}<br />
|-<br />
| 0x04<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x0028'''.}}<br />
|-<br />
| 0x06<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x0240''', '''0x0242''' or '''0x0243'''.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0x49749732''' or '''0x49749736'''.}}<br />
|-<br />
| 0x0c<br />
| 4<br />
| {{Unknown|'''Unknown''' always less than '''0xe'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| {{Unknown|'''Unknown''' floating point always less than '''1.0'''.}}<br />
|-<br />
| 0x14<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x00cc'''.}}<br />
|-<br />
| 0x16<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x0000''' or '''0x0100'''.}}<br />
|-<br />
| 0x18<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x1c<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x2001'''.}}<br />
|-<br />
| 0x1e<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''1''' or '''5'''.}}<br />
|-<br />
| 0x1f<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''1''' or '''4'''.}}<br />
|-<br />
| 0x20<br />
| 16<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x30<br />
| colspan="2" {{Unknown|End of Unknown Material Structure}}<br />
|}<br />
<br />
=== Shader Control ===<br />
<br />
A '''Shader Control''' structure is a 0x1c byte structure which describe the shader to be used by a material. A '''Shader Control''' structure is referenced by the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Shader Name 1''' offset?<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Shader Name 2''' offset?<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0''' or '''1'''.}}<br />
|-<br />
| 0x0c<br />
| 1<br />
| '''Vertex Shader Input Count'''. Number of elements in the Vertex Shader Input index group.<br />
|-<br />
| 0x0d<br />
| 1<br />
| '''Pixel Shader Input Count'''. Number of elements in the Pixel Shader Input index group.<br />
|-<br />
| 0x0e<br />
| 2<br />
| '''Parameter Count'''. Number of elements in the Parameter index group.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Vertex Shader Input [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to the index group which forms a mapping between strings, mapping an '''FVTX''' attribute to a vertex shader variable. The names are always the same in [[Mario Kart 8]], so this mapping is just ["_p0": "_p0", "_n0": "_n0", ...]?<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Pixel Shader Input [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to the index group which forms a mapping between strings, mapping an '''FVTX''' attribute to a pixel shader variable. The names are always the same in [[Mario Kart 8]], so this mapping is just ["_p0": "_p0", "_n0": "_n0", ...]?<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Parameter [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to the index group which forms a mapping between strings, mapping a uniform shader variable to a value. The values are always strings, even for numeric parameters.<br />
|-<br />
| 0x1c<br />
| colspan="2" {{Unknown|End of Material Parameter}}<br />
|}<br />
<br />
=== Shadow Parameter ===<br />
<br />
A '''Shadow Parameter''' is a repeating 0xc byte structure, each of which describes the value to assign to a shadow variable in the shader code. Shadow variables are always uniform variables. The '''Shadow Parameter''' structures are referenced by the '''Shadow Parameter index group''' in the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Variable Name''' offset.<br />
|-<br />
| 0x04<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''1'''.}}<br />
|-<br />
| 0x06<br />
| 1<br />
| {{Unknown|'''Type''' or '''Index'''?}}<br />
|-<br />
| 0x07<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Value''' of the variable.<br />
|-<br />
| 0xc<br />
| colspan="2" {{Unknown|End of Shadow Parameter}}<br />
|}<br />
<br />
== FSKL ==<br />
<br />
Each model has one '''FSKL''' section which describes one or more bones. The bones form a skeleton and give a transformation to apply to any attached polygon. Every '''[[#FSHP|FSHP polygon]]''' is attached to at least one bone. The '''FSKL''' format is somewhat different in '''BFRES''' files with values other than 0x03040004 after the '''FRES''' identifier, which may indicate an alternative version of the format. These are rare in [[Mario Kart 8]] and not documented here.<br />
<br />
=== Header (FSKL) ===<br />
<br />
The FSKL section always starts with an 0x24 byte header. The location of this header is given by the offset in the '''FMDL header'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FSKL'''" section identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x06<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x1100''' or '''0x1200'''.}}<br />
|-<br />
| 0x08<br />
| 2<br />
| '''[[#Bone|Bone]] array count'''. Number of elements in the Bone array.<br />
|-<br />
| 0x0a<br />
| 2<br />
| '''[[#Inverse Matrix|Inverse Index]] array count'''. Number of elements in the Inverse Matrix array.<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Extra Index count'''. Count of the number of extra indices at the end of the '''[[#Inverse Matrix|Inverse Index]] array'''. These serve '''unknown''' purpose.<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| '''[[#Bone|Bone]] [[BFRES (File Format)#Index Group|index group]]''' offset. Named pointers to the members of the '''Bone array''' to allow named lookups.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''[[#Bone|Bone]] array''' offset. Offset to the first element in the Bone array.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''[[#Inverse Matrix|Inverse Index]] array''' offset. Offset to the first element in the Inverse Index array. Always given even if the array is empty.<br />
|-<br />
| 0x1c<br />
| 4<br />
| '''[[#Inverse Matrix|Inverse Matrix]] array''' offset. Offset to the first element in the Inverse Matrix array. Always given even if the array is empty.<br />
|-<br />
| 0x20<br />
| 4<br />
| Padding, always '''0'''.<br />
|-<br />
| 0x24<br />
| colspan="2" {{Unknown|End of FSKL header}}<br />
|}<br />
<br />
=== Bone ===<br />
<br />
A '''Bone''' is a repeating 0x30 byte structure which descibes a transformation to apply to a polygon. Each bone has up to four parents, which form a tree called a skeleton. To compute the final transformation of a point, apply the transformation required by the bone it is attached to, then that bone's parent recursively up until no parents remain. The '''Bone''' tree is stored as an array with offset and length specified by the '''[[#Header (FSKL)|FSKL header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Name offset''' for this bone.<br />
|-<br />
| 0x04<br />
| 2<br />
| '''Bone index''' of this bone into the bone array.<br />
|-<br />
| 0x06<br />
| 8<br />
| '''Parent indices''' of up to four parents for this bone. '''0xffff''' for no parent.<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 2<br />
| '''Flags''' controlling this bone. '''Unknown''' purpose.<br />
|-<br />
| 0x12<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x1001'''.}}<br />
|-<br />
| 0x14<br />
| 12<br />
| '''Scale Vector''' 3 floats. The amount to scale the vertices by.<br />
|-<br />
| 0x20<br />
| 12<br />
| '''Rotation Vector''' 3 floats. The amount of rotation to apply to x, y and z axis in Radians.<br />
|-<br />
| 0x2c<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''1.0f'''.}}<br />
|-<br />
| 0x30<br />
| 12<br />
| '''Translation Vector''' 3 floats. The amount to translate the vertices by.<br />
|-<br />
| 0x3c<br />
| 4<br />
| Padding, always '''0'''.<br />
|-<br />
| 0x40<br />
| colspan="2" {{Unknown|End of Bone}}<br />
|}<br />
<br />
=== Inverse Matrix ===<br />
<br />
The '''FSKL''' may specify an '''Inverse Matrix''' for any '''[[#Bone|Bone]]'''. It does this by creating an entry in the '''Invese Index''' array which is the index of the bone, and in the corresponding place in the '''Inverse Matrix array''' it places a 4&times;3 transformation matrix which reverses the full transformation of the bone and all its parents. Inverse Matricies are optional, it is '''Unknown''' if they are ever referenced. The position of and number of elements in the '''Inverse Matrix array''' and the '''Inverse Index array''' are given in the [[#Header (FSKL)|FSKL Header]]. At the end of the '''Inverse Index array''' are a number of extra indices, which have '''Unkonwn''' purpose. The number of such extra indices is also present in the [[#Header (FSKL)|FSKL Header]].<br />
<br />
== FSHP ==<br />
<br />
The model may have one or more '''FSHP''' sections which describe the one polygon (e.g. the road of a track). The FSHP section consists of an 0x40 byte header, which references an '''[[#FVTX|FVTX]]''' section and indices of the polygons to draw. A basic '''FSHP''' amounts to a list of indices into the corresponding '''FVTX''' indicating which points to draw triangles between. The '''FSHP''' also references an '''[[#FMAT|FMAT]]''' to describe the material of the triangles, and an '''[[#FSKL|FSKL]]''' to indicate the bone structure of the model used in animation.<br />
<br />
=== Header (FSHP) ===<br />
<br />
Every '''FSHP''' begins with an 0x40 byte header. This references other data structures which describe the polygon.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FSHP'''" section identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Polygon name''' offset.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''2'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Section Index''' or '''[[#FVTX|FVTX]] Index'''. In every [[Mario Kart 8]] model these numbers are the same.<br />
|-<br />
| 0x0e<br />
| 2<br />
| '''[[#FMAT|FMAT]] Index'''. Index of the material for this polygon.<br />
|-<br />
| 0x10<br />
| 2<br />
| '''[[#FSKL|FSKL]] Index''' of the bone for this polygon.<br />
|-<br />
| 0x12<br />
| 2<br />
| '''Section Index''' or '''[[#FVTX|FVTX]] Index'''. In every [[Mario Kart 8]] model these numbers are the same.<br />
|-<br />
| 0x14<br />
| 2<br />
| '''FSKL Index Array Count'''. Often zero, '''Unknown''' purpose but seems to be related to '''FSKL'''.<br />
|-<br />
| 0x16<br />
| 1<br />
| {{Unknown|'''Unknown''': If '''FSKL Index Array''' is present this tends to be non-zero. Zero otherwise.}}<br />
|-<br />
| 0x17<br />
| 1<br />
| '''[[#Drawing Command|Drawing Command]] count'''. Number of elements in the array.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''[[#Drawing Extent Tree|Drawing Extent Tree Node]] count'''.<br />
|-<br />
| 0x1c<br />
| 4<br />
| {{Unknown|'''Unknown''' floating point.}}<br />
|-<br />
| 0x20<br />
| 4<br />
| '''[[#FVTX|FVTX]] offset''' to the vertex buffer for this polygon.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''[[#Drawing Command|Drawing Command]] offset'''. Offset to the first element in the array.<br />
|-<br />
| 0x28<br />
| 4<br />
| '''FSKL Index Array Offset'''. Each element of this array is a 16 bit index.<br />
|-<br />
| 0x2c<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x30<br />
| 4<br />
| '''[[#Drawing Extent Tree|Drawing Extent Tree Nodes]] offset'''.<br />
|-<br />
| 0x34<br />
| 4<br />
| '''[[#Drawing Extent Tree|Drawing Extent Tree Ranges]] offset'''.<br />
|-<br />
| 0x38<br />
| 4<br />
| '''[[#Drawing Extent Tree|Drawing Extent Tree Indices]] offset'''.<br />
|-<br />
| 0x3c<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x40<br />
| colspan="2" {{Unknown|End of FSHP header}}<br />
|}<br />
<br />
=== Drawing Command ===<br />
<br />
A '''Drawing Command''' is a repeating 0x1c byte structure which are stored in a sequential array with location and size specified by the '''FSHP Header'''<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''4'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''4'''.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Count''' of points drawn in all [[#Drawing Extent|Drawing Extent]]s.<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''[[#Drawing Extent|Drawing Extent]] count'''. The number of elements in the array.<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| '''[[#Drawing Extent|Drawing Extent]] offset'''. Offset to the first element in the array.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''[[#Index Buffer|Index Buffer]] offset'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Skip Vertices''': the number of elements to skip in the corresponding '''FVTX''' buffer.<br />
|-<br />
| 0x1c<br />
| colspan="2" {{Unknown|End of Drawing Command}}<br />
|}<br />
<br />
=== Drawing Extent ===<br />
<br />
A '''Drawing Extent''' is a repeating 0x8 byte structure describing an offset and a count in the corresponding [[#Index Buffer|Index Buffer]]. Drawing Extents are stored in a sequential array with location and count indicated by the corresponding [[#Drawing Command|Drawing Command]]. This allows multiple separate drawing commands to be issued using the same Index Buffer. In many cases, a single extent is used which simply draws the entire Index Buffer.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Offset''' into index buffer in bytes.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Count''' of the points to draw.<br />
|-<br />
| 0x08<br />
| colspan="2" {{Unknown|End of Drawing Extent}}<br />
|}<br />
<br />
=== Index Buffer ===<br />
<br />
An '''Index Buffer''' is an 0x18 byte structure which describes a list of 16 bit values which are used to index the '''FVTX''' section when drawing the polygon. Index Buffers are referenced by [[#Drawing Command|Drawing Command]]s. The format is very similar to the [[#Buffers|FVTX Buffer]] format, which may indicate they are instances of the same structure.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size''' of index data in bytes.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' Always '''1'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Index data offset'''.<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of Index Buffer}}<br />
|}<br />
<br />
=== Drawing Extent Tree ===<br />
<br />
The '''Drawing Extent Tree''' is some sort of tree structure that occurs in all FSHP sections. In all [[Mario Kart 8]] files, when the '''FSHP''' has multiple [[#Drawing Command|Drawing Command]]s, the Drawing Extent Tree is a trivial one node tree. The Drawing Extent Tree may be used to control which [[#Drawing Extent|Drawing Extent]]s need to be drawn, for example as part of a dynamic level of detail system. The true workings and purpose of the structure are however unknown.<br />
<br />
==== Nodes ====<br />
<br />
The '''Drawing Extent Tree Node''' is a repeating 0xc byte structure. The nodes form a binary tree. The [[#FSHP|FSHP header]] contains a pointer to node array, as well as specifying its length. The root node is the first node in this array. Each node specifies a range of Drawing Extents, with the root node always covering all nodes, and the children of each node always selecting disjoint subsets of that node's range.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 2<br />
| '''Left Child''' index. The current node's index if it has no left child.<br />
|-<br />
| 0x02<br />
| 2<br />
| '''Right Child''' index. The current node's index if it has no right child.<br />
|-<br />
| 0x04<br />
| 2<br />
| '''Unknown''' always the same as '''Left Child''' index.<br />
|-<br />
| 0x06<br />
| 2<br />
| '''Next Sibling''' index. For left children, always the current node's parent's right child (the current node's index if it has no right child).<br />
|-<br />
| 0x08<br />
| 2<br />
| '''[[#Drawing Extent|Drawing Extent]] Index''' selects a range of Drawing Extents along with the count.<br />
|-<br />
| 0x0a<br />
| 2<br />
| '''[[#Drawing Extent|Drawing Extent]] Count''' selects a range of Drawing Extents along with the index.<br />
|-<br />
| 0x0c<br />
| colspan="2" {{Unknown|End of Node}}<br />
|}<br />
<br />
==== Ranges ====<br />
<br />
The '''Drawing Extent Tree Range''' is a repeating 0x18 byte structure. The purpose is unknown. There are exactly as many Ranges as Nodes. The range appears to contain two 3D positions, which are not necessarily distinct.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 12<br />
| {{Unknown|'''Unknown''' 3D position (x,y,z float).}}<br />
|-<br />
| 0x0c<br />
| 12<br />
| {{Unknown|'''Unknown''' 3D position (x,y,z float).}}<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of Range}}<br />
|}<br />
<br />
==== Indices ====<br />
<br />
The '''Drawing Extent Tree Index''' array is an array of 16 bit values which appear to be the index of the leaf node of the '''Drawing Extent Tree''' which contains the corresponding '''[[#Drawing Extent|Drawing Extent]]'''. Therefore this array has length equal to the number of [[#Drawing Extent|Drawing Extent]]s in the '''FSHP''' section.<br />
<br />
== Parameter ==<br />
<br />
A '''Parameter''' is an 0xc byte structure which describes the value of some model parameter. It is only used in a handful of [[Mario Kart 8]] models to set the value of "ParticleLimit". A '''Parameter''' structure is referenced by the '''Parameter index group''' in the '''[[#Header (FMDL)|FMDL Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Variable Name''' offset.<br />
|-<br />
| 0x04<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''1'''.}}<br />
|-<br />
| 0x06<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Value''' of the variable (floating point).<br />
|-<br />
| 0xc<br />
| colspan="2" {{Unknown|End of Parameter}}<br />
|}<br />
<br />
[[Category:File Format]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=Mario_Kart_8/Beta_Elements&diff=927Mario Kart 8/Beta Elements2014-08-11T17:47:35Z<p>Chadderz: /* DLC Images */ New section.</p>
<hr />
<div>This is a list of beta elements for the game Mario Kart 8.<br />
<br />
== Early ideas ==<br />
The players were originally going to have a drill attached to their karts to tunnel through parts of the track to reach new areas and possibly for shortcuts, but Nintendo scrapped this idea in favor of the Anti-Gravity mechanic.<br />
<br />
== Beta Tracks ==<br />
* [[Gu_Menu]] - An empty course with no refreshing HUD<br />
* [[Test]] - An early version of Mario Circuit<br />
<br />
== DLC images ==<br />
In the directory [[Filesystem/content/ui/cmn/a_race/timg|/vol/content/ui/cmn/a_race/timg]] there exist four extra cup images with names DLC00 through DLC03. These are images of a Yoshi Egg, a Shine Sprite, a Boo and a Blue Shell.<br />
<br />
There are also 16 DLC track images but all of these are just the same image of the start of a Mario Circuit race with 12 Marios at the start line. The word SAMPLE is overlaid on these images.<br />
<br />
== Early builds ==<br />
* Twisted Mansion was originally called Boo House.<br />
* Donkey Kong's Standard Bike used to be brown, but in the final version it was yellow.<br />
* The Galaxy Air advertisement in Toad Harbor at the starting line was replaced by a Flower Cup logo and the cloth used a different texture.<br />
* Thwomp Ruins in the E3 trailer lacked flowers and the anti-gravity section was a normal road.<br />
* The Goomba Tower's found in Mario Circuit were both taller and harder to avoid.<br />
* The HUD looked different in the demo, having solid numbers instead of the digital ones in the final game; the same also applies to Lakitu's lap counter.<br />
<br />
Originally, the minimaps on the Gamepad were very similiar to ''Mario Kart 7'' ones; dark checkered gray background with a white colored course. In the final release, the minimaps have a checkered white background with a light blue colored course (rainbow colored for both [[Rainbow Road]] courses that appear in this game).<br />
<br />
[[Category:Development]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=FMDL_(File_Format)&diff=926FMDL (File Format)2014-08-11T14:46:56Z<p>Chadderz: Finished initial documentation of FMDL. I can confirm this is basically correct, we've been able to render models by following what's written here.</p>
<hr />
<div>The '''FMDL''' model format is a format for models which appears as a subfile of a '''[[BFRES (File Format)|BFRES file]]''' in the '''0'''th file group. Typically a BFRES file has one FMDL but some have none and some have more than one.<br />
<br />
__TOC__<br />
<br />
= Format =<br />
<br />
An '''FMDL file''' begins with an '''FMDL header'''. This is then followed by a number of sections pointed to by the header, many of which can occur multiple times. The purpose of these sections is described in the table below. Unless otherwise noted, all offsets in BFRES files are relative to themselves, not the beginning of the file which is more common in other formats.<br />
<br />
{| class="wikitable"<br />
! Section<br />
! Purpose<br />
|-<br />
| [[#FVTX|FVTX]]<br />
| Describes an array of array of vertices which can have a number of attributes including position, normal, colour and texture coordinates.<br />
|-<br />
| [[#FMAT|FMAT]]<br />
| Describes the properties of a surface necessary to draw it including texture information.<br />
|-<br />
| [[#FSKL|FSKL]]<br />
| Describes a skeleton for the model which may be used in animations.<br />
|-<br />
| [[#FSHP|FSHP]]<br />
| Selects triples of vertices from one [[#FVTX|FVTX]] section to draw triangles between. Also specifies the [[#FMAT|FMAT]] material and the [[#FSKL|FSKL]] attachment of the triangles.<br />
|-<br />
| [[#Parameter|Parameter]]<br />
| Sets a named paramter for the model.<br />
|}<br />
<br />
== Header (FMDL) ==<br />
<br />
Every FMDL begins with an 0x2c byte '''FMDL header'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FMDL'''" file identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''File name''' offset (without file extension).<br />
|-<br />
| 0x08<br />
| 4<br />
| '''End of BFRES string table''' offset. Points to just after the last string in the string table.<br />
|-<br />
| 0x0c<br />
| 4<br />
| '''[[#FSKL|FSKL]]''' offset. Offset to the '''FSKL Header'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''[[#FVTX|FVTX]] array''' offset. Offset to the first element in an array of '''FVTX Header'''s.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''[[#FSHP|FSHP]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to an index group which contains named pointers to '''FSHP Header'''s.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''[[#FMAT|FMAT]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to an index group which contains named pointers to '''FMAT Header'''s.<br />
|-<br />
| 0x1c<br />
| 4<br />
| '''[[#Parameter|Parameter]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to an index group which contains named pointers to parameter values. May be '''0''' if no parameters exist (common).<br />
|-<br />
| 0x20<br />
| 2<br />
| '''[[#FVTX|FVTX]] count''': number of FVTX sections in the '''FVTX array'''.<br />
|-<br />
| 0x22<br />
| 2<br />
| '''[[#FSHP|FSHP]] count''': number of FSHP sections in the the '''FSHP index group'''.<br />
|-<br />
| 0x24<br />
| 2<br />
| '''[[#FMAT|FMAT]] count''': number of FMAT sections in the the '''FMAT index group'''.<br />
|-<br />
| 0x26<br />
| 2<br />
| '''[[#Parameter|Parameter]] count''': number of parameters in the '''Parameter index group'''.<br />
|-<br />
| 0x28<br />
| 4<br />
| {{Unknown|'''Unknown''' possibly something like an unused face count.}}<br />
|-<br />
| 0x2c<br />
| colspan="2" {{Unknown|End of FMDL header}}<br />
|}<br />
<br />
== FVTX ==<br />
<br />
The model may have one or more '''FVTX''' sections which describe the vertices for one polygon (e.g. the road of a track). The section describes a series of buffers and attributes. Buffers are arrays of arbitrary elements which contain the actual values of the vertices and are passed directly to the graphics card. Attributes are properties of vertices (e.g. position, texture coordinate, vertex colours) and they describe the format and layout of the elements in the buffers.<br />
<br />
=== Header (FVTX) ===<br />
<br />
Each FVTX section has a 0x20 byte header. These headers are stored sequentially in an array at the offset given in the '''FMDL header'''. The length of this array is also given in that header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FVTX'''" section identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 1<br />
| '''[[#Attributes|Attribute]] count''': number of different attributes (position, normal, colour, etc) in the attribute array.<br />
|-<br />
| 0x05<br />
| 1<br />
| '''[[#Buffers|Buffer]] count''': number of attribute buffers in the buffer array.<br />
|-<br />
| 0x06<br />
| 2<br />
| '''Section index''': index into FVTX array of this entry.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Number of vertices'''. This is also the number of elements in each buffer.<br />
|-<br />
| 0x0c<br />
| 1<br />
| {{Unknown|'''Unknown'''; values seen are between '''0''' and '''4''' (normally '''0''').}}<br />
|-<br />
| 0x0d<br />
| 3<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| '''[[#Attributes|Attribute]] array''' offset. Offset to the first element in the Attribute array.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''[[#Attributes|Attribute]] [[BFRES (File Format)#Index Group|index group]]''' offset. Named pointers to the members of the '''Attribute array''' to allow named lookups.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''[[#Buffers|Buffer]] array''' offset. Offset to the first element in the Buffer array.<br />
|-<br />
| 0x1c<br />
| 4<br />
| Padding, always '''0'''.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of FVTX header}}<br />
|}<br />
<br />
=== Attributes ===<br />
<br />
The '''attributes''' of each '''FVTX''' section are stored as a simple repeating 0xc byte structure. These are stored in an array with location and length specified by the FVTX header. They are also referenced by the attribute index group, presumably to allow both index and name based lookup of attributes.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Attribute name''' offset.<br />
|-<br />
| 0x04<br />
| 1<br />
| '''Buffer index''' of the buffer containing this attribute.<br />
|-<br />
| 0x05<br />
| 3<br />
| '''Buffer offset''' of the attribute in each element in the buffer.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Format''' of the attribute's data in the buffer.<br />
|-<br />
| 0xc<br />
| colspan="2" {{Unknown|End of attribute}}<br />
|}<br />
<br />
The following values have been seen for the '''Format''' field. This list is not exhaustive.<br />
<br />
{| class="wikitable"<br />
! Format<br />
! Data Size<br />
! Description<br />
|-<br />
| 0x00000004<br />
| 2<br />
| Two 8 bit values representing numbers between 0 and 1.<br />
|-<br />
| 0x00000007<br />
| 4<br />
| Two 16 bit values representing numbers between 0 and 1.<br />
|-<br />
| 0x0000020a<br />
| 4<br />
| Four signed 8 bit values.<br />
|-<br />
| 0x0000020b<br />
| 4<br />
| Three signed 10 bit values. Divide by 511 to get decimal value. Top 2 bits are always 0b01.<br />
|-<br />
| 0x0000080d<br />
| 8<br />
| Two 32 bit floating point values.<br />
|-<br />
| 0x0000080f<br />
| 8<br />
| Four [http://en.wikipedia.org/wiki/Half_precision 16 bit floating point] values.<br />
|-<br />
| 0x00000811<br />
| 12<br />
| Three 32 bit floating point values.<br />
|}<br />
<br />
Based on the some of the shader code in [[Filesystem/content/mapobj/PackunMusic#Files|/vol/content/mapobj/PackunMusic/PackunMusic.bfres]] the following naming convention seems to be used for attributes.<br />
<br />
{| class="wikitable"<br />
! Attribute Name<br />
! Friendly Name<br />
! Description<br />
|-<br />
| _p0<br />
| position0<br />
| The position of the vertex.<br />
|-<br />
| _n0<br />
| normal0<br />
| The normal of the vertex as used in lighting calculations.<br />
|-<br />
| _t0<br />
| tangent0<br />
| The tangent of the vertex as used in advanced lighting calculations.<br />
|-<br />
| _b0<br />
| binormal0<br />
| The binormal of the vertex as used in advanced lighting calculations.<br />
|-<br />
| _w0<br />
| blendweight0<br />
| {{Unknown}}<br />
|-<br />
| _i0<br />
| blendindex0<br />
| {{Unknown}}<br />
|-<br />
| _u0<br />
| uv0<br />
| rowspan="4" | Texture coordinates used for texture mapping.<br />
|-<br />
| _u1<br />
| uv1<br />
|-<br />
| _u2<br />
| uv2<br />
|-<br />
| _u3<br />
| uv3<br />
|-<br />
| _c0<br />
| color0<br />
| rowspan="2" | Vertex colours used for simple shadow mapping.<br />
|-<br />
| _c1<br />
| color1<br />
|}<br />
<br />
=== Buffers ===<br />
<br />
The '''buffers''' of each '''FVTX''' section are stored as a repeating 0x18 byte header structure which references the actual data stored later in the BFRES file. The headers are stored in an array with location and length specified by the FVTX header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size''' of the buffer in bytes.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Stride''': the size of each element in the buffer.<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''1'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Data offset'''.<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of buffer}}<br />
|}<br />
<br />
== FMAT ==<br />
<br />
The model may have one or more '''FMAT''' sections which describe surface properties of a polygon such as textures. Every polygon is rendered using a vertex shader and a pixel shader. These are pieces of code which run on the graphics card. Like any code, these have parameters which is principally what the '''FMAT''' section controls. There are many different ways for the '''FMAT''' section to set variables in the shader code, but it remains '''unknown''' what the reason for this is. All shader parameters are either uniform or attributes. Attribute parameters vary per vertex or pixel, whereas uniform parameters are global. The '''FMAT''' must specify values for all uniform parameters, and specifies a mapping between vertex attributes in the corresponding '''[[#FVTX|FVTX]] sections''' and attribute parameters for both the pixel and vertex shader. In [[Mario Kart 8]] most models reference the same pixel shader and the same vertex shader, both called Turbo_UBER. Turbo_UBER is totally generic and has hundreds of parameters to configure the rendering. The source code for Turbo_UBER seems to be available in [[Filesystem/content/mapobj/PackunMusic#Files|/vol/content/mapobj/PackunMusic/PackunMusic.bfres]].<br />
<br />
=== Header (FMAT) ===<br />
<br />
Every FMAT begins with an 0x48 byte header structure. This references the other structures documented here to describe the material.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FMAT'''" section identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Material name''' offset.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''1'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Section Index''' of this material.<br />
|-<br />
| 0x0e<br />
| 2<br />
| '''[[#Render Info Parameter|Render Info Parameter]] Count'''. Number of elements in the Render Info Parameter index group.<br />
|-<br />
| 0x10<br />
| 1<br />
| '''[[#Texture Selector|Texture Selector]] Count'''. Number of elements in the Texture Selector array.<br />
|-<br />
| 0x11<br />
| 1<br />
| '''[[#Attribute Selector|Attribute Selector]] Count'''. Number of elements in the Attribute Selector array.<br />
|-<br />
| 0x12<br />
| 2<br />
| '''[[#Material Parameter|Material Parameter]] Count'''. Number of elements in the Material Parameter array.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''[[#Material Parameter|Material Parameter]] Data Size''' in bytes. The size of the Material Parameter Data section.<br />
|-<br />
| 0x18<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0''', '''1''' or '''2'''.}}<br />
|-<br />
| 0x1c<br />
| 4<br />
| '''[[#Render Info Parameter|Render Info Parameter]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to the index group defining render info parameters.<br />
|-<br />
| 0x20<br />
| 4<br />
| '''[[#Unknown Material Structure|Unknown Material Structure]] offset'''. Offset to the unknown material structure.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''[[#Shader Control|Shader Control]]''' offset. Offset to the shader control structure.<br />
|-<br />
| 0x28<br />
| 4<br />
| '''[[#Texture Selector|Texture Selector]]''' offset. Offset to the first element in the Texture Selector array.<br />
|-<br />
| 0x2c<br />
| 4<br />
| '''[[#Attribute Selector|Attribute Selector]]''' offset. Offset to the first element in the Attribute Selector array.<br />
|-<br />
| 0x30<br />
| 4<br />
| '''[[#Attribute Selector|Attribute Selector]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to an index group which references the Attribute Selector array, to allow named value lookups.<br />
|-<br />
| 0x34<br />
| 4<br />
| '''[[#Material Parameter|Material Parameter]]''' array offset. Offset to the first element in the Material Parameter array.<br />
|-<br />
| 0x38<br />
| 4<br />
| '''[[#Material Parameter|Material Parameter]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to an index group which references the Material Parameter array, to allow named value lookups.<br />
|-<br />
| 0x3c<br />
| 4<br />
| '''[[#Material Parameter|Material Parameter]] Data''' offset. Offset to the beggining of the values for Material Parameters. The '''Material Parameter array''' references this data.<br />
|-<br />
| 0x40<br />
| 4<br />
| '''[[#Shadow Parameter|Shadow Parameter]] [[BFRES (File Format)#Index Group|index group]]''' offset. May be '''0''' if not needed.<br />
|-<br />
| 0x44<br />
| 4<br />
| {{Unknown|'''Unknown''' offset. Always points to 12 bytes, all 0. Offset may be '''0''' if not needed.}}<br />
|-<br />
| 0x48<br />
| colspan="2" {{Unknown|End of FMAT Header}}<br />
|}<br />
<br />
=== Render Info Parameter ===<br />
<br />
A '''Render Info Parameter''' is a repeating structure of at least 0x8 bytes, each of which describes the value to assign to a render info variable in the shader code. Render info variables are always uniform variables. The '''Render Info Parameter''' structures are referenced by the '''Render Info Parameter index group''' in the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0''' or '''1'''.}}<br />
|-<br />
| 0x02<br />
| 1<br />
| '''Type''' of the variable.<br />
|-<br />
| 0x03<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Variable Name''' offset.<br />
|-<br />
| 0x08<br />
| Varies<br />
| '''Value''' of the variable.<br />
|-<br />
| Varies<br />
| colspan="2" {{Unknown|End of Render Info Parameter}}<br />
|}<br />
<br />
The '''Type''' field has values as follows.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Value Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 8<br />
| {{Unknown|'''Unknown''' data always '''0'''?}}<br />
|-<br />
| 0x01<br />
| 8<br />
| {{Unknown|'''Unknown''' vector of 2 floats?}}<br />
|-<br />
| 0x02<br />
| 4<br />
| Offset to a string.<br />
|}<br />
<br />
=== Texture Selector ===<br />
<br />
A '''Texture Selector''' is a repeating 0x8 byte structure each of which references a single '''[[FTEX (File Format)|FTEX texture]]'''. The length and position of the '''Texture Selector''' array is specified by the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Texture Name''' offset. The same as the '''FTEX''' name.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''[[FTEX (File Format)|FTEX]]''' offset. Points to the header of the '''FTEX'''.<br />
|-<br />
| 0x08<br />
| colspan="2" {{Unknown|End of Texture Selector}}<br />
|}<br />
<br />
=== Attribute Selector ===<br />
<br />
An '''Attribute Selector''' is a repeating 0x18 byte structure each of which describes one of the inputs to the pixel shader from the original stream of vertices. The length and position of the '''Attribute Selector''' array is specified by the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''2'''.}}<br />
|-<br />
| 0x01<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''0x00''', '''0x02''', '''0x04''' or '''0x12'''.}}<br />
|-<br />
| 0x02<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''0x00''', '''0x10''', '''0x12''' or '''0x5a'''.}}<br />
|-<br />
| 0x03<br />
| 1<br />
| {{Unknown|'''Unknown''' usually either near '''0''' or near '''0x80'''. Could be flags?}}<br />
|-<br />
| 0x04<br />
| 1<br />
| {{Unknown|'''Unknown''' signed integer normally close to 0.}}<br />
|-<br />
| 0x05<br />
| 1<br />
| {{Unknown|'''Unknown''' typically small value.}}<br />
|-<br />
| 0x06<br />
| 2<br />
| {{Unknown|'''Unknown''' probably flags.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0x80000000'''.}}<br />
|-<br />
| 0x0c<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Attribute Name''' offset.<br />
|-<br />
| 0x14<br />
| 1<br />
| '''Index''' of this element.<br />
|-<br />
| 0x15<br />
| 3<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of data}}<br />
|}<br />
<br />
=== Material Parameter ===<br />
<br />
A '''Material Parameter''' is a repeating 0x14 byte structure each of which describes the value to assign to a material variable in the shader code. Material variables are always uniform variables. The length and position of the '''Material Parameter''' array is controlled by the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
In some '''BFRES Files''' which do not have 0x03040004 after the '''FRES''' identifier, the '''Material Parameter''' structure is shorter or longer than 0x14 bytes. This seems to be consistent across entire model files. This is presumably a different verson of the '''FMDL''' format. It is rare in [[Mario Kart 8]] (affecting only 6 models).<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 1<br />
| '''Type''' of the variable.<br />
|-<br />
| 0x01<br />
| 1<br />
| '''Size''' of the value in bytes.<br />
|-<br />
| 0x02<br />
| 2<br />
| '''Offset''' relative to the start of the '''Material Parameter Data''' section to the value.<br />
|-<br />
| 0x04<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0xffffffff'''.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Parameter Index''' into the Material Parameter array.<br />
|-<br />
| 0x0e<br />
| 2<br />
| Same value as '''Parameter Index''' again.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Variable Name''' offset.<br />
|-<br />
| 0x14<br />
| colspan="2" {{Unknown|End of Material Parameter}}<br />
|}<br />
<br />
The '''Type''' field has values as follows.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Size<br />
! Description<br />
|-<br />
| 0x04<br />
| 4<br />
| Signed Integer.<br />
|-<br />
| 0x0c<br />
| 4<br />
| Floating point value.<br />
|-<br />
| 0x0d<br />
| 8<br />
| Vector of 2 floats.<br />
|-<br />
| 0x0e<br />
| 12<br />
| Vector of 3 floats.<br />
|-<br />
| 0x0f<br />
| 16<br />
| Vector of 4 floats.<br />
|-<br />
| 0x1e<br />
| 24<br />
| 2&times;3 Texutre Matrix. Encoded down columns then along rows, so the identity matrix would be encoded '''1, 0, 0, 1, 0, 0'''.<br />
|}<br />
<br />
=== Unknown Material Structure ===<br />
<br />
A '''Unknown Material''' structure is a 0x30 byte structure with unknown purpose. A '''Unknown Material''' structure is referenced by the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' always less than '''0x14'''.}}<br />
|-<br />
| 0x04<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x0028'''.}}<br />
|-<br />
| 0x06<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x0240''', '''0x0242''' or '''0x0243'''.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0x49749732''' or '''0x49749736'''.}}<br />
|-<br />
| 0x0c<br />
| 4<br />
| {{Unknown|'''Unknown''' always less than '''0xe'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| {{Unknown|'''Unknown''' floating point always less than '''1.0'''.}}<br />
|-<br />
| 0x14<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x00cc'''.}}<br />
|-<br />
| 0x16<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x0000''' or '''0x0100'''.}}<br />
|-<br />
| 0x18<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x1c<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x2001'''.}}<br />
|-<br />
| 0x1e<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''1''' or '''5'''.}}<br />
|-<br />
| 0x1f<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''1''' or '''4'''.}}<br />
|-<br />
| 0x20<br />
| 16<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x30<br />
| colspan="2" {{Unknown|End of Unknown Material Structure}}<br />
|}<br />
<br />
=== Shader Control ===<br />
<br />
A '''Shader Control''' structure is a 0x1c byte structure which describe the shader to be used by a material. A '''Shader Control''' structure is referenced by the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Shader Name 1''' offset?<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Shader Name 2''' offset?<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0''' or '''1'''.}}<br />
|-<br />
| 0x0c<br />
| 1<br />
| '''Vertex Shader Input Count'''. Number of elements in the Vertex Shader Input index group.<br />
|-<br />
| 0x0d<br />
| 1<br />
| '''Pixel Shader Input Count'''. Number of elements in the Pixel Shader Input index group.<br />
|-<br />
| 0x0e<br />
| 2<br />
| '''Parameter Count'''. Number of elements in the Parameter index group.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Vertex Shader Input [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to the index group which forms a mapping between strings, mapping an '''FVTX''' attribute to a vertex shader variable. The names are always the same in [[Mario Kart 8]], so this mapping is just ["_p0": "_p0", "_n0": "_n0", ...]?<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Pixel Shader Input [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to the index group which forms a mapping between strings, mapping an '''FVTX''' attribute to a pixel shader variable. The names are always the same in [[Mario Kart 8]], so this mapping is just ["_p0": "_p0", "_n0": "_n0", ...]?<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Parameter [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to the index group which forms a mapping between strings, mapping a uniform shader variable to a value. The values are always strings, even for numeric parameters.<br />
|-<br />
| 0x1c<br />
| colspan="2" {{Unknown|End of Material Parameter}}<br />
|}<br />
<br />
=== Shadow Parameter ===<br />
<br />
A '''Shadow Parameter''' is a repeating 0xc byte structure, each of which describes the value to assign to a shadow variable in the shader code. Shadow variables are always uniform variables. The '''Shadow Parameter''' structures are referenced by the '''Shadow Parameter index group''' in the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Variable Name''' offset.<br />
|-<br />
| 0x04<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''1'''.}}<br />
|-<br />
| 0x06<br />
| 1<br />
| {{Unknown|'''Type''' or '''Index'''?}}<br />
|-<br />
| 0x07<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Value''' of the variable.<br />
|-<br />
| 0xc<br />
| colspan="2" {{Unknown|End of Shadow Parameter}}<br />
|}<br />
<br />
== FSKL ==<br />
<br />
Each model has one '''FSKL''' section which describes one or more bones. The bones form a skeleton and give a transformation to apply to any attached polygon. Every '''[[#FSHP|FSHP polygon]]''' is attached to at least one bone. The '''FSKL''' format is somewhat different in '''BFRES''' files with values other than 0x03040004 after the '''FRES''' identifier, which may indicate an alternative version of the format. These are rare in [[Mario Kart 8]] and not documented here.<br />
<br />
=== Header (FSKL) ===<br />
<br />
The FSKL section always starts with an 0x24 byte header. The location of this header is given by the offset in the '''FMDL header'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FSKL'''" section identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x06<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x1100''' or '''0x1200'''.}}<br />
|-<br />
| 0x08<br />
| 2<br />
| '''[[#Bone|Bone]] array count'''. Number of elements in the Bone array.<br />
|-<br />
| 0x0a<br />
| 2<br />
| '''[[#Inverse Matrix|Inverse Index]] array count'''. Number of elements in the Inverse Matrix array.<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Extra Index count'''. Count of the number of extra indices at the end of the '''[[#Inverse Matrix|Inverse Index]] array'''. These serve '''unknown''' purpose.<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| '''[[#Bone|Bone]] [[BFRES (File Format)#Index Group|index group]]''' offset. Named pointers to the members of the '''Bone array''' to allow named lookups.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''[[#Bone|Bone]] array''' offset. Offset to the first element in the Bone array.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''[[#Inverse Matrix|Inverse Index]] array''' offset. Offset to the first element in the Inverse Index array. Always given even if the array is empty.<br />
|-<br />
| 0x1c<br />
| 4<br />
| '''[[#Inverse Matrix|Inverse Matrix]] array''' offset. Offset to the first element in the Inverse Matrix array. Always given even if the array is empty.<br />
|-<br />
| 0x20<br />
| 4<br />
| Padding, always '''0'''.<br />
|-<br />
| 0x24<br />
| colspan="2" {{Unknown|End of FSKL header}}<br />
|}<br />
<br />
=== Bone ===<br />
<br />
A '''Bone''' is a repeating 0x30 byte structure which descibes a transformation to apply to a polygon. Each bone has up to four parents, which form a tree called a skeleton. To compute the final transformation of a point, apply the transformation required by the bone it is attached to, then that bone's parent recursively up until no parents remain. The '''Bone''' tree is stored as an array with offset and length specified by the '''[[#Header (FSKL)|FSKL header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Name offset''' for this bone.<br />
|-<br />
| 0x04<br />
| 2<br />
| '''Bone index''' of this bone into the bone array.<br />
|-<br />
| 0x06<br />
| 8<br />
| '''Parent indices''' of up to four parents for this bone. '''0xffff''' for no parent.<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 2<br />
| '''Flags''' controlling this bone. '''Unknown''' purpose.<br />
|-<br />
| 0x12<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x1001'''.}}<br />
|-<br />
| 0x14<br />
| 12<br />
| '''Scale Vector''' 3 floats. The amount to scale the vertices by.<br />
|-<br />
| 0x20<br />
| 12<br />
| '''Rotation Vector''' 3 floats. The amount of rotation to apply to x, y and z axis in Radians.<br />
|-<br />
| 0x2c<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''1.0f'''.}}<br />
|-<br />
| 0x30<br />
| 12<br />
| '''Translation Vector''' 3 floats. The amount to translate the vertices by.<br />
|-<br />
| 0x3c<br />
| 4<br />
| Padding, always '''0'''.<br />
|-<br />
| 0x40<br />
| colspan="2" {{Unknown|End of Bone}}<br />
|}<br />
<br />
=== Inverse Matrix ===<br />
<br />
The '''FSKL''' may specify an '''Inverse Matrix''' for any '''[[#Bone|Bone]]'''. It does this by creating an entry in the '''Invese Index''' array which is the index of the bone, and in the corresponding place in the '''Inverse Matrix array''' it places a 4&times;3 transformation matrix which reverses the full transformation of the bone and all its parents. Inverse Matricies are optional, it is '''Unknown''' if they are ever referenced. The position of and number of elements in the '''Inverse Matrix array''' and the '''Inverse Index array''' are given in the [[#Header (FSKL)|FSKL Header]]. At the end of the '''Inverse Index array''' are a number of extra indices, which have '''Unkonwn''' purpose. The number of such extra indices is also present in the [[#Header (FSKL)|FSKL Header]].<br />
<br />
== FSHP ==<br />
<br />
The model may have one or more '''FSHP''' sections which describe the one polygon (e.g. the road of a track). The FSHP section consists of an 0x40 byte header, which references an '''[[#FVTX|FVTX]]''' section and indices of the polygons to draw. A basic '''FSHP''' amounts to a list of indices into the corresponding '''FVTX''' indicating which points to draw triangles between. The '''FSHP''' also references an '''[[#FMAT|FMAT]]''' to describe the material of the triangles, and an '''[[#FSKL|FSKL]]''' to indicate the bone structure of the model used in animation.<br />
<br />
=== Header (FSHP) ===<br />
<br />
Every '''FSHP''' begins with an 0x40 byte header. This references other data structures which describe the polygon.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FSHP'''" section identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Polygon name''' offset.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''2'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Section Index''' or '''[[#FVTX|FVTX]] Index'''. In every [[Mario Kart 8]] model these numbers are the same.<br />
|-<br />
| 0x0e<br />
| 2<br />
| '''[[#FMAT|FMAT]] Index'''. Index of the material for this polygon.<br />
|-<br />
| 0x10<br />
| 2<br />
| '''[[#FSKL|FSKL]] Index''' of the bone for this polygon.<br />
|-<br />
| 0x12<br />
| 2<br />
| '''Section Index''' or '''[[#FVTX|FVTX]] Index'''. In every [[Mario Kart 8]] model these numbers are the same.<br />
|-<br />
| 0x14<br />
| 2<br />
| '''FSKL Index Array Count'''. Often zero, '''Unknown''' purpose but seems to be related to '''FSKL'''.<br />
|-<br />
| 0x16<br />
| 1<br />
| {{Unknown|'''Unknown''': If '''FSKL Index Array''' is present this tends to be non-zero. Zero otherwise.}}<br />
|-<br />
| 0x17<br />
| 1<br />
| '''[[#Drawing Command|Drawing Command]] count'''. Number of elements in the array.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''[[#Drawing Extent Tree|Drawing Extent Tree Node]] count'''.<br />
|-<br />
| 0x1c<br />
| 4<br />
| {{Unknown|'''Unknown''' floating point.}}<br />
|-<br />
| 0x20<br />
| 4<br />
| '''[[#FVTX|FVTX]] offset''' to the vertex buffer for this polygon.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''[[#Drawing Command|Drawing Command]] offset'''. Offset to the first element in the array.<br />
|-<br />
| 0x28<br />
| 4<br />
| '''FSKL Index Array Offset'''. Each element of this array is a 16 bit index.<br />
|-<br />
| 0x2c<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x30<br />
| 4<br />
| '''[[#Drawing Extent Tree|Drawing Extent Tree Nodes]] offset'''.<br />
|-<br />
| 0x34<br />
| 4<br />
| '''[[#Drawing Extent Tree|Drawing Extent Tree Ranges]] offset'''.<br />
|-<br />
| 0x38<br />
| 4<br />
| '''[[#Drawing Extent Tree|Drawing Extent Tree Indices]] offset'''.<br />
|-<br />
| 0x3c<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x40<br />
| colspan="2" {{Unknown|End of FSHP header}}<br />
|}<br />
<br />
=== Drawing Command ===<br />
<br />
A '''Drawing Command''' is a repeating 0x1c byte structure which are stored in a sequential array with location and size specified by the '''FSHP Header'''<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''4'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''4'''.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Count''' of points drawn in all [[#Drawing Extent|Drawing Extent]]s.<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''[[#Drawing Extent|Drawing Extent]] count'''. The number of elements in the array.<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| '''[[#Drawing Extent|Drawing Extent]] offset'''. Offset to the first element in the array.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''[[#Index Buffer|Index Buffer]] offset'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Skip Vertices''': the number of elements to skip in the corresponding '''FVTX''' buffer.<br />
|-<br />
| 0x1c<br />
| colspan="2" {{Unknown|End of Drawing Command}}<br />
|}<br />
<br />
=== Drawing Extent ===<br />
<br />
A '''Drawing Extent''' is a repeating 0x8 byte structure describing an offset and a count in the corresponding [[#Index Buffer|Index Buffer]]. Drawing Extents are stored in a sequential array with location and count indicated by the corresponding [[#Drawing Command|Drawing Command]]. This allows multiple separate drawing commands to be issued using the same Index Buffer. In many cases, a single extent is used which simply draws the entire Index Buffer.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Offset''' into index buffer in bytes.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Count''' of the points to draw.<br />
|-<br />
| 0x08<br />
| colspan="2" {{Unknown|End of Drawing Extent}}<br />
|}<br />
<br />
=== Index Buffer ===<br />
<br />
An '''Index Buffer''' is an 0x18 byte structure which describes a list of 16 bit values which are used to index the '''FVTX''' section when drawing the polygon. Index Buffers are referenced by [[#Drawing Command|Drawing Command]]s. The format is very similar to the [[#Buffers|FVTX Buffer]] format, which may indicate they are instances of the same structure.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size''' of index data in bytes.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' Always '''1'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Index data offset'''.<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of Index Buffer}}<br />
|}<br />
<br />
=== Drawing Extent Tree ===<br />
<br />
The '''Drawing Extent Tree''' is some sort of tree structure that occurs in all FSHP sections. In all [[Mario Kart 8]] files, when the '''FSHP''' has multiple [[#Drawing Command|Drawing Command]]s, the Drawing Extent Tree is a trivial one node tree. The Drawing Extent Tree may be used to control which [[#Drawing Extent|Drawing Extent]]s need to be drawn, for example as part of a dynamic level of detail system. The true workings and purpose of the structure are however unknown.<br />
<br />
==== Nodes ====<br />
<br />
The '''Drawing Extent Tree Node''' is a repeating 0xc byte structure. The nodes form a binary tree. The [[#FSHP|FSHP header]] contains a pointer to node array, as well as specifying its length. The root node is the first node in this array. Each node specifies a range of Drawing Extents, with the root node always covering all nodes, and the children of each node always selecting disjoint subsets of that node's range.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 2<br />
| '''Left Child''' index. The current node's index if it has no left child.<br />
|-<br />
| 0x02<br />
| 2<br />
| '''Right Child''' index. The current node's index if it has no right child.<br />
|-<br />
| 0x04<br />
| 2<br />
| '''Unknown''' always the same as '''Left Child''' index.<br />
|-<br />
| 0x06<br />
| 2<br />
| '''Next Sibling''' index. For left children, always the current node's parent's right child (the current node's index if it has no right child).<br />
|-<br />
| 0x08<br />
| 2<br />
| '''[[#Drawing Extent|Drawing Extent]] Index''' selects a range of Drawing Extents along with the count.<br />
|-<br />
| 0x0a<br />
| 2<br />
| '''[[#Drawing Extent|Drawing Extent]] Count''' selects a range of Drawing Extents along with the index.<br />
|-<br />
| 0x0c<br />
| colspan="2" {{Unknown|End of Node}}<br />
|}<br />
<br />
==== Ranges ====<br />
<br />
The '''Drawing Extent Tree Range''' is a repeating 0x18 byte structure. The purpose is unknown. There are exactly as many Ranges as Nodes. The range appears to contain two 3D positions, which are not necessarily distinct.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 12<br />
| {{Unknown|'''Unknown''' 3D position (x,y,z float).}}<br />
|-<br />
| 0x0c<br />
| 12<br />
| {{Unknown|'''Unknown''' 3D position (x,y,z float).}}<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of Range}}<br />
|}<br />
<br />
==== Indices ====<br />
<br />
The '''Drawing Extent Tree Index''' array is an array of 16 bit values which appear to be the index of the leaf node of the '''Drawing Extent Tree''' which contains the corresponding '''[[#Drawing Extent|Drawing Extent]]'''. Therefore this array has length equal to the number of [[#Drawing Extent|Drawing Extent]]s in the '''FSHP''' section.<br />
<br />
== Parameter ==<br />
<br />
A '''Parameter''' is an 0xc byte structure which describes the value of some model parameter. It is only used in a handful of [[Mario Kart 8]] models to set the value of "ParticleLimit". A '''Parameter''' structure is referenced by the '''Parameter index group''' in the '''[[#Header (FMDL)|FMDL Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Variable Name''' offset.<br />
|-<br />
| 0x04<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''1'''.}}<br />
|-<br />
| 0x06<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Value''' of the variable (floating point).<br />
|-<br />
| 0xc<br />
| colspan="2" {{Unknown|End of Parameter}}<br />
|}<br />
<br />
[[Category:File Format]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=FMDL_(File_Format)&diff=921FMDL (File Format)2014-08-11T10:29:23Z<p>Chadderz: /* FMAT */ New section based on initial analysis.</p>
<hr />
<div>{{under-construction}}<br />
<br />
The '''FMDL''' model format is a format for models which appears as a subfile of a '''[[BFRES (File Format)|BFRES file]]''' in the '''0'''th file group. Typically a BFRES file has one FMDL but some have none and some have more than one.<br />
<br />
__TOC__<br />
<br />
= Format =<br />
<br />
An '''FMDL file''' begins with an '''FMDL header'''. This is then followed by a number of sections pointed to by the header, many of which can occur multiple times. The purpose of these sections is described in the table below. Unless otherwise noted, all offsets in BFRES files are relative to themselves, not the beginning of the file which is more common in other formats.<br />
<br />
{| class="wikitable"<br />
! Section<br />
! Purpose<br />
|-<br />
| [[#FVTX|FVTX]]<br />
| Describes an array of array of vertices which can have a number of attributes including position, normal, colour and texture coordinates.<br />
|-<br />
| [[#FMAT|FMAT]]<br />
| Describes the properties of a surface necessary to draw it including texture information.<br />
|-<br />
| [[#FSKL|FSKL]]<br />
| Describes a skeleton for the model which may be used in animations.<br />
|-<br />
| [[#FSHP|FSHP]]<br />
| Selects triples of vertices from one [[#FVTX|FVTX]] section to draw triangles between. Also specifies the [[#FMAT|FMAT]] material and the [[#FSKL|FSKL]] attachment of the triangles.<br />
|-<br />
| [[#Parameter|Parameter]]<br />
| Sets a named paramter for the model.<br />
|}<br />
<br />
== Header (FMDL) ==<br />
<br />
Every FMDL begins with an 0x2c byte '''FMDL header'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FMDL'''" file identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''File name''' offset (without file extension).<br />
|-<br />
| 0x08<br />
| 4<br />
| '''End of BFRES string table''' offset. Points to just after the last string in the string table.<br />
|-<br />
| 0x0c<br />
| 4<br />
| '''[[#FSKL|FSKL]]''' offset. Offset to the '''FSKL Header'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''[[#FVTX|FVTX]] array''' offset. Offset to the first element in an array of '''FVTX Header'''s.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''[[#FSHP|FSHP]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to an index group which contains named pointers to '''FSHP Header'''s.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''[[#FMAT|FMAT]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to an index group which contains named pointers to '''FMAT Header'''s.<br />
|-<br />
| 0x1c<br />
| 4<br />
| '''[[#Parameter|Parameter]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to an index group which contains named pointers to parameter values. May be '''0''' if no parameters exist (common).<br />
|-<br />
| 0x20<br />
| 2<br />
| '''[[#FVTX|FVTX]] count''': number of FVTX sections in the '''FVTX array'''.<br />
|-<br />
| 0x22<br />
| 2<br />
| '''[[#FSHP|FSHP]] count''': number of FSHP sections in the the '''FSHP index group'''.<br />
|-<br />
| 0x24<br />
| 2<br />
| '''[[#FMAT|FMAT]] count''': number of FMAT sections in the the '''FMAT index group'''.<br />
|-<br />
| 0x26<br />
| 2<br />
| '''[[#Parameter|Parameter]] count''': number of parameters in the '''Parameter index group'''.<br />
|-<br />
| 0x28<br />
| 4<br />
| {{Unknown|'''Unknown''' possibly something like an unused face count.}}<br />
|-<br />
| 0x2c<br />
| colspan="2" {{Unknown|End of FMDL header}}<br />
|}<br />
<br />
== FVTX ==<br />
<br />
The model may have one or more '''FVTX''' sections which describe the vertices for one polygon (e.g. the road of a track). The section describes a series of buffers and attributes. Buffers are arrays of arbitrary elements which contain the actual values of the vertices and are passed directly to the graphics card. Attributes are properties of vertices (e.g. position, texture coordinate, vertex colours) and they describe the format and layout of the elements in the buffers.<br />
<br />
=== Header (FVTX) ===<br />
<br />
Each FVTX section has a 0x20 byte header. These headers are stored sequentially in an array at the offset given in the '''FMDL header'''. The length of this array is also given in that header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FVTX'''" section identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 1<br />
| '''[[#Attributes|Attribute]] count''': number of different attributes (position, normal, colour, etc) in the attribute array.<br />
|-<br />
| 0x05<br />
| 1<br />
| '''[[#Buffers|Buffer]] count''': number of attribute buffers in the buffer array.<br />
|-<br />
| 0x06<br />
| 2<br />
| '''Section index''': index into FVTX array of this entry.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Number of vertices'''. This is also the number of elements in each buffer.<br />
|-<br />
| 0x0c<br />
| 1<br />
| {{Unknown|'''Unknown'''; values seen are between '''0''' and '''4''' (normally '''0''').}}<br />
|-<br />
| 0x0d<br />
| 3<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| '''[[#Attributes|Attribute]] array''' offset. Offset to the first element in the Attribute array.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''[[#Attributes|Attribute]] [[BFRES (File Format)#Index Group|index group]]''' offset. Named pointers to the members of the '''Attribute array''' to allow named lookups.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''[[#Buffers|Buffer]] array''' offset. Offset to the first element in the Buffer array.<br />
|-<br />
| 0x1c<br />
| 4<br />
| Padding, always '''0'''.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of FVTX header}}<br />
|}<br />
<br />
=== Attributes ===<br />
<br />
The '''attributes''' of each '''FVTX''' section are stored as a simple repeating 0xc byte structure. These are stored in an array with location and length specified by the FVTX header. They are also referenced by the attribute index group, presumably to allow both index and name based lookup of attributes.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Attribute name''' offset.<br />
|-<br />
| 0x04<br />
| 1<br />
| '''Buffer index''' of the buffer containing this attribute.<br />
|-<br />
| 0x05<br />
| 3<br />
| '''Buffer offset''' of the attribute in each element in the buffer.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Format''' of the attribute's data in the buffer.<br />
|-<br />
| 0xc<br />
| colspan="2" {{Unknown|End of attribute}}<br />
|}<br />
<br />
The following values have been seen for the '''Format''' field. This list is not exhaustive.<br />
<br />
{| class="wikitable"<br />
! Format<br />
! Data Size<br />
! Description<br />
|-<br />
| 0x00000004<br />
| 2<br />
| Two 8 bit values representing numbers between 0 and 1.<br />
|-<br />
| 0x00000007<br />
| 4<br />
| Two 16 bit values representing numbers between 0 and 1.<br />
|-<br />
| 0x0000020a<br />
| 4<br />
| Four signed 8 bit values.<br />
|-<br />
| 0x0000020b<br />
| 4<br />
| {{Unknown|'''Unknown'''. Used for normals.}}<br />
|-<br />
| 0x0000080d<br />
| 8<br />
| Two 32 bit floating point values.<br />
|-<br />
| 0x0000080f<br />
| 8<br />
| Four [http://en.wikipedia.org/wiki/Half_precision 16 bit floating point] values.<br />
|-<br />
| 0x00000811<br />
| 12<br />
| Three 32 bit floating point values.<br />
|}<br />
<br />
Based on the some of the shader code in [[Filesystem/content/mapobj/PackunMusic#Files|/vol/content/mapobj/PackunMusic/PackunMusic.bfres]] the following naming convention seems to be used for attributes.<br />
<br />
{| class="wikitable"<br />
! Attribute Name<br />
! Friendly Name<br />
! Description<br />
|-<br />
| _p0<br />
| position0<br />
| The position of the vertex.<br />
|-<br />
| _n0<br />
| normal0<br />
| The normal of the vertex as used in lighting calculations.<br />
|-<br />
| _t0<br />
| tangent0<br />
| The tangent of the vertex as used in advanced lighting calculations.<br />
|-<br />
| _b0<br />
| binormal0<br />
| The binormal of the vertex as used in advanced lighting calculations.<br />
|-<br />
| _w0<br />
| blendweight0<br />
| {{Unknown}}<br />
|-<br />
| _i0<br />
| blendindex0<br />
| {{Unknown}}<br />
|-<br />
| _u0<br />
| uv0<br />
| rowspan="4" | Texture coordinates used for texture mapping.<br />
|-<br />
| _u1<br />
| uv1<br />
|-<br />
| _u2<br />
| uv2<br />
|-<br />
| _u3<br />
| uv3<br />
|-<br />
| _c0<br />
| color0<br />
| rowspan="2" | Vertex colours used for simple shadow mapping.<br />
|-<br />
| _c1<br />
| color1<br />
|}<br />
<br />
=== Buffers ===<br />
<br />
The '''buffers''' of each '''FVTX''' section are stored as a repeating 0x18 byte header structure which references the actual data stored later in the BFRES file. The headers are stored in an array with location and length specified by the FVTX header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size''' of the buffer in bytes.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Stride''': the size of each element in the buffer.<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''1'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Data offset'''.<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of buffer}}<br />
|}<br />
<br />
== FMAT ==<br />
<br />
The model may have one or more '''FMAT''' sections which describe surface properties of a polygon such as textures. Every polygon is rendered using a vertex shader and a pixel shader. These are pieces of code which run on the graphics card. Like any code, these have parameters which is principally what the '''FMAT''' section controls. There are many different ways for the '''FMAT''' section to set variables in the shader code, but it remains '''unknown''' what the reason for this is. All shader parameters are either uniform or attributes. Attribute parameters vary per vertex or pixel, whereas uniform parameters are global. The '''FMAT''' must specify values for all uniform parameters, and specifies a mapping between vertex attributes in the corresponding '''[[#FVTX|FVTX]] sections''' and attribute parameters for both the pixel and vertex shader. In [[Mario Kart 8]] most models reference the same pixel shader and the same vertex shader, both called Turbo_UBER. Turbo_UBER is totally generic and has hundreds of parameters to configure the rendering. The source code for Turbo_UBER seems to be available in [[Filesystem/content/mapobj/PackunMusic#Files|/vol/content/mapobj/PackunMusic/PackunMusic.bfres]].<br />
<br />
=== Header (FMAT) ===<br />
<br />
Every FMAT begins with an 0x48 byte header structure. This references the other structures documented here to describe the material.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FMAT'''" section identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Material name''' offset.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''1'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Section Index''' of this material.<br />
|-<br />
| 0x0e<br />
| 2<br />
| '''[[#Render Info Parameter|Render Info Parameter]] Count'''. Number of elements in the Render Info Parameter index group.<br />
|-<br />
| 0x10<br />
| 1<br />
| '''[[#Texture Selector|Texture Selector]] Count'''. Number of elements in the Texture Selector array.<br />
|-<br />
| 0x11<br />
| 1<br />
| '''[[#Attribute Selector|Attribute Selector]] Count'''. Number of elements in the Attribute Selector array.<br />
|-<br />
| 0x12<br />
| 2<br />
| '''[[#Material Parameter|Material Parameter]] Count'''. Number of elements in the Material Parameter array.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''[[#Material Parameter|Material Parameter]] Data Size''' in bytes. The size of the Material Parameter Data section.<br />
|-<br />
| 0x18<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0''', '''1''' or '''2'''.}}<br />
|-<br />
| 0x1c<br />
| 4<br />
| '''[[#Render Info Parameter|Render Info Parameter]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to the index group defining render info parameters.<br />
|-<br />
| 0x20<br />
| 4<br />
| '''[[#Unknown Material Structure|Unknown Material Structure]] offset'''. Offset to the unknown material structure.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''[[#Shader Control|Shader Control]]''' offset. Offset to the shader control structure.<br />
|-<br />
| 0x28<br />
| 4<br />
| '''[[#Texture Selector|Texture Selector]]''' offset. Offset to the first element in the Texture Selector array.<br />
|-<br />
| 0x2c<br />
| 4<br />
| '''[[#Attribute Selector|Attribute Selector]]''' offset. Offset to the first element in the Attribute Selector array.<br />
|-<br />
| 0x30<br />
| 4<br />
| '''[[#Attribute Selector|Attribute Selector]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to an index group which references the Attribute Selector array, to allow named value lookups.<br />
|-<br />
| 0x34<br />
| 4<br />
| '''[[#Material Parameter|Material Parameter]]''' array offset. Offset to the first element in the Material Parameter array.<br />
|-<br />
| 0x38<br />
| 4<br />
| '''[[#Material Parameter|Material Parameter]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to an index group which references the Material Parameter array, to allow named value lookups.<br />
|-<br />
| 0x3c<br />
| 4<br />
| '''[[#Material Parameter|Material Parameter]] Data''' offset. Offset to the beggining of the values for Material Parameters. The '''Material Parameter array''' references this data.<br />
|-<br />
| 0x40<br />
| 4<br />
| '''[[#Shadow Parameter|Shadow Parameter]] [[BFRES (File Format)#Index Group|index group]]''' offset. May be '''0''' if not needed.<br />
|-<br />
| 0x44<br />
| 4<br />
| {{Unknown|'''Unknown''' offset. Always points to 12 bytes, all 0. Offset may be '''0''' if not needed.}}<br />
|-<br />
| 0x48<br />
| colspan="2" {{Unknown|End of FMAT Header}}<br />
|}<br />
<br />
=== Render Info Parameter ===<br />
<br />
A '''Render Info Parameter''' is a repeating structure of at least 0x8 bytes, each of which describes the value to assign to a render info variable in the shader code. Render info variables are always uniform variables. The '''Render Info Parameter''' structures are referenced by the '''Render Info Parameter index group''' in the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0''' or '''1'''.}}<br />
|-<br />
| 0x02<br />
| 1<br />
| '''Type''' of the variable.<br />
|-<br />
| 0x03<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Variable Name''' offset.<br />
|-<br />
| 0x08<br />
| Varies<br />
| '''Value''' of the variable.<br />
|-<br />
| Varies<br />
| colspan="2" {{Unknown|End of Render Info Parameter}}<br />
|}<br />
<br />
The '''Type''' field has values as follows.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Value Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 8<br />
| {{Unknown|'''Unknown''' data always '''0'''?}}<br />
|-<br />
| 0x01<br />
| 8<br />
| {{Unknown|'''Unknown''' vector of 2 floats?}}<br />
|-<br />
| 0x02<br />
| 4<br />
| Offset to a string.<br />
|}<br />
<br />
=== Texture Selector ===<br />
<br />
A '''Texture Selector''' is a repeating 0x8 byte structure each of which references a single '''[[FTEX (File Format)|FTEX texture]]'''. The length and position of the '''Texture Selector''' array is specified by the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Texture Name''' offset. The same as the '''FTEX''' name.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''[[FTEX (File Format)|FTEX]]''' offset. Points to the header of the '''FTEX'''.<br />
|-<br />
| 0x08<br />
| colspan="2" {{Unknown|End of Texture Selector}}<br />
|}<br />
<br />
=== Attribute Selector ===<br />
<br />
An '''Attribute Selector''' is a repeating 0x18 byte structure each of which describes one of the inputs to the pixel shader from the original stream of vertices. The length and position of the '''Attribute Selector''' array is specified by the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''2'''.}}<br />
|-<br />
| 0x01<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''0x00''', '''0x02''', '''0x04''' or '''0x12'''.}}<br />
|-<br />
| 0x02<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''0x00''', '''0x10''', '''0x12''' or '''0x5a'''.}}<br />
|-<br />
| 0x03<br />
| 1<br />
| {{Unknown|'''Unknown''' usually either near '''0''' or near '''0x80'''. Could be flags?}}<br />
|-<br />
| 0x04<br />
| 1<br />
| {{Unknown|'''Unknown''' signed integer normally close to 0.}}<br />
|-<br />
| 0x05<br />
| 1<br />
| {{Unknown|'''Unknown''' typically small value.}}<br />
|-<br />
| 0x06<br />
| 2<br />
| {{Unknown|'''Unknown''' probably flags.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0x80000000'''.}}<br />
|-<br />
| 0x0c<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Attribute Name''' offset.<br />
|-<br />
| 0x14<br />
| 1<br />
| '''Index''' of this element.<br />
|-<br />
| 0x15<br />
| 3<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of data}}<br />
|}<br />
<br />
=== Material Parameter ===<br />
<br />
A '''Material Parameter''' is a repeating 0x14 byte structure each of which describes the value to assign to a material variable in the shader code. Material variables are always uniform variables. The length and position of the '''Material Parameter''' array is controlled by the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
Sometimes, the '''Material Parameter''' structure is shorter or longer than 0x14 bytes. This seems to be consistent across entire model files. It is currently '''unknown''' why this occurs, or the correct way to detect it. It is rare in [[Mario Kart 8]] (affecting only 6 models).<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 1<br />
| '''Type''' of the variable.<br />
|-<br />
| 0x01<br />
| 1<br />
| '''Size''' of the value in bytes.<br />
|-<br />
| 0x02<br />
| 2<br />
| '''Offset''' relative to the start of the '''Material Parameter Data''' section to the value.<br />
|-<br />
| 0x04<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0xffffffff'''.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Parameter Index''' into the Material Parameter array.<br />
|-<br />
| 0x0e<br />
| 2<br />
| Same value as '''Parameter Index''' again.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Variable Name''' offset.<br />
|-<br />
| 0x14<br />
| colspan="2" {{Unknown|End of Material Parameter}}<br />
|}<br />
<br />
The '''Type''' field has values as follows.<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Size<br />
! Description<br />
|-<br />
| 0x04<br />
| 4<br />
| Signed Integer.<br />
|-<br />
| 0x0c<br />
| 4<br />
| Floating point value.<br />
|-<br />
| 0x0d<br />
| 8<br />
| Vector of 2 floats.<br />
|-<br />
| 0x0e<br />
| 12<br />
| Vector of 3 floats.<br />
|-<br />
| 0x0f<br />
| 16<br />
| Vector of 4 floats.<br />
|-<br />
| 0x1e<br />
| 24<br />
| 2&times;3 Texutre Matrix. Encoded down columns then along rows, so the identity matrix would be encoded '''1, 0, 0, 1, 0, 0'''.<br />
|}<br />
<br />
=== Unknown Material Structure ===<br />
<br />
A '''Unknown Material''' structure is a 0x30 byte structure with unknown purpose. A '''Unknown Material''' structure is referenced by the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' always less than '''0x14'''.}}<br />
|-<br />
| 0x04<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x0028'''.}}<br />
|-<br />
| 0x06<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x0240''', '''0x0242''' or '''0x0243'''.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0x49749732''' or '''0x49749736'''.}}<br />
|-<br />
| 0x0c<br />
| 4<br />
| {{Unknown|'''Unknown''' always less than '''0xe'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| {{Unknown|'''Unknown''' floating point always less than '''1.0'''.}}<br />
|-<br />
| 0x14<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x00cc'''.}}<br />
|-<br />
| 0x16<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x0000''' or '''0x0100'''.}}<br />
|-<br />
| 0x18<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x1c<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''0x2001'''.}}<br />
|-<br />
| 0x1e<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''1''' or '''5'''.}}<br />
|-<br />
| 0x1f<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''1''' or '''4'''.}}<br />
|-<br />
| 0x20<br />
| 16<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x30<br />
| colspan="2" {{Unknown|End of Unknown Material Structure}}<br />
|}<br />
<br />
=== Shader Control ===<br />
<br />
A '''Shader Control''' structure is a 0x1c byte structure which describe the shader to be used by a material. A '''Shader Control''' structure is referenced by the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Shader Name 1''' offset?<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Shader Name 2''' offset?<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0''' or '''1'''.}}<br />
|-<br />
| 0x0c<br />
| 1<br />
| '''Vertex Shader Input Count'''. Number of elements in the Vertex Shader Input index group.<br />
|-<br />
| 0x0d<br />
| 1<br />
| '''Pixel Shader Input Count'''. Number of elements in the Pixel Shader Input index group.<br />
|-<br />
| 0x0e<br />
| 2<br />
| '''Parameter Count'''. Number of elements in the Parameter index group.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Vertex Shader Input [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to the index group which forms a mapping between strings, mapping an '''FVTX''' attribute to a vertex shader variable. The names are always the same in [[Mario Kart 8]], so this mapping is just ["_p0": "_p0", "_n0": "_n0", ...]?<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Pixel Shader Input [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to the index group which forms a mapping between strings, mapping an '''FVTX''' attribute to a pixel shader variable. The names are always the same in [[Mario Kart 8]], so this mapping is just ["_p0": "_p0", "_n0": "_n0", ...]?<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Parameter [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to the index group which forms a mapping between strings, mapping a uniform shader variable to a value. The values are always strings, even for numeric parameters.<br />
|-<br />
| 0x1c<br />
| colspan="2" {{Unknown|End of Material Parameter}}<br />
|}<br />
<br />
=== Shadow Parameter ===<br />
<br />
A '''Shadow Parameter''' is a repeating 0xc byte structure, each of which describes the value to assign to a shadow variable in the shader code. Shadow variables are always uniform variables. The '''Shadow Parameter''' structures are referenced by the '''Shadow Parameter index group''' in the corresponding '''[[#Header (FMAT)|FMAT Header]]'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Variable Name''' offset.<br />
|-<br />
| 0x04<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''1'''.}}<br />
|-<br />
| 0x06<br />
| 1<br />
| {{Unknown|'''Type''' or '''Index'''?}}<br />
|-<br />
| 0x07<br />
| 1<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Value''' of the variable.<br />
|-<br />
| 0xc<br />
| colspan="2" {{Unknown|End of Shadow Parameter}}<br />
|}<br />
<br />
== FSHP ==<br />
<br />
The model may have one or more '''FSHP''' sections which describe the one polygon (e.g. the road of a track). The FSHP section consists of an 0x40 byte header, which references an '''[[#FVTX|FVTX]]''' section and indices of the polygons to draw. A basic '''FSHP''' amounts to a list of indices into the corresponding '''FVTX''' indicating which points to draw triangles between. The '''FSHP''' also references an '''[[#FMAT|FMAT]]''' to describe the material of the triangles, and an '''[[#FSKL|FSKL]]''' to indicate the bone structure of the model used in animation.<br />
<br />
=== Header (FSHP) ===<br />
<br />
Every '''FSHP''' begins with an 0x40 byte header. This references other data structures which describe the polygon.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FSHP'''" section identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Polygon name''' offset.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''2'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Section Index''' or '''[[#FVTX|FVTX]] Index'''. In every [[Mario Kart 8]] model these numbers are the same.<br />
|-<br />
| 0x0e<br />
| 2<br />
| '''[[#FMAT|FMAT]] Index'''. Index of the material for this polygon.<br />
|-<br />
| 0x10<br />
| 2<br />
| '''[[#FSKL|FSKL]] Index''' of the bone for this polygon.<br />
|-<br />
| 0x12<br />
| 2<br />
| '''Section Index''' or '''[[#FVTX|FVTX]] Index'''. In every [[Mario Kart 8]] model these numbers are the same.<br />
|-<br />
| 0x14<br />
| 2<br />
| '''FSKL Index Array Count'''. Often zero, '''Unknown''' purpose but seems to be related to '''FSKL'''.<br />
|-<br />
| 0x16<br />
| 1<br />
| {{Unknown|'''Unknown''': If '''FSKL Index Array''' is present this tends to be non-zero. Zero otherwise.}}<br />
|-<br />
| 0x17<br />
| 1<br />
| '''[[#Drawing Command|Drawing Command]] count'''. Number of elements in the array.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''[[#Drawing Extent Tree|Drawing Extent Tree Node]] count'''.<br />
|-<br />
| 0x1c<br />
| 4<br />
| {{Unknown|'''Unknown''' floating point.}}<br />
|-<br />
| 0x20<br />
| 4<br />
| '''[[#FVTX|FVTX]] offset''' to the vertex buffer for this polygon.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''[[#Drawing Command|Drawing Command]] offset'''. Offset to the first element in the array.<br />
|-<br />
| 0x28<br />
| 4<br />
| '''FSKL Index Array Offset'''. Each element of this array is a 16 bit index.<br />
|-<br />
| 0x2c<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x30<br />
| 4<br />
| '''[[#Drawing Extent Tree|Drawing Extent Tree Nodes]] offset'''.<br />
|-<br />
| 0x34<br />
| 4<br />
| '''[[#Drawing Extent Tree|Drawing Extent Tree Ranges]] offset'''.<br />
|-<br />
| 0x38<br />
| 4<br />
| '''[[#Drawing Extent Tree|Drawing Extent Tree Indices]] offset'''.<br />
|-<br />
| 0x3c<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x40<br />
| colspan="2" {{Unknown|End of FSHP header}}<br />
|}<br />
<br />
=== Drawing Command ===<br />
<br />
A '''Drawing Command''' is a repeating 0x1c byte structure which are stored in a sequential array with location and size specified by the '''FSHP Header'''<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''4'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''4'''.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Count''' of points drawn in all [[#Drawing Extent|Drawing Extent]]s.<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''[[#Drawing Extent|Drawing Extent]] count'''. The number of elements in the array.<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| '''[[#Drawing Extent|Drawing Extent]] offset'''. Offset to the first element in the array.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''[[#Index Buffer|Index Buffer]] offset'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Skip Vertices''': the number of elements to skip in the corresponding '''FVTX''' buffer.<br />
|-<br />
| 0x1c<br />
| colspan="2" {{Unknown|End of Drawing Command}}<br />
|}<br />
<br />
=== Drawing Extent ===<br />
<br />
A '''Drawing Extent''' is a repeating 0x8 byte structure describing an offset and a count in the corresponding [[#Index Buffer|Index Buffer]]. Drawing Extents are stored in a sequential array with location and count indicated by the corresponding [[#Drawing Command|Drawing Command]]. This allows multiple separate drawing commands to be issued using the same Index Buffer. In many cases, a single extent is used which simply draws the entire Index Buffer.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Offset''' into index buffer in bytes.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Count''' of the points to draw.<br />
|-<br />
| 0x08<br />
| colspan="2" {{Unknown|End of Drawing Extent}}<br />
|}<br />
<br />
=== Index Buffer ===<br />
<br />
An '''Index Buffer''' is an 0x18 byte structure which describes a list of 16 bit values which are used to index the '''FVTX''' section when drawing the polygon. Index Buffers are referenced by [[#Drawing Command|Drawing Command]]s. The format is very similar to the [[#Buffers|FVTX Buffer]] format, which may indicate they are instances of the same structure.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size''' of index data in bytes.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' Always '''1'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Index data offset'''.<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of Index Buffer}}<br />
|}<br />
<br />
=== Drawing Extent Tree ===<br />
<br />
The '''Drawing Extent Tree''' is some sort of tree structure that occurs in all FSHP sections. In all [[Mario Kart 8]] files, when the '''FSHP''' has multiple [[#Drawing Command|Drawing Command]]s, the Drawing Extent Tree is a trivial one node tree. The Drawing Extent Tree may be used to control which [[#Drawing Extent|Drawing Extent]]s need to be drawn, for example as part of a dynamic level of detail system. The true workings and purpose of the structure are however unknown.<br />
<br />
==== Nodes ====<br />
<br />
The '''Drawing Extent Tree Node''' is a repeating 0xc byte structure. The nodes form a binary tree. The [[#FSHP|FSHP header]] contains a pointer to node array, as well as specifying its length. The root node is the first node in this array. Each node specifies a range of Drawing Extents, with the root node always covering all nodes, and the children of each node always selecting disjoint subsets of that node's range.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 2<br />
| '''Left Child''' index. The current node's index if it has no left child.<br />
|-<br />
| 0x02<br />
| 2<br />
| '''Right Child''' index. The current node's index if it has no right child.<br />
|-<br />
| 0x04<br />
| 2<br />
| '''Unknown''' always the same as '''Left Child''' index.<br />
|-<br />
| 0x06<br />
| 2<br />
| '''Next Sibling''' index. For left children, always the current node's parent's right child (the current node's index if it has no right child).<br />
|-<br />
| 0x08<br />
| 2<br />
| '''[[#Drawing Extent|Drawing Extent]] Index''' selects a range of Drawing Extents along with the count.<br />
|-<br />
| 0x0a<br />
| 2<br />
| '''[[#Drawing Extent|Drawing Extent]] Count''' selects a range of Drawing Extents along with the index.<br />
|-<br />
| 0x0c<br />
| colspan="2" {{Unknown|End of Node}}<br />
|}<br />
<br />
==== Ranges ====<br />
<br />
The '''Drawing Extent Tree Range''' is a repeating 0x18 byte structure. The purpose is unknown. There are exactly as many Ranges as Nodes. The range appears to contain two 3D positions, which are not necessarily distinct.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 12<br />
| {{Unknown|'''Unknown''' 3D position (x,y,z float).}}<br />
|-<br />
| 0x0c<br />
| 12<br />
| {{Unknown|'''Unknown''' 3D position (x,y,z float).}}<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of Range}}<br />
|}<br />
<br />
==== Indices ====<br />
<br />
The '''Drawing Extent Tree Index''' array is an array of 16 bit values which appear to be the index of the leaf node of the '''Drawing Extent Tree''' which contains the corresponding '''[[#Drawing Extent|Drawing Extent]]'''. Therefore this array has length equal to the number of [[#Drawing Extent|Drawing Extent]]s in the '''FSHP''' section.<br />
<br />
[[Category:File Format]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=Yaz0&diff=899Yaz02014-08-11T08:04:51Z<p>Chadderz: Created redirect to mkw:YAZ0 (File Format).</p>
<hr />
<div>#redirect [[mkw:YAZ0 (File Format)]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=YAZ0&diff=898YAZ02014-08-11T08:04:34Z<p>Chadderz: Created redirect to mkw:YAZ0 (File Format).</p>
<hr />
<div>#redirect [[mkw:YAZ0 (File Format)]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=SARC_(File_Format)&diff=896SARC (File Format)2014-08-11T08:01:53Z<p>Chadderz: Added .bgenv explanation to summary.</p>
<hr />
<div>'''SARC Files''' are uncompressed archive files used in [[Wii U]] software, 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, .sarc, .pack, and .bars. The '''.bars''' extension is commonly used when the archive contains audio data. The '''.bgenv''' extension is commonly used when the archive contains shader 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 archive beings 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 || '''Byte order mark''' (BOM): 0xFE,0xFF for big endian and 0xFF,0xFE for little endian. <br />
|-<br />
| 0x08 || 4 || '''File size''' of the entire archive in bytes.<br />
|-<br />
| 0x0c || 4 || '''Beginning of data''' offset.<br />
|-<br />
| 0x10 || 4 || {{Unknown|'''Unknown'''. Always '''0x01000000'''?}}<br />
|-<br />
| 0x14 || colspan=2 {{Unknown|End of '''SARC''' header}}<br />
|-<br />
|}<br />
<br />
== File Table ==<br />
Unlike the U8 format, SARC does generally not contain directory nodes (though files may reside inside subfolders). It is currently unknown if it is able to.<br />
<br />
=== Header (SFAT) ===<br />
The '''SARC Header''' is immediately followed by 0xc 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 || {{Unknown|'''Unknown.''' Always '''0x00000065'''?}}<br />
|-<br />
| 0x0c || colspan=2 {{Unknown|End of '''SFAT''' header}}<br />
|-<br />
|}<br />
<br />
=== Node ===<br />
The '''SFAT Header''' is followed by an array of 0x10 byte '''SFAT Node''' structures.<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Description<br />
|-<br />
| 0x00 || 4 || {{Unknown|'''Unknown.''' Could plausibly be an ID of some sort, the files are encoded sorted by this value, so perhaps even a hash of the name.}}<br />
|-<br />
| 0x04 || 1 || {{Unknown|'''Unknown.''' Always '''0x01'''? Comparable to the file/folder flag from U8?}}<br />
|-<br />
| 0x05 || 3 || '''File name table entry''' offset, relative to the end of the file name table 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 />
<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 0x8 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 || {{Unknown|'''Unknown.''' Always '''0'''?}}<br />
|-<br />
| 0x08 || colspan=2 {{Unknown|End of '''SFNT''' header}}<br />
|-<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'''. There is padding between the files for 256-byte (0x100) alignment.<br />
<br />
= Tools =<br />
<br />
The following tool can extract SARC files:<br />
<br />
* SARCUnpack from the [https://www.dropbox.com/sh/tfg2nd6q809oqn3/AADWk3SgQEsqnvlbplcWOfv5a CWRT] package, by [[User:Celcodioc|Celcodioc]]<br />
<br />
[[Category:File Format]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=BGENV_(File_Format)&diff=895BGENV (File Format)2014-08-11T08:00:57Z<p>Chadderz: Created redirect to SARC (File Format).</p>
<hr />
<div>#redirect [[SARC (File Format)]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=FMDL_(File_Format)&diff=890FMDL (File Format)2014-08-11T06:26:07Z<p>Chadderz: Fleshed out some of the descriptions, clarified things, standardised naming. Added some format values to FVTX.</p>
<hr />
<div>{{Under-construction}}<br />
<br />
The '''FMDL''' model format is a format for models which appears as a subfile of a '''[[BFRES (File Format)|BFRES file]]''' in the '''0'''th file group. Typically a BFRES file has one FMDL but some have none and some have more than one.<br />
<br />
__TOC__<br />
<br />
= Format =<br />
<br />
An '''FMDL file''' begins with an '''FMDL header'''. This is then followed by a number of sections pointed to by the header, many of which can occur multiple times. The purpose of these sections is described in the table below. Unless otherwise noted, all offsets in BFRES files are relative to themselves, not the beginning of the file which is more common in other formats.<br />
<br />
{| class="wikitable"<br />
! Section<br />
! Purpose<br />
|-<br />
| [[FMDL (File Format)#FVTX|FVTX]]<br />
| Describes an array of array of vertices which can have a number of attributes including position, normal, colour and texture coordinates.<br />
|-<br />
| [[FMDL (File Format)#FMAT|FMAT]]<br />
| Describes the properties of a surface necessary to draw it including texture information.<br />
|-<br />
| [[FMDL (File Format)#FSKL|FSKL]]<br />
| Describes a skeleton for the model which may be used in animations.<br />
|-<br />
| [[FMDL (File Format)#FSHP|FSHP]]<br />
| Selects triples of vertices from one [[FMDL (File Format)#FVTX|FVTX]] section to draw triangles between. Also specifies the [[FMDL (File Format)#FMAT|FMAT]] material and the [[FMDL (File Format)#FSKL|FSKL]] attachment of the triangles.<br />
|-<br />
| [[FMDL (File Format)#Parameter|Parameter]]<br />
| Sets a named paramter for the model.<br />
|}<br />
<br />
== Header (FMDL) ==<br />
<br />
Every FMDL begins with an 0x2c byte '''FMDL header'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FMDL'''" file identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''File name''' offset (without file extension).<br />
|-<br />
| 0x08<br />
| 4<br />
| '''End of BFRES string table''' offset. Points to just after the last string in the string table.<br />
|-<br />
| 0x0c<br />
| 4<br />
| '''[[FMDL (File Format)#FSKL|FSKL]]''' offset. Offset to the '''FSKL Header'''.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''[[FMDL (File Format)#FVTX|FVTX]] array''' offset. Offset to the first element in an array of '''FVTX Header'''s.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''[[FMDL (File Format)#FSHP|FSHP]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to an index group which contains named pointers to '''FSHP Header'''s.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''[[FMDL (File Format)#FMAT|FMAT]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to an index group which contains named pointers to '''FMAT Header'''s.<br />
|-<br />
| 0x1c<br />
| 4<br />
| '''[[FMDL (File Format)#Parameter|Parameter]] [[BFRES (File Format)#Index Group|index group]]''' offset. Offset to an index group which contains named pointers to parameter values. May be '''0''' if no parameters exist (common).<br />
|-<br />
| 0x20<br />
| 2<br />
| '''[[FMDL (File Format)#FVTX|FVTX]] count''': number of FVTX sections in the '''FVTX array'''.<br />
|-<br />
| 0x22<br />
| 2<br />
| '''[[FMDL (File Format)#FSHP|FSHP]] count''': number of FSHP sections in the the '''FSHP index group'''.<br />
|-<br />
| 0x24<br />
| 2<br />
| '''[[FMDL (File Format)#FMAT|FMAT]] count''': number of FMAT sections in the the '''FMAT index group'''.<br />
|-<br />
| 0x26<br />
| 2<br />
| '''[[FMDL (File Format)#Parameter|Parameter]] count''': number of parameters in the '''Parameter index group'''.<br />
|-<br />
| 0x28<br />
| 4<br />
| {{Unknown|'''Unknown''' possibly something like an unused face count.}}<br />
|-<br />
| 0x2c<br />
| colspan="2" {{Unknown|End of FMDL header}}<br />
|}<br />
<br />
== FVTX ==<br />
<br />
The model may have one or more '''FVTX''' sections which describe the vertices for one polygon (e.g. the road of a track). The section describes a series of buffers and attributes. Buffers are arrays of arbitrary elements which contain the actual values of the vertices and are passed directly to the graphics card. Attributes are properties of vertices (e.g. position, texture coordinate, vertex colours) and they describe the format and layout of the elements in the buffers.<br />
<br />
=== Header (FVTX) ===<br />
<br />
Each FVTX section has a 0x20 byte header. These headers are stored sequentially in an array at the offset given in the '''FMDL header'''. The length of this array is also given in that header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FVTX'''" section identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 1<br />
| '''[[FMDL (File Format)#Attributes|Attribute]] count''': number of different attributes (position, normal, colour, etc) in the attribute array.<br />
|-<br />
| 0x05<br />
| 1<br />
| '''[[FMDL (File Format)#Buffers|Buffer]] count''': number of attribute buffers in the buffer array.<br />
|-<br />
| 0x06<br />
| 2<br />
| '''Section index''': index into FVTX array of this entry.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Number of vertices'''. This is also the number of elements in each buffer.<br />
|-<br />
| 0x0c<br />
| 1<br />
| {{Unknown|'''Unknown'''; values seen are between '''0''' and '''4''' (normally '''0''').}}<br />
|-<br />
| 0x0d<br />
| 3<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| '''[[FMDL (File Format)#Attributes|Attribute]] array''' offset. Offset to the first element in the Attribute array.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''[[FMDL (File Format)#Attributes|Attribute]] [[BFRES (File Format)#Index Group|index group]]''' offset. Named pointers to the members of the '''Attribute array''' to allow named lookups.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''[[FMDL (File Format)#Buffers|Buffer]] array''' offset. Offset to the first element in the Buffer array.<br />
|-<br />
| 0x1c<br />
| 4<br />
| Padding, always '''0'''.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of FVTX header}}<br />
|}<br />
<br />
=== Attributes ===<br />
<br />
The '''attributes''' of each '''FVTX''' section are stored as a simple repeating 0xc byte structure. These are stored in an array with location and length specified by the FVTX header. They are also referenced by the attribute index group, presumably to allow both index and name based lookup of attributes.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Attribute name''' offset.<br />
|-<br />
| 0x04<br />
| 1<br />
| '''Buffer index''' of the buffer containing this attribute.<br />
|-<br />
| 0x05<br />
| 3<br />
| '''Buffer offset''' of the attribute in each element in the buffer.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Format''' of the attribute's data in the buffer.<br />
|-<br />
| 0xc<br />
| colspan="2" {{Unknown|End of attribute}}<br />
|}<br />
<br />
The following values have been seen for the '''Format''' field. This list is not exhaustive.<br />
<br />
{| class="wikitable"<br />
! Format<br />
! Data Size<br />
! Description<br />
|-<br />
| 0x00000004<br />
| 2<br />
| Two 8 bit values representing numbers between 0 and 1.<br />
|-<br />
| 0x0000020a<br />
| 4<br />
| Four signed 8 bit values.<br />
|-<br />
| 0x0000020b<br />
| 4<br />
| {{Unknown|'''Unknown'''. Used for normals.}}<br />
|-<br />
| 0x00000007<br />
| 4<br />
| Two 16 bit values representing numbers between 0 and 1.<br />
|-<br />
| 0x0000080d<br />
| 8<br />
| Two 32 bit floating point values.<br />
|-<br />
| 0x0000080f<br />
| 8<br />
| Four [http://en.wikipedia.org/wiki/Half_precision 16 bit floating point] values.<br />
|-<br />
| 0x00000811<br />
| 12<br />
| Three 32 bit floating point values.<br />
|}<br />
<br />
Based on the some of the shader code in [[Filesystem/content/mapobj/PackunMusic#Files|/vol/content/mapobj/PackunMusic/PackunMusic.bfres]] the following naming convention seems to be used for attributes.<br />
<br />
{| class="wikitable"<br />
! Attribute Name<br />
! Friendly Name<br />
! Description<br />
|-<br />
| _p0<br />
| position0<br />
| The position of the vertex.<br />
|-<br />
| _n0<br />
| normal0<br />
| The normal of the vertex as used in lighting calculations.<br />
|-<br />
| _t0<br />
| tangent0<br />
| The tangent of the vertex as used in advanced lighting calculations.<br />
|-<br />
| _b0<br />
| binormal0<br />
| The binormal of the vertex as used in advanced lighting calculations.<br />
|-<br />
| _w0<br />
| blendweight0<br />
| {{Unknown}}<br />
|-<br />
| _i0<br />
| blendindex0<br />
| {{Unknown}}<br />
|-<br />
| _u0<br />
| uv0<br />
| rowspan="4" | Texture coordinates used for texture mapping.<br />
|-<br />
| _u1<br />
| uv1<br />
|-<br />
| _u2<br />
| uv2<br />
|-<br />
| _u3<br />
| uv3<br />
|-<br />
| _c0<br />
| color0<br />
| rowspan="2" | Vertex colours used for simple shadow mapping.<br />
|-<br />
| _c1<br />
| color1<br />
|}<br />
<br />
=== Buffers ===<br />
<br />
The '''buffers''' of each '''FVTX''' section are stored as a repeating 0x18 byte header structure which references the actual data stored later in the BFRES file. The headers are stored in an array with location and length specified by the FVTX header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size''' of the buffer in bytes.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Stride''': the size of each element in the buffer.<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''1'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Data offset'''.<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of buffer}}<br />
|}<br />
<br />
== FSHP ==<br />
<br />
The model may have one or more '''FSHP''' sections which describe the one polygon (e.g. the road of a track). The FSHP section consists of an 0x40 byte header, which references an '''[[FMDL (File Format)#FVTX|FVTX]]''' section and indices of the polygons to draw. A basic '''FSHP''' amounts to a list of indices into the corresponding '''FVTX''' indicating which points to draw triangles between. The '''FSHP''' also references an '''[[FMDL (File Format)#FMAT|FMAT]]''' to describe the material of the triangles, and an '''[[FMDL (File Format)#FSKL|FSKL]]''' to indicate the bone structure of the model used in animation.<br />
<br />
=== Header (FSHP) ===<br />
<br />
Every '''FSHP''' begins with an 0x40 byte header. This references other data structures which describe the polygon.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FSHP'''" section identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Polygon name''' offset.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''2'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Section Index''' or '''[[FMDL (File Format)#FVTX|FVTX]] Index'''. In every [[Mario Kart 8]] model these numbers are the same.<br />
|-<br />
| 0x0e<br />
| 2<br />
| '''[[FMDL (File Format)#FMAT|FMAT]] Index'''. Index of the material for this polygon.<br />
|-<br />
| 0x10<br />
| 2<br />
| '''[[FMDL (File Format)#FSKL|FSKL]] Index''' of the bone for this polygon.<br />
|-<br />
| 0x12<br />
| 2<br />
| '''Section Index''' or '''[[FMDL (File Format)#FVTX|FVTX]] Index'''. In every [[Mario Kart 8]] model these numbers are the same.<br />
|-<br />
| 0x14<br />
| 2<br />
| '''FSKL Index Array Count'''. Often zero, '''Unknown''' purpose but seems to be related to '''FSKL'''.<br />
|-<br />
| 0x16<br />
| 1<br />
| {{Unknown|'''Unknown''': If '''FSKL Index Array''' is present this tends to be non-zero. Zero otherwise.}}<br />
|-<br />
| 0x17<br />
| 1<br />
| '''[[FMDL (File Format)#Drawing Command|Drawing Command]] count'''. Number of elements in the array.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''[[FMDL (File Format)#Drawing Extent Tree|Drawing Extent Tree Node]] count'''.<br />
|-<br />
| 0x1c<br />
| 4<br />
| {{Unknown|'''Unknown''' floating point.}}<br />
|-<br />
| 0x20<br />
| 4<br />
| '''[[FMDL (File Format)#FVTX|FVTX]] offset''' to the vertex buffer for this polygon.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''[[FMDL (File Format)#Drawing Command|Drawing Command]] offset'''. Offset to the first element in the array.<br />
|-<br />
| 0x28<br />
| 4<br />
| '''FSKL Index Array Offset'''. Each element of this array is a 16 bit index.<br />
|-<br />
| 0x2c<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x30<br />
| 4<br />
| '''[[FMDL (File Format)#Drawing Extent Tree|Drawing Extent Tree Nodes]] offset'''.<br />
|-<br />
| 0x34<br />
| 4<br />
| '''[[FMDL (File Format)#Drawing Extent Tree|Drawing Extent Tree Ranges]] offset'''.<br />
|-<br />
| 0x38<br />
| 4<br />
| '''[[FMDL (File Format)#Drawing Extent Tree|Drawing Extent Tree Indices]] offset'''.<br />
|-<br />
| 0x3c<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x40<br />
| colspan="2" {{Unknown|End of FSHP header}}<br />
|}<br />
<br />
=== Drawing Command ===<br />
<br />
A '''Drawing Command''' is a repeating 0x1c byte structure which are stored in a sequential array with location and size specified by the '''FSHP Header'''<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''4'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''4'''.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Count''' of points drawn in all [[FMDL (File Format)#Drawing Extent|Drawing Extent]]s.<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''[[FMDL (File Format)#Drawing Extent|Drawing Extent]] count'''. The number of elements in the array.<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| '''[[FMDL (File Format)#Drawing Extent|Drawing Extent]] offset'''. Offset to the first element in the array.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''[[FMDL (File Format)#Index Buffer|Index Buffer]] offset'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Skip Vertices''': the number of elements to skip in the corresponding '''FVTX''' buffer.<br />
|-<br />
| 0x1c<br />
| colspan="2" {{Unknown|End of Drawing Command}}<br />
|}<br />
<br />
=== Drawing Extent ===<br />
<br />
A '''Drawing Extent''' is a repeating 0x8 byte structure describing an offset and a count in the corresponding [[FMDL (File Format)#Index Buffer|Index Buffer]]. Drawing Extents are stored in a sequential array with location and count indicated by the corresponding [[FMDL (File Format)#Drawing Command|Drawing Command]]. This allows multiple separate drawing commands to be issued using the same Index Buffer. In many cases, a single extent is used which simply draws the entire Index Buffer.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Offset''' into index buffer in bytes.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Count''' of the points to draw.<br />
|-<br />
| 0x08<br />
| colspan="2" {{Unknown|End of Drawing Extent}}<br />
|}<br />
<br />
=== Index Buffer ===<br />
<br />
An '''Index Buffer''' is an 0x18 byte structure which describes a list of 16 bit values which are used to index the '''FVTX''' section when drawing the polygon. Index Buffers are referenced by [[FMDL (File Format)#Drawing Command|Drawing Command]]s. The format is very similar to the [[FMDL (File Format)#Buffers|FVTX Buffer]] format, which may indicate they are instances of the same structure.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size''' of index data in bytes.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' Always '''1'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Index data offset'''.<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of Index Buffer}}<br />
|}<br />
<br />
=== Drawing Extent Tree ===<br />
<br />
The '''Drawing Extent Tree''' is some sort of tree structure that occurs in all FSHP sections. In all [[Mario Kart 8]] files, when the '''FSHP''' has multiple [[FMDL (File Format)#Drawing Command|Drawing Command]]s, the Drawing Extent Tree is a trivial one node tree. The Drawing Extent Tree may be used to control which [[FMDL (File Format)#Drawing Extent|Drawing Extent]]s need to be drawn, for example as part of a dynamic level of detail system. The true workings and purpose of the structure are however unknown.<br />
<br />
==== Nodes ====<br />
<br />
The '''Drawing Extent Tree Node''' is a repeating 0xc byte structure. The nodes form a binary tree. The [[FMDL (File Format)#FSHP|FSHP header]] contains a pointer to node array, as well as specifying its length. The root node is the first node in this array. Each node specifies a range of Drawing Extents, with the root node always covering all nodes, and the children of each node always selecting disjoint subsets of that node's range.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 2<br />
| '''Left Child''' index. The current node's index if it has no left child.<br />
|-<br />
| 0x02<br />
| 2<br />
| '''Right Child''' index. The current node's index if it has no right child.<br />
|-<br />
| 0x04<br />
| 2<br />
| '''Unknown''' always the same as '''Left Child''' index.<br />
|-<br />
| 0x06<br />
| 2<br />
| '''Next Sibling''' index. Always the current node's parent's right child (the current node's index if it has no right child).<br />
|-<br />
| 0x08<br />
| 2<br />
| '''[[FMDL (File Format)#Drawing Extent|Drawing Extent]] Index''' selects a range of Drawing Extents along with the count.<br />
|-<br />
| 0x0a<br />
| 2<br />
| '''[[FMDL (File Format)#Drawing Extent|Drawing Extent]] Count''' selects a range of Drawing Extents along with the index.<br />
|-<br />
| 0x0c<br />
| colspan="2" {{Unknown|End of Node}}<br />
|}<br />
<br />
==== Ranges ====<br />
<br />
The '''Drawing Extent Tree Range''' is a repeating 0x18 byte structure. The purpose is unknown. There are exactly as many Ranges as Nodes. The range appears to contain two 3D positions, which are not necessarily distinct.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 12<br />
| {{Unknown|'''Unknown''' 3D position (x,y,z float).}}<br />
|-<br />
| 0x0c<br />
| 12<br />
| {{Unknown|'''Unknown''' 3D position (x,y,z float).}}<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of Range}}<br />
|}<br />
<br />
==== Indices ====<br />
<br />
The '''Drawing Extent Tree Index''' array is an array of 16 bit values which appear to be the index of the leaf node of the '''Drawing Extent Tree''' which contains the corresponding '''[[FMDL (File Format)#Drawing Extent|Drawing Extent]]'''. Therefore this array has length equal to the number of [[FMDL (File Format)#Drawing Extent|Drawing Extent]]s in the '''FSHP''' section.<br />
<br />
[[category:File Format]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=FMDL_(File_Format)&diff=882FMDL (File Format)2014-08-10T05:51:08Z<p>Chadderz: /* Format */ Added an overview table to help understand the format.</p>
<hr />
<div>{{Under-construction}}<br />
<br />
The '''FMDL''' model format is a format for models which appears as a subfile of a '''[[BFRES (File Format)|BFRES file]]''' in the '''0'''th file group. Typically a BFRES file has one FMDL but some have none and some have more than one.<br />
<br />
__TOC__<br />
<br />
= Format =<br />
<br />
An '''FMDL file''' begins with an '''FMDL header'''. This is then followed by a number of sections pointed to by the header, many of which can occur multiple times. The purpose of these sections is described in the table below. Unless otherwise noted, all offsets in BFRES files are relative to themselves, not the beginning of the file which is more common in other formats.<br />
<br />
{| class="wikitable"<br />
! Section<br />
! Purpose<br />
|-<br />
| [[FMDL (File Format)#FVTX|FVTX]]<br />
| Describes an array of array of vertices which can have a number of attributes including position, normal, colour and texture coordinates.<br />
|-<br />
| [[FMDL (File Format)#FMAT|FMAT]]<br />
| Describes the properties of a surface necessary to draw it including texture information.<br />
|-<br />
| [[FMDL (File Format)#FSKL|FSKL]]<br />
| Describes a skeleton for the model which may be used in animations.<br />
|-<br />
| [[FMDL (File Format)#FSHP|FSHP]]<br />
| Selects triples of vertices from one [[FMDL (File Format)#FVTX|FVTX]] section to draw triangles between. Also specifies the [[FMDL (File Format)#FMAT|FMAT]] material and the [[FMDL (File Format)#FSKL|FSKL]] attachment of the triangles.<br />
|-<br />
| [[FMDL (File Format)#Parameter|Parameter]]<br />
| Sets a named paramter for the model.<br />
|}<br />
<br />
== Header (FMDL) ==<br />
<br />
Every FMDL begins with an 0x2c byte '''FMDL header'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FMDL'''" file identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''File name''' offset (without file extension).<br />
|-<br />
| 0x08<br />
| 4<br />
| '''End of BFRES string table''' offset.<br />
|-<br />
| 0x0c<br />
| 4<br />
| [[FMDL (File Format)#FSKL|FSKL]] offset.<br />
|-<br />
| 0x10<br />
| 4<br />
| [[FMDL (File Format)#FVTX|FVTX]] array offset.<br />
|-<br />
| 0x14<br />
| 4<br />
| [[FMDL (File Format)#FSHP|FSHP]] [[BFRES (File Format)#Index Group|index group]] offset.<br />
|-<br />
| 0x18<br />
| 4<br />
| [[FMDL (File Format)#FMAT|FMAT]] [[BFRES (File Format)#Index Group|index group]] offset.<br />
|-<br />
| 0x1c<br />
| 4<br />
| [[FMDL (File Format)#Parameter|Parameter]] [[BFRES (File Format)#Index Group|index group]] offset. May be '''0''' if no parameters exist (common).<br />
|-<br />
| 0x20<br />
| 2<br />
| '''[[FMDL (File Format)#FVTX|FVTX]] count''': number of FVTX sections.<br />
|-<br />
| 0x22<br />
| 2<br />
| '''[[FMDL (File Format)#FSHP|FSHP]] count''': number of FSHP sections.<br />
|-<br />
| 0x24<br />
| 2<br />
| '''[[FMDL (File Format)#FMAT|FMAT]] count''': number of FMAT sections.<br />
|-<br />
| 0x26<br />
| 2<br />
| '''[[FMDL (File Format)#Parameter|Parameter]] count''': number of parameter sections.<br />
|-<br />
| 0x28<br />
| 4<br />
| {{Unknown|'''Unknown''' possibly something like an unused face count.}}<br />
|-<br />
| 0x2c<br />
| colspan="2" {{Unknown|End of FMDL header}}<br />
|}<br />
<br />
== FVTX ==<br />
<br />
The model may have one or more '''FVTX''' sections which describe the vertices for one polygon (e.g. the road of a track). The section describes a series of buffers and attributes. Buffers are arbitrary pieces of data which contain the actual values of the vertices and are passed directly to the graphics card. Attributes are properties of vertices (e.g. position, texture coordinate, vertex colours) and they describe the format and layout of the data in the buffers.<br />
<br />
=== Header (FVTX) ===<br />
<br />
Each FVTX section has a 0x20 byte header. These headers are stored sequentially in an array at the offset given in the '''FMDL header'''. The length of this array is also given in that header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FVTX'''" section identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 1<br />
| '''Attribute count''': number of different attributes in section (position, normal, colour, etc).<br />
|-<br />
| 0x05<br />
| 1<br />
| '''Buffer count''': number of attribute buffers.<br />
|-<br />
| 0x06<br />
| 2<br />
| '''Section index''': index into FVTX array of this entry.<br />
|-<br />
| 0x08<br />
| 4<br />
| Number of vertices.<br />
|-<br />
| 0x0c<br />
| 1<br />
| {{Unknown|'''Unknown'''; values seen are between '''0''' and '''4''' (normally '''0''').}}<br />
|-<br />
| 0x0d<br />
| 3<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| Attribute array offset.<br />
|-<br />
| 0x14<br />
| 4<br />
| Attribute [[BFRES (File Format)#Index Group|index group]] offset.<br />
|-<br />
| 0x18<br />
| 4<br />
| Buffer array offset.<br />
|-<br />
| 0x1c<br />
| 4<br />
| Padding, always '''0'''.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of FVTX header}}<br />
|}<br />
<br />
=== Attributes ===<br />
<br />
The '''attributes''' of each '''FVTX''' section are stored as a simple repeating 0xc byte structure. These are stored in an array with location and length specified by the FVTX header. They are also referenced by the attribute index group, presumably to allow both index and name based lookup of attributes.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Attribute name''' offset.<br />
|-<br />
| 0x04<br />
| 1<br />
| '''Buffer index''' of the buffer containing this attribute.<br />
|-<br />
| 0x05<br />
| 3<br />
| '''Buffer offset''' of the attribute in each structure in the buffer.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Format''' of the attribute's data in the buffer.<br />
|-<br />
| 0xc<br />
| colspan="2" {{Unknown|End of attribute}}<br />
|}<br />
<br />
Based on the some of the shader code in [[Filesystem/content/mapobj/PackunMusic#Files|/vol/content/mapobj/PackunMusic/PackunMusic.bfres]] the following naming convention seems to be used for attributes.<br />
<br />
{| class="wikitable"<br />
! Attribute Name<br />
! Friendly Name<br />
! Description<br />
|-<br />
| _p0<br />
| position0<br />
| The position of the vertex.<br />
|-<br />
| _n0<br />
| normal0<br />
| The normal of the vertex as used in lighting calculations.<br />
|-<br />
| _t0<br />
| tangent0<br />
| The tangent of the vertex as used in advanced lighting calculations.<br />
|-<br />
| _b0<br />
| binormal0<br />
| The binormal of the vertex as used in advanced lighting calculations.<br />
|-<br />
| _w0<br />
| blendweight0<br />
| {{Unknown}}<br />
|-<br />
| _i0<br />
| blendindex0<br />
| {{Unknown}}<br />
|-<br />
| _u0<br />
| uv0<br />
| rowspan="4" | Texture coordinates used for texture mapping.<br />
|-<br />
| _u1<br />
| uv1<br />
|-<br />
| _u2<br />
| uv2<br />
|-<br />
| _u3<br />
| uv3<br />
|-<br />
| _c0<br />
| color0<br />
| rowspan="2" | Vertex colours used for simple shadow mapping.<br />
|-<br />
| _c1<br />
| color1<br />
|}<br />
<br />
=== Buffers ===<br />
<br />
The '''buffers''' of each '''FVTX''' section are stored as a repeating 0x18 byte header structure which references the actual data stored later in the BFRES file. The headers are stored in an array with location and length specified by the FVTX header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size''' of the buffer in bytes.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Stride''': the size of each element in the buffer.<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''1'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Data offset'''.<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of buffer}}<br />
|}<br />
<br />
== FSHP ==<br />
<br />
The model may have one or more '''FSHP''' sections which describe the one polygon (e.g. the road of a track). The FSHP section consists of an 0x40 byte header, which references an '''[[FMDL (File Format)#FVTX|FVTX]]''' section and indices of the polygons to draw. A basic '''FSHP''' amounts to a list of indices into the corresponding '''FVTX''' indicating which points to draw triangles between. The '''FSHP''' also references an '''[[FMDL (File Format)#FMAT|FMAT]]''' to describe the material of the triangles, and an '''[[FMDL (File Format)#FSKL|FSKL]]''' to indicate the bone structure of the model used in animation.<br />
<br />
=== Header (FSHP) ===<br />
<br />
Every '''FSHP''' begins with an 0x40 byte header. This references other data structures which describe the polygon.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FSHP'''" section identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Polygon name''' offset.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''2'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Section Index''' or '''[[FMDL (File Format)#FVTX|FVTX]] Index'''. In every [[Mario Kart 8]] model these numbers are the same.<br />
|-<br />
| 0x0e<br />
| 2<br />
| '''[[FMDL (File Format)#FMAT|FMAT]] Index'''. Index of the material for this polygon.<br />
|-<br />
| 0x10<br />
| 2<br />
| '''[[FMDL (File Format)#FSKL|FSKL]] Index''' of the bone for this polygon.<br />
|-<br />
| 0x12<br />
| 2<br />
| '''Section Index''' or '''[[FMDL (File Format)#FVTX|FVTX]] Index'''. In every [[Mario Kart 8]] model these numbers are the same.<br />
|-<br />
| 0x14<br />
| 2<br />
| '''FSKL Index Array Count'''. Often zero, '''Unknown''' purpose but seems to be related to '''FSKL'''.<br />
|-<br />
| 0x16<br />
| 1<br />
| {{Unknown|'''Unknown''': If '''FSKL Index Array''' is present this tends to be non-zero. Zero otherwise.}}<br />
|-<br />
| 0x17<br />
| 1<br />
| '''[[FMDL (File Format)#Drawing Command|Drawing Command]] count'''. Number of elements in the array.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''[[FMDL (File Format)#Drawing Extent Tree|Drawing Extent Tree Node]] count'''.<br />
|-<br />
| 0x1c<br />
| 4<br />
| {{Unknown|'''Unknown''' floating point.}}<br />
|-<br />
| 0x20<br />
| 4<br />
| '''[[FMDL (File Format)#FVTX|FVTX]] offset''' to the vertex buffer for this polygon.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''[[FMDL (File Format)#Drawing Command|Drawing Command]] offset'''. Offset to the first element in the array.<br />
|-<br />
| 0x28<br />
| 4<br />
| '''FSKL Index Array Offset'''. Each element of this array is a 16 bit index.<br />
|-<br />
| 0x2c<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x30<br />
| 4<br />
| '''[[FMDL (File Format)#Drawing Extent Tree|Drawing Extent Tree Nodes]] offset'''.<br />
|-<br />
| 0x34<br />
| 4<br />
| '''[[FMDL (File Format)#Drawing Extent Tree|Drawing Extent Tree Ranges]] offset'''.<br />
|-<br />
| 0x38<br />
| 4<br />
| '''[[FMDL (File Format)#Drawing Extent Tree|Drawing Extent Tree Indices]] offset'''.<br />
|-<br />
| 0x3c<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x40<br />
| colspan="2" {{Unknown|End of FSHP header}}<br />
|}<br />
<br />
=== Drawing Command ===<br />
<br />
A '''Drawing Command''' is a repeating 0x18 byte structure which are stored in a sequential array with location and size specified by the '''FSHP Header'''<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''4'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''4'''.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Count''' of points drawn in all [[FMDL (File Format)#Drawing Extent|Drawing Extent]]s.<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''[[FMDL (File Format)#Drawing Extent|Drawing Extent]] count'''. The number of elements in the array.<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| '''[[FMDL (File Format)#Drawing Extent|Drawing Extent]] offset'''. Offset to the first element in the array.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''[[FMDL (File Format)#Index Buffer|Index Buffer]] offset'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Vertex offset''': the number of elements to skip in the corresponding '''FVTX''' buffer.<br />
|-<br />
| 0x1c<br />
| colspan="2" {{Unknown|End of Drawing Command}}<br />
|}<br />
<br />
=== Drawing Extent ===<br />
<br />
A '''Drawing Extent''' is a repeating 0x8 byte structure describing an offset and a count in the corresponding [[FMDL (File Format)#Index Buffer|Index Buffer]]. Drawing Extents are stored in a sequential array with location and count indicated by the corresponding [[FMDL (File Format)#Drawing Command|Drawing Command]]. This allows multiple separate drawing commands to be issued using the same Index Buffer. In many cases, a single extent is used which simply draws the entire Index Buffer.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Offset''' into index buffer in bytes.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Count''' of the points to draw.<br />
|-<br />
| 0x08<br />
| colspan="2" {{Unknown|End of Drawing Extent}}<br />
|}<br />
<br />
=== Index Buffer ===<br />
<br />
An '''Index Buffer''' is an 0x18 byte structure which describes a list of 16 bit values which are used to index the '''FVTX''' section when drawing the polygon. Index Buffers are referenced by [[FMDL (File Format)#Drawing Command|Drawing Command]]s. The format is very similar to the [[FMDL (File Format)#Buffers|FVTX Buffer]] format, which may indicate they are instances of the same structure.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size''' of index data in bytes.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' Always '''1'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Index data offset'''.<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of Index Buffer}}<br />
|}<br />
<br />
=== Drawing Extent Tree ===<br />
<br />
The '''Drawing Extent Tree''' is some sort of tree structure that occurs in all FSHP sections. In all [[Mario Kart 8]] files, when the '''FSHP''' has multiple [[FMDL (File Format)#Drawing Command|Drawing Command]]s, the Drawing Extent Tree is a trivial one node tree. The Drawing Extent Tree may be used to control which [[FMDL (File Format)#Drawing Extent|Drawing Extent]]s need to be drawn, for example as part of a dynamic level of detail system. The true workings and purpose of the structure are however unknown.<br />
<br />
==== Nodes ====<br />
<br />
The '''Drawing Extent Tree Node''' is a repeating 0xc byte structure. The nodes form a binary tree. The [[FMDL (File Format)#FSHP|FSHP header]] contains a pointer to node array, as well as specifying its length. The root node is the first node in this array. Each node specifies a range of Drawing Extents, with the root node always covering all nodes, and the children of each node always selecting disjoint subsets of that node's range.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 2<br />
| '''Left Child''' index. The current node's index if it has no left child.<br />
|-<br />
| 0x02<br />
| 2<br />
| '''Right Child''' index. The current node's index if it has no right child.<br />
|-<br />
| 0x04<br />
| 2<br />
| '''Unknown''' always the same as '''Left Child''' index.<br />
|-<br />
| 0x06<br />
| 2<br />
| '''Next Sibling''' index. Always the current node's parent's right child (the current node's index if it has no right child).<br />
|-<br />
| 0x08<br />
| 2<br />
| '''[[FMDL (File Format)#Drawing Extent|Drawing Extent]] Index''' selects a range of Drawing Extents along with the count.<br />
|-<br />
| 0x0a<br />
| 2<br />
| '''[[FMDL (File Format)#Drawing Extent|Drawing Extent]] Count''' selects a range of Drawing Extents along with the index.<br />
|-<br />
| 0x0c<br />
| colspan="2" {{Unknown|End of Node}}<br />
|}<br />
<br />
==== Ranges ====<br />
<br />
The '''Drawing Extent Tree Range''' is a repeating 0x18 byte structure. The purpose is unknown. There are exactly as many Ranges as Nodes. The range appears to contain two 3D positions, which are not necessarily distinct.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 12<br />
| {{Unknown|'''Unknown''' 3D position (x,y,z float).}}<br />
|-<br />
| 0x0c<br />
| 12<br />
| {{Unknown|'''Unknown''' 3D position (x,y,z float).}}<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of Range}}<br />
|}<br />
<br />
==== Indices ====<br />
<br />
The '''Drawing Extent Tree Index''' array is an array of 16 bit values which appear to be the index of the leaf node of the '''Drawing Extent Tree''' which contains the corresponding '''[[FMDL (File Format)#Drawing Extent|Drawing Extent]]'''. Therefore this array has length equal to the number of [[FMDL (File Format)#Drawing Extent|Drawing Extent]]s in the '''FSHP''' section.<br />
<br />
[[category:File Format]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=BARS_(File_Format)&diff=881BARS (File Format)2014-08-10T05:30:21Z<p>Chadderz: Created redirect to SARC (File Format).</p>
<hr />
<div>#redirect [[SARC (File Format)]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=SARC_(File_Format)&diff=880SARC (File Format)2014-08-10T05:29:03Z<p>Chadderz: /* Header (SFNT) */ Typod heading.</p>
<hr />
<div>'''SARC Files''' are uncompressed archive files used in [[Wii U]] software, 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, .sarc, .pack, and .bars. The '''.bars''' extension is commonly used when the archive contains audio data.<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 archive beings 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 || '''Byte order mark''' (BOM): 0xFE,0xFF for big endian and 0xFF,0xFE for little endian. <br />
|-<br />
| 0x08 || 4 || '''File size''' of the entire archive in bytes.<br />
|-<br />
| 0x0c || 4 || '''Beginning of data''' offset.<br />
|-<br />
| 0x10 || 4 || {{Unknown|'''Unknown'''. Always '''0x01000000'''?}}<br />
|-<br />
| 0x14 || colspan=2 {{Unknown|End of '''SARC''' header}}<br />
|-<br />
|}<br />
<br />
== File Table ==<br />
Unlike the U8 format, SARC does generally not contain directory nodes (though files may reside inside subfolders). It is currently unknown if it is able to.<br />
<br />
=== Header (SFAT) ===<br />
The '''SARC Header''' is immediately followed by 0xc 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 || {{Unknown|'''Unknown.''' Always '''0x00000065'''?}}<br />
|-<br />
| 0x0c || colspan=2 {{Unknown|End of '''SFAT''' header}}<br />
|-<br />
|}<br />
<br />
=== Node ===<br />
The '''SFAT Header''' is followed by an array of 0x10 byte '''SFAT Node''' structures.<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Description<br />
|-<br />
| 0x00 || 4 || {{Unknown|'''Unknown.''' Could plausibly be an ID of some sort, the files are encoded sorted by this value, so perhaps even a hash of the name.}}<br />
|-<br />
| 0x04 || 1 || {{Unknown|'''Unknown.''' Always '''0x01'''? Comparable to the file/folder flag from U8?}}<br />
|-<br />
| 0x05 || 3 || '''File name table entry''' offset, relative to the end of the file name table 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 />
<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 0x8 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 || {{Unknown|'''Unknown.''' Always '''0'''?}}<br />
|-<br />
| 0x08 || colspan=2 {{Unknown|End of '''SFNT''' header}}<br />
|-<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'''. There is padding between the files for 256-byte (0x100) alignment.<br />
<br />
= Tools =<br />
<br />
The following tool can extract SARC files:<br />
<br />
* SARCUnpack from the [https://www.dropbox.com/sh/tfg2nd6q809oqn3/AADWk3SgQEsqnvlbplcWOfv5a CWRT] package, by [[User:Celcodioc|Celcodioc]]<br />
<br />
[[Category:File Format]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=SARC_(File_Format)&diff=879SARC (File Format)2014-08-10T05:28:07Z<p>Chadderz: Tidied page up and added some information based on a bit of guesswork. Props to Celcodioc for the article.</p>
<hr />
<div>'''SARC Files''' are uncompressed archive files used in [[Wii U]] software, 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, .sarc, .pack, and .bars. The '''.bars''' extension is commonly used when the archive contains audio data.<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 archive beings 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 || '''Byte order mark''' (BOM): 0xFE,0xFF for big endian and 0xFF,0xFE for little endian. <br />
|-<br />
| 0x08 || 4 || '''File size''' of the entire archive in bytes.<br />
|-<br />
| 0x0c || 4 || '''Beginning of data''' offset.<br />
|-<br />
| 0x10 || 4 || {{Unknown|'''Unknown'''. Always '''0x01000000'''?}}<br />
|-<br />
| 0x14 || colspan=2 {{Unknown|End of '''SARC''' header}}<br />
|-<br />
|}<br />
<br />
== File Table ==<br />
Unlike the U8 format, SARC does generally not contain directory nodes (though files may reside inside subfolders). It is currently unknown if it is able to.<br />
<br />
=== Header (SFAT) ===<br />
The '''SARC Header''' is immediately followed by 0xc 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 || {{Unknown|'''Unknown.''' Always '''0x00000065'''?}}<br />
|-<br />
| 0x0c || colspan=2 {{Unknown|End of '''SFAT''' header}}<br />
|-<br />
|}<br />
<br />
=== Node ===<br />
The '''SFAT Header''' is followed by an array of 0x10 byte '''SFAT Node''' structures.<br />
<br />
{| class="wikitable"<br />
! Offset !! Size !! Description<br />
|-<br />
| 0x00 || 4 || {{Unknown|'''Unknown.''' Could plausibly be an ID of some sort, the files are encoded sorted by this value, so perhaps even a hash of the name.}}<br />
|-<br />
| 0x04 || 1 || {{Unknown|'''Unknown.''' Always '''0x01'''? Comparable to the file/folder flag from U8?}}<br />
|-<br />
| 0x05 || 3 || '''File name table entry''' offset, relative to the end of the file name table 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 />
<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 (SFAT) ===<br />
The '''SFAT Node''' array is immediately followed by an 0x8 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 || {{Unknown|'''Unknown.''' Always '''0'''?}}<br />
|-<br />
| 0x08 || colspan=2 {{Unknown|End of '''SFNT''' header}}<br />
|-<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'''. There is padding between the files for 256-byte (0x100) alignment.<br />
<br />
= Tools =<br />
<br />
The following tool can extract SARC files:<br />
<br />
* SARCUnpack from the [https://www.dropbox.com/sh/tfg2nd6q809oqn3/AADWk3SgQEsqnvlbplcWOfv5a CWRT] package, by [[User:Celcodioc|Celcodioc]]<br />
<br />
[[Category:File Format]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=FMDL_(File_Format)&diff=845FMDL (File Format)2014-08-09T18:14:27Z<p>Chadderz: /* FSHP */ Fleshed out some of the descriptions.</p>
<hr />
<div>{{Under-construction}}<br />
<br />
The '''FMDL''' model format is a format for models which appears as a subfile of a '''[[BFRES (File Format)|BFRES file]]''' in the '''0'''th file group. Typically a BFRES file has one FMDL but some have none and some have more than one.<br />
<br />
__TOC__<br />
<br />
= Format =<br />
<br />
An FMDL file begins with an FMDL header. This is then followed by a number of sections pointed to by the header, many of which can occur multiple times. Unless otherwise noted, all offsets in BFRES files are relative to themselves, not the beginning of the file which is more common in other formats.<br />
<br />
== Header (FMDL) ==<br />
<br />
Every FMDL begins with an 0x2c byte '''FMDL header'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FMDL'''" file identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''File name''' offset (without file extension).<br />
|-<br />
| 0x08<br />
| 4<br />
| '''End of BFRES string table''' offset.<br />
|-<br />
| 0x0c<br />
| 4<br />
| [[FMDL (File Format)#FSKL|FSKL]] offset.<br />
|-<br />
| 0x10<br />
| 4<br />
| [[FMDL (File Format)#FVTX|FVTX]] array offset.<br />
|-<br />
| 0x14<br />
| 4<br />
| [[FMDL (File Format)#FSHP|FSHP]] [[BFRES (File Format)#Index Group|index group]] offset.<br />
|-<br />
| 0x18<br />
| 4<br />
| [[FMDL (File Format)#FMAT|FMAT]] [[BFRES (File Format)#Index Group|index group]] offset.<br />
|-<br />
| 0x1c<br />
| 4<br />
| [[FMDL (File Format)#Parameter|Parameter]] [[BFRES (File Format)#Index Group|index group]] offset. May be '''0''' if no parameters exist (common).<br />
|-<br />
| 0x20<br />
| 2<br />
| '''[[FMDL (File Format)#FVTX|FVTX]] count''': number of FVTX sections.<br />
|-<br />
| 0x22<br />
| 2<br />
| '''[[FMDL (File Format)#FSHP|FSHP]] count''': number of FSHP sections.<br />
|-<br />
| 0x24<br />
| 2<br />
| '''[[FMDL (File Format)#FMAT|FMAT]] count''': number of FMAT sections.<br />
|-<br />
| 0x26<br />
| 2<br />
| '''[[FMDL (File Format)#Parameter|Parameter]] count''': number of parameter sections.<br />
|-<br />
| 0x28<br />
| 4<br />
| {{Unknown|'''Unknown''' possibly something like an unused face count.}}<br />
|-<br />
| 0x2c<br />
| colspan="2" {{Unknown|End of FMDL header}}<br />
|}<br />
<br />
== FVTX ==<br />
<br />
The model may have one or more '''FVTX''' sections which describe the vertices for one polygon (e.g. the road of a track). The section describes a series of buffers and attributes. Buffers are arbitrary pieces of data which contain the actual values of the vertices and are passed directly to the graphics card. Attributes are properties of vertices (e.g. position, texture coordinate, vertex colours) and they describe the format and layout of the data in the buffers.<br />
<br />
=== Header (FVTX) ===<br />
<br />
Each FVTX section has a 0x20 byte header. These headers are stored sequentially in an array at the offset given in the '''FMDL header'''. The length of this array is also given in that header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FVTX'''" section identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 1<br />
| '''Attribute count''': number of different attributes in section (position, normal, colour, etc).<br />
|-<br />
| 0x05<br />
| 1<br />
| '''Buffer count''': number of attribute buffers.<br />
|-<br />
| 0x06<br />
| 2<br />
| '''Section index''': index into FVTX array of this entry.<br />
|-<br />
| 0x08<br />
| 4<br />
| Number of vertices.<br />
|-<br />
| 0x0c<br />
| 1<br />
| {{Unknown|'''Unknown'''; values seen are between '''0''' and '''4''' (normally '''0''').}}<br />
|-<br />
| 0x0d<br />
| 3<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| Attribute array offset.<br />
|-<br />
| 0x14<br />
| 4<br />
| Attribute [[BFRES (File Format)#Index Group|index group]] offset.<br />
|-<br />
| 0x18<br />
| 4<br />
| Buffer array offset.<br />
|-<br />
| 0x1c<br />
| 4<br />
| Padding, always '''0'''.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of FVTX header}}<br />
|}<br />
<br />
=== Attributes ===<br />
<br />
The '''attributes''' of each '''FVTX''' section are stored as a simple repeating 0xc byte structure. These are stored in an array with location and length specified by the FVTX header. They are also referenced by the attribute index group, presumably to allow both index and name based lookup of attributes.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Attribute name''' offset.<br />
|-<br />
| 0x04<br />
| 1<br />
| '''Buffer index''' of the buffer containing this attribute.<br />
|-<br />
| 0x05<br />
| 3<br />
| '''Buffer offset''' of the attribute in each structure in the buffer.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Format''' of the attribute's data in the buffer.<br />
|-<br />
| 0xc<br />
| colspan="2" {{Unknown|End of attribute}}<br />
|}<br />
<br />
Based on the some of the shader code in [[Filesystem/content/mapobj/PackunMusic#Files|/vol/content/mapobj/PackunMusic/PackunMusic.bfres]] the following naming convention seems to be used for attributes.<br />
<br />
{| class="wikitable"<br />
! Attribute Name<br />
! Friendly Name<br />
! Description<br />
|-<br />
| _p0<br />
| position0<br />
| The position of the vertex.<br />
|-<br />
| _n0<br />
| normal0<br />
| The normal of the vertex as used in lighting calculations.<br />
|-<br />
| _t0<br />
| tangent0<br />
| The tangent of the vertex as used in advanced lighting calculations.<br />
|-<br />
| _b0<br />
| binormal0<br />
| The binormal of the vertex as used in advanced lighting calculations.<br />
|-<br />
| _w0<br />
| blendweight0<br />
| {{Unknown}}<br />
|-<br />
| _i0<br />
| blendindex0<br />
| {{Unknown}}<br />
|-<br />
| _u0<br />
| uv0<br />
| rowspan="4" | Texture coordinates used for texture mapping.<br />
|-<br />
| _u1<br />
| uv1<br />
|-<br />
| _u2<br />
| uv2<br />
|-<br />
| _u3<br />
| uv3<br />
|-<br />
| _c0<br />
| color0<br />
| rowspan="2" | Vertex colours used for simple shadow mapping.<br />
|-<br />
| _c1<br />
| color1<br />
|}<br />
<br />
=== Buffers ===<br />
<br />
The '''buffers''' of each '''FVTX''' section are stored as a repeating 0x18 byte header structure which references the actual data stored later in the BFRES file. The headers are stored in an array with location and length specified by the FVTX header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size''' of the buffer in bytes.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Stride''': the size of each element in the buffer.<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''1'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Data offset'''.<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of buffer}}<br />
|}<br />
<br />
== FSHP ==<br />
<br />
The model may have one or more '''FSHP''' sections which describe the one polygon (e.g. the road of a track). The FSHP section consists of an 0x40 byte header, which references an '''[[FMDL (File Format)#FVTX|FVTX]]''' section and indices of the polygons to draw. A basic '''FSHP''' amounts to a list of indices into the corresponding '''FVTX''' indicating which points to draw triangles between. The '''FSHP''' also references an '''[[FMDL (File Format)#FMAT|FMAT]]''' to describe the material of the triangles, and an '''[[FMDL (File Format)#FSKL|FSKL]]''' to indicate the bone structure of the model used in animation.<br />
<br />
=== Header (FSHP) ===<br />
<br />
Every '''FSHP''' begins with an 0x40 byte header. This references other data structures which describe the polygon.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FSHP'''" section identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Polygon name''' offset.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''2'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Section Index''' or '''[[FMDL (File Format)#FVTX|FVTX]] Index'''. In every [[Mario Kart 8]] model these numbers are the same.<br />
|-<br />
| 0x0e<br />
| 2<br />
| '''[[FMDL (File Format)#FMAT|FMAT]] Index'''. Index of the material for this polygon.<br />
|-<br />
| 0x10<br />
| 2<br />
| '''[[FMDL (File Format)#FSKL|FSKL]] Index''' of the bone for this polygon.<br />
|-<br />
| 0x12<br />
| 2<br />
| '''Section Index''' or '''[[FMDL (File Format)#FVTX|FVTX]] Index'''. In every [[Mario Kart 8]] model these numbers are the same.<br />
|-<br />
| 0x14<br />
| 2<br />
| '''FSKL Index Array Count'''. Often zero, '''Unknown''' purpose but seems to be related to '''FSKL'''.<br />
|-<br />
| 0x16<br />
| 1<br />
| {{Unknown|'''Unknown''': If '''FSKL Index Array''' is present this tends to be non-zero. Zero otherwise.}}<br />
|-<br />
| 0x17<br />
| 1<br />
| '''[[FMDL (File Format)#Drawing Command|Drawing Command]] count'''. Number of elements in the array.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''[[FMDL (File Format)#Drawing Extent Tree|Drawing Extent Tree Node]] count'''.<br />
|-<br />
| 0x1c<br />
| 4<br />
| {{Unknown|'''Unknown''' floating point.}}<br />
|-<br />
| 0x20<br />
| 4<br />
| '''[[FMDL (File Format)#FVTX|FVTX]] offset''' to the vertex buffer for this polygon.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''[[FMDL (File Format)#Drawing Command|Drawing Command]] offset'''. Offset to the first element in the array.<br />
|-<br />
| 0x28<br />
| 4<br />
| '''FSKL Index Array Offset'''. Each element of this array is a 16 bit index.<br />
|-<br />
| 0x2c<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x30<br />
| 4<br />
| '''[[FMDL (File Format)#Drawing Extent Tree|Drawing Extent Tree Nodes]] offset'''.<br />
|-<br />
| 0x34<br />
| 4<br />
| '''[[FMDL (File Format)#Drawing Extent Tree|Drawing Extent Tree Ranges]] offset'''.<br />
|-<br />
| 0x38<br />
| 4<br />
| '''[[FMDL (File Format)#Drawing Extent Tree|Drawing Extent Tree Indices]] offset'''.<br />
|-<br />
| 0x3c<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x40<br />
| colspan="2" {{Unknown|End of FSHP header}}<br />
|}<br />
<br />
=== Drawing Command ===<br />
<br />
A '''Drawing Command''' is a repeating 0x18 byte structure which are stored in a sequential array with location and size specified by the '''FSHP Header'''<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''4'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''4'''.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Count''' of points drawn in all [[FMDL (File Format)#Drawing Extent|Drawing Extent]]s.<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''[[FMDL (File Format)#Drawing Extent|Drawing Extent]] count'''. The number of elements in the array.<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| '''[[FMDL (File Format)#Drawing Extent|Drawing Extent]] offset'''. Offset to the first element in the array.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''[[FMDL (File Format)#Index Buffer|Index Buffer]] offset'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Vertex offset''': the number of elements to skip in the corresponding '''FVTX''' buffer.<br />
|-<br />
| 0x1c<br />
| colspan="2" {{Unknown|End of Drawing Command}}<br />
|}<br />
<br />
=== Drawing Extent ===<br />
<br />
A '''Drawing Extent''' is a repeating 0x8 byte structure describing an offset and a count in the corresponding [[FMDL (File Format)#Index Buffer|Index Buffer]]. Drawing Extents are stored in a sequential array with location and count indicated by the corresponding [[FMDL (File Format)#Drawing Command|Drawing Command]]. This allows multiple separate drawing commands to be issued using the same Index Buffer. In many cases, a single extent is used which simply draws the entire Index Buffer.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Offset''' into index buffer in bytes.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Count''' of the points to draw.<br />
|-<br />
| 0x08<br />
| colspan="2" {{Unknown|End of Drawing Extent}}<br />
|}<br />
<br />
=== Index Buffer ===<br />
<br />
An '''Index Buffer''' is an 0x18 byte structure which describes a list of 16 bit values which are used to index the '''FVTX''' section when drawing the polygon. Index Buffers are referenced by [[FMDL (File Format)#Drawing Command|Drawing Command]]s. The format is very similar to the [[FMDL (File Format)#Buffers|FVTX Buffer]] format, which may indicate they are instances of the same structure.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size''' of index data in bytes.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' Always '''1'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Index data offset'''.<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of Index Buffer}}<br />
|}<br />
<br />
=== Drawing Extent Tree ===<br />
<br />
The '''Drawing Extent Tree''' is some sort of tree structure that occurs in all FSHP sections. In all [[Mario Kart 8]] files, when the '''FSHP''' has multiple [[FMDL (File Format)#Drawing Command|Drawing Command]]s, the Drawing Extent Tree is a trivial one node tree. The Drawing Extent Tree may be used to control which [[FMDL (File Format)#Drawing Extent|Drawing Extent]]s need to be drawn, for example as part of a dynamic level of detail system. The true workings and purpose of the structure are however unknown.<br />
<br />
==== Nodes ====<br />
<br />
The '''Drawing Extent Tree Node''' is a repeating 0xc byte structure. The nodes form a binary tree. The [[FMDL (File Format)#FSHP|FSHP header]] contains a pointer to node array, as well as specifying its length. The root node is the first node in this array. Each node specifies a range of Drawing Extents, with the root node always covering all nodes, and the children of each node always selecting disjoint subsets of that node's range.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 2<br />
| '''Left Child''' index. The current node's index if it has no left child.<br />
|-<br />
| 0x02<br />
| 2<br />
| '''Right Child''' index. The current node's index if it has no right child.<br />
|-<br />
| 0x04<br />
| 2<br />
| '''Unknown''' always the same as '''Left Child''' index.<br />
|-<br />
| 0x06<br />
| 2<br />
| '''Next Sibling''' index. Always the current node's parent's right child (the current node's index if it has no right child).<br />
|-<br />
| 0x08<br />
| 2<br />
| '''[[FMDL (File Format)#Drawing Extent|Drawing Extent]] Index''' selects a range of Drawing Extents along with the count.<br />
|-<br />
| 0x0a<br />
| 2<br />
| '''[[FMDL (File Format)#Drawing Extent|Drawing Extent]] Count''' selects a range of Drawing Extents along with the index.<br />
|-<br />
| 0x0c<br />
| colspan="2" {{Unknown|End of Node}}<br />
|}<br />
<br />
==== Ranges ====<br />
<br />
The '''Drawing Extent Tree Range''' is a repeating 0x18 byte structure. The purpose is unknown. There are exactly as many Ranges as Nodes. The range appears to contain two 3D positions, which are not necessarily distinct.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 12<br />
| {{Unknown|'''Unknown''' 3D position (x,y,z float).}}<br />
|-<br />
| 0x0c<br />
| 12<br />
| {{Unknown|'''Unknown''' 3D position (x,y,z float).}}<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of Range}}<br />
|}<br />
<br />
==== Indices ====<br />
<br />
The '''Drawing Extent Tree Index''' array is an array of 16 bit values which appear to be the index of the leaf node of the '''Drawing Extent Tree''' which contains the corresponding '''[[FMDL (File Format)#Drawing Extent|Drawing Extent]]'''. Therefore this array has length equal to the number of [[FMDL (File Format)#Drawing Extent|Drawing Extent]]s in the '''FSHP''' section.<br />
<br />
[[category:File Format]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=FMDL_(File_Format)&diff=804FMDL (File Format)2014-08-09T11:22:51Z<p>Chadderz: /* FSHP */ New section analysis. Still many unknowns.</p>
<hr />
<div>{{Under-construction}}<br />
<br />
The '''FMDL''' model format is a format for models which appears as a subfile of a '''[[BFRES (File Format)|BFRES file]]''' in the '''0'''th file group. Typically a BFRES file has one FMDL but some have none and some have more than one.<br />
<br />
__TOC__<br />
<br />
= Format =<br />
<br />
An FMDL file begins with an FMDL header. This is then followed by a number of sections pointed to by the header, many of which can occur multiple times. Unless otherwise noted, all offsets in BFRES files are relative to themselves, not the beginning of the file which is more common in other formats.<br />
<br />
== Header (FMDL) ==<br />
<br />
Every FMDL begins with an 0x2c byte '''FMDL header'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FMDL'''" file identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''File name''' offset (without file extension).<br />
|-<br />
| 0x08<br />
| 4<br />
| '''End of BFRES string table''' offset.<br />
|-<br />
| 0x0c<br />
| 4<br />
| [[FMDL (File Format)#FSKL|FSKL]] offset.<br />
|-<br />
| 0x10<br />
| 4<br />
| [[FMDL (File Format)#FVTX|FVTX]] array offset.<br />
|-<br />
| 0x14<br />
| 4<br />
| [[FMDL (File Format)#FSHP|FSHP]] [[BFRES (File Format)#Index Group|index group]] offset.<br />
|-<br />
| 0x18<br />
| 4<br />
| [[FMDL (File Format)#FMAT|FMAT]] [[BFRES (File Format)#Index Group|index group]] offset.<br />
|-<br />
| 0x1c<br />
| 4<br />
| [[FMDL (File Format)#Parameter|Parameter]] [[BFRES (File Format)#Index Group|index group]] offset. May be '''0''' if no parameters exist (common).<br />
|-<br />
| 0x20<br />
| 2<br />
| '''[[FMDL (File Format)#FVTX|FVTX]] count''': number of FVTX sections.<br />
|-<br />
| 0x22<br />
| 2<br />
| '''[[FMDL (File Format)#FSHP|FSHP]] count''': number of FSHP sections.<br />
|-<br />
| 0x24<br />
| 2<br />
| '''[[FMDL (File Format)#FMAT|FMAT]] count''': number of FMAT sections.<br />
|-<br />
| 0x26<br />
| 2<br />
| '''[[FMDL (File Format)#Parameter|Parameter]] count''': number of parameter sections.<br />
|-<br />
| 0x28<br />
| 4<br />
| {{Unknown|'''Unknown''' possibly something like an unused face count.}}<br />
|-<br />
| 0x2c<br />
| colspan="2" {{Unknown|End of FMDL header}}<br />
|}<br />
<br />
== FVTX ==<br />
<br />
The model may have one or more '''FVTX''' sections which describe the vertices for one polygon (e.g. the road of a track). The section describes a series of buffers and attributes. Buffers are arbitrary pieces of data which contain the actual values of the vertices and are passed directly to the graphics card. Attributes are properties of vertices (e.g. position, texture coordinate, vertex colours) and they describe the format and layout of the data in the buffers.<br />
<br />
=== Header (FVTX) ===<br />
<br />
Each FVTX section has a 0x20 byte header. These headers are stored sequentially in an array at the offset given in the '''FMDL header'''. The length of this array is also given in that header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FVTX'''" section identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 1<br />
| '''Attribute count''': number of different attributes in section (position, normal, colour, etc).<br />
|-<br />
| 0x05<br />
| 1<br />
| '''Buffer count''': number of attribute buffers.<br />
|-<br />
| 0x06<br />
| 2<br />
| '''Section index''': index into FVTX array of this entry.<br />
|-<br />
| 0x08<br />
| 4<br />
| Number of vertices.<br />
|-<br />
| 0x0c<br />
| 1<br />
| {{Unknown|'''Unknown'''; values seen are between '''0''' and '''4''' (normally '''0''').}}<br />
|-<br />
| 0x0d<br />
| 3<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| Attribute array offset.<br />
|-<br />
| 0x14<br />
| 4<br />
| Attribute [[BFRES (File Format)#Index Group|index group]] offset.<br />
|-<br />
| 0x18<br />
| 4<br />
| Buffer array offset.<br />
|-<br />
| 0x1c<br />
| 4<br />
| Padding, always '''0'''.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of FVTX header}}<br />
|}<br />
<br />
=== Attributes ===<br />
<br />
The '''attributes''' of each '''FVTX''' section are stored as a simple repeating 0xc byte structure. These are stored in an array with location and length specified by the FVTX header. They are also referenced by the attribute index group, presumably to allow both index and name based lookup of attributes.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Attribute name''' offset.<br />
|-<br />
| 0x04<br />
| 1<br />
| '''Buffer index''' of the buffer containing this attribute.<br />
|-<br />
| 0x05<br />
| 3<br />
| '''Buffer offset''' of the attribute in each structure in the buffer.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Format''' of the attribute's data in the buffer.<br />
|-<br />
| 0xc<br />
| colspan="2" {{Unknown|End of attribute}}<br />
|}<br />
<br />
Based on the some of the shader code in [[Filesystem/content/mapobj/PackunMusic#Files|/vol/content/mapobj/PackunMusic/PackunMusic.bfres]] the following naming convention seems to be used for attributes.<br />
<br />
{| class="wikitable"<br />
! Attribute Name<br />
! Friendly Name<br />
! Description<br />
|-<br />
| _p0<br />
| position0<br />
| The position of the vertex.<br />
|-<br />
| _n0<br />
| normal0<br />
| The normal of the vertex as used in lighting calculations.<br />
|-<br />
| _t0<br />
| tangent0<br />
| The tangent of the vertex as used in advanced lighting calculations.<br />
|-<br />
| _b0<br />
| binormal0<br />
| The binormal of the vertex as used in advanced lighting calculations.<br />
|-<br />
| _w0<br />
| blendweight0<br />
| {{Unknown}}<br />
|-<br />
| _i0<br />
| blendindex0<br />
| {{Unknown}}<br />
|-<br />
| _u0<br />
| uv0<br />
| rowspan="4" | Texture coordinates used for texture mapping.<br />
|-<br />
| _u1<br />
| uv1<br />
|-<br />
| _u2<br />
| uv2<br />
|-<br />
| _u3<br />
| uv3<br />
|-<br />
| _c0<br />
| color0<br />
| rowspan="2" | Vertex colours used for simple shadow mapping.<br />
|-<br />
| _c1<br />
| color1<br />
|}<br />
<br />
=== Buffers ===<br />
<br />
The '''buffers''' of each '''FVTX''' section are stored as a repeating 0x18 byte header structure which references the actual data stored later in the BFRES file. The headers are stored in an array with location and length specified by the FVTX header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size''' of the buffer in bytes.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Stride''': the size of each element in the buffer.<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''1'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Data offset'''.<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of buffer}}<br />
|}<br />
<br />
== FSHP ==<br />
<br />
The model may have one or more '''FSHP''' sections which describe the one polygon (e.g. the road of a track). The FSHP section consists of an 0x40 byte header, which references an '''[[FMDL (File Format)#FVTX|FVTX]]''' section and indices of the polygons to draw.<br />
<br />
=== Header (FSHP) ===<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FSHP'''" section identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Polygon name''' offset.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''2'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Section Index''' or '''[[FMDL (File Format)#FVTX|FVTX]] Index'''. In every [[Mario Kart 8]] model these numbers are the same.<br />
|-<br />
| 0x0e<br />
| 2<br />
| '''[[FMDL (File Format)#FMAT|FMAT]] Index'''. Index of the material for this polygon.<br />
|-<br />
| 0x10<br />
| 2<br />
| '''[[FMDL (File Format)#FSKL|FSKL]] Index''' of the bone for this polygon.<br />
|-<br />
| 0x12<br />
| 2<br />
| '''Section Index''' or '''[[FMDL (File Format)#FVTX|FVTX]] Index'''. In every [[Mario Kart 8]] model these numbers are the same.<br />
|-<br />
| 0x14<br />
| 2<br />
| '''FSKL Index Array Count'''. Often zero, '''Unknown''' purpose but seems to be related to '''FSKL'''.<br />
|-<br />
| 0x16<br />
| 1<br />
| {{Unknown|'''Unknown''': If '''FSKL Index Array''' is present this tends to be non-zero. Zero otherwise.}}<br />
|-<br />
| 0x17<br />
| 1<br />
| '''[[FMDL (File Format)#Drawing Command|Drawing Command]] count'''. Number of elements in the array.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''[[FMDL (File Format)#Drawing Extent Tree|Drawing Extent Tree Node]] count'''.<br />
|-<br />
| 0x1c<br />
| 4<br />
| {{Unknown|'''Unknown''' floating point.}}<br />
|-<br />
| 0x20<br />
| 4<br />
| '''[[FMDL (File Format)#FVTX|FVTX]] offset''' to the vertex buffer for this polygon.<br />
|-<br />
| 0x24<br />
| 4<br />
| '''[[FMDL (File Format)#Drawing Command|Drawing Command]] offset'''. Offset to the first element in the array.<br />
|-<br />
| 0x28<br />
| 4<br />
| '''FSKL Index Array Offset'''. Each element of this array is a 16 bit index.<br />
|-<br />
| 0x2c<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x30<br />
| 4<br />
| '''[[FMDL (File Format)#Drawing Extent Tree|Drawing Extent Tree Nodes]] offset'''.<br />
|-<br />
| 0x34<br />
| 4<br />
| '''[[FMDL (File Format)#Drawing Extent Tree|Drawing Extent Tree Ranges]] offset'''.<br />
|-<br />
| 0x38<br />
| 4<br />
| '''[[FMDL (File Format)#Drawing Extent Tree|Drawing Extent Tree Indices]] offset'''.<br />
|-<br />
| 0x3c<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x40<br />
| colspan="2" {{Unknown|End of FSHP header}}<br />
|}<br />
<br />
=== Drawing Command ===<br />
<br />
A '''Drawing Command''' is a repeating 0x18 byte structure which are stored in a sequential array with location and size specified by the '''FSHP Header'''<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''4'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''4'''.}}<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Count''' of points drawn in all [[FMDL (File Format)#Drawing Extent|Drawing Extent]]s.<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''[[FMDL (File Format)#Drawing Extent|Drawing Extent]] count'''. The number of elements in the array.<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| '''[[FMDL (File Format)#Drawing Extent|Drawing Extent]] offset'''. Offset to the first element in the array.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''[[FMDL (File Format)#Index Buffer|Index Buffer]] offset'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Vertex offset''': the number of elements to skip in the corresponding '''FVTX''' buffer.<br />
|-<br />
| 0x1c<br />
| colspan="2" {{Unknown|End of Drawing Command}}<br />
|}<br />
<br />
=== Drawing Extent ===<br />
<br />
A '''Drawing Extent''' is a repeating 0x8 byte structure describing an offset and a count in the corresponding [[FMDL (File Format)#Index Buffer|Index Buffer]]. Drawing Extents are stored in a sequential array with location and count indicated by the corresponding [[FMDL (File Format)#Drawing Command|Drawing Command]]. This allows multiple separate drawing commands to be issued using the same Index Buffer. In many cases, a single extent is used which simply draws the entire Index Buffer.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Offset''' into index buffer in bytes.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Count''' of the points to draw.<br />
|-<br />
| 0x08<br />
| colspan="2" {{Unknown|End of Drawing Extent}}<br />
|}<br />
<br />
=== Index Buffer ===<br />
<br />
An '''Index Buffer''' is an 0x18 byte structure which describes a list of 16 bit values which are used to index the '''FVTX''' section when drawing the polygon. Index Buffers are referenced by [[FMDL (File Format)#Drawing Command|Drawing Command]]s. The format is very similar to the [[FMDL (File Format)#Buffers|FVTX Buffer]] format, which may indicate they are instances of the same structure.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size''' of index data in bytes.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' Always '''1'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| {{Unknown|'''Unknown''' Always '''0'''.}}<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Index data offset'''.<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of Index Buffer}}<br />
|}<br />
<br />
=== Drawing Extent Tree ===<br />
<br />
The '''Drawing Extent Tree''' is some sort of tree structure that occurs in all FSHP sections. In all [[Mario Kart 8]] files, when the '''FSHP''' has multiple [[FMDL (File Format)#Drawing Command|Drawing Command]]s, the Drawing Extent Tree is a trivial one node tree. The Drawing Extent Tree may be used to control which [[FMDL (File Format)#Drawing Extent|Drawing Extent]]s need to be drawn, for example as part of a dynamic level of detail system. The true workings and purpose of the structure are however unknown.<br />
<br />
==== Nodes ====<br />
<br />
The '''Drawing Extent Tree Node''' is a repeating 0xc byte structure. The nodes form a binary tree. The [[FMDL (File Format)#FSHP|FSHP header]] contains a pointer to node array, as well as specifying its length. The root node is the first node in this array. Each node specifies a range of Drawing Extents, with the root node always covering all nodes, and the children of each node always selecting disjoint subsets of that node's range.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 2<br />
| '''Left Child''' index. The current node's index if it has no left child.<br />
|-<br />
| 0x02<br />
| 2<br />
| '''Right Child''' index. The current node's index if it has no right child.<br />
|-<br />
| 0x04<br />
| 2<br />
| '''Unknown''' always the same as '''Left Child''' index.<br />
|-<br />
| 0x06<br />
| 2<br />
| '''Next Sibling''' index. Always the current node's parent's right child (the current node's index if it has no right child).<br />
|-<br />
| 0x08<br />
| 2<br />
| '''[[FMDL (File Format)#Drawing Extent|Drawing Extent]] Index''' selects a range of Drawing Extents along with the count.<br />
|-<br />
| 0x0a<br />
| 2<br />
| '''[[FMDL (File Format)#Drawing Extent|Drawing Extent]] Count''' selects a range of Drawing Extents along with the index.<br />
|-<br />
| 0x0c<br />
| colspan="2" {{Unknown|End of Node}}<br />
|}<br />
<br />
==== Ranges ====<br />
<br />
The '''Drawing Extent Tree Range''' is a repeating 0x18 byte structure. The purpose is unknown. There are exactly as many Ranges as Nodes. The range appears to contain two 3D positions, which are not necessarily distinct.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 12<br />
| {{Unknown|'''Unknown''' 3D position (x,y,z float).}}<br />
|-<br />
| 0x0c<br />
| 12<br />
| {{Unknown|'''Unknown''' 3D position (x,y,z float).}}<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of Range}}<br />
|}<br />
<br />
==== Indices ====<br />
<br />
The '''Drawing Extent Tree Index''' array is an array of 16 bit values which appear to be the index of the leaf node of the '''Drawing Extent Tree''' which contains the corresponding '''[[FMDL (File Format)#Drawing Extent|Drawing Extent]]'''. Therefore this array has length equal to the number of [[FMDL (File Format)#Drawing Extent|Drawing Extent]]s in the '''FSHP''' section.<br />
<br />
[[category:File Format]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=BFRES_(File_Format)&diff=796BFRES (File Format)2014-08-09T04:52:29Z<p>Chadderz: /* String Table */ typo.</p>
<hr />
<div>'''BFRES''' is an archive format used on [[Wii U]] and in [[Mario Kart 8]] to store graphics data. Typically, a BFRES file will contain information for one model including textures and animations, but this is not necessarily the case. BFRES seems to be a direct upgrade of the [[mkw:BRRES (File Format)|BRRES]] format used on [[mkw:Wii|Wii]]. Due to their vast size, large BFRES files are often compressed using [[YAZ0 (File Format)|YAZ0 compression]].<br />
<br />
__TOC__<br />
<br />
= Format =<br />
<br />
This article describes the '''BFRES''' file format seen in [[Mario Kart 8]]. It is unknown if the file format differs between games like the [[mkw:BRRES (File Format)|BRRES]] format does. The basic architecture of a '''BFRES''' file is any number of subfiles each in one of 12 groups governing format and purpose. Each subfile is something like a model or a texture. Unless otherwise noted, all offsets in BFRES files are relative to themselves, not the beginning of the file which is more common in other formats.<br />
<br />
== Header (FRES) ==<br />
<br />
Every BFRES file begins with an 0x6c byte '''FRES''' header. <br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FRES'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 1<br />
| {{Unknown|'''Unknown''' has value '''0x03''' in [[Mario Kart 8]] files.}}<ref group="FRES">Almost certainly 4 separate bytes as have not yet read BOM.</ref><br />
|-<br />
| 0x05<br />
| 1<br />
| {{Unknown|'''Unknown''' has value '''0x00, 0x03 or 0x04''' in [[Mario Kart 8]] files.}}<br />
|-<br />
| 0x06<br />
| 1<br />
| {{Unknown|'''Unknown''' has value '''0x00''' in [[Mario Kart 8]] files.}}<br />
|-<br />
| 0x07<br />
| 1<br />
| {{Unknown|'''Unknown''' has value '''0x01, 0x02 or 0x04''' in [[Mario Kart 8]] files.}}<br />
|-<br />
| 0x08<br />
| 2<br />
| '''Byte order mark''' (BOM): 0xFE,0xFF for big endian and 0xFF,0xFE for little endian.<br />
|-<br />
| 0x0a<br />
| 2<br />
| {{Unknown|'''Unknown''' Probably a version number<ref group="FRES">This is an assumption because of the parallel with BRRES.</ref>, always has value '''0x0010''' in [[Mario Kart 8]] files.}}<br />
|-<br />
| 0x0c<br />
| 4<br />
| '''File length''' including all headers, in bytes.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''File alignment''' a power of 2. Most specific data alignment required in the file. The graphics card often requires data to be aligned to specific power of 2 boundaries. If the file is loaded into memory aligned to this value<ref group="FRES">That is to say, the address of the data is a multiple of this value.</ref>, then all addresses will be correct for the graphics card.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''File name''' offset (without file extension).<br />
|-<br />
| 0x18<br />
| 4<br />
| {{Unknown|'''Unknown'''. Probably a length or an offset.}}<br />
|-<br />
| 0x1c<br />
| 4<br />
| '''String table''' offset.<br />
|-<br />
| 0x20<br />
| 4 &times; 12<br />
| '''File offsets'''. Offsets to [[BFRES (File Format)#Index Group|index groups]] for each of the 12 subfile types. '''0''' indicates that a particular subfile type is not present.<br />
|-<br />
| 0x50<br />
| 2 &times; 12<br />
| '''File counts'''. Numer of files in the [[BFRES (File Format)#Index Group|index groups]] for each of the 12 subfile types. '''0''' for subfile types which are not present.<br />
|-<br />
| 0x68<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0''' in [[Mario Kart 8]] files.}}<br />
|-<br />
| 0x6c<br />
| colspan="2" {{Unknown|End of '''FRES''' header}}<br />
|}<br />
<references group="FRES"/><br />
<br />
== Index Group ==<br />
<br />
The '''BFRES Index Group''' is a data structure that occurs very often within BFRES files and subfiles. It is a binary search tree in which a series of named data pointers are stored which are used to represent subfiles. It has a 0x08 byte header, as follows.<br />
{| class="wikitable"<br />
|-<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Length''' of group in bytes.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Number''' in group (excluding the root entry).<br />
|-<br />
| 0x08<br />
| colspan="2" {{Unknown|End of index group header}}<br />
|}<br />
This is then followed by a number of entries equal to the number in the header. The first entry is never an actual data entry, but instead a reference point. Each entry is a 0x10 byte structure as follows.<br />
{| class="wikitable"<br />
|-<br />
! Offset<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Search value''' a value used in the binary search tree traversal algorithm.<br />
|-<br />
| 0x04<br />
| 2<br />
| '''Left index''' used in binary search tree traversal algorithm.<br />
|-<br />
| 0x06<br />
| 2<br />
| '''Right index''' used in binary search tree traversal algorithm.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Name pointer'''. Offset to the name of this entry.<br />
|-<br />
| 0x0c<br />
| 4<br />
| '''Data pointer'''. Offset to the data of this entry.<br />
|-<br />
| 0x10<br />
| colspan="2" {{Unknown|End of entry}}<br />
|}<br />
<br />
It is unknown how the binary search tree algorithm works but it may be similar to the [[mkw:BRRES Index Group (File Format)|BRRES Index Group]].<br />
<br />
== String Table ==<br />
<br />
The '''BFRES String Table''' is a table that occurs near the end of the BFRES file. There is no header information for the table. References to the table are stored as offsets to stored to strings directly. The strings are stored in ASCII order (so Z comes before a). The length of each string is stored in the 4 bytes before that string and the strings are also null terminated. Each length is 4 byte aligned. The pointer in the [[BFRES (File Format)#Header|FRES header]] points to the length of the first string.<br />
<br />
== Sub Files ==<br />
<br />
The format and purpose of subfiles is determined entirely by the index group they're in of the 12 main index groups references by the FRES header.<br />
<br />
{| class="wikitable"<br />
! Index<br />
! Format<br />
|-<br />
| 0<br />
| [[FMDL (File Format)|FMDL model]].<br />
|-<br />
| 1<br />
| [[FTEX (File Format)|FTEX texture]].<br />
|-<br />
| 2<br />
| [[FSKA (File Format)|FSKA data]].<br />
|-<br />
| 3<br />
| rowspan="3" | [[FSHU (File Format)|FSHU data]]. '''Unknown''' why 3 indices all use the same format.<br />
|-<br />
| 4<br />
|-<br />
| 5<br />
|-<br />
| 6<br />
| [[FTXP (File Format)|FTXP data]].<br />
|-<br />
| 7<br />
| '''Unknown''' not seen in Mario Kart 8.<br />
|-<br />
| 8<br />
| [[FVIS (File Format)|FVIS bone visibility]].<br />
|-<br />
| 9<br />
| [[FSHA (File Format)|FSHA data]].<br />
|-<br />
| 10<br />
| [[FSCN (File Format)|FSCN scene data]].<br />
|-<br />
| 11<br />
| '''Embedded file'''. The data offset points to a offset &amp; length pair which describe the embedded file. The embedded files always seem to be placed at the end of the BFRES fille. Shader source code has been seen in embedded files, though this is not typically the case.<br />
|}<br />
<br />
[[category:File Format]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=FMDL_(File_Format)&diff=793FMDL (File Format)2014-08-08T18:52:00Z<p>Chadderz: Started FMDL article based on analysis of the header and FVTX sections. More to follow soon, I'm documenting as I analyse.</p>
<hr />
<div>{{Under-construction}}<br />
<br />
The '''FMDL''' model format is a format for models which appears as a subfile of a '''[[BFRES (File Format)|BFRES file]]''' in the '''0'''th file group. Typically a BFRES file has one FMDL but some have none and some have more than one.<br />
<br />
__TOC__<br />
<br />
= Format =<br />
<br />
An FMDL file begins with an FMDL header. This is then followed by a number of sections pointed to by the header, many of which can occur multiple times. Unless otherwise noted, all offsets in BFRES files are relative to themselves, not the beginning of the file which is more common in other formats.<br />
<br />
== Header (FMDL) ==<br />
<br />
Every FMDL begins with an 0x2c byte '''FMDL header'''.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FMDL'''" file identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''File name''' offset (without file extension).<br />
|-<br />
| 0x08<br />
| 4<br />
| '''End of BFRES string table''' offset.<br />
|-<br />
| 0x0c<br />
| 4<br />
| [[FMDL (File Format)#FSKL|FSKL]] offset.<br />
|-<br />
| 0x10<br />
| 4<br />
| [[FMDL (File Format)#FVTX|FVTX]] array offset.<br />
|-<br />
| 0x14<br />
| 4<br />
| [[FMDL (File Format)#FSHP|FSHP]] [[BFRES (File Format)#Index Group|index group]] offset.<br />
|-<br />
| 0x18<br />
| 4<br />
| [[FMDL (File Format)#FMAT|FMAT]] [[BFRES (File Format)#Index Group|index group]] offset.<br />
|-<br />
| 0x1c<br />
| 4<br />
| [[FMDL (File Format)#Parameter|Parameter]] [[BFRES (File Format)#Index Group|index group]] offset. May be '''0''' if no parameters exist (common).<br />
|-<br />
| 0x20<br />
| 2<br />
| '''[[FMDL (File Format)#FVTX|FVTX]] count''': number of FVTX sections.<br />
|-<br />
| 0x22<br />
| 2<br />
| '''[[FMDL (File Format)#FSHP|FSHP]] count''': number of FSHP sections.<br />
|-<br />
| 0x24<br />
| 2<br />
| '''[[FMDL (File Format)#FMAT|FMAT]] count''': number of FMAT sections.<br />
|-<br />
| 0x26<br />
| 2<br />
| '''[[FMDL (File Format)#Parameter|Parameter]] count''': number of parameter sections.<br />
|-<br />
| 0x28<br />
| 4<br />
| {{Unknown|'''Unknown''' possibly something like an unused face count.}}<br />
|-<br />
| 0x2c<br />
| colspan="2" {{Unknown|End of FMDL header}}<br />
|}<br />
<br />
== FVTX ==<br />
<br />
The model may have one or more '''FVTX''' sections which describe the vertices for one polygon (e.g. the road of a track). The section describes a series of buffers and attributes. Buffers are arbitrary pieces of data which contain the actual values of the vertices and are passed directly to the graphics card. Attributes are properties of vertices (e.g. position, texture coordinate, vertex colours) and they describe the format and layout of the data in the buffers.<br />
<br />
=== Header ===<br />
<br />
Each FVTX section has a 0x20 byte header. These headers are stored sequentially in an array at the offset given in the '''FMDL header'''. The length of this array is also given in that header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FVTX'''" section identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 1<br />
| '''Attribute count''': number of different attributes in section (position, normal, colour, etc).<br />
|-<br />
| 0x05<br />
| 1<br />
| '''Buffer count''': number of attribute buffers.<br />
|-<br />
| 0x06<br />
| 2<br />
| '''Section index''': index into FVTX array of this entry.<br />
|-<br />
| 0x08<br />
| 4<br />
| Number of vertices.<br />
|-<br />
| 0x0c<br />
| 1<br />
| {{Unknown|'''Unknown'''; values seen are between '''0''' and '''4''' (normally '''0''').}}<br />
|-<br />
| 0x0d<br />
| 3<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| Attribute array offset.<br />
|-<br />
| 0x14<br />
| 4<br />
| Attribute [[BFRES (File Format)#Index Group|index group]] offset.<br />
|-<br />
| 0x18<br />
| 4<br />
| Buffer array offset.<br />
|-<br />
| 0x1c<br />
| 4<br />
| Padding, always '''0'''.<br />
|-<br />
| 0x20<br />
| colspan="2" {{Unknown|End of FVTX header}}<br />
|}<br />
<br />
=== Attributes ===<br />
<br />
The '''attributes''' of each '''FVTX''' section are stored as a simple repeating 0xc byte structure. These are stored in an array with location and length specified by the FVTX header. They are also referenced by the attribute index group, presumably to allow both index and name based lookup of attributes.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Attribute name''' offset.<br />
|-<br />
| 0x04<br />
| 1<br />
| '''Buffer index''' of the buffer containing this attribute.<br />
|-<br />
| 0x05<br />
| 3<br />
| '''Buffer offset''' of the attribute in each structure in the buffer.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Format''' of the attribute's data in the buffer.<br />
|-<br />
| 0xc<br />
| colspan="2" {{Unknown|End of attribute}}<br />
|}<br />
<br />
Based on the some of the shader code in [[Filesystem/content/mapobj/PackunMusic#Files|/vol/content/mapobj/PackunMusic/PackunMusic.bfres]] the following naming convention seems to be used for attributes.<br />
<br />
{| class="wikitable"<br />
! Attribute Name<br />
! Friendly Name<br />
! Description<br />
|-<br />
| _p0<br />
| position0<br />
| The position of the vertex.<br />
|-<br />
| _n0<br />
| normal0<br />
| The normal of the vertex as used in lighting calculations.<br />
|-<br />
| _t0<br />
| tangent0<br />
| The tangent of the vertex as used in advanced lighting calculations.<br />
|-<br />
| _b0<br />
| binormal0<br />
| The binormal of the vertex as used in advanced lighting calculations.<br />
|-<br />
| _w0<br />
| blendweight0<br />
| {{Unknown}}<br />
|-<br />
| _i0<br />
| blendindex0<br />
| {{Unknown}}<br />
|-<br />
| _u0<br />
| uv0<br />
| rowspan="4" | Texture coordinates used for texture mapping.<br />
|-<br />
| _u1<br />
| uv1<br />
|-<br />
| _u2<br />
| uv2<br />
|-<br />
| _u3<br />
| uv3<br />
|-<br />
| _c0<br />
| color0<br />
| rowspan="2" | Vertex colours used for simple shadow mapping.<br />
|-<br />
| _c1<br />
| color1<br />
|}<br />
<br />
=== Buffers ===<br />
<br />
The '''buffers''' of each '''FVTX''' section are stored as a repeating 0x18 byte header structure which references the actual data stored later in the BFRES file. The headers are stored in an array with location and length specified by the FVTX header.<br />
<br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Size''' of the buffer in bytes.<br />
|-<br />
| 0x08<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x0c<br />
| 2<br />
| '''Stride''': the size of each element in the buffer.<br />
|-<br />
| 0x0e<br />
| 2<br />
| {{Unknown|'''Unknown''' always '''1'''.}}<br />
|-<br />
| 0x10<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0'''.}}<br />
|-<br />
| 0x14<br />
| 4<br />
| '''Data offset'''.<br />
|-<br />
| 0x18<br />
| colspan="2" {{Unknown|End of buffer}}<br />
|}<br />
<br />
[[category:File Format]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=BFRES_(File_Format)&diff=787BFRES (File Format)2014-08-08T12:00:07Z<p>Chadderz: Completed basc BFRES format page based on initial analysis.</p>
<hr />
<div>'''BFRES''' is an archive format used on [[Wii U]] and in [[Mario Kart 8]] to store graphics data. Typically, a BFRES file will contain information for one model including textures and animations, but this is not necessarily the case. BFRES seems to be a direct upgrade of the [[mkw:BRRES (File Format)|BRRES]] format used on [[mkw:Wii|Wii]]. Due to their vast size, large BFRES files are often compressed using [[YAZ0 (File Format)|YAZ0 compression]].<br />
<br />
__TOC__<br />
<br />
= Format =<br />
<br />
This article describes the '''BFRES''' file format seen in [[Mario Kart 8]]. It is unknown if the file format differs between games like the [[mkw:BRRES (File Format)|BRRES]] format does. The basic architecture of a '''BFRES''' file is any number of subfiles each in one of 12 groups governing format and purpose. Each subfile is something like a model or a texture. Unless otherwise noted, all offsets in BFRES files are relative to themselves, not the beginning of the file which is more common in other formats.<br />
<br />
== Header (FRES) ==<br />
<br />
Every BFRES file begins with an 0x6c byte '''FRES''' header. <br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FRES'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 1<br />
| {{Unknown|'''Unknown''' has value '''0x03''' in [[Mario Kart 8]] files.}}<ref group="FRES">Almost certainly 4 separate bytes as have not yet read BOM.</ref><br />
|-<br />
| 0x05<br />
| 1<br />
| {{Unknown|'''Unknown''' has value '''0x00, 0x03 or 0x04''' in [[Mario Kart 8]] files.}}<br />
|-<br />
| 0x06<br />
| 1<br />
| {{Unknown|'''Unknown''' has value '''0x00''' in [[Mario Kart 8]] files.}}<br />
|-<br />
| 0x07<br />
| 1<br />
| {{Unknown|'''Unknown''' has value '''0x01, 0x02 or 0x04''' in [[Mario Kart 8]] files.}}<br />
|-<br />
| 0x08<br />
| 2<br />
| '''Byte order mark''' (BOM): 0xFE,0xFF for big endian and 0xFF,0xFE for little endian.<br />
|-<br />
| 0x0a<br />
| 2<br />
| {{Unknown|'''Unknown''' Probably a version number<ref group="FRES">This is an assumption because of the parallel with BRRES.</ref>, always has value '''0x0010''' in [[Mario Kart 8]] files.}}<br />
|-<br />
| 0x0c<br />
| 4<br />
| '''File length''' including all headers, in bytes.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''File alignment''' a power of 2. Most specific data alignment required in the file. The graphics card often requires data to be aligned to specific power of 2 boundaries. If the file is loaded into memory aligned to this value<ref group="FRES">That is to say, the address of the data is a multiple of this value.</ref>, then all addresses will be correct for the graphics card.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''File name''' offset (without file extension).<br />
|-<br />
| 0x18<br />
| 4<br />
| {{Unknown|'''Unknown'''. Probably a length or an offset.}}<br />
|-<br />
| 0x1c<br />
| 4<br />
| '''String table''' offset.<br />
|-<br />
| 0x20<br />
| 4 &times; 12<br />
| '''File offsets'''. Offsets to [[BFRES (File Format)#Index Group|index groups]] for each of the 12 subfile types. '''0''' indicates that a particular subfile type is not present.<br />
|-<br />
| 0x50<br />
| 2 &times; 12<br />
| '''File counts'''. Numer of files in the [[BFRES (File Format)#Index Group|index groups]] for each of the 12 subfile types. '''0''' for subfile types which are not present.<br />
|-<br />
| 0x68<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0''' in [[Mario Kart 8]] files.}}<br />
|-<br />
| 0x6c<br />
| colspan="2" {{Unknown|End of '''FRES''' header}}<br />
|}<br />
<references group="FRES"/><br />
<br />
== Index Group ==<br />
<br />
The '''BFRES Index Group''' is a data structure that occurs very often within BFRES files and subfiles. It is a binary search tree in which a series of named data pointers are stored which are used to represent subfiles. It has a 0x08 byte header, as follows.<br />
{| class="wikitable"<br />
|-<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Length''' of group in bytes.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Number''' in group (excluding the root entry).<br />
|-<br />
| 0x08<br />
| colspan="2" {{Unknown|End of index group header}}<br />
|}<br />
This is then followed by a number of entries equal to the number in the header. The first entry is never an actual data entry, but instead a reference point. Each entry is a 0x10 byte structure as follows.<br />
{| class="wikitable"<br />
|-<br />
! Offset<br />
! Type<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| '''Search value''' a value used in the binary search tree traversal algorithm.<br />
|-<br />
| 0x04<br />
| 2<br />
| '''Left index''' used in binary search tree traversal algorithm.<br />
|-<br />
| 0x06<br />
| 2<br />
| '''Right index''' used in binary search tree traversal algorithm.<br />
|-<br />
| 0x08<br />
| 4<br />
| '''Name pointer'''. Offset to the name of this entry.<br />
|-<br />
| 0x0c<br />
| 4<br />
| '''Data pointer'''. Offset to the data of this entry.<br />
|-<br />
| 0x10<br />
| colspan="2" {{Unknown|End of entry}}<br />
|}<br />
<br />
It is unknown how the binary search tree algorithm works but it may be similar to the [[mkw:BRRES Index Group (File Format)|BRRES Index Group]].<br />
<br />
== String Table ==<br />
<br />
The '''BFRES String Table''' is a table that occurs near the end of the BFRES file. There is no header information for the table. References to the table are stored as offsets to stored to strings directly. The strings are stored in ASII order (so Z comes before a). The length of each string is stored in the 4 bytes before that string and the strings are also null terminated. Each length is 4 byte aligned. The pointer in the [[BFRES (File Format)#Header|FRES header]] points to the length of the first string.<br />
<br />
== Sub Files ==<br />
<br />
The format and purpose of subfiles is determined entirely by the index group they're in of the 12 main index groups references by the FRES header.<br />
<br />
{| class="wikitable"<br />
! Index<br />
! Format<br />
|-<br />
| 0<br />
| [[FMDL (File Format)|FMDL model]].<br />
|-<br />
| 1<br />
| [[FTEX (File Format)|FTEX texture]].<br />
|-<br />
| 2<br />
| [[FSKA (File Format)|FSKA data]].<br />
|-<br />
| 3<br />
| rowspan="3" | [[FSHU (File Format)|FSHU data]]. '''Unknown''' why 3 indices all use the same format.<br />
|-<br />
| 4<br />
|-<br />
| 5<br />
|-<br />
| 6<br />
| [[FTXP (File Format)|FTXP data]].<br />
|-<br />
| 7<br />
| '''Unknown''' not seen in Mario Kart 8.<br />
|-<br />
| 8<br />
| [[FVIS (File Format)|FVIS bone visibility]].<br />
|-<br />
| 9<br />
| [[FSHA (File Format)|FSHA data]].<br />
|-<br />
| 10<br />
| [[FSCN (File Format)|FSCN scene data]].<br />
|-<br />
| 11<br />
| '''Embedded file'''. The data offset points to a offset &amp; length pair which describe the embedded file. The embedded files always seem to be placed at the end of the BFRES fille. Shader source code has been seen in embedded files, though this is not typically the case.<br />
|}<br />
<br />
[[category:File Format]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=BFRES_(File_Format)&diff=786BFRES (File Format)2014-08-08T10:08:14Z<p>Chadderz: Started BFRES article based on analysis of the header. More to follow soon, I'm documenting as I analyse.</p>
<hr />
<div>{{Under-construction}}<br />
<br />
'''BFRES''' is an archive format used on [[Wii U]] and in [[Mario Kart 8]] to store graphics data. Typically, a BFRES file will contain information for one model including textures and animations, but this is not necessarily the case. BFRES seems to be a direct upgrade of the [[mkw:BRRES (File Format)|BRRES]] format used on [[mkw:Wii|Wii]]. Due to their vast size, large BFRES files are often compressed using [[YAZ0 (File Format)|YAZ0 compression]].<br />
<br />
__TOC__<br />
<br />
= Format =<br />
<br />
This article describes the '''BFRES''' file format seen in [[Mario Kart 8]]. It is unknown if the file format differs between games like the [[mkw:BRRES (File Format)|BRRES]] format does. The basic architecture of a '''BFRES''' file is any number of subfiles each in one of 12 specific formats. Each subfile is something like a model or a texture. Unless otherwise noted, all offsets in BFRES files are relative to themselves, not the beginning of the file which is more common in other formats.<br />
<br />
== Header (FRES) ==<br />
<br />
Every BFRES file begins with an 0x6c byte '''FRES''' header. <br />
{| class="wikitable"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 4<br />
| "'''FRES'''" File identifier, ASCII string.<br />
|-<br />
| 0x04<br />
| 1<br />
| {{Unknown|'''Unknown''' has value '''0x03''' in [[Mario Kart 8]] files.}}<ref group="FRES">Almost certainly 4 separate bytes as have not yet read BOM.</ref><br />
|-<br />
| 0x05<br />
| 1<br />
| {{Unknown|'''Unknown''' has value '''0x00, 0x03 or 0x04''' in [[Mario Kart 8]] files.}}<br />
|-<br />
| 0x06<br />
| 1<br />
| {{Unknown|'''Unknown''' has value '''0x00''' in [[Mario Kart 8]] files.}}<br />
|-<br />
| 0x07<br />
| 1<br />
| {{Unknown|'''Unknown''' has value '''0x01, 0x02 or 0x04''' in [[Mario Kart 8]] files.}}<br />
|-<br />
| 0x08<br />
| 2<br />
| '''Byte order mark''' (BOM): 0xFE,0xFF for big endian and 0xFF,0xFE for little endian.<br />
|-<br />
| 0x0a<br />
| 2<br />
| {{Unknown|'''Unknown''' Probably a version number<ref group="FRES">This is an assumption because of the parallel with BRRES.</ref>, always has value '''0x0010''' in [[Mario Kart 8]] files.}}<br />
|-<br />
| 0x0c<br />
| 4<br />
| '''File length''' including all headers, in bytes.<br />
|-<br />
| 0x10<br />
| 4<br />
| '''File alignment''' a power of 2. Most specific data alignment required in the file. The graphics card often requires data to be aligned to specific power of 2 boundaries. If the file is loaded into memory aligned to this value<ref group="FRES">That is to say, the address of the data is a multiple of this value.</ref>, then all addresses will be correct for the graphics card.<br />
|-<br />
| 0x14<br />
| 4<br />
| '''File name''' offset (without file extension).<br />
|-<br />
| 0x18<br />
| 4<br />
| {{Unknown|'''Unknown'''. Probably a length or an offset.}}<br />
|-<br />
| 0x1c<br />
| 4<br />
| '''String table''' offset.<br />
|-<br />
| 0x20<br />
| 4 &times; 12<br />
| '''File offsets'''. Offsets to index groups for each of the 12 subfile types. '''0''' indicates that a particular subfile type is not present.<br />
|-<br />
| 0x50<br />
| 2 &times; 12<br />
| '''File counts'''. Numer of files in the index groups for each of the 12 subfile types. '''0''' for subfile types which are not present.<br />
|-<br />
| 0x68<br />
| 4<br />
| {{Unknown|'''Unknown''' always '''0''' in [[Mario Kart 8]] files.}}<br />
|-<br />
| 0x6c<br />
| colspan="2" {{Unknown|End of '''FRES''' header}}<br />
|}<br />
<references group="FRES"/><br />
<br />
[[category:File Format]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=Main_Page&diff=783Main Page2014-08-07T19:22:44Z<p>Chadderz: BYAML is more than just a replacement KMP.</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|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 />
{{multi-column|<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 - Image file]]<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 />
[[Unused Tracks]]<br><br />
}}<br />
|<br />
<br />
{{textbox|news|Latest Wiiki News|<br />
<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 />
<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 />
<br />
'''All News: [[News 2014|2014]]'''<br />
}}<br />
}}<br />
<br />
[[Category:General Information]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=List_of_File_Formats&diff=721List of File Formats2014-08-05T20:03:47Z<p>Chadderz: Created page based on intial analysis of file formats.</p>
<hr />
<div>This article contains a list of '''file formats''' in [[Mario Kart 8]]. For a comparison with [[mkw: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 />
| 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 | [[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|Unknown.}}<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 | [[GSH (File Format)|GSH]]<br />
| Compiled graphics shader.<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 />
| {{Unknown|Unknown.}}<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]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=Version_Number&diff=720Version Number2014-08-05T19:44:59Z<p>Chadderz: Created redirect to mkw:Version Number.</p>
<hr />
<div>#redirect [[mkw:Version Number]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=Template:Main-news&diff=719Template:Main-news2014-08-05T19:41:53Z<p>Chadderz: Added some historical news items.</p>
<hr />
<div><noinclude><br />
{{News Attention}}<br />
<br />
== News List ==<br />
<!-- *********************************** --><br />
<!-- *** INSERT BELOW THIS COMMENT *** --><br />
<!-- *********************************** --></noinclude><br />
;2014-08-04<br />
* This MK8-Wiki was founded.<br />
<br />
;2014-07-21<br />
* '''[[MrBean35000vr]]''' and '''[[Chadderz]]''' created the first [[Mario Kart 8]] [[Texture Hack]]; '''[[Icy Thwomp Ruins (Thwomp Ruins Texture)|Icy Thwomp Ruins]]'''.<br />
<br />
;2014-07-05<br />
* '''[[MrBean35000vr]]''' and '''[[Chadderz]]''' created the first '''[[Mario Kart 8]] mods''' on a [http://www.twitch.tv/mrbean35000vr/b/544826295 twitch.tv livestream].</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=News_2014&diff=718News 20142014-08-05T19:39:49Z<p>Chadderz: Added some historical news items.</p>
<hr />
<div>{{News Attention}}<br />
<!-- WARNING: Newer entries within the same date must be put below older entries. --><br />
{{textbox|news|August 2014|<br />
;2014-08-04<br />
* This MK8-Wiki was founded.<br />
}}<br />
{{textbox|news|July 2014|<br />
;2014-07-21<br />
* '''[[MrBean35000vr]]''' and '''[[Chadderz]]''' created the first [[Mario Kart 8]] [[Texture Hack]]; '''[[Icy Thwomp Ruins (Thwomp Ruins Texture)|Icy Thwomp Ruins]]'''.<br />
<br />
;2014-07-05<br />
* '''[[MrBean35000vr]]''' and '''[[Chadderz]]''' created the first '''[[Mario Kart 8]] mods''' on a [http://www.twitch.tv/mrbean35000vr/b/544826295 twitch.tv livestream].<br />
}}<br />
<br />
{{News Links}}<br />
[[Category:History]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=Icy_Thwomp_Ruins_(Thwomp_Ruins_Texture)_(MrBean35000vr_%26_Chadderz)&diff=716Icy Thwomp Ruins (Thwomp Ruins Texture) (MrBean35000vr & Chadderz)2014-08-05T19:17:34Z<p>Chadderz: /* Overview */ Added more information about the hack.</p>
<hr />
<div><div class="float-right"><br />
{{Text-Info<br />
|texture hack name= Icy Thwomp Ruins<br />
|author= [[MrBean35000vr]], [[Chadderz]]<br />
|type= Snow, Ice, Night<br />
|version=<br />
|date of released= 2014-07-21<br />
|download=<br />
}}<br />
</div><br />
<br />
==Overview==<br />
'''Icy Thwomp Ruins''' is the first [[Mario Kart 8]] [[Texture Hack]]. It gives Thwomp Ruins a snow/ice/night theme. It was made using textures from GCN Sherbet Land and Mount Wario, as well as simple hue edits to the existing Thwomp Ruins textures. It also features a [[course_muunt.byaml (File Format)|course_muunt.byaml]] edit in order to change the skybox, add a moon, remove the plants near the beginning, remove the sun and add snowmen. The course.bgenv file was also swapped with the one from N64 Toad's Turnpike to create the night lighting effect.<br />
<br />
==Media==<br />
{{youtube-box||kyz5NIeM5ws|VS Race}}<br />
<br />
==Version History==<br />
{| class="wikitable"<br />
|-<br />
! align=left| Version<br />
! align=left| Date of release<br />
! align=left| Information<br />
|-<br />
|<br />
| 2014-07-21<br />
| Preview Video<br />
|}<br />
<br />
{{User-MrBean35000vr-Link}}<br />
{{User-Chadderz-Link}}<br />
[[Category:Track/Texture]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=Talk:Filesystem/content/course&diff=625Talk:Filesystem/content/course2014-08-05T13:55:25Z<p>Chadderz: Reply to Emer.</p>
<hr />
<div>== Compression ==<br />
So courses, with the exception of their models, are stored uncompressed within folders? --CT creator [[User:Emergamer02|Emer]], ([[User talk:Emergamer02|talk here]]) 13:27, 5 August 2014 (UTC)<br />
: Correct. [[User:Chadderz|Chadderz]] ([[User talk:Chadderz|talk]]) 13:55, 5 August 2014 (UTC)</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=YAZ0_(File_Format)&diff=620YAZ0 (File Format)2014-08-05T12:24:52Z<p>Chadderz: Added redirect to mkw:YAZ0 (File Format).</p>
<hr />
<div>#redirect [[mkw:YAZ0 (File Format)]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=Filesystem&diff=28Filesystem2014-08-05T10:58:29Z<p>Chadderz: Added introduction page for filesystem.</p>
<hr />
<div>This article describes the '''filesystem''' of [[Mario Kart 8]] ([[PAL]] release).<br />
<br />
The [[Wii U]] uses an architecture similar to the [http://en.wikipedia.org/wiki/Unix_filesystem Unix filesystem], in that there is a root directory '''/''' and all devices are mounted to subdirectories of this root. While an application is running '''[[Filesystem/content|/vol/content]]''' points to the main read-only data directory of that application. The contents of the [[Mario Kart 8]] game disk or download data are mounted to this directory. The data contains all the courses, music, and many other files used by the game.<br />
<br />
[[Category: Filesystem|!]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=BYAML_(File_Format)&diff=25BYAML (File Format)2014-08-05T08:50:18Z<p>Chadderz: /* Uses */ Edited links for consitency</p>
<hr />
<div>The '''BYAML''' file format is a generic data container format used in [[Mario Kart 8]]. It is similar in some ways to [http://en.wikipedia.org/wiki/Xml XML], but it is a binary data format. Like XML files, BYAML files are somewhat self describing making it easier to understand and edit them than unformated binary data. In Mario Kart 8 they're used to describe course control information such as layout and checkpointing, as well as describing game-wide settings such as objects and AIs.<br />
<br />
__TOC__<br />
<br />
= Format =<br />
<br />
The file is broken up into a node structure, with possible interlinking between the nodes. Each node has a one byte format identifier. The file begins with a header which points to up to four special nodes: the node name table node; the string value table node; the path value node and finally the root node.<br />
<br />
== Header ==<br />
<br />
The BYAML file format starts with a 0x14 byte header structure.<br />
<br />
{| class="wikitable"<br />
|-<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 2<br />
| '''String "BY" in ASCII''' (file identifier).<br />
|-<br />
| 0x02<br />
| 2<br />
| '''Version''' 0x0001 in [[Mario Kart 8]].<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Node name table node''' Offset to the node name table node, relative to start (usually 0x014). Unknown if this can ever be 0. Must be a '''string value node''' (0xc2).<br />
|-<br />
| 0x08<br />
| 4<br />
| '''String value table node''' Offset to the string value table node, relative to start. May be '''0''' if string values unused. Must be a '''string value node''' (0xc2).<br />
|-<br />
| 0x0c<br />
| 4<br />
| '''Path value table node''' Offset to the path value table node, relative to start. May be '''0''' if path values unused. Must be a '''path value node''' (0xc3).<br />
|-<br />
| 0x10<br />
| 4<br />
| '''Root node''' Offset to the root node, relative to start. Must be either an '''array node''' (0xc0) or a '''dictionary node''' (0xc1).<br />
|-<br />
| 0x14<br />
| colspan=2 {{unknown|End of file header}}<br />
|}<br />
<br />
== Nodes ==<br />
<br />
Every node format has a unique one byte identifier as follows. Some nodes are considered value nodes as indicated below. The full nodes have a longer encoding in the file, which must be four byte aligned. The order of encoding full nodes within the file does not seem to matter.<br />
<br />
{| class="wikitable"<br />
|-<br />
! Identifier<br />
! Type<br />
! Description<br />
|-<br />
| 0xa0<br />
| '''Value''' (Index)<br />
| String. Value is an index into the string value table.<br />
|-<br />
| 0xa1<br />
| '''Value''' (Index)<br />
| Path. Value is an index into the path value table.<br />
|-<br />
| 0xc0<br />
| '''Full'''<br />
| Array. Node is an array of nodes, typically, though not necessarily, all of the same format.<br />
|-<br />
| 0xc1<br />
| '''Full'''<br />
| Dictionary. Node is a mapping from strings in the node name table to other nodes.<br />
|-<br />
| 0xc2<br />
| '''Full''' (Special Purpose)<br />
| String table. Special purpose node type only seen in the node name table and the string value table.<br />
|-<br />
| 0xc3<br />
| '''Full''' (Special Purpose)<br />
| Path table. Special purpose node type only seen in the path value table.<br />
|-<br />
| 0xd0<br />
| '''Value'''<br />
| Boolean. Node is '''1''' or '''0''' representing '''true''' or '''false''' respectively.<br />
|-<br />
| 0xd1<br />
| '''Value'''<br />
| Integer. Node is a signed integer value.<br />
|-<br />
| 0xd2<br />
| '''Value'''<br />
| Float. Node is a 32 bit floating point value.<br />
|}<br />
<br />
=== Value Nodes ===<br />
<br />
Value nodes can only be encoded as children of other nodes. Each value node has a direct four byte encoding. For string and path values, this encoding is simply a four byte index into the string or path tables respectively.<br />
<br />
=== 0xc0 - Array Node ===<br />
<br />
An array node begins with the following header.<br />
<br />
{| class="wikitable"<br />
|-<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 1<br />
| '''0xc0''' node type.<br />
|-<br />
| 0x01<br />
| 3<br />
| '''N'''= '''Count''' number of entries in array.<br />
|-<br />
| 0x04<br />
| '''N'''<br />
| Variable length array of node types; the type of each element in the array.<br />
|-<br />
| 0x04+'''N'''<br />
| colspan=2 {{unknown|End of node header}}<br />
|}<br />
<br />
There then follows padding bytes up to the nearest 4 bytes. After the padding is the variable length array of '''N''' node values. For '''value''' nodes this is the four byte node value. For '''full''' nodes this is an offset to the node relative to the start of the file.<br />
<br />
=== 0xc1 - Dictionary Node ===<br />
<br />
Dictionary nodes are used to encode name value collections. The order of entries in the dictionary does not seem to matter. A dictionary node begins with the following header.<br />
<br />
{| class="wikitable"<br />
|-<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 1<br />
| '''0xc1''' node type.<br />
|-<br />
| 0x01<br />
| 3<br />
| '''N'''= '''Count''' number of entries in dictionary.<br />
|-<br />
| 0x04<br />
| colspan=2 {{unknown|End of node header}}<br />
|}<br />
<br />
What then follows is a variable length array of '''N''' dictionary entries. Each entry has the following structure.<br />
<br />
{| class="wikitable"<br />
|-<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 1<br />
| '''Node type'''. One of the node type constants.<br />
|-<br />
| 0x01<br />
| 3<br />
| '''Name'''. Index into the node name value table for the name of this entry.<br />
|-<br />
| 0x04<br />
| 4<br />
| '''Value'''. For '''value''' nodes this is the four byte node value. For '''full''' nodes this is an offset to the node relative to the start of the file.<br />
|-<br />
| 0x08<br />
| colspan=2 {{unknown|End of entry}}<br />
|}<br />
<br />
=== 0xc2 - String Table Node ===<br />
<br />
A string table node begins with the following header.<br />
<br />
{| class="wikitable"<br />
|-<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 1<br />
| '''0xc2''' node type.<br />
|-<br />
| 0x01<br />
| 3<br />
| '''N'''= '''Count''' number of entries in string value table.<br />
|-<br />
| 0x04<br />
| 4*('''N'''+1)<br />
| '''Offsets'''. Variable length array of offsets to each string relative to the start of the node. The last entry is an offset to the end of the last string.<br />
|-<br />
| 0x04+4*('''N'''+1)<br />
| colspan=2 {{unknown|End of node header}}<br />
|}<br />
<br />
Immediately following the node header are the string values at the positions indicated by the offsets. Despite the length being clear from the table, the string values are null terminated, perhaps for ease of decoding. The are always stored in alphabetical order.<br />
<br />
=== 0xc3 - Path Table Node ===<br />
<br />
A path table node begins with the following header.<br />
<br />
{| class="wikitable"<br />
|-<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 1<br />
| '''0xc3''' node type.<br />
|-<br />
| 0x01<br />
| 3<br />
| '''N'''= '''Count''' number of entries in path value table.<br />
|-<br />
| 0x04<br />
| 4*('''N'''+1)<br />
| '''Offsets'''. Variable length array of offsets to each path relative to the start of the node. The last entry is an offset to the end of the last path.<br />
|-<br />
| 0x04+4*('''N'''+1)<br />
| colspan=2 {{unknown|End of node header}}<br />
|}<br />
<br />
Immediately following the header are the paths at the positions indicated by the offsets. The length of each path is implicit; subtract the offset to the next path from the offset to this path. Each path consists of multiple points. Each point is a structure as follows.<br />
<br />
{| class="wikitable"<br />
|-<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x00<br />
| 12<br />
| '''Posiition''' three floating point values, '''x''', '''y''' and '''z'''.<br />
|-<br />
| 0x0c<br />
| 12<br />
| '''Normal''' three floating point values, '''x''', '''y''' and '''z'''.<br />
|-<br />
| 0x18<br />
| 4<br />
| '''Unknown'''.<br />
|-<br />
| 0x1c<br />
| colspan=2 {{unknown|End of point}}<br />
|}<br />
<br />
= Uses =<br />
<br />
Since the BYAML format is a generic data container, this format specification cannot detail what structure a particular BYAML file ought to have. The following table links to articles on specific instances of BYAML files.<br />
<br />
{| class="wikitable"<br />
|-<br />
! File(s)<br />
! Description<br />
|-<br />
| [[Filesystem/content/ai#Files|/content/ai/AIRivalTable.byaml]]<br />
| {{Unknown}}<br />
|-<br />
| [[Filesystem/content/race_common/ai#Files|/content/race_common/ai/AIConfuseTable.byaml]]<br />
| {{Unknown}}<br />
|-<br />
| [[Filesystem/content/race_common/ai#Files|/content/race_common/ai/AICourseTable_GP.byaml]]<br />
| {{Unknown}}<br />
|-<br />
| [[Filesystem/content/race_common/ai#Files|/content/race_common/ai/AICourseTable_VS.byaml]]<br />
| {{Unknown}}<br />
|-<br />
| [[Filesystem/content/race_common/ai#Files|/content/race_common/ai/AIItemTable.byaml]]<br />
| {{Unknown}}<br />
|-<br />
| [[Filesystem/content/race_common/ai#Files|/content/race_common/ai/AILevelTable.byaml]]<br />
| {{Unknown}}<br />
|-<br />
| [[Filesystem/content/race_common/ai#Files|/content/race_common/ai/AIProbability_Drift_Table.byaml]]<br />
| {{Unknown}}<br />
|-<br />
| [[Filesystem/content/race_common/ai#Files|/content/race_common/ai/AIProbability_JumpAction_Table.byaml]]<br />
| {{Unknown}}<br />
|-<br />
| [[Filesystem/content/race_common/ai#Files|/content/race_common/ai/AIProbability_RocketStart_Table.byaml]]<br />
| {{Unknown}}<br />
|-<br />
| [[Filesystem/content/race_common/ai#Files|/content/race_common/ai/AIProbability_WheelSpin_Table.byaml]]<br />
| {{Unknown}}<br />
|-<br />
| [[Filesystem/content/race_common/ai#Files|/content/race_common/ai/AIItemTable.byaml]]<br />
| {{Unknown}}<br />
|-<br />
| [[Filesystem/content/race_common/item#Files|/content/race_common/item/ItemSlotTable.byaml]]<br />
| {{Unknown}}<br />
|-<br />
| /content/course/*/[[battle_muunt.byaml (File Format)|battle_muunt.byaml]]<br />
| Parameters for the battle such as spawn location.<br />
|-<br />
| /content/course/*/[[course_muunt.byaml (File Format)|course_muunt.byaml]]<br />
| Parameters for the course such as lap path, gravity and object placement.<br />
|-<br />
| [[Filesystem/content/data|/content/data]]/[[objflow.byaml (File Format)|objflow.byaml]]<br />
| Object paramters such as hit box, resource list, animation, id.<br />
|-<br />
|}<br />
<br />
= Tools =<br />
<br />
== yamlconv ==<br />
<br />
[[Chadderz]] developed a tool called '''yamlconv''' to convert BYAML files to XML. This is to aid understanding and make editing easier than binary.<br />
<br />
=== Conversion ===<br />
<br />
The conversion procedure begins at the root node. It is encoded as the root XML node with name "yaml". Every sub-node is then recursively converted. Value nodes may either be converted to XML attributes or XML elements. Integers are encoded directly, booleans are encoded as "true" or "false" and floats are encoded as the numeric representation followed by an "f". A string is encoded as the inner text of an XML element with the attribute "type" set to "string". A path is encoded as a series of "point" elements with attributes "x", "y", "z", "nx", "ny", "nz" and "val". The container element of the path has attribute "type" equal to "path". Finally, arrays are encoded as a series of "value" elements with the container having attribute "type" equal to "array" and dictionaries are encoded as a series of named elements or attributes.<br />
<br />
=== Examples ===<br />
<br />
The following is an example of the output of yamlconv showing all features mentioned above.<br />
<br />
<?xml version="1.0" encoding="utf-8"?><br />
<yaml float_field_example="1.0f" int_field_example="0" bool_field_example="true"><br />
<string_field_example type="string">Hello!</string_field_example><br />
<path_example type="path"><br />
<point x="0f" y="0f" z="0f" nx="0f" ny="1f" nz="0f" val="0" /><br />
<point x="1f" y="0f" z="0f" nx="0f" ny="1f" nz="0f" val="0" /><br />
</path_example><br />
<array_example type="array"><br />
<value sample_int="0" /><br />
<value sample_int="1" /><br />
</array_example><br />
<empty_array type="array" /><br />
<dictionary_example><br />
<attr type="string">Hi!</attr><br />
</dictionary_example><br />
<empty_dictionary /><br />
</yaml><br />
[[Category: File Format]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=Mario_Kart_Wii_File_Format_Comparison&diff=24Mario Kart Wii File Format Comparison2014-08-05T08:04:15Z<p>Chadderz: Removed unnecessry whitespace.</p>
<hr />
<div>This page compares the file formats and file structure of '''[[Mario Kart 8]]''' and '''[[mkw:Mario Kart Wii|Mario Kart Wii]]'''.<br />
<br />
Fundamentally, [[Mario Kart 8]] and [[mkw:Mario Kart Wii|Mario Kart Wii]] are very similar in their use of files and file formats. This may indicate that some of the codebase is shared between the two games.<br />
<br />
__TOC__<br />
<br />
= Courses =<br />
<br />
The courses in [[Mario Kart 8]] are each stored as a subdirectory of the [[Filesystem/content/course|/vol/content/course]] directory. In [[mkw:Mario Kart Wii|Mario Kart Wii]] each course is stored as a compressed [[mkw:U8 (File Format)|U8 Archive]] in the [[mkw:Filesystem/Race/Course|/Race/Course]] directory. The contents of these directories/archives are qutie similar.<br />
<br />
{| class=wikitable<br />
! Mario Kart 8<br />
! Mario Kart Wii<br />
! Description<br />
|-<br />
| [[course_muunt.byaml (File Format)|course_muunt.byaml]]<br />
| rowspan="2" | [[mkw:KMP (File Format)|course.kmp]]<br />
| rowspan="2" | These files describe control information about courses such as the lap path. In Mario Kart 8, battles occur on race tracks, hence the need for two separate files, whereas battle tracks are dedicated tracks in Mario Kart Wii, so they also use course.kmp.<br />
|-<br />
| [[battle_muunt.byaml (File Format)|battle_muunt.byaml]]<br />
|-<br />
| [[KCL (File Format)|course.kcl]]<br />
| [[mkw:KCL (File Format)|course.kcl]]<br />
| The KCL format has changed between Mario Kart 8 and Mario Kart Wii, but the purpose remains the same.<br />
|-<br />
| [[BFRES (File Format)|course_model.szs]]<br />
| [[mkw:BRRES (File Format)|course_model.brres]]<br />
| The course model in Mario Kart 8 is a [[mkw:YAZ0 (File Format)|YAZ0]] compressed [[BFRES (File Format)|BFRES file]]. In Martio Kart Wii, it is a [[mkw:BRRES (File Format)|BRRES file]] which is not compressed as the whole course is. Mario Kart 8 does not include simplified course models for multiplayer as Mario Kart Wii does.<br />
|-<br />
| {{Unknown|-}}<br />
| [[mkw:BRRES (File Format)|vrcorn_model.brres]]<br />
| The skybox for Mario Kart 8 is simply an object instantiated by the muunt.byaml file like any other. In Mario Kart Wii it was a special model file in the course folder. The objflow.byaml file has a flag indicating which objects are skybox models (VR) which may indicate that they are treated specially.<br />
|-<br />
| [[BFLIM (File Format)|course_maptexture.bflim]]<br />
| [[mkw:BRRES (File Format)|map_model.brres]]<br />
| The minimap in Mario Kart 8 is a [[BFLIM (File Format)|BFLIM image file]]. In Mario Kart Wii it is a 3D model. The change from a model to an image may be down to the map now being displayed on the gamepad.<br />
|-<br />
| colspan="3" {{Unknown|This list is incomplete.}}<br />
|}<br />
<br />
= Objects =<br />
<br />
Mario Kart 8 has a global store fo objects which is a change from the Mario Kart Wii system in which the files necessary for objects are stored in each track that requires them (leading to duplication). The objects are stored in the directory [[Filesystem/content/mapobj|/vol/content/mapobj]] with one subdirectory per object. Each object may have one or more [[BFRES (File Format)|BFRES models]], zero or more [[KCL (File Format)|KCL collision model]] and other files such as a [[BARS (File Format)|BARS archive]].<br />
<br />
In both Mario Kart 8 and Mario Kart Wii, an '''objflow''' file exists which describes object metadata such as simple collision properties and asset names. In Mario Kart 8 this is [[Filesystem/content/data|/vol/content/data]]/[[objflow.byaml (File Format)|objflow.byaml]], which is a [[BYAML (File Format)|BYAML file]]. In Mario Kart Wii this is [[mkw:Filesystem/Race/Common.szs/ObjFlow.bin|/Race/Common.szs/ObjFlow.bin]] and is a binary data file.<br />
<br />
[[Category:File Format]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=Mario_Kart_Wii_File_Format_Comparison&diff=23Mario Kart Wii File Format Comparison2014-08-05T08:01:18Z<p>Chadderz: Added section about objects.</p>
<hr />
<div>This page compares the file formats and file structure of '''[[Mario Kart 8]]''' and '''[[mkw:Mario Kart Wii|Mario Kart Wii]]'''.<br />
<br />
<br />
Fundamentally, [[Mario Kart 8]] and [[mkw:Mario Kart Wii|Mario Kart Wii]] are very similar in their use of files and file formats. This may indicate that some of the codebase is shared between the two games.<br />
<br />
__TOC__<br />
<br />
= Courses =<br />
<br />
The courses in [[Mario Kart 8]] are each stored as a subdirectory of the [[Filesystem/content/course|/vol/content/course]] directory. In [[mkw:Mario Kart Wii|Mario Kart Wii]] each course is stored as a compressed [[mkw:U8 (File Format)|U8 Archive]] in the [[mkw:Filesystem/Race/Course|/Race/Course]] directory. The contents of these directories/archives are qutie similar.<br />
<br />
{| class=wikitable<br />
! Mario Kart 8<br />
! Mario Kart Wii<br />
! Description<br />
|-<br />
| [[course_muunt.byaml (File Format)|course_muunt.byaml]]<br />
| rowspan="2" | [[mkw:KMP (File Format)|course.kmp]]<br />
| rowspan="2" | These files describe control information about courses such as the lap path. In Mario Kart 8, battles occur on race tracks, hence the need for two separate files, whereas battle tracks are dedicated tracks in Mario Kart Wii, so they also use course.kmp.<br />
|-<br />
| [[battle_muunt.byaml (File Format)|battle_muunt.byaml]]<br />
|-<br />
| [[KCL (File Format)|course.kcl]]<br />
| [[mkw:KCL (File Format)|course.kcl]]<br />
| The KCL format has changed between Mario Kart 8 and Mario Kart Wii, but the purpose remains the same.<br />
|-<br />
| [[BFRES (File Format)|course_model.szs]]<br />
| [[mkw:BRRES (File Format)|course_model.brres]]<br />
| The course model in Mario Kart 8 is a [[mkw:YAZ0 (File Format)|YAZ0]] compressed [[BFRES (File Format)|BFRES file]]. In Martio Kart Wii, it is a [[mkw:BRRES (File Format)|BRRES file]] which is not compressed as the whole course is. Mario Kart 8 does not include simplified course models for multiplayer as Mario Kart Wii does.<br />
|-<br />
| {{Unknown|-}}<br />
| [[mkw:BRRES (File Format)|vrcorn_model.brres]]<br />
| The skybox for Mario Kart 8 is simply an object instantiated by the muunt.byaml file like any other. In Mario Kart Wii it was a special model file in the course folder. The objflow.byaml file has a flag indicating which objects are skybox models (VR) which may indicate that they are treated specially.<br />
|-<br />
| [[BFLIM (File Format)|course_maptexture.bflim]]<br />
| [[mkw:BRRES (File Format)|map_model.brres]]<br />
| The minimap in Mario Kart 8 is a [[BFLIM (File Format)|BFLIM image file]]. In Mario Kart Wii it is a 3D model. The change from a model to an image may be down to the map now being displayed on the gamepad.<br />
|-<br />
| colspan="3" {{Unknown|This list is incomplete.}}<br />
|}<br />
<br />
= Objects =<br />
<br />
Mario Kart 8 has a global store fo objects which is a change from the Mario Kart Wii system in which the files necessary for objects are stored in each track that requires them (leading to duplication). The objects are stored in the directory [[Filesystem/content/mapobj|/vol/content/mapobj]] with one subdirectory per object. Each object may have one or more [[BFRES (File Format)|BFRES models]], zero or more [[KCL (File Format)|KCL collision model]] and other files such as a [[BARS (File Format)|BARS archive]].<br />
<br />
In both Mario Kart 8 and Mario Kart Wii, an '''objflow''' file exists which describes object metadata such as simple collision properties and asset names. In Mario Kart 8 this is [[Filesystem/content/data|/vol/content/data]]/[[objflow.byaml (File Format)|objflow.byaml]], which is a [[BYAML (File Format)|BYAML file]]. In Mario Kart Wii this is [[mkw:Filesystem/Race/Common.szs/ObjFlow.bin|/Race/Common.szs/ObjFlow.bin]] and is a binary data file.<br />
<br />
[[Category:File Format]]</div>Chadderzhttps://mk8.tockdom.com/w/index.php?title=Mario_Kart_Wii_File_Format_Comparison&diff=22Mario Kart Wii File Format Comparison2014-08-05T07:32:54Z<p>Chadderz: Created page based on intial analysis of file formats.</p>
<hr />
<div>This page compares the file formats and file structure of '''[[Mario Kart 8]]''' and '''[[mkw:Mario Kart Wii|Mario Kart Wii]]'''.<br />
<br />
<br />
Fundamentally, [[Mario Kart 8]] and [[mkw:Mario Kart Wii|Mario Kart Wii]] are very similar in their use of files and file formats. This may indicate that some of the codebase is shared between the two games.<br />
<br />
__TOC__<br />
<br />
= Courses =<br />
<br />
The courses in [[Mario Kart 8]] are each stored as a subdirectory of the [[Filesystem/content/course|/vol/content/course]] directory. In [[mkw:Mario Kart Wii|Mario Kart Wii]] each course is stored as a compressed [[mkw:U8 (File Format)|U8 Archive]] in the [[mkw:Filesystem/Race/Course|/Race/Course]] directory. The contents of these directories/archives are qutie similar.<br />
<br />
{| class=wikitable<br />
! Mario Kart 8<br />
! Mario Kart Wii<br />
! Description<br />
|-<br />
| [[course_muunt.byaml (File Format)|course_muunt.byaml]]<br />
| rowspan="2" | [[mkw:KMP (File Format)|course.kmp]]<br />
| rowspan="2" | These files describe control information about courses such as the lap path. In Mario Kart 8, battles occur on race tracks, hence the need for two separate files, whereas battle tracks are dedicated tracks in Mario Kart Wii, so they also use course.kmp.<br />
|-<br />
| [[battle_muunt.byaml (File Format)|battle_muunt.byaml]]<br />
|-<br />
| [[KCL (File Format)|course.kcl]]<br />
| [[mkw:KCL (File Format)|course.kcl]]<br />
| The KCL format has changed between Mario Kart 8 and Mario Kart Wii, but the purpose remains the same.<br />
|-<br />
| [[BFRES (File Format)|course_model.szs]]<br />
| [[mkw:BRRES (File Format)|course_model.brres]]<br />
| The course model in Mario Kart 8 is a [[mkw:YAZ0 (File Format)|YAZ0]] compressed [[BFRES (File Format)|BFRES file]]. In Martio Kart Wii, it is a [[mkw:BRRES (File Format)|BRRES file]] which is not compressed as the whole course is. Mario Kart 8 does not include simplified course models for multiplayer as Mario Kart Wii does.<br />
|-<br />
| {{Unknown|-}}<br />
| [[mkw:BRRES (File Format)|vrcorn_model.brres]]<br />
| The skybox for Mario Kart 8 is simply an object instantiated by the muunt.byaml file like any other. In Mario Kart Wii it was a special model file in the course folder. The objflow.byaml file has a flag indicating which objects are skybox models (VR) which may indicate that they are treated specially.<br />
|-<br />
| [[BFLIM (File Format)|course_maptexture.bflim]]<br />
| [[mkw:BRRES (File Format)|map_model.brres]]<br />
| The minimap in Mario Kart 8 is a [[BFLIM (File Format)|BFLIM image file]]. In Mario Kart Wii it is a 3D model. The change from a model to an image may be down to the map now being displayed on the gamepad.<br />
|-<br />
| colspan="3" {{Unknown|This list is incomplete.}}<br />
|}<br />
<br />
[[Category:File Format]]</div>Chadderz