Difference between revisions of "Material List (RW Section)"

From GTAMods Wiki
Jump to navigation Jump to search
m
(Limitations of material instancing)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{RW Section|Material List|0x0008}}
+
{{RW Section
 +
| NAME = Material List
 +
| VENDORNAME = Criterion Games
 +
| MODULENAME = Core
 +
| MODULEID = 000000
 +
| IDENTIFIER = 08
 +
| PARENTS = [[Geometry (RW Section)|Geometry]]
 +
| CHILDREN = [[Struct (RW Section)|Struct]], [[Material (RW Section)|Material]]
 +
}}
  
'''Material List''' is a container section used in [[model file|DFF files]] as child of a [[Geometry (RW Section)|geometry section]]. The section itself does not store any data at all. All additional information get stored inside a [[Struct (RW Section)|struct section]] which directly follows this one as a child. ''Material List'' stores the different materials used by the ''geometry'' section it is appendet to.
+
'''Material List''' is a container section used in [[model file|DFF files]] as child of a [[Geometry (RW Section)|geometry section]]. The section itself does not store any data at all. All additional information get stored inside a [[Struct (RW Section)|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:
  
== Structure ==
+
  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.
  
The structure simply stores the number of materials and some reserved values for each material
+
Note that it is not possible to create material instances in a forward declarative manner:
  
4b - DWORD   - Number of materials
+
  000 3   // There are three materials in the list.
  Xb - DWORD[] - Array of material indices (references). "-1" means this material is not referenced to any other material.
+
  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
  
An example:
+
Thus it is a good practice to store base materials before material instances:
  000 7  --materials count
 
  004 -1  --first material (it will be "-1" always, since the first material in list can't be referenced to any other material)
 
  008 -1  --second material
 
  00C  0  --third material is referenced to first material
 
  010  1  --fourth material is referenced to second material
 
--014  2  --an error! 3rd material is not exist. This material list contain only 2 unique materials above
 
  014  0  --that one is fine. Another reference to first material.
 
  018 -1  --third unique material
 
  01C  2  --now we can make a reference to third material
 
  
== Child sections ==
+
  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
 +
  (...)
  
The number of child sections is defined inside the structure of this section.
+
=== Limitations of material instancing ===
  
* [[Material (RW Section)|Material]]
+
Unlike later shader-based implementations in other game engines, material instances in Renderware 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''.
  
 
== See also ==
 
== See also ==
 +
 
* [[Geometry (RW Section)|Geometry]]
 
* [[Geometry (RW Section)|Geometry]]
* [[RenderWare_binary_stream_file|RW file format specification]]
 
  
{{N|SA|VC}}
+
{{N|SA|VC|3}}
[[Category:GTA_3]]
 

Latest revision as of 08:20, 22 January 2022

Material List
RenderWare Stream Section
Vendor Criterion Games
Module Core
Module ID 0x000000
Identifier 0x08
Chunk ID 0x00000008
Versions All
Hierarchy
Parents:
Geometry
Children:
Struct, Material
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 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.

See also