Material Asset

From COD Engine Research
Revision as of 00:49, 18 February 2014 by Aerosoul94 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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];
 #ifdef MW2 || 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;
#ifdef MW2 || MW3
	const char **unknownXStringArray;
#endif
};

Black Ops & Black Ops 2

struct MaterialConstantDef 
{
	int nameHash;
	char name[12];
	vec4_t literal;
};
 
struct GfxStateBits 
{
#ifdef XBOX || BO2	// ps3 uses this for bo2..
	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
#ifdef BO1
	water_t *water;		// MaterialTextureDef->semantic == TS_WATER_MAP
#endif
};
 
struct MaterialTextureDef
{
	unsigned int nameHash;
	char nameStart;
	char nameEnd;
	char sampleState;
	char semantic;
	int unknown;
	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;
	int gameFlags;
	char unknown1;
	char sortKey;
	char textureAtlasRowCount;
	char textureAtlasColumnCount;
	int unknown2;
	GfxDrawSurf drawSurf;
	unsigned long long surfaceTypeBits;
#ifdef BO2
	unsigned long long unknown3;
#endif
};
 
struct Material
{
	MaterialInfo info;
	char stateBitsEntry[TECHNIQUE_COUNT];	// see MaterialTechniqueType
	char textureCount;
	char constantCount;
	char stateBitsCount;
	char stateFlags;
	char cameraRegion;
	MaterialTechniqueSet *techniqueSet;
	MaterialTextureDef *textureTable;
	MaterialConstantDef *constantTable;
	GfxStateBits *stateBitTable;
#ifdef BO2
	Material *unknownMaterial;
	int unknown;
#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;
};