Material Asset

From COD Engine Research
Revision as of 16:52, 12 January 2015 by Therifboy (Talk | contribs)

Jump to: navigation, search

Call of Duty 4 & World at War & Modern Warfare 2 & Modern Warfare 3

struct MaterialConstantDef 
{
	int nameHash;
	char name[12];
	vec4_t literal;
};
 
struct GfxStateBits 
{
#ifdef XBOX
	int loadBits[2];
#elif defined(PS3)
	int (*loadBits)[2];
 #if defined(MW2) || defined(MW3)
	int unknown;
 #endif
#endif
};
 
struct WaterWritable
{
	float floatTime;
};
 
struct water_t 
{
	WaterWritable writable;
	float *H0X;		// Count = M * N
	float *H0Y;		// Count = M * N
	float *wTerm;		// Count = M * N
	int M;
	int N;
	float Lx;
	float Lz;
	float gravity;
	float windvel;
	float winddir[2];
	float amplitude;
	float codeConstant[4];
	GfxImage *image;
};
 
/* MaterialTextureDef->semantic */
#define TS_2D		0x0
#define TS_FUNCTION	0x1
#define TS_COLOR_MAP	0x2
#define TS_UNUSED_1	0x3
#define TS_UNUSED_2	0x4
#define TS_NORMAL_MAP	0x5
#define TS_UNUSED_3	0x6
#define TS_UNUSED_4	0x7
#define TS_SPECULAR_MAP	0x8
#define TS_UNUSED_5	0x9
#define TS_UNUSED_6	0xA
#define TS_WATER_MAP	0xB
 
union MaterialTextureDefInfo 
{
	GfxImage *image;	// MaterialTextureDef->semantic != TS_WATER_MAP
	water_t *water;		// MaterialTextureDef->semantic == TS_WATER_MAP
};
 
struct MaterialTextureDef
{
	unsigned int nameHash;
	char nameStart;
	char nameEnd;
	char sampleState;
	char semantic;
#ifdef WAW
	int unknown;
#endif
	MaterialTextureDefInfo u;
};
 
union GFxDrawSurfFields
{
	unsigned long long unused,
			primarySortKey,
			surfType,
			primaryLightIndex,
			prepass,
			materialSortedIndex,
			customIndex,
			reflectionProbeIndex,
			objectId;
};
 
union GfxDrawSurf 
{
	GFxDrawSurfFields fields;
	unsigned long long packed;
};
 
struct __declspec(align(8)) MaterialInfo
{
	const char *name;
	char gameFlags;
	char sortKey;
	char textureAtlasRowCount;
	char textureAtlasColumnCount;
	GfxDrawSurf drawSurf;
	int surfaceTypeBits;
};
 
struct Material
{
	MaterialInfo info;
	char stateBitsEntry[TECHNIQUE_COUNT];	// see MaterialTechniqueType
	char textureCount;
	char constantCount;
	char stateBitsCount;
	char stateFlags;
	char cameraRegion;
#ifdef PS3
	unsigned short ushorts[TECHNIQUE_COUNT];
	unsigned short *ushortArray;	// count = TECHNIQUE_COUNT, see MaterialTechniqueType
#endif
	MaterialTechniqueSet *techniqueSet;
	MaterialTextureDef *textureTable;
	MaterialConstantDef *constantTable;
	GfxStateBits *stateBitTable;
#if defined(MW2) || defined(MW3)
	const char **unknownXStringArray;
#endif
};

Black Ops & Black Ops 2

struct MaterialConstantDef 
{
  unsigned int nameHash;
  char name[12];
  vec4_t literal;
};
 
struct GfxStateBits 
{
#if defined(XBOX) || defined(BO2)	// ps3 uses this for bo2..
  unsigned int loadBits[2];
#elif defined PS3
	int (*loadBits)[2];
#endif
};
 
struct WaterWritable
{
	float floatTime;
};
 
struct water_t 
{
	WaterWritable writable;
	float *H0X;		// Count = M * N
	float *H0Y;		// Count = M * N
	float *wTerm;		// Count = M * N
	int M;
	int N;
	float Lx;
	float Lz;
	float gravity;
	float windvel;
	float winddir[2];
	float amplitude;
	float codeConstant[4];
	GfxImage *image;
};
 
/* MaterialTextureDef->semantic */
#define TS_2D		0x0
#define TS_FUNCTION	0x1
#define TS_COLOR_MAP	0x2
#define TS_UNUSED_1	0x3
#define TS_UNUSED_2	0x4
#define TS_NORMAL_MAP	0x5
#define TS_UNUSED_3	0x6
#define TS_UNUSED_4	0x7
#define TS_SPECULAR_MAP	0x8
#define TS_UNUSED_5	0x9
#define TS_UNUSED_6	0xA
#define TS_WATER_MAP	0xB
 
union MaterialTextureDefInfo 
{
  GfxImage *image;	// MaterialTextureDef->semantic != TS_WATER_MAP
  water_t *water;		// MaterialTextureDef->semantic == TS_WATER_MAP
};
 
