Technique Set Asset

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

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
struct MaterialArgumentCodeConst 
{
	unsigned __int16 index;
	char firstRow;
	char rowCount;
};
 
union MaterialArgumentDef 
{
	const float *literalConst;
	MaterialArgumentCodeConst codeConst;
	unsigned int codeSampler;
	unsigned int nameHash;
};
 
/* MaterialShaderArgument->type */
#define MTL_ARG_MATERIAL_VERTEX_CONST	0x0
#define MTL_ARG_LITERAL_VERTEX_CONST	0x1
#define MTL_ARG_MATERIAL_PIXEL_SAMPLER	0x2
#define  MTL_ARG_CODE_PRIM_BEGIN	0x3
#define MTL_ARG_CODE_VERTEX_CONST	0x3
#define MTL_ARG_CODE_PIXEL_SAMPLER	0x4
#define MTL_ARG_CODE_PIXEL_CONST	0x5
#define MTL_ARG_MATERIAL_PIXEL_CONST	0x6
#define  MTL_ARG_CODE_PRIM_END		0x6
#define MTL_ARG_LITERAL_PIXEL_CONST	0x7
#define MLT_ARG_COUNT			0x8
 
struct MaterialShaderArgument
{
	unsigned __int16 type;
	unsigned __int16 dest;
	MaterialArgumentDef u;
};
 
struct MaterialVertexDeclaration
{
#if defined(COD4) || defined(WAW) || defined(BO1)
	char unknown[0x22];
#elif defined(MW2) || defined(MW3)
	char unknown[0x1C];
#elif defined(GHOSTS)
	char unknown[0x20];
#endif
};
 
#pragma pack(push, 4)
struct MaterialPass 
{
	MaterialVertexDeclaration *vertexDecl;
	MaterialVertexShader *vertexShader;
	MaterialPixelShader *pixelShader;
	char perPrimArgCount;
	char perObjArgCount;
	char stableArgCount;
	char customSamplerFlags;
	char precompiledIndex;
	MaterialShaderArgument *args;
};
#pragma pack(pop)
 
struct MaterialTechnique 
{
	const char *name;
	unsigned __int16 flags;
	unsigned __int16 passCount;
	MaterialPass passArray[1];	// count = passCount
};
 
/* MaterialTechniqueSet->worldVertFormat */
enum MaterialWorldVertexFormat : char
{
  MTL_WORLDVERT_TEX_1_NRM_1 = 0x0,
  MTL_WORLDVERT_TEX_2_NRM_1 = 0x1,
  MTL_WORLDVERT_TEX_2_NRM_2 = 0x2,
  MTL_WORLDVERT_TEX_3_NRM_1 = 0x3,
  MTL_WORLDVERT_TEX_3_NRM_2 = 0x4,
  MTL_WORLDVERT_TEX_3_NRM_3 = 0x5,
  MTL_WORLDVERT_TEX_4_NRM_1 = 0x6,
  MTL_WORLDVERT_TEX_4_NRM_2 = 0x7,
  MTL_WORLDVERT_TEX_4_NRM_3 = 0x8,
  MTL_WORLDVERT_TEX_5_NRM_1 = 0x9,
  MTL_WORLDVERT_TEX_5_NRM_2 = 0xA,
  MTL_WORLDVERT_TEX_5_NRM_3 = 0xB,
};
 
#ifdef PS3
 #ifdef COD4
  #define MAX_TECHNIQUES 26
 #elif defined(WAW)
  #define MAX_TECHNIQUES 51
 #elif defined(MW2)
  #define MAX_TECHNIQUES 37
 #elif defined(BO1)
  #define MAX_TECHNIQUES 71
 #elif defined(MW3)
  #define MAX_TECHNIQUES 41
 #elif defined(GHOSTS)
  #define MAX_TECHNIQUES 39
 #endif
#endif
 
#ifdef XBOX
 #ifdef COD4
  #define MAX_TECHNIQUES 26
 #elif defined(WAW)
  #define MAX_TECHNIQUES 51
 #elif defined(MW2)
  #define MAX_TECHNIQUES 33
 #elif defined(BO1)
  #define MAX_TECHNIQUES 71
 #elif defined(MW3)
  #define MAX_TECHNIQUES 37
 #elif defined(GHOSTS)
  #define MAX_TECHNIQUES 36
 #endif
#endif
 
#ifdef PC
 #ifdef COD4
  #define MAX_TECHNIQUES 34
 #elif defined(WAW)
  #define MAX_TECHNIQUES 59
 #elif defined(MW2)
  #define MAX_TECHNIQUES 48
 #elif defined(BO1)
  #define MAX_TECHNIQUES 130
 #elif defined(MW3)
  #define MAX_TECHNIQUES 54
 #endif
#endif
 
struct MaterialTechniqueSet 
{
	char *name;
	MaterialWorldVertexFormat worldVertFormat;
	MaterialTechnique *techniques[MAX_TECHNIQUES];
};

