CMDL (Donkey Kong Country Returns) and TXTR (Metroid Prime): Difference between pages

From Retro Modding Wiki
(Difference between pages)
Jump to navigation Jump to search
>Aruki
No edit summary
 
>Aruki
No edit summary
 
Line 1: Line 1:
''See [[CMDL (File Format)]] for the other revisions of this format.''
'''TXTR''' is, as the name suggests, the Retro Studios texture format. The format remains completely unchanged from Metroid Prime all the way up to Donkey Kong Country Returns.
 
The '''CMDL format''' is DKCR's model format. It's similar to the CMDL format found in the Metroid Prime trilogy, but with a lot of additions and changes, and some layout changes.
 
{{research|moderate|The visibility group data in the header has a lot of unknown values.}}


__TOC__
__TOC__
Line 9: Line 5:
== Format ==
== Format ==


Like the previous CMDL formats, DKCR CMDL files are split up into a number of 32-byte aligned ''sections''. Every section both starts and ends on a 32-byte boundary. These are used to separate different parts of the file; different types of sections typically indicate different sets of data. The header declares the section count and the size of each one; using these is the only way to navigate the file.
TXTR files contain a very short 12-byte header, followed by the image data.


=== Header ===
=== Header ===
Line 15: Line 11:
{| class="wikitable"
{| class="wikitable"
! Offset
! Offset
! Type
! Size
! Count
! Description
! Name
! Notes
|-
|-
| 0x0
| 0x0
| u16
| 4
| 1
| '''Image format'''. Possible values range from 0x0 to 0xA; see below for more details.
| '''Magic'''
| Always <code>0x9381</code>
|-
| 0x2
| u16
| 1
| '''Version'''
| Always 0xA. See [[CMDL (File Format)|hub article]] for a list of possible version numbers.
|-
|-
| 0x4
| 0x4
| u32
| 2
| 1
| '''Width'''
| '''Flags'''
| [[#Flags|See below]]
|-
| 0x8
| float
| 6
| '''Model Bounding Box'''
|
|-
| 0x20
| u32
| 1
| '''Section Count'''
| Count of data sections in the file.
|-
| 0x24
| u32
| 1
| '''Material Set Count'''
| Count of material sets in the model.
|-
| 0x28
| [[#Visibility Groups|Visibility Groups]]
| 1
| '''Visibility Group Data'''
| Only present if flag 0x10 is set.
|-
| {{none}}
| u32
| ''Section Count''
| '''Section Sizes'''
|
|-
| colspan=5 {{unknown|End of header; pad to multiple of 32 before first section starts}}
|}
 
==== Flags ====
 
The following flags are possible:
 
{| class="wikitable"
! Bit
! Hex
! Description
|-
| 0
| 0x1
| {{unknown|Unknown}}
|-
| 1
| 0x2
| {{unknown|Unknown}}
|-
|-
| 0x6
| 2
| 2
| 0x4
| '''Height'''
| {{unknown|Unknown}}
|-
|-
| 3
| 0x8
| 0x8
| {{unknown|Unknown}}
|-
| 4
| 4
| 0x10
| '''Mipmap count'''
| Enable visibility groups
|-
|-
| 5
| 0xC
| 0x20
| colspan=2 | End of header
| Store vertex positions as shorts
|}
|}


==== Visibility Groups ====
=== Palettes ===


Visibility group data is present in the header if bit 0x10 is set, after the material set count and before the section sizes. Visibility groups are used to toggle the visibility of certain surfaces on or off during animations; for instance, Diddy's jetpack is part of his model but doesn't render in most of his animations.
The C4 and C8 image formats contain a palette table after the header, before the image data begins.


{| class="wikitable"
{| class="wikitable"
! Offset
! Offset
! Type
! Size
! Size
! Description
! Description
|-
|-
| 0x0
| 0x0
| u32
| 4
| 4
| {{unknown|'''Unknown'''}}
| '''Palette format'''. Possible values range from 0 to 2.
|-
|-
| 0x4
| 0x4
| u32
| 2
| 4
| Always 0x1 in C4, 0x100 in C8
| '''Visibility Group count'''
|-
| 0x6
| 2
| Always 0x10 in C4, 0x1 in C8
|-
| 0x8
| Varies
| '''Palette colors'''. 16-bit color values; 16 colors in C4, 256 in C8.
|-
| colspan=3 | End of palette table; image data begins immediately after
|}
|}


The following structure repeats for each group:
== Image Formats ==
 
There are 11 different image formats; these are built directly into GX, so they remain the same across all GameCube and Wii games. Rather than storing pixels in a linear left-to-right order, GX textures encode pixels in large blocks. The size of the block varies depending on the image format.
 
For example, suppose you have a format that stores 4x4 blocks. Pixels 1-4 of the image will make up the first row of the first block; pixels 5-8 will make up the second row; 9-12 will make up the third row; 13-16 will make up the fourth row, completing the block; and the 17-20 will begin the first row of the second block, appearing directly to the right of the first row of the first block.


{| class="wikitable"
{| class="wikitable"
! Offset
! ID
! Type
! Name
! Size
! Bits per pixel
! Block size
! Description
! Description
|-
|-
| 0x0
| 0x0
| u32
| I4
| 4
| 4
| '''Name length'''
| 8x8
| 4-bit greyscale intensity values. Two pixels per byte.
|-
| 0x1
| I8
| 8
| 8x4
| 8-bit greyscale intensity values.
|-
|-
| 0x4
| 0x2
| string
| IA4
| -
| 8
| '''Visibility Group name'''
| 8x4
|}
| 4-bit greyscale intensity values with an additional 4-bit alpha channel.
 
Finally, it ends with this before the sizes begin:
 
{| class="wikitable"
! Offset
! Type
! Size
! Description
|-
|-
| 0x0
| 0x3
| u32
| IA8
| 4
| 16
| {{unknown|'''Unknown'''}}
| 4x4
| 8-bit greyscale intensity values with an additional 8-bit alpha channel.
|-
|-
| 0x4
| 0x4
| u32
| C4
| 4
| 4
| {{unknown|'''Unknown'''}}
| 8x8
| 4-bit palette indices.
|-
| 0x5
| C8
| 8
| 8x4
| 8-bit palette indices.
|-
| 0x6
| C14x2
| 16
| 4x4
| Another palette format. Not used by any official textures.
|-
| 0x7
| RGB565
| 16
| 4x4
| 16-bit colors without alpha.
|-
|-
| 0x8
| 0x8
| u32
| RGB5A3
| 4
| 16
| {{unknown|'''Unknown'''}}
| 4x4
| 16-bit colors with alpha.
|-
|-
| 0xC
| 0x9
| u32
| RGBA8
| 4
| 32
| {{unknown|'''Unknown'''}}
| 4x4
| Uncompressed 32-bit colors with alpha.
|-
|-
| 0x10
| 0xA
| u32
| CMPR
| 4
| 4
| {{unknown|'''Unknown'''}}
| 8x8
| DXT1-compressed textures.
|}
|}


=== Materials ===
== External links ==
 
''See [[Materials (Metroid Prime 3)]]''
 
DKCR uses the same material format as Metroid Prime 3, with the main differences being what pass types and UV animation modes are supported (a few have been added/removed). The only other significant difference in DKCR compared to Prime 3 is that in Prime 3, each material set would get its own section. In DKCR, every material set is in the same section. Each material set begins with a material count, and each material begins with its own size.


=== Geometry ===
* [http://wiki.tockdom.com/wiki/Image_Formats Custom Mario Kart Wiiki]: More detailed information on each format, and how to decode them.


''See [[Geometry (Donkey Kong Country Returns)]]''


[[Category:File Formats]]
[[Category:File Formats]]
[[Category:Metroid Prime]]
[[Category:Metroid Prime 2: Echoes]]
[[Category:Metroid Prime 3: Corruption]]
[[Category:Donkey Kong Country Returns]]
[[Category:Donkey Kong Country Returns]]

Revision as of 14:44, 23 January 2015

TXTR is, as the name suggests, the Retro Studios texture format. The format remains completely unchanged from Metroid Prime all the way up to Donkey Kong Country Returns.

Format

TXTR files contain a very short 12-byte header, followed by the image data.

Header

Offset Size Description
0x0 4 Image format. Possible values range from 0x0 to 0xA; see below for more details.
0x4 2 Width
0x6 2 Height
0x8 4 Mipmap count
0xC End of header

Palettes

The C4 and C8 image formats contain a palette table after the header, before the image data begins.

Offset Size Description
0x0 4 Palette format. Possible values range from 0 to 2.
0x4 2 Always 0x1 in C4, 0x100 in C8
0x6 2 Always 0x10 in C4, 0x1 in C8
0x8 Varies Palette colors. 16-bit color values; 16 colors in C4, 256 in C8.
End of palette table; image data begins immediately after

Image Formats

There are 11 different image formats; these are built directly into GX, so they remain the same across all GameCube and Wii games. Rather than storing pixels in a linear left-to-right order, GX textures encode pixels in large blocks. The size of the block varies depending on the image format.

For example, suppose you have a format that stores 4x4 blocks. Pixels 1-4 of the image will make up the first row of the first block; pixels 5-8 will make up the second row; 9-12 will make up the third row; 13-16 will make up the fourth row, completing the block; and the 17-20 will begin the first row of the second block, appearing directly to the right of the first row of the first block.

ID Name Bits per pixel Block size Description
0x0 I4 4 8x8 4-bit greyscale intensity values. Two pixels per byte.
0x1 I8 8 8x4 8-bit greyscale intensity values.
0x2 IA4 8 8x4 4-bit greyscale intensity values with an additional 4-bit alpha channel.
0x3 IA8 16 4x4 8-bit greyscale intensity values with an additional 8-bit alpha channel.
0x4 C4 4 8x8 4-bit palette indices.
0x5 C8 8 8x4 8-bit palette indices.
0x6 C14x2 16 4x4 Another palette format. Not used by any official textures.
0x7 RGB565 16 4x4 16-bit colors without alpha.
0x8 RGB5A3 16 4x4 16-bit colors with alpha.
0x9 RGBA8 32 4x4 Uncompressed 32-bit colors with alpha.
0xA CMPR 4 8x8 DXT1-compressed textures.

External links