struct MaterialTextureDef
{
  unsigned int nameHash;
  char nameStart;
  char nameEnd;
  char samplerState;
  char semantic;
  char isMatureContent;
#ifdef BO1
  MaterialTextureDefInfo u;
#elif
  GfxImage *image;
#endif
};
 
union GFxDrawSurfFields
{
	unsigned long long unused,
			primarySortKey,
			surfType,
			primaryLightIndex,
			prepass,
			materialSortedIndex,
			customIndex,
			reflectionProbeIndex,
			objectId;
};
 
union GfxDrawSurf 
{
  GFxDrawSurfFields fields;
  unsigned long long packed;
};
 
struct MaterialInfo
{
  const char *name;
  unsigned int gameFlags;
  char pad;
  char sortKey;
  char textureAtlasRowCount;
  char textureAtlasColumnCount;
  GfxDrawSurf drawSurf;
  unsigned int surfaceTypeBits;
  unsigned int layeredSurfaceTypes;
  unsigned __int16 hashIndex;
  int surfaceFlags;
#ifdef BO2
  int contents;
#endif
};
 
struct Material
{
  MaterialInfo info;
  char stateBitsEntry[TECHNIQUE_COUNT];	// see MaterialTechniqueType
  char textureCount;
  char constantCount;
  char stateBitsCount;
  char stateFlags;
  char cameraRegion;
  char probeMipBits;
  MaterialTechniqueSet *techniqueSet;
  MaterialTextureDef *textureTable;
  MaterialConstantDef *constantTable;
  GfxStateBits *stateBitTable;
#ifdef BO2
  Material *thermalMaterial;
#endif
};

Ghosts

struct MaterialConstantDef 
{
	unsigned int nameHash;
	char name[12];
	float literal[4];
};
 
struct GfxStateBits
{
	int (*loadBits)[3];
	char unknown1[0xE];
	char unknown2[0xE];
	char unknown3[2];
	char unknown4[2];
};
 
struct WaterWritable
{
	float floatTime;
};
 
struct water_t 
{
	WaterWritable writable;
	float *H0X;	// Count = M * N
	float *H0Y;	// Count = M * N
	float *wTerm;	// Count = M * N
	int M;
	int N;
	float Lx;
	float Lz;
	float gravity;
	float windvel;
	float winddir[2];
	float amplitude;
	float codeConstant[4];
	GfxImage *image;
};
 
/* MaterialTextureDef->semantic */
#define TS_2D		0x0
#define TS_FUNCTION	0x1
#define TS_COLOR_MAP	0x2
#define TS_UNUSED_1	0x3
#define TS_UNUSED_2	0x4
#define TS_NORMAL_MAP	0x5
#define TS_UNUSED_3	0x6
#define TS_UNUSED_4	0x7
#define TS_SPECULAR_MAP	0x8
#define TS_UNUSED_5	0x9
#define TS_UNUSED_6	0xA
#define TS_WATER_MAP	0xB
 
union MaterialTextureDefInfo 
{
	GfxImage *image;
	water_t *water;
};
 
struct MaterialTextureDef
{
	unsigned int nameHash;
	char nameStart;
	char nameEnd;
	char sampleState;
	char semantic;
	MaterialTextureDefInfo u;
};
 
union GFxDrawSurfFields
{
	unsigned long long unused,
			primarySortKey,
			surfType,
			primaryLightIndex,
			prepass,
			materialSortedIndex,
			customIndex,
			reflectionProbeIndex,
			objectId;
};
 
union GfxDrawSurf 
{
	GFxDrawSurfFields fields;
	unsigned long long packed;
};
 
struct __declspec(align(8)) MaterialInfo // 0x20
{
	const char *name;
	char gameFlags;
	char sortKey;
	char textureAtlasRowCount;
	char textureAtlasColumnCount;
	GfxDrawSurf drawSurf;
	int surfaceTypeBits;
	char unknown[0xC];
};
 
struct Material	// 0xB8
{
	MaterialInfo info;
	char stateBitsEntry[TECHNIQUE_COUNT];	// see MaterialTechniqueType
	char textureCount;	// 0x47
	char constantCount;	// 0x48
	char stateBitsCount;	// 0x49
	char stateFlags;	// 0x4A
	char cameraRegion;	// 0x4B
	char unknown;		// 0x4C
	char stringCount;	// 0x4D
#ifdef PS3
	unsigned short ushorts[TECHNIQUE_COUNT];
	unsigned short *ushortArray;		// count = TECHNIQUE_COUNT, see MaterialTechniqueType
#endif
	MaterialTechniqueSet *techniqueSet;
	MaterialTextureDef *textureTable;	// count = textureCount
	MaterialConstantDef *constantTable;	// count = constantCount
	GfxStateBits *stateBitTable;	// count = stateBitsCount
	const char **XStringArray;	// count = stringCount
	int unknown;
};