Material List (RW Section)

From GTAMods Wiki
Revision as of 12:03, 15 April 2016 by Aschratt (talk | contribs) (Extented the examples section changed terminology. "Material Instance" is a concept, users of other game engines may be more familiar with.)
Jump to navigation Jump to search
{{{NAME}}}
RenderWare Stream Section
Vendor {{{VENDORNAME}}}
Module {{{MODULENAME}}}
Module ID 0x{{{MODULEID}}}
Identifier 0x{{{IDENTIFIER}}}
Chunk ID 0x{{{MODULEID}}}{{{IDENTIFIER}}}
Versions All
Hierarchy
Parents:
None
Children:
None
Extensions:
None
File Format

Material List is a container section used in DFF files as child of a geometry section. The section itself does not store any data at all. All additional information get stored inside a struct section which directly follows this one as a child. Material List stores the different materials used by the geometry section it is appended to.



Structure

The structure stores the number of materials and material instances inside the list.

4b - DWORD   - Number of materials, including material instances
Xb - DWORD[] - Array of material indices.

A material index equals -1 if it is a material. If the material is an instance of a previously defined material, the index equals the base materials one.

Examples

As an example, the definition of a material list with two different materials would look like this:

  000 2   // There are two materials in the list.
  004 -1  // First material (always -1, since there needs to be at least one base material).
  008 -1  // A second material.

If there is a material instance, it will store the index of the parent material:

  000 4   // There are four materials in the list.
  004 -1  // First material (always -1, since there needs to be at least one base material).
  008 -1  // A second material.
  00C  0  // Instance of the first material.
  010  1  // Instance of the second material.

Note that it is not possible to create material instances in a forward declarative manner:

  000 3   // There are three materials in the list.
  004 -1  // First material (always -1, since there needs to be at least one base material).
  008 1   // Instance of the second material defined below (error!).
  00C -1  // Second material

Thus it is a good practice to store base materials before material instances:

  000 4   // There are four materials in the list.
  004 -1  // First material (always -1, since there needs to be at least one base material).
  008 -1  // Second material
  00C 0   // First instance
  010 1   // Second instance
  (...)

Limitations of material instancing

Unlike later shader-based implementations in other game engines, material instances in Renderware are do not support manipulation of (even basic) material parameters, like phong parameters (e.g. specular, ambient and diffuse colors). They are more like implicit copies of a material and therefor may also be called material references.

Child sections

As stated above, the number of child sections is equal to number of materials (excluding material instances) in the list.

See also