Black Ops 2

struct MaterialArgumentCodeConst 
{
  unsigned __int16 index;
  char firstRow;
  char rowCount;
};
 
union MaterialArgumentDef 
{
  const float *literalConst;
  MaterialArgumentCodeConst codeConst;
  unsigned int codeSampler;
  unsigned int nameHash;
};
 
/* MaterialShaderArgument->type */
#define MTL_ARG_MATERIAL_VERTEX_CONST	0x0
#define MTL_ARG_LITERAL_VERTEX_CONST	0x1
#define MTL_ARG_MATERIAL_PIXEL_SAMPLER	0x2
#define  MTL_ARG_CODE_PRIM_BEGIN	0x3
#define MTL_ARG_CODE_VERTEX_CONST	0x3
#define MTL_ARG_CODE_PIXEL_SAMPLER	0x4
#define MTL_ARG_CODE_PIXEL_CONST	0x5
#define MTL_ARG_MATERIAL_PIXEL_CONST	0x6
#define  MTL_ARG_CODE_PRIM_END		0x6
#define MTL_ARG_LITERAL_PIXEL_CONST	0x7
#define MLT_ARG_COUNT			0x8
 
struct MaterialShaderArgument
{
  unsigned __int16 type;
  unsigned __int16 dest;
  MaterialArgumentDef u;
};
 
struct MaterialStreamRouting
{
  char source;
  char dest;
};
 
struct MaterialVertexStreamRouting
{
  MaterialStreamRouting data[16];
};
 
struct MaterialVertexDeclaration
{
  char streamCount;
  bool hasOptionalSource;
  MaterialVertexStreamRouting routing;
};
 
struct GfxVertexShaderLoadDef
{
  char *cachedPart;
  char *physicalPart;
  unsigned __int16 cachedPartSize;
  unsigned __int16 physicalPartSize;
};
 
struct MaterialVertexShaderProgram
{
  D3DVertexShader *vs;
  GfxVertexShaderLoadDef loadDef;
};
 
struct MaterialVertexShader
{
  const char *name;
  MaterialVertexShaderProgram prog;
};
 
struct GfxPixelShaderLoadDef
{
  char *cachedPart;
  char *physicalPart;
  unsigned __int16 cachedPartSize;
  unsigned __int16 physicalPartSize;
};
 
union MaterialPixelShaderProgram
{
  D3DPixelShader *ps;
  GfxPixelShaderLoadDef loadDef;
};
 
struct MaterialPixelShader
{
  const char *name;
  MaterialPixelShaderProgram prog;
};
 
#pragma pack(push, 4)
struct MaterialPass 
{
  MaterialVertexDeclaration *vertexDecl;
  MaterialVertexShader *vertexShader;
  union
  {
    MaterialPixelShader *pixelShader;
    MaterialPixelShader *localPixelShader;
  };
  char perPrimArgCount;
  char perObjArgCount;
  char stableArgCount;
  char customSamplerFlags;
  char precompiledIndex;
  char materialType;  //It is unknown wether this is used/exists on Xbox or PS3.
  union
  {
    MaterialShaderArgument *args;
    MaterialShaderArgument *localArgs;
  };
};
#pragma pack(pop)
 
struct MaterialTechnique
{
  const char *name;
  unsigned __int16 flags;
  unsigned __int16 passCount;
  MaterialPass passArray;
};
 
/* MaterialTechniqueSet->worldVertFormat */
enum MaterialWorldVertexFormat : char
{
  MTL_WORLDVERT_TEX_1_NRM_1 = 0x0,
  MTL_WORLDVERT_TEX_2_NRM_1 = 0x1,
  MTL_WORLDVERT_TEX_2_NRM_2 = 0x2,
  MTL_WORLDVERT_TEX_3_NRM_1 = 0x3,
  MTL_WORLDVERT_TEX_3_NRM_2 = 0x4,
  MTL_WORLDVERT_TEX_3_NRM_3 = 0x5,
  MTL_WORLDVERT_TEX_4_NRM_1 = 0x6,
  MTL_WORLDVERT_TEX_4_NRM_2 = 0x7,
  MTL_WORLDVERT_TEX_4_NRM_3 = 0x8,
  MTL_WORLDVERT_TEX_5_NRM_1 = 0x9,
  MTL_WORLDVERT_TEX_5_NRM_2 = 0xA,
  MTL_WORLDVERT_TEX_5_NRM_3 = 0xB,
};
 
#ifdef PS3
  #define MAX_TECHNIQUES 32
#endif
 
#ifdef XBOX
  #define MAX_TECHNIQUES 36
#endif
 
#ifdef PC
 #define MAX_TECHNIQUES 36
#endif
 
struct MaterialTechniqueSet 
{
  const char *name;
  MaterialWorldVertexFormat worldVertFormat;
  MaterialTechnique *techniques[MAX_TECHNIQUES];
};