Difference between revisions of "Materials (Metroid Prime 3)"

From Retro Modding Wiki
Jump to: navigation, search
Line 23: Line 23:
 
| u32
 
| u32
 
| 4
 
| 4
| {{unknown|'''Unknown'''}}
+
| '''Material Flags'''
 
| Only bottom 17 bits are valid
 
| Only bottom 17 bits are valid
 
|-
 
|-
Line 127: Line 127:
 
|-
 
|-
 
| <code>DIFF</code>
 
| <code>DIFF</code>
| Commonly used for lightmaps
+
| Commonly used for lightmaps, can be used interchangeably with <code>CLR</code>
 
|-
 
|-
 
| <code>BLOL</code>
 
| <code>BLOL</code>
|  
+
| Gaussian Blur lightmap, unknown how to apply properly.
 
|-
 
|-
 
| <code>CLR </code>
 
| <code>CLR </code>
Line 139: Line 139:
 
|-
 
|-
 
| <code>INCA</code>
 
| <code>INCA</code>
| Likely incandescence/emissive maps
+
| Emissive maps
 
|-
 
|-
 
| <code>RFLV</code>
 
| <code>RFLV</code>
|  
+
| Specular map, oddly seems to use the same texture as CLR/DIFF in most cases.
 
|-
 
|-
 
| <code>RFLD</code>
 
| <code>RFLD</code>
|  
+
| Reflection/Sphere maps
 
|-
 
|-
 
| <code>LRLD</code>
 
| <code>LRLD</code>
|  
+
| See RFLD
 
|-
 
|-
 
| <code>LURD</code>
 
| <code>LURD</code>
|  
+
| See RFLV
 
|-
 
|-
 
| <code>BLOD</code>
 
| <code>BLOD</code>
|  
+
| See BLOL
 
|-
 
|-
 
| <code>BLOI</code>
 
| <code>BLOI</code>
|  
+
| See BLOL
 
|-
 
|-
 
| <code>XRAY</code>
 
| <code>XRAY</code>
| From the name, possibly texture map setting visuals for X-Ray Visor
+
| Sphere map for X-Ray models, behaves in the same manner as RFLD, usually with a mode 0 UV animation.
 
|}
 
|}
  

Revision as of 19:28, 2 April 2015

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.


Morphball wirerender.png This file format needs more research
Need to find TEV values for each subsection type


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:

Offset Type Size Description Notes
0x0 u32 4 Material Flags Only bottom 17 bits are valid
0x4 u32 4 Unknown
0x8 u32 4 Unknown Value is possibly unused; the material loading code seems to skip it
0xC u32 4 Vertex attribute flags Functionality is identical to Metroid Prime 2
0x10 u32 4 Unknown Value is possibly unused; the material loading code seems to skip it
0x14 u32 4 Unknown
0x18 u32 4 Unknown
0x1C End of header

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.

The order of the subsections doesn't matter. One material can only have one of each type of subsection; if there's any additional ones, they will overwrite the previous ones.

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

PASS

Offset Type Size Description Notes
0x0 u32 4 PASS subsection size
0x4 char[4] 4 Section subtype fourCC See below for possible subtypes
0x8 u32 4 Unknown Only bottom 5 bits are valid
0xC TXTR 8 Texture ID
0x14 u32 4 UV Source Only bottom 4 bits are valid
0x18 u32 4 UV animations size Needs verification; only bottom 8 bits are valid

List of possible PASS subtypes:

Type Description
DIFF Commonly used for lightmaps, can be used interchangeably with CLR
BLOL Gaussian Blur lightmap, unknown how to apply properly.
CLR Likely color map, similar to DIFF; commonly used for diffuse maps
TRAN Greyscale opacity map; white indicates transparent, black indicates opaque (Retro is backwards)
INCA Emissive maps
RFLV Specular map, oddly seems to use the same texture as CLR/DIFF in most cases.
RFLD Reflection/Sphere maps
LRLD See RFLD
LURD See RFLV
BLOD See BLOL
BLOI See BLOL
XRAY Sphere map for X-Ray models, behaves in the same manner as RFLD, usually with a mode 0 UV animation.

CLR

Offset Type Size Description Notes
0x0 char[4] 4 Section subtype fourCC See below for possible subtypes
0x4 u32 4 Color value 32-bit RGBA value

List of possible CLR subtypes:

Type Description
CLR
DIFB

INT

Offset Type Size Description Notes
0x0 char[4] 4 Section subtype fourCC See below for possible subtypes
0x4 u32 4 Value Actually an 8-bit value; the top 24 bits are ignored

List of possible INT subtypes:

Type Description
OPAC Sets the opacity of the entire material
BLOD
BLOI
BNIF
XRBR