CMDL (Tropical Freeze): Difference between revisions

>Embyr 75
m ({{research}})
>Aruki
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
''See [[CMDL (File Format)]] for the other revisions of this format.''
''See [[CMDL (File Format)]] for the other revisions of this format.''


The '''CMDL, SMDL, and WMDL''' format are Tropical Freeze's three model formats; CMDL is a generic model format, SMDL is for skinned models, and WMDL is for world (terrain) models. All three are the same basic format, with SMDL and WMDL each containing an extra data section at the start of the file. With the Wii U's graphics system being updated from GX to GX2, the Retro model format has been dramatically overhauled, bearing little to no resemblance to the previous CMDL format found in DKCR and the Prime series.
Tropical Freeze features a new model format (necessitated by the hardware jump from Wii to Wii U) that bears little-to-no resemblance to the CMDL format of past games. There are three extensions used for models:


{{research|2|There's still a lot of unknown data. The entire optional section at the end of HEAD is completely unknown to me and there's lots of scattered unknown values.}}
* '''CMDL''': Generic models
* '''SMDL''': Skinned models (ie. animated characters)
* '''WMDL''': World models (ie. level geometry)
 
All three share the same basic format, with SMDL and WMDL each containing an extra data chunk at the start of the file.
 
{{research|2|There's a lot of unknown data.}}


__TOC__
__TOC__
Line 9: Line 15:
== Format ==
== Format ==


After the [[RFRM Header]], the first section of the file is SKHD in SMDL, and WDHD in WMDL. Following those extra sections, all three formats start with a header.
File layout:
 
=== HEAD ===


{| class="wikitable"
{| class="wikitable"
! Offset
! Type/Name
! Size
! Notes
! Description
|-
| [[Form Descriptor (Tropical Freeze)|Form Descriptor]]
| Form ID is <code>CMDL</code>, <code>SMDL</code>, or <code>WMDL</code>.
|-
|-
| 0x0
| [[#Skinned Model Header|Skinned Model Header]]
| 24
| '''Only present in SMDL files'''
| '''"HEAD" [[Section Header (Tropical Freeze)|section header]]
|-
|-
| 0x18
| [[#World Model Header|World Model Header]]
| 4
| '''Only present in WMDL files'''
| {{unknown|'''Unknown'''}}
|-
|-
| 0x1C
| [[#Model Header|Model Header]]
| 4
|  
| {{unknown|'''Unknown'''}}
|-
|-
| 0x20
| [[#Material Data|Material Data]]
| 4
|  
| {{unknown|'''Unknown'''}}
|-
|-
| 0x24
| [[#Render Meshes|Render Meshes]]
| 4
|  
| {{unknown|'''Unknown'''}}
|-
|-
| 0x28
| [[#Vertex Buffers|Vertex Buffers]]
| 4
|  
| {{unknown|'''Unknown'''}}
|-
|-
| 0x2C
| [[#Index Buffers|Index Buffers]]
| 24
|  
| '''Axis-aligned bounding box'''
|-
|-
| 0x30
| [[#GPU Data|GPU Data]]
| 4
|  
| '''Extra data flag'''
|}
|}


If the ending flag is 1, then a large chunk of extra data follows before the next section begins; otherwise, the HEAD section ends.
=== Skinned Model Header ===


=== MTRL ===
{| class="wikitable"
! Offset
! Type
! Count
! Name
! Notes
|-
| 0x0
| [[Chunk Descriptor (Tropical Freeze)|Chunk Descriptor]]
| 1
| '''SKHD Chunk Descriptor'''
| Data type is <code>SKHD</code>
|-
| 0x18
| u32
| 1
| {{unknown|Unknown}}
|
|-
| 0x1C
| colspan=5 {{unknown|End of Skinned Model Header}}
|}


The MTRL section has a 32-bit material count, then lays out its materials one after the other. The material structure is somewhat complicated; each material has a name, something that wasn't present in Retro's previous material formats, as well as a shader ID. The rest of the material structure appears to be defining parameters to pass to the shader. This needs a lot more research to determine what the parameters are and what the different data is.
=== World Model Header ===


{| class="wikitable"
{| class="wikitable"
! Type
! Type
! Size
! Count
! Description
! Name
! Notes
|-
|-
| string
| [[Chunk Descriptor (Tropical Freeze)|Chunk Descriptor]]
| -
| 1
| '''Name''' (zero-terminated)
| '''WDHD Chunk Descriptor'''
| Chunk ID is <code>WDHD</code>
|-
|-
| [[MTRL (File Format)|MTRL]]
| u8
| 16
| 1
| '''Shader ID'''
| {{unknown|Unknown}}
|  
|-
|-
| char[4]
| [[#Render Octree|Render Octree]]
| 4
| 1
| '''Shading type fourCC'''; can be PHNG, LAMB, SURF, or FURM
| '''Render Octree'''
|
|-
|-
| u32
| u32
| 4
| 1
| {{unknown|'''Unknown'''}}
| {{unknown|Unknown AABox Count}}
|
|-
| {{AABox}}
| ''Unknown AABox Count''
| {{unknown|Unknown AABox Array}}
|
|-
|-
| u32
| u32
| 4
| 1
| '''Subsection count'''
| {{unknown|Unknown Float Count}}
|
|-
| float
| ''Unknown Float Count''
| {{unknown|Unknown Float Array}}
|
|}
|}


Material subsections each have a fourCC name and a type identifer, followed by a set of parameters. The type and number of parameters is dependent on the subsection type; there are five known types currently.
==== Render Octree ====
 
This seems to be an updated version of the [[AROT (MREA Section)|AROT]] format seen in previous Retro games.


{| class="wikitable"
{| class="wikitable"
! Offset
! Offset
! Type
! Type
! Size
! Count
! Description
! Name
! Notes
|-
|-
| 0x0
| 0x0
| char[4]
| {{FourCC}}
| 4
| 1
| '''Section name fourCC'''
| '''Magic'''
| Always <code>AROT</code> (Area Octree)
|-
|-
| 0x4
| 0x4
| u32
| u32
| 4
| 1
| '''Section type'''
| {{unknown}}
| Always 1. Version number?
|-
|-
| 0x8
| 0x8
| struct
| u32
| -
| 1
| '''Section data struct'''; type varies based on the section type value
| {{unknown}}
|
|-
| 0xC
| u32
| 1
| {{unknown}}
|
|-
| 0x10
| u32
| 1
| {{unknown}}
|
|-
| 0x14
| {{AABox}}
| 1
| '''Octree Bounding Box'''
| Bounds of the entire octree; matches the bounding box from the main model header.
|-
|-
| colspan=4 {{unknown|End of subsection; next one begins}}
| 0x2C
| u32
| 1
| {{unknown|Unknown Count A}}
|
|-
| 0x30
| u32
| ''Unknown Count A''
| {{unknown|Unknown Array A}}
|
|-
| {{none}}
| u32
| 1
| {{unknown|Unknown Count B}}
|
|-
| {{none}}
| u8
| ''Unknown Count B''
| {{unknown|Unknown Array B}}
|
|-
| {{none}}
| u32
| 1
| {{unknown|Unknown AABox Count}}
|
|-
| {{none}}
| {{AABox}}
| ''Unknown AABox Count''
| {{unknown|Unknown AABox Array}}
|
|}
|}


==== Type 0: Texture Map ====
=== Model Header ===


{| class="wikitable"
{| class="wikitable"
! Offset
! Offset
! Type
! Type
! Size
! Count
! Description
! Name
! Notes
|-
|-
| 0x0
| 0x0
| [[TXTR (Tropical Freeze)|TXTR]]
| [[Chunk Descriptor (Tropical Freeze)|Chunk Descriptor]]
| 0x10
| 1
| '''Texture ID'''
| '''HEAD Chunk Descriptor'''
| Chunk ID is <code>HEAD</code>
|-
| 0x18
| u32
| 1
| {{unknown}}
|
|-
|-
| 0x10
| 0x1C
| u32
| u32
| 4
| 1
| {{unknown|'''Unknown'''}}
| {{unknown}}
|
|-
|-
| 0x14
| 0x20
| u32
| u32
| 4
| 1
| {{unknown|'''Unknown'''}}
| {{unknown}}
|
|-
|-
| 0x18
| 0x24
| u32
| u32
| 4
| 1
| {{unknown|'''Unknown'''}}
| {{unknown}}
|
|-
|-
| 0x1C
| 0x28
| u32
| u32
| 4
| 1
| {{unknown|'''Unknown'''}}
| {{unknown}}
|
|-
| 0x2C
| {{AABox}}
| 1
| '''Model Bounding Box'''
|
|-
|-
| 0x20
| 0x44
| u32
| u32
| 4
| 1
| {{unknown|'''Unknown'''}}
| '''Model Data Source Count'''
|
|-
|-
| 0x24
| 0x48
| colspan=3 {{unknown|End of struct}}
| [[#Model Data Source|Model Data Source]]
| ''Model Data Source Count''
| '''Model Data Source Array'''
|  
|}
|}


==== Type 1: Unknown ====
==== Model Data Source ====


{| class="wikitable"
{| class="wikitable"
! Offset
! Offset
! Type
! Type
! Size
! Name
! Description
! Notes
|-
|-
| 0x0
| 0x0
| float
| u32
| 4
| '''Model Data Source Type'''
| {{unknown|'''Unknown'''}}
| Controls the type of data present in this data source. Valid values are 0, 1, 2, or 3.
|-
|-
| 0x4
| 0x4
| float
| {{none}}
| 4
| '''Model Data Source Data'''
| {{unknown|'''Unknown'''}}
| Structure and size varies depending on ''Model Data Source Type''. See below.
|}
 
===== Type 0: UV Animation =====
 
{{todo|Needs research. The loader function doesn't reveal much because the game just loads all the data into a couple big buffers.}}
 
===== Type 1: Wind =====
 
{| class="wikitable"
! Type
! Count
! Name
! Notes
|-
| u32
| 1
| '''Wind Set Count'''
| Count of Wind Set elements in the next array.
|-
|-
| 0x8
| [[#Wind Set|Wind Set]]
| float
| ''Wind Set Count''
| 4
| '''Wind Set Array'''
| {{unknown|'''Unknown'''}}
|
|-
|-
| 0xC
| u32
| float
| 1
| 4
| {{unknown|Unknown Count}}
| {{unknown|'''Unknown'''}}
|
|-
|-
| 0x10
| u8
| colspan=3 {{unknown|End of struct}}
| ''Unknown Count''
| {{unknown|Unknown Data}}
|
|}
|}


==== Type 2: Unknown ====
====== Wind Set ======


{| class="wikitable"
{| class="wikitable"
! Offset
! Offset
! Type
! Type
! Size
! Name
! Description
! Notes
|-
|-
| 0x0
| 0x0
| {{Vector3f}}
| {{unknown}}
|
|-
| 0xC
| {{Vector3f}}
| {{unknown}}
|
|-
| 0x18
| float
| float
| 4
| {{unknown}}
| {{unknown|'''Unknown'''}}
|
|-
| 0x1C
| colspan=3 {{unknown|End of Wind Set}}
|}
 
===== Type 2: Caustic =====
 
{| class="wikitable"
! Type
! Count
! Name
! Notes
|-
| u32
| 1
| {{unknown|Unknown Count}}
|
|-
|-
| 0x4
| u32
| colspan=3 {{unknown|End of struct}}
| ''Unknown Count''
| {{unknown|Unknown Array}}
|
|}
|}


==== Type 4: Unknown ====
===== Type 3: Fur =====


{| class="wikitable"
{| class="wikitable"
! Offset
! Type
! Type
! Size
! Count
! Description
! Name
! Notes
|-
|-
| 0x0
| u32
| u32
| 4
| 1
| {{unknown|'''Unknown'''}}
| {{unknown|Unknown Count A}}
|
|-
|-
| 0x4
| float
| float
| 4
| ''Unknown Count A''
| {{unknown|'''Unknown'''}}
| {{unknown|Unknown Array A}}
|
|-
| u32
| 1
| {{unknown|Unknown Count B}}
|
|-
|-
| 0x8
| float
| float
| 4
| ''Unknown Count B''
| {{unknown|'''Unknown'''}}
| {{unknown|Unknown Array B}}
|
|-
|-
| 0xC
| u32
| float
| 1
| 4
| {{unknown|Unknown Count C}}
| {{unknown|'''Unknown'''}}
|
|-
|-
| 0x10
| float
| float
| 4
| ''Unknown Count C''
| {{unknown|'''Unknown'''}}
| {{unknown|Unknown Array C}}
|
|}
 
=== Material Data ===
 
The MTRL section has a 32-bit material count, then lays out its materials one after the other. Materials are composed of basically a [[MTRL (File Format)|MTRL asset ID]] which contains the shader the material is rendered with, then per-instance material parameters (textures, scalar/color parameters, etc).
 
{| class="wikitable"
! Type
! Count
! Name
! Notes
|-
|-
| 0x14
| string
| float
| 1
| 4
| '''Material Name'''
| {{unknown|'''Unknown'''}}
| Zero-terminated string
|-
|-
| 0x18
| Asset ID ([[MTRL (File Format)|MTRL]])
| float
| 1
| 4
| '''Material Shader Asset ID'''
| {{unknown|'''Unknown'''}}
| Points to the MTRL file containing the shader for this material.
|-
|-
| 0x1C
| {{FourCC}}
| float
| 1
| 4
| '''Material Type'''
| {{unknown|'''Unknown'''}}
| Can be <code>PHNG</code> (Phong), <code>LAMB</code> (Lambert), <code>SURF</code> (Surface), <code>FURM</code> (Fur), or <code>REFL</code> (Reflect). <code>REFL</code> may be unused.
|-
|-
| 0x20
| u32
| u32
| 4
| 1
| {{unknown|'''Unknown'''}}
| '''Material Flags'''
| Bitfield used to toggle various settings on the material. None of the flags are known.
|-
|-
| 0x24
| u32
| u32
| 4
| 1
| {{unknown|'''Unknown'''}}
| '''Parameter Count'''
| Count of parameters in this material definition.
|-
| [[#Material Parameter|Material Parameter]]
| ''Parameter Count''
| '''Parameter Array'''
|
|}
 
==== Material Parameter ====
 
Each parameter has a fourCC parameter ID as well as a parameter type enum. There are five possible parameter types that each have a different layout in the file.
 
{| class="wikitable"
! Offset
! Type
! Count
! Name
! Notes
|-
|-
| 0x28
| 0x0
| u32
| {{FourCC}}
| 4
| 1
| {{unknown|'''Unknown'''}}
| '''Parameter ID'''
|
|-
|-
| 0x2C
| 0x4
| u32
| u32
| 4
| 1
| {{unknown|'''Unknown'''}}
| '''Parameter Type'''
| Determines what type of data this parameter contains. Can be either 0, 1, 2, 4, or 5. (Note: 3 is an invalid value, not an unused type.)
|-
|-
| 0x30
| 0x8
| u32
| {{none}}
| 4
| {{none}}
| {{unknown|'''Unknown'''}}
| '''Parameter Data'''
| Structure and size varies depending on ''Parameter Type''. See below.
|}
 
==== Type 0: Texture Token Data ====
 
{| class="wikitable"
! Offset
! Type
! Count
! Name
! Notes
|-
|-
| 0x34
| 0x0
| u8
| Asset ID ([[TXTR (Tropical Freeze)|TXTR]])
| 1
| 1
| {{unknown|'''Unknown'''}}
| '''Texture ID'''
| Texture asset ID.
|-
|-
| 0x35
| [[TXTR (Tropical Freeze)|TXTR]]
| 0x10
| 0x10
| {{unknown|'''Unknown Texture ID'''}}
| [[#Texture Usage Info|Texture Usage Info]]
| 1
| '''Texture Usage Info'''
| '''Note:''' Not present if the TXTR asset ID is invalid.
|-
|-
| 0x45
| colspan=5 {{unknown|End of Texture Token Data}}
| u32
|}
| 4
 
| {{unknown|'''Unknown'''}}
==== Type 1: Color Data ====
 
{| class="wikitable"
! Offset
! Type
! Count
! Name
! Notes
|-
| 0x0
| {{Color4f}}
| 1
| '''Color Value'''
|
|-
|-
| 0x49
| 0x10
| u32
| colspan=4 {{unknown|End of Color Data}}
| 4
|}
| {{unknown|'''Unknown'''}}
 
==== Type 2: Scalar Data ====
 
{| class="wikitable"
! Offset
! Type
! Count
! Name
! Notes
|-
|-
| 0x4D
| 0x0
| u32
| float
| 4
| 1
| {{unknown|'''Unknown'''}}
| '''Scalar Value'''
|
|-
|-
| 0x51
| 0x4
| u32
| colspan=4 {{unknown|End of Scalar Data}}
| 4
|}
| {{unknown|'''Unknown'''}}
 
==== Type 4: Layered Texture Data ====
 
{| class="wikitable"
! Offset
! Type
! Count
! Name
! Notes
|-
|-
| 0x55
| 0x0
| u32
| u32
| 4
| 1
| {{unknown|'''Unknown'''}}
| {{unknown|Unknown}}
|
|-
|-
| 0x59
| 0x4
| [[TXTR (Tropical Freeze)|TXTR]]
| {{Color4f}}
| 0x10
| 1
| {{unknown|'''Unknown Texture ID'''}}
| {{unknown|Unknown Color}}
|
|-
|-
| 0x69
| 0x14
| u32
| {{Color4f}}
| 4
| 1
| {{unknown|'''Unknown'''}}
| {{unknown|Unknown Color}}
|
|-
|-
| 0x6D
| 0x24
| u32
| {{Color4f}}
| 4
| 1
| {{unknown|'''Unknown'''}}
| {{unknown|Unknown Color}}
|
|-
|-
| 0x71
| 0x34
| u32
| u8
| 4
| 1
| {{unknown|'''Unknown'''}}
| {{unknown|Unknown}}
|
|-
|-
| 0x75
| 0x35
| u32
| [[#Type 0: Texture Token Data|Texture Token Data]]
| 4
| 1
| {{unknown|'''Unknown'''}}
| {{unknown|Unknown Texture Token Data}}
|
|-
|-
| 0x79
| {{none}}
| u32
| [[#Type 0: Texture Token Data|Texture Token Data]]
| 4
| 1
| {{unknown|'''Unknown'''}}
| {{unknown|Unknown Texture Token Data}}
|
|-
|-
| 0x7D
| {{none}}
| u32
| [[#Type 0: Texture Token Data|Texture Token Data]]
| 4
| 1
| {{unknown|'''Unknown'''}}
| {{unknown|Unknown Texture Token Data}}
|
|-
|-
| 0x81
| colspan=5 {{unknown|End of Layered Texture Data}}
| u32
|}
| 4
 
| {{unknown|'''Unknown'''}}
==== Type 5: Int4 Data ====
 
{| class="wikitable"
! Offset
! Type
! Count
! Name
! Notes
|-
|-
| 0x85
| 0x0
| u32
| u32
| 4
| 4
| {{unknown|'''Unknown'''}}
| '''Int4 Value'''
|
|-
|-
| 0x89
| 0x10
| u32
| colspan=4 {{unknown|End of Int4 Data}}
| 4
| {{unknown|'''Unknown'''}}
|-
| 0x8D
| colspan=3 {{unknown|End of struct}}
|}
|}


==== Type 5: Unknown ====
==== Texture Usage Info ====


{| class="wikitable"
{| class="wikitable"
! Offset
! Offset
! Type
! Type
! Size
! Count
! Description
! Name
! Notes
|-
|-
| 0x0
| 0x0
| u32
| u32
| 4
| 1
| {{unknown|'''Unknown'''}}
| {{unknown|Unknown}}
|
|-
|-
| 0x4
| 0x4
| u32
| u32
| 4
| 1
| {{unknown|'''Unknown'''}}
| {{unknown|Unknown}}
|
|-
|-
| 0x8
| 0x8
| u32
| u32
| 4
| 1
| {{unknown|'''Unknown'''}}
| {{unknown|Unknown}}
|
|-
|-
| 0xC
| 0xC
| u32
| u32
| 4
| 1
| {{unknown|'''Unknown'''}}
| {{unknown|Unknown}}
|
|-
|-
| 0x10
| 0x10
| colspan=3 {{unknown|End of struct}}
| u32
| 1
| {{unknown|Unknown}}
|
|-
| 0x14
| colspan=4 {{unknown|End of Texture Usage Info}}
|}
|}


=== MESH ===
=== Render Meshes ===


The MESH section does what the name suggests: it defines submeshes. The MESH section header is as follows:
The MESH section defines render meshes.


{| class="wikitable"
{| class="wikitable"
! Offset
! Type
! Size
! Count
! Description
! Name
! Notes
|-
|-
| 0x0
| [[Chunk Descriptor (Tropical Freeze)|Chunk Descriptor]]
| 24
| 1
| '''"HEAD" [[Section Header (Tropical Freeze)|section header]]
| '''MESH Chunk Descriptor'''
| Chunk ID is <code>MESH</code>
|-
|-
| 0x18
| u32
| 4
| 1
| Submesh count
| '''Render Mesh Count'''
|  
|-
|-
| 0x1C
| [[#Render Mesh|Render Mesh]]
| colspan=2 {{unknown|End of MESH header}}
| ''Render Mesh Count''
| '''Render Mesh Array'''
|  
|}
|}


Each submesh definition is structured as follows:
==== Render Mesh ====


{|class="wikitable"
{| class="wikitable"
! Offset
! Offset
! Size
! Type
! Description
! Count
! Name
! Notes
|-
|-
| 0x0
| 0x0
| 4
| u32
| {{unknown|'''Unknown'''; always 3?}}
| 1
| {{unknown}}
| Always 3?
|-
|-
| 0x4
| 0x4
| 2
| u16
| '''Material ID'''
| 1
| '''Material Index'''
|
|-
|-
| 0x6
| 0x6
| u8
| 1
| 1
| '''Vertex buffer ID'''
| '''Vertex Buffer Index'''
|
|-
|-
| 0x7
| 0x7
| u8
| 1
| 1
| '''Index buffer ID'''
| '''Index Buffer Index'''
|
|-
|-
| 0x8
| 0x8
| 4
| u32
| '''Start index'''
| 1
| '''Start Index'''
| This is basically an offset into the selected index buffer.
|-
|-
| 0xC
| 0xC
| 4
| u32
| '''Index count'''
| 1
| '''Index Count'''
| Number of indices for this mesh in the index buffer.
|-
|-
| 0x10
| 0x10
| 4
| u32
| {{unknown|'''Unknown'''}}
| 1
| {{unknown}}
|
|-
|-
| 0x14
| 0x14
| bool
| 1
| 1
| {{unknown|'''Unknown'''; usually seems to be either 0 or 1, possibly a bool value}}
| {{unknown}}
|
|-
|-
| 0x15
| 0x15
| colspan=2 {{unknown|End of submesh definition}}
| colspan=4 {{unknown|End of Render Mesh}}
|}
|}


=== VBUF ===
=== Vertex Buffers ===


The VBUF section defines vertex buffers; each buffer can have different vertex types, with different strides and attributes.
The VBUF section defines vertex buffers; each buffer can have different vertex types, with different strides and attributes.
==== Header ====


{| class="wikitable"
{| class="wikitable"
! Offset
! Type
! Size
! Count
! Description
! Name
! Notes
|-
|-
| 0x0
| [[Chunk Descriptor (Tropical Freeze)|Chunk Descriptor]]
| 24
| 1
| '''"VBUF" [[Section Header (Tropical Freeze)|section header]]
| '''VBUF Chunk Descriptor'''
| Chunk ID is <code>VBUF</code>
|-
|-
| 0x18
| u32
| 4
| 1
| Vertex buffer count
| '''Vertex Buffer Count'''
|
|-
|-
| 0x1C
| [[#Vertex Buffer|Vertex Buffer]]
| colspan=2 {{unknown|End of VBUF header}}
| ''Vertex Buffer Count''
| '''Vertex Buffer Array'''
| The model will contain a separate vertex buffer for every unique vertex configuration needed.
|}
|}


==== Vertex Buffer ====
==== Vertex Buffer ====


{|class="wikitable"
{| class="wikitable"
! Offset
! Type
! Size
! Count
! Description
! Name
! Notes
|-
|-
| 0x0
| u32
| 4
| 1
| '''Vertex count'''
| '''Vertex Count'''
| Number of vertices in the buffer.
|-
|-
| 0x4
| u32
| 4
| 1
| '''Attrib count''' (AC)
| '''Vertex Component Count'''
| Number of components in each vertex.
|-
|-
| 0x8
| [[#Vertex Component|Vertex Component]]
| 0x14 &times; AC
| ''Vertex Component Count''
| '''Vertex attributes'''
| '''Vertex Component Array'''
|-
| Definitions for each component in the vertex.
| colspan=3 {{unknown|End of vertex buffer}}
|}
|}


==== Vertex Attribute ====
==== Vertex Component ====


{|class="wikitable"
{| class="wikitable"
! Offset
! Offset
! Size
! Type
! Description
! Count
! Name
! Notes
|-
|-
| 0x0
| 0x0
| 4
| u32
| {{unknown|'''Unknown'''}}
| 1
| {{unknown}}
|
|-
|-
| 0x4
| 0x4
| 4
| u32
| 1
| '''Offset'''
| '''Offset'''
| Offset of this component within the vertex.
|-
|-
| 0x8
| 0x8
| 4
| u32
| 1
| '''Stride'''
| '''Stride'''
| Distance in bytes between elements of this component within the vertex buffer. (This is equivalent to the full size of a single vertex.)
|-
|-
| 0xC
| 0xC
| 4
| u32
| {{unknown|'''Unknown'''}}
| 1
| {{unknown}}
|
|-
|-
| 0x10
| 0x10
| 4
| u32
|{{unknown|'''Unknown''' (likely attrib type/format)}}
| 1
| {{unknown}}
| Likely component type/format
|-
|-
| 0x14
| 0x14
| colspan=2 {{unknown|End of attribute}}
| colspan=4 {{unknown|End of Vertex Component}}
|}
|}


=== IBUF ===
=== Index Buffers ===


Just like how the VBUF section defines vertex buffers, the IBUF section defines index buffers. Each index buffer only has one value associated with it, so it's fairly simple, and you generally will only see one or two index buffers per file.
Just like how the VBUF section defines vertex buffers, the IBUF section defines index buffers. Each index buffer only has one value associated with it, so it's fairly simple, and you generally will only see one or two index buffers per file (as there's only two possible index buffer configurations).
 
==== Header ====


{| class="wikitable"
{| class="wikitable"
! Offset
! Type
! Size
! Count
! Description
! Name
! Notes
|-
|-
| 0x0
| [[Chunk Descriptor (Tropical Freeze)|Chunk Descriptor]]
| 24
| 1
| '''"IBUF" [[Section Header (Tropical Freeze)|section header]]
| '''IBUF Chunk Descriptor'''
| Chunk Descriptor is <code>IBUF</code>
|-
|-
| 0x18
| u32
| 4
| 1
| Index buffer count
| '''Index Buffer Count'''
|
|-
|-
| 0x1C
| [[#Index Buffer|Index Buffer]]
| colspan=2 {{unknown|End of IBUF header}}
| ''Index Buffer Count''
| '''Index Buffer Array'''
|  
|}
|}


Line 561: Line 868:
{| class="wikitable"
{| class="wikitable"
! Offset
! Offset
! Size
! Type
! Description
! Name
! Notes
|-
|-
| 0x0
| 0x0
| 4
| u32
| '''Format''' (1 means unsigned short; 2 means unsigned long)
| '''Format'''
| 1 means unsigned short; 2 means unsigned long.
|-
|-
| 0x4
| 0x4
| colspan=2 {{unknown|End of index buffer}}
| colspan=3 {{unknown|End of Index Buffer}}
|}
|}


=== GPU ===
=== GPU Data ===


The GPU section contains raw buffer data that's fed to the GPU. It's essentially just a giant blob with all the vertex and index buffers laid out next to each other. The tricky part is, all the buffer data is [[LZSS Compression|LZSS-compressed]], and the metadata needed to decompress it is stored in the pak rather than in the files themselves; not only that, but that metadata is also the only way to distinguish the different buffers from each other.
The GPU section contains raw buffer data that's fed to the GPU. It's essentially just a giant blob with all the vertex and index buffers laid out next to each other. The tricky part is, all the buffer data is [[LZSS Compression|LZSS-compressed]], and the metadata needed to decompress it is stored in the pak rather than in the files themselves; not only that, but that metadata is also the only way to distinguish the different buffers from each other.
Line 580: Line 889:
== PAK Metadata ==
== PAK Metadata ==


The pak metadata for the model formats contains mainly information related to the size and layout of the GPU section, and the metadata required to locate and decompress specific buffers within it.
The PAK metadata for the model formats contains mainly information related to the size and layout of the GPU section, and the metadata required to locate and decompress specific buffers within it.


{| class="wikitable"
{| class="wikitable"
! Offset
! Type
! Size
! Count
! Description
! Name
! Notes
|-
|-
| 0x0
| u32
| 4
| 1
| {{unknown|'''Unknown'''; always 4?}}
| {{unknown}}
| Always 4?
|-
|-
| 0x4
| u32
| 4
| 1
| '''GPU section offset'''
| '''GPU Section Offset'''
|-
|-
| 0x8
| u32
| 4
| 1
| '''GPU chunk count''' (CC)
| '''Read Buffer Count'''
| Number of read buffers making up the GPU section.
|-
|-
| 0xC
| [[#Read Buffer Info|Read Buffer Info]]
| 8 &times; CC
| ''Read Buffer Count''
| '''GPU chunk definitions'''
| '''Read Buffer Array'''
| Definitions for each read buffer.
|-
|-
| -
| u32
| 4
| 1
| '''Compressed vertex buffer count''' (VC)
| '''Vertex Buffer Count'''
| Number of vertex buffers in the model.
|-
|-
| -
| [[#Buffer Info|Buffer Info]]
| 0x10 &times; VC
| ''Vertex Buffer Count''
| '''Vertex buffer definitions'''
| '''Vertex Buffer Info Array'''
| Array containing all data needed to decompress each vertex buffer.
|-
|-
| -
| u32
| 4
| 1
| '''Compressed index buffer count''' (IC)
| '''Index Buffer Count'''
| Number of index buffers in the model.
|-
|-
| -
| [[#Buffer Info|Buffer Info]]
| 0x10 &times; IC
| ''Index Buffer Count''
| '''Index buffer definitions'''
| '''Index Buffer Info Array'''
|-
| Array containing all data needed to decompress each index buffer.
| colspan = 3 {{unknown|End of pak metadata}}
|}
|}


=== GPU Chunk ===
=== Read Buffer Info ===


For large models, the GPU section might be split up into multiple chunks, rather than read as one data buffer; all offsets into the GPU section will be relative to the start of the chosen chunk.
For large models, the GPU section may be split into multiple read buffers. All offsets into the GPU section will be relative to the beginning of the chosen buffer.


{| class="wikitable"
{| class="wikitable"
! Offset
! Offset
! Size
! Type
! Description
! Name
! Notes
|-
|-
| 0x0
| 0x0
| 4
| u32
| '''Size'''
| '''Size'''
| Size of the buffer.
|-
|-
| 0x4
| 0x4
| 4
| u32
| '''Offset'''
| '''Offset'''
| Offset of the buffer within the GPU section.
|-
|-
| 0x8
| 0x8
| colspan=2 {{unknown|End of GPU chunk definition}}
| colspan=3 {{unknown|End of Read Buffer Info}}
|}
|}


=== Compressed Buffer ===
=== Buffer Info ===


The format for compressed buffer definitions is the same regardless of buffer type (vertex/index).
This structure is used for both vertex and index buffers.


{| class="wikitable"
{| class="wikitable"
! Offset
! Offset
! Size
! Type
! Description
! Name
! Notes
|-
|-
| 0x0
| 0x0
| 4
| u32
| '''GPU chunk index'''
| '''Read Buffer Index'''
| The read buffer that this buffer is inside of.
|-
|-
| 0x4
| 0x4
| 4
| u32
| '''Start offset''' (relative to the start of the chosen GPU chunk)
| '''Start Offset'''
| Starting offset of this buffer, relative to the start of the chosen read buffer.
|-
|-
| 0x8
| 0x8
| 4
| u32
| '''Compressed size'''
| '''Compressed Size'''
| Size of the compressed data.
|-
|-
| 0xC
| 0xC
| 4
| u32
| '''Decompressed size'''
| '''Decompressed Size'''
| Size of the data after being decompressed.
|-
|-
| 0x10
| 0x10
| colspan=2 {{unknown|End of compressed buffer definition}}
| colspan=3 {{unknown|End of Buffer Info}}
|}
|}


[[Category:File Formats]]
[[Category:File Formats]]
[[Category:Donkey Kong Country: Tropical Freeze]]
[[Category:Donkey Kong Country: Tropical Freeze]]
Anonymous user