Materials (Metroid Prime 3)

The format for materials saw a dramatic overhaul in Metroid Prime 3. The format is seen in both the CMDL and MREA formats and is identical in both. This particular material format appears in Metroid Prime 3: Corruption and Donkey Kong Country Returns.

Material Set Format
Materials come as part of a set; although most files will only have one set, some CMDLs will have more, as indicated by a count value in the header. The set format is merely a 32-bit count value followed by that number of materials, with each material beginning with a 32-bit size value.

Material Format
Every material begins with a 0x1C-byte header, followed by a number of subsections. The header is structured as follows:

Subsections
The rest of the material data is made up of a number of subsections. These subsections generally set different texture slots, as well as other parameters like Konst colors and material opacity. There's no count for the number of subsections; it needs to be read in using a while loop. The "END " section denotes the end of the material.

There are three subsection types (aside from END): PASS, CLR, and INT. Each of these types has a number of subtypes.

PASS
List of possible PASS subtypes:

CLR
List of possible CLR subtypes:

INT
List of possible INT subtypes: