Materials (Metroid Prime 3): Difference between revisions

m
>Aruki
>Aruki
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
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.
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.


{{research|moderate|Need to find TEV values for each subsection type}}
{{research|moderate|There are a ton of unknowns in this format}}


__TOC__
__TOC__
Line 7: Line 7:
== Material Set Format ==
== 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.
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. In Metroid Prime 3, each material set will be in its own CMDL/MREA section, but in DKCR each set will be in the same section.


== Material Format ==
== Material Format ==
Line 151: Line 151:
| {{unknown|Unknown}}
| {{unknown|Unknown}}
|-
|-
| 17+
| 17
| 0x20000
| {{unknown|Unknown; DKCR only}}
|-
| 18
| 0x40000
| {{unknown|Unknown; DKCR only}}
|-
| 19
| 0x80000
| Render with white ambient color. This is used on world geometry that doesn't have lightmaps. DKCR only.
|-
| 20
| -
| -
| Unused
| Unused in MP3; possibly used in DKCR
|}
 
==== Vertex Attribute Flags ====
 
These flags are generally toggled in pairs, with each pair corresponding to a vertex attribute; if a pair is set, then vertices using this material will have the corresponding attribute. This is vital for reading geometry. Each pair is used to indicate the size of the attribute indices in the geometry data, with 3 meaning a 16-bit index and 2 meaning an 8-bit index. (This isn't actually used, though; the original game data always uses 16-bit indices.)
 
GX supports up to 8 texture coords per vertex, but the game doesn't seem to allow you to assign more than 7 (though this could do with some double-checking).
 
These are the possible attributes:
 
{| class="wikitable"
! Bit pair
! Attribute
|-
| 0x3
| Position
|-
| 0xC
| Normal
|-
| 0x30
| Color 0
|-
| 0xC0
| Color 1
|-
| 0x300
| Tex 0
|-
| 0xC00
| Tex 1
|-
| 0x3000
| Tex 2
|-
| 0xC000
| Tex 3
|-
| 0x30000
| Tex 4
|-
| 0xC0000
| Tex 5
|-
| 0x300000
| Tex 6
|}
 
The top byte is structured differently; unlike the other flags, the bits in the top byte Are not set in pairs. Each individual bit indicates the presence of a different attribute. The indices in the geometry data are always 8 bits.
 
{| class="wikitable"
! Bit
! Attribute
|-
| 0x1
| Position Matrix Index
|-
| 0x2
| Tex0 Matrix Index
|-
| 0x4
| Tex1 Matrix Index
|-
| 0x8
| Tex2 Matrix Index
|-
| 0x10
| Tex3 Matrix Index
|-
| 0x20
| Tex4 Matrix Index
|-
| 0x40
| Tex5 Matrix Index
|-
| 0x80
| Tex6 Matrix Index
|}
|}


=== Subsections ===
=== 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 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 <code>END </code> 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.
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.
There are three subsection types (aside from <code>END </code>): <code>PASS</code>, <code>CLR </code>, and <code>INT </code>. Each of these types has a number of subtypes.


==== PASS ====
==== PASS ====
Line 233: Line 322:
| u32
| u32
| 4
| 4
| '''[[Materials_(Metroid_Prime)#UV_Animations|Animation Type]]'''
| '''[[UV_Animations#Animation_Modes|Animation Type]]'''
|}
|}


Line 250: Line 339:
|-
|-
| <code>RIML</code>
| <code>RIML</code>
| {{unknown|Unknown}}
| Rim lighting map
| {{nocheck}}
| {{nocheck}}
| {{check}}
| {{check}}
|-
|-
| <code>BLOL</code>
| <code>BLOL</code>
| Bloom map for lightmaps
| Bloom lightmap
| {{check}}
| {{check}}
| {{nocheck}}
| {{nocheck}}
|-
|-
| <code>BLOD</code>
| <code>BLOD</code>
| {{unknown|Unknown}}
| Bloom diffuse map
| {{check}}
| {{check}}
| {{nocheck}}
| {{nocheck}}
Line 270: Line 359:
|-
|-
| <code>TRAN</code>
| <code>TRAN</code>
| Greyscale opacity map
| Opacity map
| {{check}}
| {{check}}
| {{check}}
| {{check}}
|-
|-
| <code>INCA</code>
| <code>INCA</code>
| Emissive map
| Incandescence map
| {{check}}
| {{check}}
| {{check}}
| {{check}}
|-
|-
| <code>RFLV</code>
| <code>RFLV</code>
| Specular map
| Reflectivity map
| {{check}}
| {{check}}
| {{check}}
| {{check}}
|-
|-
| <code>RFLD</code>
| <code>RFLD</code>
| Reflection/sphere map
| Reflection map
| {{check}}
| {{check}}
| {{check}}
| {{check}}
Line 300: Line 389:
|-
|-
| <code>BLOI</code>
| <code>BLOI</code>
| Bloom map for diffuse map
| Bloom incandescence map
| {{check}}
| {{check}}
| {{nocheck}}
| {{nocheck}}
|-
|-
| <code>XRAY</code>
| <code>XRAY</code>
| Sphere map for X-Ray models; similar to RFLD
| Reflection map for X-Ray models; similar to <code>RFLD</code>
| {{check}}
| {{check}}
| {{nocheck}}
| {{nocheck}}
Line 348: Line 437:
| Unused
| Unused
|}
|}
===== UV Animations =====
'' See [[UV Animations]]


==== CLR  ====
==== CLR  ====
Line 423: Line 516:
| Sets the opacity of the entire material
| Sets the opacity of the entire material
| {{check}}
| {{check}}
| {{nocheck}}
| {{check}}
|-
|-
| <code>BLOD</code>
| <code>BLOD</code>
| {{unknown|Unknown}}
| {{unknown|Unknown; bloom-related?}}
| {{check}}
| {{check}}
| {{nocheck}}
| {{nocheck}}
|-
|-
| <code>BLOI</code>
| <code>BLOI</code>
| {{unknown|Unknown}}
| {{unknown|Unknown; bloom-related?}}
| {{check}}
| {{check}}
| {{nocheck}}
| {{nocheck}}
Line 441: Line 534:
|-
|-
| <code>XRBR</code>
| <code>XRBR</code>
| {{unknown|Unknown}}
| {{unknown|Unknown; X-Ray related?}}
| {{check}}
| {{check}}
| {{nocheck}}
| {{nocheck}}
Anonymous user