Files
2025-04-16 20:32:11 -07:00

319 lines
7.8 KiB
Plaintext

#ifndef _MATERIALARCHIVE
#define _MATERIALARCHIVE
struct SBufferTOCEntry {
uint align;
uint size;
};
struct CPermutation {
uint64 unk1;
uint64 unk2;
};
enum <char> EMaterialTechnique {
kMT_None = 'x', /* offset 0x10 = 9, offset 0x20 = 0, offset 0x28 = 1, type = 0 */
kMT_DepthOnly = 'z',/* offset 0x10 = 15, offset 0x20 = 0, offset 0x28 = 1, type 1 */
kMT_DeferredGBuffer = 'g',/* offset 0x10 = 15, offset 0x20 = 0, offset 0x28 = 1, type 2 */
kMT_DeferredInstance = 'i',/* offset 0x10 = 16, offset 0x20 = 0, offset 0x28 = 1, type 3 */
kMT_ForwardRender = 'f', /* offset 0x10 = 13, offset 0x20 = 0, offset 0x28 = 1, type 4 */
kMT_ParticleTechniqueSprite = 's', /* offset 0x10 = 23, offset 0x20 = 0, offset 0x28 = 1, type 5 */
kMT_ParticleTechniqueSwoosh = 'w', /* offset 0x10 = 23, offset 0x20 = 0, offset 0x28 = 1, type 6 */
kMT_ParticleTechniqueModel = 'm', /* offset 0x10 = 22, offset 0x20 = 0, offset 0x28 = 1, type 7 */
};
struct CShaderIdentifier {
EMaterialTechnique matTechnique;
CPermutation perm;
};
struct SShaderTOCEntry {
CShaderIdentifier identifier;
uint unk1;
uint unk2;
};
struct SMaterialTOCEntry {
GUID guid;
uint unk1;
uint nameLen;
char name[nameLen];
ushort unk2;
uint shaderEntryCount;
SShaderTOCEntry shaderEntries[shaderEntryCount];
SBufferTOCEntry bufferToc;
};
struct SShaderSource {
uchar state;
uint strLen;
if (strLen)
char str[strLen];
uint dataLen;
uchar data[dataLen];
};
struct CShaderDefines {
struct Name {
if (isDKCTF)
{
CString str1;
}
else
{
CStringFixed str1;
}
};
uint namesCount;
if (namesCount)
Name names[namesCount] <optimize = false>;
uint unk;
};
struct CShaderVariable {
ushort unk1;
};
struct SShaderImportDesc {
if (!isDKCTF)
{
CShaderIdentifier ident;
}
uint64 shaderID;
int vertexProgramIndex;
if (!isDKCTF)
{
int pixelProgramIndex;
}
else
{
int fragProgramIndex;
}
int geomProgramIndex;
if (!isDKCTF)
{
int computeProgramIndex;
}
uint unk;
CShaderDefines defines;
uint dataSize;
union {
struct {
uint variableCount;
CShaderVariable variables[1];
} meta;
char data[dataSize];
} data;
};
struct SExpression {
uint unk1;
uint unk2;
};
struct CBooleanExpressionEvaluator {
uint expressionCount;
SExpression expressions[expressionCount];
};
struct SSimpleFeatureInstanceInternalOptionRequirement {
uint unk;
CBooleanExpressionEvaluator evaluator;
};
struct SSimpleFeatureInstanceShaderBinding {
CStringFixed name;
CStringFixed binding;
};
struct SSimpleFeatureInstanceInternalOption {
uint unk;
CShaderDefines shaderDefines;
uint bindingCount;
if (bindingCount) {
SSimpleFeatureInstanceShaderBinding binding[bindingCount] <optimize = false>;
}
};
struct IFeatureInstance;
struct CFeatureSet {
uint count;
IFeatureInstance features[count] <optimize = false>;
CBooleanExpressionEvaluator evaluator;
};
struct CSimpleFeatureInstance {
FourCC unk1;
uint fccCount;
uint fccs[fccCount];
uint boolExpresionEvalCount;
CBooleanExpressionEvaluator evaluators[boolExpresionEvalCount] <optimize = false>;
uint internalOptionCount;
SSimpleFeatureInstanceInternalOption internalOption[internalOptionCount] <optimize = false>;
uint unk;
uint unkIntCount;
Assert(unkIntCount <= 32);
uint unkInts[unkIntCount];
uint optionRequirementCount;
if (optionRequirementCount)
SSimpleFeatureInstanceInternalOptionRequirement optionRequirements[optionRequirementCount] <optimize = false>;
};
struct SCompositeFeatureInstanceInternalOptionRequirement {
uint unk;
CBooleanExpressionEvaluator eval;
};
struct SCompositeFeatureInstanceInternalOption {
CStringFixed name;
CPermutation perm;
CShaderDefines defines;
};
struct SCompositeFeatureInstanceArgument {
CStringFixed name;
CBooleanExpressionEvaluator evaluator;
};
struct CCompositeFeatureInstance {
CFeatureSet subSet;
uint argumentCount1;
if (argumentCount1) {
SCompositeFeatureInstanceArgument arguments1[argumentCount1] <optimize = false>;
}
uint argumentCount2;
if (argumentCount2) {
SCompositeFeatureInstanceArgument arguments2[argumentCount2] <optimize = false>;
}
uint optionCount;
SCompositeFeatureInstanceInternalOption optionRequirements1[optionCount] <optimize = false>;
uint optionRequirementsCount;
SCompositeFeatureInstanceInternalOptionRequirement optionRequirements2[optionRequirementsCount] <optimize = false>;
};
struct IFeatureInstance;
struct CExplicitCompositeFeatureInstance;
struct CExplicitCompositeFeatureInstance {
CCompositeFeatureInstance base;
IFeatureInstance sub;
};
struct IFeatureInstance {
uint type;
CStringFixed name;
uint dataOrigin;
uint optionCount;
switch(type) {
case 0:
CSimpleFeatureInstance simple <optimize = false>;
break;
case 1:
CCompositeFeatureInstance composite <optimize = false>;
break;
case 2:
CExplicitCompositeFeatureInstance explicitComposite <optimize = false>;
break;
}
};
struct SDepthModeState {
};
struct SStencilModeState {
};
struct CGraphicsState {
uint flags;
};
struct SOverrideState {
CBooleanExpressionEvaluator evaluator;
CGraphicsState state;
};
struct SMaterialImportDesc {
if (!isDKCTF)
{
GUID guid;
uint shaderHash;
CStringFixed name;
}
else
{
FourCC name;
}
ushort unk2;
uint shaderImportCount;
SShaderImportDesc shaderImportDescs[shaderImportCount] <optimize = false>;
uint dataSize;
union {
struct {
uchar hasFeatureSet;
if (hasFeatureSet) {
CFeatureSet featureSet;
}
CGraphicsState state;
uint overrideStateCount;
if (overrideStateCount) {
SOverrideState overrideStates;
}
} meta;
char data[dataSize];
} data;
};
struct MaterialBackend {
ChunkDescriptor chunk;
local uint64 start <format=hex, hidden=true> = FTell();
uint flags;
if (flags != 0) {
uint tocSize;
uint bufferEntryCount;
SBufferTOCEntry bufferEntries[bufferEntryCount];
if (!isDKCTF)
{
uint materialEntryCount;
SMaterialTOCEntry materialEntries[materialEntryCount] <optimize = false>;
}
}
if (!isDKCTF)
{
uint shaderSourceCount;
SShaderSource shaderSources[shaderSourceCount] <optimize = false>;
}
uint materialImportDescCount;
SMaterialImportDesc materialImportDescs[materialImportDescCount] <optimize = false>;
if ((FTell() - start) != chunk.size) {
char data[chunk.size - (FTell() - start)];
}
};
struct MaterialArchive(uint64 size) {
local uint64 start <format=hex, hidden=true> = FTell();
while (FTell() < start + size) {
MaterialBackend backend;
}
};
struct SMaterialMetaData(uint64 fileStart) {
uint32 count;
uint32 version;
uint32 compressedSize;
uint32 decompressedSize;
uint32 fileOffset;
local uint64 pos <format=hex, hidden=true> = FTell();
FSeek(fileStart + fileOffset);
byte zlibData[compressedSize];
FSeek(pos);
};
#endif// _MATERIALARCHIVE