Material Effects PLG (RW Section)

From GTAMods Wiki
Revision as of 14:14, 6 May 2016 by Aschratt (talk | contribs) (Dual Texturing (rwMATFXEFFECTDUAL))
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 Effects PLG is an extension to the Material section in the Renderware stream file format. It is part of the Renderware Toolkit and can be used to attach certain effects to a material, such as bump mapping, reflections and UV-Animations.

Binary structure

Basically each section is structured starting with a header, that contains a effect type identifier, followed by two effects that can be overlayed, if the effect type supports it.

 4b - DWORD  - Type (Header)
 Xb - Effect - First Effect
 Xb - Effect - Second Effect

It's certain, that at least the second effect is not used, even both effects can be disabled by setting the type identifier to 0x00 (rwMATFXNULL). It is important to note, that the effect rwMATFXNULL allocates 4 bytes of memory for it's effect header.

Header

The section starts with a type identifier. The section's actual size depends on the section type.

 4b - DWORD  - Type

The section type can be of one of the following values:

 0 rwMATFXEFFECTNULL            No Effect
 1 rwMATFXEFFECTBUMPMAP         Bump Map
 2 rwMATFXEFFECTENVMAP          Environment Map (Reflections)
 3 rwMATFXEFFECTBUMPENVMAP      Bump Map/Environment Map
 4 rwMATFXEFFECTDUAL            Dual Textures
 5 rwMATFXEFFECTUVTRANSFORM     UV-Tranformation
 6 rwMATFXEFFECTDUALUVTRANSFORM Dual Textures/UV-Transformation

The effect types 3 (rwMATFXEFFECTBUMPENVMAP) and 6 (rwMATFXEFFECTDUALUVTRANSFORM) are requiring both effects to be set. For all other section types, the second effect is usually set to 0 (rwMATFXEFFECTNULL).

Effects (Types)

Each effect starts with a header on it's own, containing the effect identifier. The effect identifier is of the same type as the section identifier and therefor the effect identifier of the first effect typically equals the section identifier. Exceptions are the section types 3 (rwMATFXEFFECTBUMPENVMAP) and 6 (rwMATFXEFFECTDUALUVTRANSFORM), which are invalid when beeing used as effect type.

No Effect (rwMATFXNULL)

The effect starts with a header, containing its type identifier.

 4b - DWORD  - 0x00, rwMATFXEFFECTNULL

There are no other contents stored within this effect.

Bump Mapping (rwMATFXEFFECTBUMPMAP)

The effect starts with a header, containing its type identifier, followed by some settings.

 4b - DWORD      - 0x01, rwMATFXEFFECTBUMPMAP
 4b - FLOAT      - Intensity
 4b - BOOL       - Contains Bump Map
 Xb - RwTexture  - Bump Map (Only if effect contains a bump map)
 4b - BOOL       - Contains Height Map
 Xb - RwTexture  - Height Map (Only if the effect contains a height map)

Note that there are two switches within the effect, that determine the existence of two child sections, containing the actual bump or height map. The textures are stored as raw RwTextures, simply within the effect structure.

Environment Mapping (rwMATFXENVMAP)

Environment maps are used to simulate real-time reflections by blending in a pre-rendered environmental texture. Renderware does not support real-time reflections, besides Environment Mapping out of the box, but it can be hooked up with mods like ENBSeries.

 4b - DWORD      - 0x02, rwMATFXENVMAP
 4b - FLOAT      - Reflection Coefficient (default is 1.0)
 4b - BOOL       - Use Frame Buffer Alpha Channel
 4b - BOOL       - Contains Environment Map
 Xb - RwTexture  - Environment Map

The effect itself contains a switch that determines the existence of a environment map in form of a texture. If the switch is true, the texture is stored as a raw RwTexture section, succeeded by the switch itself.

Dual Texturing (rwMATFXEFFECTDUAL)

Dual Texturing enables the engine to blend two textures together. The effect therefor defines a set of blending options.

 4b - DWORD     - 0x04, rwMATFXEFFECTDUAL
 4b - FLOAT     - Blending Power (default is 1.0)
 4b - DWORD     - Blending Mode
 4b - BOOL      - Contains Texture
 Xb - RwTexture - Texture

If the effect contains a texture, it is stored as a raw RwTexture section right after the Contains Texture option. The Blend Mode option defines how two textures are blend together. Basically each mode executes a different vector function that returns the blending result for each texel.

The first set of functions returns a constant value for each texel.

 0x00 - rwNOBLEND
 0x01 - rwBLENDZERO             (0,    0,    0,    0   )
 rwBLENDONE              (1,    1,    1,    1   )

The very first function, rwNOBLEND, disables blending at all, meaning that only the base texture of the material will be drawn. This has pretty much the same effect, as the second function, which blends the base texture over the blend texture. rwBLENDONE does the exact opposite by blending the blend texture over the base texture.

The other blend functions are blending together both textures, depending on different texture channels.

 0x02 - rwBLENDSRCCOLOR         (Rs,   Gs,   Bs,   As  )
 0x03 - rwBLENDINVSRCCOLOR      (1-Rs, 1-Gs, 1-Bs, 1-As)
 0x04 - rwBLENDSRCALPHA         (As,   As,   As,   As  )
 0x05 - rwBLENDINVSRCALPHA      (1-As, 1-As, 1-As, 1-As)
 0x06 - rwBLENDDESTALPHA        (Ad,   Ad,   Ad,   Ad  )
 0x07 - rwBLENDINVDESTALPHA     (1-Ad, 1-Ad, 1-Ad, 1-Ad)
 0x08 - rwBLENDDESTCOLOR        (Rd,   Gd,   Bd,   Ad  )
 0x09 - rwBLENDINVDESTCOLOR     (1-Rd, 1-Gd, 1-Bd, 1-Ad)
 0x0A - rwBLENDSRCALPHASAT      (f,    f,    f,    1   )  f = min (As, 1-Ad)

UV-Animation (rwMATFXEFFECTUVTRANSFORM)

UV-Animation itself does not contain any further information, besides it obligatory header.

 4b - DWORD     - 0x05, rwMATFXEFFECTUVTRANSFORM

If this effect is defined, the Material also contains a UV Animation PLG extension.

See also