Chapter 3 Binary Format

3-13 Material List

2. Mat Area

u32 | mat_tag
u32 | this_mat_index
u32 | mat_size
u32 | mat_name_index
u32 | mat_type
u32 | mat_shade_type
u32 | mat_color_type0
u32 | mat_color_type1
u32 | mat_alpha_type0
u32 | mat_alpha_type1
float | prim_red
float | prim_green
float | prim_blue
float | prim_alpha
u32 | user_flag0
u32 | user_flag1
u32 | user_flag2
u32 | user_flag3
u32 | user_flag4
u32 | user_flag5
u32 | user_flag6
u32 | user_flag7
u32 | local_light_index
u32 | tex_num
u32 | nintendo_extension_block_size
u32 | user_extension_block_size
u32 | tex_index(0)
...
u32 | tex_index(tex_num - 1)
NintendoExtensionBlock
UserExtensionBlock

Figure: Mat Area Memory Map

u32 mat_tag | Tag indicating Mat. Set the following flag.
    TAG_MAT	0x000a0100
u32 this_mat_index | Index number of this Mat area.
u32 mat_size | Size of this Mat area
u32 mat_name_index | Index number in NameList that describes Mat name.
u32 mat_type | Material in NIFF has three types: mat_shade_type, mat_color_type, and mat_alpha_type. mat_shade_type is the field primaly to specify the setting for shooting. mat_color_type is the field to specify the setting of color value. mat_alpha_typeis the field to specify the setting for Alpha value. Also, mat_color_type and mat_alpha_type have two fields each for application on N64.

You can specify how to refer to flags for Color setting and Alpha setting at mat_type field for customaization. The following flags are already specified at present.

    MAT_TYPE_NIFF	0x00000000
    MAT_TYPE_N64	0x01010101

MAT_TYPE_NIFF sets the conbination of color value and that of Alpha value respectively using colors to be set in the NIFF format. Flags set in these fields for mat_color_type* or mat_alpha_type* specify the exclusive flag for MAT_TYPE_N.

MAT_TYPE_N64 can use flags specified in mat_color type* and mat_alpha_type* to be able to specify all setting in color combiner of NINTENDO64. However, in case of the usage of color value which is not set in NIFF, you need to allocate colors to several user_flag on convertor to convert from NIFF to N64 in advance.

For details, please see Chapter 4, "Note for material type setting."

u32 mat_shade_type | This field primarily specifies the shading attributes of materials. The following flags are currently defined.
    MAT_SHADE_LIGHT_OFF	0x00000000
    MAT_SHADE_LIGHT_LOCAL	0x00000001
    MAT_SHADE_LIGHT_GLOBAL	0x00000002
    MAT_SHADE_FLAT		0x00000000
    MAT_SHADE_SMOOTH	0x00000010
    MAT_SHADE_USE_HILIGHT	0x00000100
    MAT_SHADE_USE_REFLECT	0x00000200
The MAT_SHADE_LIGHT_* flag specifies the effect of light on materials. If MAT_SHADE_LIGHT_OFF is set,the lighting process specified is not performed. If MAT_SHADE_LIGHT_LOCAL is set, the Light in LightList that has the index specified by the local_light_index of this Mat area is used.

MAT_SHADE_LIGHT_GLOBAL is used, the Light that links to Scene is used.

MAT_SHADE_FLAT and MAT_SHADE_SMOOTH are flags that specify shading information of triangles.
If MAT_SHADE_FLAT is set, triangles are drawn using the spefified material.

If MAT_SHADE_SMOOTH is set, triangles are drawn using the specified material with color graduated between vertices.

MAT_SHADE_USE_HILIGHT specifies the use of highlight texture mapping.

MAT_SHADE_USE_REFLECT specifies the use of reflection texture mapping.

The MAT_SHADE_LIGHT_* flag must always be specified and only one MAT_SHADE_LIGHT_* setting can be specified.

Either MAT_SHADE_FLAT or MAT_SHADE_SMOOTH must always be specified. The use of MAT_SHADE_USE_HILIGHT and MAT_SHADE_USE_REFLECT is optional. Only one or the other may be specified.

u32 mat_color_type0 | Sets color gradations of materials. For details, please see, "Note for material type setting."
u32 mat_color_type1 | Sets color gradations of materials. Used only when specifying a 2-cycle mode rendering type. For details, please see, "Note for material type setting."
u32 mat_alpha_type0 | Sets alpha gradations of materials. For details, please see, "Note for material type setting."
u32 mat_alpha_type1 | Sets alpha gradations of materials. Used only when specifying a 2-cycle mode rendering type. For details, please see, "Note for material type setting."
float prim_red | Red component of primitive color 0 prim_red 1.0
float prim_green | Green component of primitive color 0 prim_red 1.0
float prim_blue | Blue component of primitive color 0 prim_red 1.0
float prim_alpha | Alpha component of primitive color 0 prim_red 1.0
u32 usr_flag0 | 32-bit user-defined flag. With the converter to be released by NCL, there may be cases where a user flag is allocated data in advance. For details, please see, "Note for material type setting."
u32 usr_flag1 | 32-bit user-defined flag. With the converter to be released by NCL, there may be cases where a user flag is allocated data in advance. For details, please see, "Note for material type setting."
u32 usr_flag2 | 32-bit user-defined flag. With the converter to be released by NCL, there may be cases where a user flag is allocated data in advance. For details, please see, "Note for material type setting."
u32 usr_flag3 | 32-bit user-defined flag. With the converter to be released by NCL, there may be cases where a user flag is allocated data in advance. For details, please see, "Note for material type setting."
u32 usr_flag4 | 32-bit user-defined flag. With the converter to be released by NCL, there may be cases where a user flag is allocated data in advance. For details, please see, "Note for material type setting."
u32 usr_flag5 | 32-bit user-defined flag. With the converter to be released by NCL, there may be cases where a user flag is allocated data in advance. For details, please see, "Note for material type setting."
u32 usr_flag6 | 32-bit user-defined flag. With the converter to be released by NCL, there may be cases where a user flag is allocated data in advance. For details, please see, "Note for material type setting."
u32 usr_flag7 | 32-bit user-defined flag. With the converter to be released by NCL, there may be cases where a user flag is allocated data in advance. For details, please see, "Note for material type setting."
u32 local_light_index | Specifies the index number in LightList of Light that is referred to when specifying MAT_SHADE_LIGHT_LOCAL. Applies only when MAT_SHADE_LIGHT_LOCAL is specified. (In other cases, this data area exists but its contents are ignored.)
u32 tex_num | The number of textures to be used with Mat. Either 0, 1, or 2.
u32 nintendo_extension_block_size | Size of Nintendo extension block
u32 user_extension_block_size | Size of user extension block
u32 tex_index | Index number in TexList of the texture used with Mat.
NintendoExtensinoBlock | Nintendo extension block
UserExtensionBlock | User extension block