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

From GTAMods Wiki
Jump to navigation Jump to search
 
(16 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
| MODULEID = 00CAFE
 
| MODULEID = 00CAFE
 
| IDENTIFIER = 45
 
| IDENTIFIER = 45
| PARENTS = [[Material (RW Section)|Material]] ''([[Extension (RW Section)|Extension]])'', [[Atomic (RW Section)|Atomic]] ''([[Extension (RW Section)|Extension]], see [[Material_Effects_PLG_(RW_Section)#Atomic_extension|below]])''
+
| PARENTS = [[Material (RW Section)|Material]] ''([[Extension (RW Section)|Extension]])''
 
}}
 
}}
  
The custom '''material''' extension was developed by THQ to attach geometric rendering properties to a material, using alpha referencing, z-test flags, blend functions, and culling, used for the known game ''[[wikipedia:Jimmy Neutron: Attack of the Twonkies|Jimmy Neutron: Attack of the Twonkies]]''.
+
The custom '''material''' extension was developed by THQ to attach geometric rendering properties to a material, using alpha referencing, z-test flags, blend functions, and culling, used for the known game ''[[wikipedia:The Adventures of Jimmy Neutron Boy Genius: Attack of the Twonkies|The Adventures of Jimmy Neutron Boy Genius: Attack of the Twonkies]]''.
  
 
==Structure==
 
==Structure==
 +
uint32 header
 +
int32 sectionSize
 +
uint32 version
 +
int32 dataSize // Usually 4.
 +
uint32 renderProps
 +
 
 +
void THQMaterial(void)
 
  {
 
  {
  uint32 header
+
   int32 AlphaTestFunc
   int32 sectionSize
 
  uint32 renderProps
 
 
 
 
   int32 AlphaTestRef
 
   int32 AlphaTestRef
   uint32 ZWriteFlags
+
   bool ZTest
 +
  bool ZWrite
 
   int32 SrcBlend
 
   int32 SrcBlend
 
   int32 DestBlend
 
   int32 DestBlend
   int32 FaceCullIndex
+
   int32 FaceCullMode
 
+
   bool AlphaEnabled
  RwCullMode FaceCullMode
 
    
 
  AlphaTestRef = ((renderProps << 1) & 0xFF000000) >> 24);
 
  SrcBlend = ((renderProps << 1) & 0xF0) >> 4;
 
  DstBlend = ((renderProps << 1) & 0xF00) >> 8;
 
  FaceCullIndex = (renderProps << 1) & 0xF;
 
 
 
  switch( FaceCullIndex )
 
    {
 
        case 0:
 
        {
 
            FaceCullMode = rwCULLMODECULLNONE;
 
            break;
 
        }
 
 
    
 
    
        case 1:
+
  AlphaTestFunc = (renderProps & 0x7800) >> 11;
        {
+
  AlphaTestRef = (renderProps & 0x7F8000) >> 15;
            FaceCullMode = rwCULLMODECULLBACK;
+
  ZTest = (renderProps & 0x800000) >> 17;
            break;
+
  SrcBlend = (renderProps & 0x78) >> 3;
        }
+
  DstBlend = (renderProps & 0x780) >> 7;
 +
  FaceCullIndex = min(max(renderProps & 0x7, 1), 3);
 
    
 
    
        case 2:
+
  if (DstBlend == (void *)rwBLENDZERO)
        {
+
    ZWrite = TRUE
            FaceCullMode = rwCULLMODECULLFRONT;
+
    AlphaEnabled = FALSE
            break;
+
  else
        }
+
  {
     }
+
    ZWrite = FALSE
 +
    AlphaEnabled = TRUE
 +
   
 +
     if (renderProps & 0x4000000)
 +
      FaceCullIndex = (void *)rwCULLMODECULLNONE;
 +
  }
 
  }
 
  }

Latest revision as of 08:56, 14 December 2023

THQ Material (Custom)
RenderWare Stream Section
Vendor THQ
Module Plug-In
Module ID 0x00CAFE
Identifier 0x45
Chunk ID 0x00CAFE45
Versions All
Hierarchy
Parents:
Material (Extension)
Children:
None
Extensions:
None
File Format

The custom material extension was developed by THQ to attach geometric rendering properties to a material, using alpha referencing, z-test flags, blend functions, and culling, used for the known game The Adventures of Jimmy Neutron Boy Genius: Attack of the Twonkies.

Structure

uint32 header
int32 sectionSize
uint32 version
int32 dataSize // Usually 4.
uint32 renderProps
 
void THQMaterial(void)
{
 int32 AlphaTestFunc
 int32 AlphaTestRef
 bool ZTest
 bool ZWrite
 int32 SrcBlend
 int32 DestBlend
 int32 FaceCullMode
 bool AlphaEnabled
 
 AlphaTestFunc = (renderProps & 0x7800) >> 11;
 AlphaTestRef = (renderProps & 0x7F8000) >> 15;
 ZTest = (renderProps & 0x800000) >> 17;
 SrcBlend = (renderProps & 0x78) >> 3;
 DstBlend = (renderProps & 0x780) >> 7;
 FaceCullIndex = min(max(renderProps & 0x7, 1), 3);
 
 if (DstBlend == (void *)rwBLENDZERO)
   ZWrite = TRUE
   AlphaEnabled = FALSE
 else
 {
   ZWrite = FALSE
   AlphaEnabled = TRUE
   
   if (renderProps & 0x4000000)
      FaceCullIndex = (void *)rwCULLMODECULLNONE;
 }
}