[General] Adjust shader structures
This commit is contained in:
parent
6d8f93c470
commit
a830fcde97
@ -173,17 +173,17 @@ namespace Components
|
||||
{
|
||||
if (asset.techniqueSet->techniques[i])
|
||||
{
|
||||
for (int j = 0; j < asset.techniqueSet->techniques[i]->numPasses; ++j)
|
||||
for (int j = 0; j < asset.techniqueSet->techniques[i]->passCount; ++j)
|
||||
{
|
||||
Game::MaterialPass* pass = &asset.techniqueSet->techniques[i]->passes[j];
|
||||
Game::MaterialPass* pass = &asset.techniqueSet->techniques[i]->passArray[j];
|
||||
|
||||
for (int k = 0; k < (pass->argCount1 + pass->argCount2 + pass->argCount3); ++k)
|
||||
for (int k = 0; k < (pass->perPrimArgCount + pass->perObjArgCount + pass->stableArgCount); ++k)
|
||||
{
|
||||
if (pass->argumentDef[k].type == D3DSHADER_PARAM_REGISTER_TYPE::D3DSPR_CONSTINT)
|
||||
if (pass->args[k].type == D3DSHADER_PARAM_REGISTER_TYPE::D3DSPR_CONSTINT)
|
||||
{
|
||||
if (pass->argumentDef[k].paramID == -28132)
|
||||
if (pass->args[k].u.codeConst.index == -28132)
|
||||
{
|
||||
pass->argumentDef[k].paramID = 2644;
|
||||
pass->args[k].u.codeConst.index = 2644;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,11 @@ namespace Assets
|
||||
Utils::Stream::ClearPointer(&dest->name);
|
||||
}
|
||||
|
||||
if (asset->loadDef.physicalPart)
|
||||
if (asset->prog.loadDef.program)
|
||||
{
|
||||
buffer->align(Utils::Stream::ALIGN_4);
|
||||
buffer->save(asset->loadDef.physicalPart, 4, asset->loadDef.cachedPartSize & 0xFFFF);
|
||||
Utils::Stream::ClearPointer(&dest->loadDef.physicalPart);
|
||||
buffer->saveArray(asset->prog.loadDef.program, asset->prog.loadDef.programSize);
|
||||
Utils::Stream::ClearPointer(&dest->prog.loadDef.program);
|
||||
}
|
||||
|
||||
buffer->popBlock();
|
||||
|
@ -12,9 +12,9 @@ namespace Assets
|
||||
|
||||
if (!technique) continue;
|
||||
|
||||
for (short j = 0; j < technique->numPasses; ++j)
|
||||
for (short j = 0; j < technique->passCount; ++j)
|
||||
{
|
||||
Game::MaterialPass* pass = &technique->passes[j];
|
||||
Game::MaterialPass* pass = &technique->passArray[j];
|
||||
|
||||
if (pass->vertexDecl)
|
||||
{
|
||||
@ -75,14 +75,14 @@ namespace Assets
|
||||
|
||||
// Save_MaterialPassArray
|
||||
Game::MaterialPass* destPasses = buffer->dest<Game::MaterialPass>();
|
||||
buffer->saveArray(technique->passes, technique->numPasses);
|
||||
buffer->saveArray(technique->passArray, technique->passCount);
|
||||
|
||||
for (short j = 0; j < technique->numPasses; ++j)
|
||||
for (short j = 0; j < technique->passCount; ++j)
|
||||
{
|
||||
AssertSize(Game::MaterialPass, 20);
|
||||
|
||||
Game::MaterialPass* destPass = &destPasses[j];
|
||||
Game::MaterialPass* pass = &technique->passes[j];
|
||||
Game::MaterialPass* pass = &technique->passArray[j];
|
||||
|
||||
if (pass->vertexDecl)
|
||||
{
|
||||
@ -99,11 +99,11 @@ namespace Assets
|
||||
destPass->pixelShader = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_PIXELSHADER, pass->pixelShader).pixelShader;
|
||||
}
|
||||
|
||||
if (pass->argumentDef)
|
||||
if (pass->args)
|
||||
{
|
||||
buffer->align(Utils::Stream::ALIGN_4);
|
||||
buffer->saveArray(pass->argumentDef, pass->argCount1 + pass->argCount2 + pass->argCount3);
|
||||
Utils::Stream::ClearPointer(&destPass->argumentDef);
|
||||
buffer->saveArray(pass->args, pass->perPrimArgCount + pass->perObjArgCount + pass->stableArgCount);
|
||||
Utils::Stream::ClearPointer(&destPass->args);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,8 @@ namespace Assets
|
||||
Utils::Stream::ClearPointer(&dest->name);
|
||||
}
|
||||
|
||||
AssertSize(Game::MaterialVertexStreamRouting, 92);
|
||||
|
||||
buffer->popBlock();
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,11 @@ namespace Assets
|
||||
Utils::Stream::ClearPointer(&dest->name);
|
||||
}
|
||||
|
||||
if (asset->loadDef.physicalPart)
|
||||
if (asset->prog.loadDef.program)
|
||||
{
|
||||
buffer->align(Utils::Stream::ALIGN_4);
|
||||
buffer->save(asset->loadDef.physicalPart, 4, asset->loadDef.cachedPartSize & 0xFFFF);
|
||||
Utils::Stream::ClearPointer(&dest->loadDef.physicalPart);
|
||||
buffer->saveArray(asset->prog.loadDef.program, asset->prog.loadDef.programSize);
|
||||
Utils::Stream::ClearPointer(&dest->prog.loadDef.program);
|
||||
}
|
||||
|
||||
buffer->popBlock();
|
||||
|
@ -514,17 +514,17 @@ namespace Components
|
||||
|
||||
if (Utils::IO::FileExists(Utils::String::VA(formatString, name))) return;
|
||||
|
||||
Utils::Stream* buffer = new Utils::Stream(0x1000);
|
||||
Game::MaterialPixelShader* dest = buffer->dest<Game::MaterialPixelShader>();
|
||||
buffer->save(asset.pixelShader);
|
||||
Utils::Stream buffer(0x1000);
|
||||
Game::MaterialPixelShader* dest = buffer.dest<Game::MaterialPixelShader>();
|
||||
buffer.save(asset.pixelShader);
|
||||
|
||||
if (asset.pixelShader->loadDef.physicalPart)
|
||||
if (asset.pixelShader->prog.loadDef.program)
|
||||
{
|
||||
buffer->save(asset.pixelShader->loadDef.physicalPart, 4, asset.pixelShader->loadDef.cachedPartSize & 0xFFFF);
|
||||
Utils::Stream::ClearPointer(&dest->loadDef.physicalPart);
|
||||
buffer.saveArray(asset.pixelShader->prog.loadDef.program, asset.pixelShader->prog.loadDef.programSize);
|
||||
Utils::Stream::ClearPointer(&dest->prog.loadDef.program);
|
||||
}
|
||||
|
||||
Utils::IO::WriteFile(Utils::String::VA(formatString, name), buffer->toBuffer());
|
||||
Utils::IO::WriteFile(Utils::String::VA(formatString, name), buffer.toBuffer());
|
||||
}
|
||||
|
||||
static std::map<const void*, unsigned int> pointerMap;
|
||||
@ -583,25 +583,25 @@ namespace Components
|
||||
|
||||
// Save_MaterialPassArray
|
||||
Game::MaterialPass* destPasses = buffer->dest<Game::MaterialPass>();
|
||||
buffer->saveArray(technique->passes, technique->numPasses);
|
||||
buffer->saveArray(technique->passArray, technique->passCount);
|
||||
|
||||
for (short j = 0; j < technique->numPasses; ++j)
|
||||
for (short j = 0; j < technique->passCount; ++j)
|
||||
{
|
||||
AssertSize(Game::MaterialPass, 20);
|
||||
|
||||
Game::MaterialPass* destPass = &destPasses[j];
|
||||
Game::MaterialPass* pass = &technique->passes[j];
|
||||
Game::MaterialPass* pass = &technique->passArray[j];
|
||||
|
||||
if (pass->vertexDecl)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if (pass->argumentDef)
|
||||
if (pass->args)
|
||||
{
|
||||
buffer->align(Utils::Stream::ALIGN_4);
|
||||
buffer->saveArray(pass->argumentDef, pass->argCount1 + pass->argCount2 + pass->argCount3);
|
||||
Utils::Stream::ClearPointer(&destPass->argumentDef);
|
||||
buffer->saveArray(pass->args, pass->perPrimArgCount + pass->perObjArgCount + pass->stableArgCount);
|
||||
Utils::Stream::ClearPointer(&destPass->args);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1069,7 +1069,7 @@ namespace Components
|
||||
bool result = Game::Load_Stream(atStreamStart, argument, size);
|
||||
|
||||
Game::MaterialPass* curPass = *Game::varMaterialPass;
|
||||
int count = curPass->argCount1 + curPass->argCount2 + curPass->argCount3;
|
||||
int count = curPass->perPrimArgCount + curPass->perObjArgCount + curPass->stableArgCount;
|
||||
|
||||
for (int i = 0; i < count && (Zones::ZoneVersion >= VERSION_ALPHA2); ++i)
|
||||
{
|
||||
@ -1084,40 +1084,40 @@ namespace Components
|
||||
// >= 58 fixes foliage without bad side effects
|
||||
// >= 53 still has broken shadow mapping
|
||||
// >= 23 is still broken somehow
|
||||
if (arg->paramID >= 58 && arg->paramID <= 135) // >= 34 would be 31 in iw4 terms
|
||||
if (arg->u.codeConst.index >= 58 && arg->u.codeConst.index <= 135) // >= 34 would be 31 in iw4 terms
|
||||
{
|
||||
arg->paramID -= 3;
|
||||
arg->u.codeConst.index -= 3;
|
||||
|
||||
if (Zones::Version() >= 359/* && arg->paramID <= 113*/)
|
||||
{
|
||||
arg->paramID -= 7;
|
||||
arg->u.codeConst.index -= 7;
|
||||
|
||||
if (arg->paramID <= 53)
|
||||
if (arg->u.codeConst.index <= 53)
|
||||
{
|
||||
arg->paramID += 1;
|
||||
arg->u.codeConst.index += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
// >= 21 works fine for specular, but breaks trees
|
||||
// >= 4 is too low, breaks specular
|
||||
else if (arg->paramID >= 11 && arg->paramID < 58)
|
||||
else if (arg->u.codeConst.index >= 11 && arg->u.codeConst.index < 58)
|
||||
{
|
||||
arg->paramID -= 2;
|
||||
arg->u.codeConst.index -= 2;
|
||||
|
||||
if (Zones::Version() >= 359)
|
||||
{
|
||||
if (arg->paramID > 15 && arg->paramID < 30)
|
||||
if (arg->u.codeConst.index > 15 && arg->u.codeConst.index < 30)
|
||||
{
|
||||
arg->paramID -= 1;
|
||||
arg->u.codeConst.index -= 1;
|
||||
|
||||
if (arg->paramID == 19)
|
||||
if (arg->u.codeConst.index == 19)
|
||||
{
|
||||
arg->paramID = 21;
|
||||
arg->u.codeConst.index = 21;
|
||||
}
|
||||
}
|
||||
else if (arg->paramID >= 50)
|
||||
else if (arg->u.codeConst.index >= 50)
|
||||
{
|
||||
arg->paramID += 6;
|
||||
arg->u.codeConst.index += 6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,11 @@
|
||||
#define NUM_CUSTOM_CLASSES 15
|
||||
|
||||
// This allows us to compile our structures in IDA, for easier reversing :3
|
||||
#ifdef __cplusplus
|
||||
#ifndef __cplusplus
|
||||
#define IDA
|
||||
#endif
|
||||
|
||||
#ifndef IDA
|
||||
namespace Game
|
||||
{
|
||||
#endif
|
||||
@ -336,7 +340,7 @@ namespace Game
|
||||
union
|
||||
{
|
||||
GfxImageLoadDef* loadDef;
|
||||
#ifdef __cplusplus
|
||||
#ifndef IDA
|
||||
IDirect3DBaseTexture9 *basemap;
|
||||
IDirect3DTexture9 *map;
|
||||
IDirect3DVolumeTexture9 *volmap;
|
||||
@ -405,48 +409,107 @@ namespace Game
|
||||
MaterialTextureDefInfo info;
|
||||
};
|
||||
|
||||
struct GfxShaderConstantBlock
|
||||
{
|
||||
unsigned int count;
|
||||
unsigned __int16 dest[16];
|
||||
const float *value[16];
|
||||
};
|
||||
|
||||
struct MaterialArgumentCodeConst
|
||||
{
|
||||
unsigned __int16 index;
|
||||
char firstRow;
|
||||
char rowCount;
|
||||
};
|
||||
|
||||
union MaterialArgumentDef
|
||||
{
|
||||
const float *literalConst;
|
||||
MaterialArgumentCodeConst codeConst;
|
||||
unsigned int codeSampler;
|
||||
unsigned int nameHash;
|
||||
};
|
||||
|
||||
struct MaterialShaderArgument
|
||||
{
|
||||
short type;
|
||||
short dest;
|
||||
short paramID;
|
||||
short more;
|
||||
unsigned __int16 type;
|
||||
unsigned __int16 dest;
|
||||
MaterialArgumentDef u;
|
||||
};
|
||||
|
||||
struct MaterialStreamRouting
|
||||
{
|
||||
char source;
|
||||
char dest;
|
||||
};
|
||||
|
||||
struct MaterialVertexStreamRouting
|
||||
{
|
||||
MaterialStreamRouting data[14];
|
||||
#ifdef IDA
|
||||
void
|
||||
#else
|
||||
IDirect3DVertexDeclaration9
|
||||
#endif
|
||||
*decl[16];
|
||||
};
|
||||
|
||||
struct MaterialVertexDeclaration
|
||||
{
|
||||
const char* name;
|
||||
int unknown;
|
||||
char pad[28];
|
||||
/*IDirect3DVertexDeclaration9**/void* declarations[16];
|
||||
char streamCount;
|
||||
bool hasOptionalSource;
|
||||
bool isLoaded;
|
||||
MaterialVertexStreamRouting routing;
|
||||
};
|
||||
|
||||
struct GfxPixelShaderLoadDef
|
||||
{
|
||||
char *cachedPart;
|
||||
char *physicalPart;
|
||||
unsigned __int16 cachedPartSize;
|
||||
unsigned __int16 physicalPartSize;
|
||||
unsigned int *program;
|
||||
unsigned __int16 programSize;
|
||||
unsigned __int16 loadForRenderer;
|
||||
};
|
||||
|
||||
struct MaterialPixelShaderProgram
|
||||
{
|
||||
#ifdef IDA
|
||||
void
|
||||
#else
|
||||
IDirect3DPixelShader9
|
||||
#endif
|
||||
*ps;
|
||||
GfxPixelShaderLoadDef loadDef;
|
||||
};
|
||||
|
||||
struct MaterialPixelShader
|
||||
{
|
||||
const char* name;
|
||||
GfxPixelShaderLoadDef loadDef;
|
||||
MaterialPixelShaderProgram prog;
|
||||
};
|
||||
|
||||
struct GfxVertexShaderLoadDef
|
||||
{
|
||||
char *cachedPart;
|
||||
char *physicalPart;
|
||||
unsigned __int16 cachedPartSize;
|
||||
unsigned __int16 physicalPartSize;
|
||||
unsigned int *program;
|
||||
unsigned __int16 programSize;
|
||||
unsigned __int16 loadForRenderer;
|
||||
};
|
||||
|
||||
struct MaterialVertexShaderProgram
|
||||
{
|
||||
#ifdef IDA
|
||||
void
|
||||
#else
|
||||
IDirect3DVertexShader9
|
||||
#endif
|
||||
*vs;
|
||||
GfxVertexShaderLoadDef loadDef;
|
||||
};
|
||||
|
||||
struct MaterialVertexShader
|
||||
{
|
||||
const char* name;
|
||||
GfxVertexShaderLoadDef loadDef;
|
||||
const char *name;
|
||||
MaterialVertexShaderProgram prog;
|
||||
};
|
||||
|
||||
struct MaterialPass
|
||||
@ -454,19 +517,19 @@ namespace Game
|
||||
MaterialVertexDeclaration* vertexDecl;
|
||||
MaterialVertexShader* vertexShader;
|
||||
MaterialPixelShader* pixelShader;
|
||||
char argCount1;
|
||||
char argCount2;
|
||||
char argCount3;
|
||||
char unk;
|
||||
MaterialShaderArgument* argumentDef;
|
||||
char perPrimArgCount;
|
||||
char perObjArgCount;
|
||||
char stableArgCount;
|
||||
char customSamplerFlags;
|
||||
MaterialShaderArgument* args;
|
||||
};
|
||||
|
||||
struct MaterialTechnique
|
||||
{
|
||||
char* name;
|
||||
short pad2;
|
||||
short numPasses;
|
||||
MaterialPass passes[1];
|
||||
const char *name;
|
||||
unsigned __int16 flags;
|
||||
unsigned __int16 passCount;
|
||||
MaterialPass passArray[1];
|
||||
};
|
||||
|
||||
enum MaterialTechniqueType
|
||||
@ -3773,7 +3836,7 @@ namespace Game
|
||||
fileInIwd_s *buildBuffer;
|
||||
};
|
||||
|
||||
#ifndef __cplusplus
|
||||
#ifdef IDA
|
||||
typedef void _iobuf;
|
||||
#endif
|
||||
|
||||
@ -3884,6 +3947,6 @@ namespace Game
|
||||
int dataCount;
|
||||
} gameState;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#ifndef IDA
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user