mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-09-09 15:37:05 +00:00
feat: add support for t4 materials (#891)
* feat: add support for t4 materials * fix: t4 material struct
This commit is contained in:
@@ -0,0 +1,249 @@
|
||||
#include "MaterialConstantZoneStateT4.h"
|
||||
|
||||
#include "Game/T4/CommonT4.h"
|
||||
#include "Game/T4/GameT4.h"
|
||||
#include "ObjWriting.h"
|
||||
#include "Zone/ZoneRegistry.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
const char* KNOWN_CONSTANT_NAMES[]{
|
||||
"worldViewProjectionMatrix",
|
||||
"worldViewMatrix2",
|
||||
"worldViewMatrix1",
|
||||
"worldViewMatrix",
|
||||
"worldOutdoorLookupMatrix",
|
||||
"worldMatrix",
|
||||
"waterColor",
|
||||
"viewportDimensions",
|
||||
"viewProjectionMatrix",
|
||||
"uvScale",
|
||||
"uvAnimParms",
|
||||
"thermalColorOffset",
|
||||
"sunShadowmapPixelAdjust",
|
||||
"ssaoParms",
|
||||
"spotShadowmapPixelAdjust",
|
||||
"shadowmapSwitchPartition",
|
||||
"shadowmapScale",
|
||||
"shadowmapPolygonOffset",
|
||||
"shadowLookupMatrix",
|
||||
"renderTargetSize",
|
||||
"renderSourceSize",
|
||||
"projectionMatrix",
|
||||
"playlistPopulationParams",
|
||||
"pixelCostFracs",
|
||||
"pixelCostDecode",
|
||||
"particleCloudSparkColor2",
|
||||
"particleCloudSparkColor1",
|
||||
"particleCloudSparkColor0",
|
||||
"particleCloudMatrix2",
|
||||
"particleCloudMatrix1",
|
||||
"particleCloudMatrix",
|
||||
"particleCloudColor",
|
||||
"outdoorFeatherParms",
|
||||
"oceanUVAnimParmPaintedFoam",
|
||||
"oceanUVAnimParmOctave2",
|
||||
"oceanUVAnimParmOctave1",
|
||||
"oceanUVAnimParmOctave0",
|
||||
"oceanUVAnimParmFoam",
|
||||
"oceanUVAnimParmDetail1",
|
||||
"oceanUVAnimParmDetail0",
|
||||
"oceanScrollParms",
|
||||
"oceanMiscParms",
|
||||
"oceanFoamParms",
|
||||
"oceanAmplitude",
|
||||
"materialColor",
|
||||
"lightprobeAmbient",
|
||||
"lightingLookupScale",
|
||||
"lightSpotFactors",
|
||||
"lightSpotDir",
|
||||
"lightSpecular",
|
||||
"lightPosition",
|
||||
"lightFalloffPlacement",
|
||||
"lightDiffuse",
|
||||
"inverseWorldViewMatrix",
|
||||
"inverseViewProjectionMatrix",
|
||||
"inverseTransposeWorldViewMatrix",
|
||||
"heatMapDetail",
|
||||
"glowSetup",
|
||||
"glowApply",
|
||||
"gameTime",
|
||||
"fullscreenDistortion",
|
||||
"fogSunDir",
|
||||
"fogSunConsts",
|
||||
"fogSunColorLinear",
|
||||
"fogSunColorGamma",
|
||||
"fogConsts",
|
||||
"fogColorLinear",
|
||||
"fogColorGamma",
|
||||
"flagParms",
|
||||
"filterTap",
|
||||
"featherParms",
|
||||
"falloffParms",
|
||||
"falloffEndColor",
|
||||
"falloffBeginColor",
|
||||
"fadeEffect",
|
||||
"eyeOffsetParms",
|
||||
"eyeOffset",
|
||||
"envMapParms",
|
||||
"dustTint",
|
||||
"dustParms",
|
||||
"dustEyeParms",
|
||||
"dofRowDelta",
|
||||
"dofLerpScale",
|
||||
"dofLerpBias",
|
||||
"dofEquationViewModelAndFarBlur",
|
||||
"dofEquationScene",
|
||||
"distortionScale",
|
||||
"detailScale",
|
||||
"depthFromClip",
|
||||
"debugBumpmap",
|
||||
"colorTintQuadraticDelta",
|
||||
"colorTintDelta",
|
||||
"colorTintBase",
|
||||
"colorSaturationR",
|
||||
"colorSaturationG",
|
||||
"colorSaturationB",
|
||||
"colorObjMin",
|
||||
"colorObjMax",
|
||||
"colorMatrixR",
|
||||
"colorMatrixG",
|
||||
"colorMatrixB",
|
||||
"colorBias",
|
||||
"codeMeshArg",
|
||||
"clipSpaceLookupScale",
|
||||
"clipSpaceLookupOffset",
|
||||
"baseLightingCoords",
|
||||
};
|
||||
|
||||
const char* KNOWN_TEXTURE_DEF_NAMES[]{
|
||||
"attenuation",
|
||||
"attenuationSampler",
|
||||
"cinematicA",
|
||||
"cinematicASampler",
|
||||
"cinematicCb",
|
||||
"cinematicCbSampler",
|
||||
"cinematicCr",
|
||||
"cinematicCrSampler",
|
||||
"cinematicY",
|
||||
"cinematicYSampler",
|
||||
"colorMap",
|
||||
"colorMap1",
|
||||
"colorMap2",
|
||||
"colorMapPostSun",
|
||||
"colorMapPostSunSampler",
|
||||
"colorMapSampler",
|
||||
"colorMapSampler1",
|
||||
"colorMapSampler2",
|
||||
"cucoloris",
|
||||
"cucolorisSampler",
|
||||
"detailMap",
|
||||
"detailMapSampler",
|
||||
"dust",
|
||||
"dustSampler",
|
||||
"fadeMap",
|
||||
"fadeMapSampler",
|
||||
"floatZ",
|
||||
"floatZSampler",
|
||||
"grainMap",
|
||||
"grainMapSampler",
|
||||
"halfParticleColor",
|
||||
"halfParticleColorSampler",
|
||||
"halfParticleDepth",
|
||||
"halfParticleDepthSampler",
|
||||
"heatmap",
|
||||
"heatmapSampler",
|
||||
"lightmapPrimary",
|
||||
"lightmapSamplerPrimary",
|
||||
"lightmapSamplerSecondary",
|
||||
"lightmapSecondary",
|
||||
"lookupMap",
|
||||
"lookupMapSampler",
|
||||
"modelLighting",
|
||||
"modelLightingSampler",
|
||||
"normalMap",
|
||||
"normalMapSampler",
|
||||
"oceanColorRamp",
|
||||
"oceanColorRampSampler",
|
||||
"oceanDetailNormal",
|
||||
"oceanDetailNormalSampler",
|
||||
"oceanDisplacement",
|
||||
"oceanDisplacementSampler",
|
||||
"oceanEnv",
|
||||
"oceanEnvSampler",
|
||||
"oceanFoam",
|
||||
"oceanFoamSampler",
|
||||
"oceanHeightNormal",
|
||||
"oceanHeightNormalSampler",
|
||||
"oceanPaintedFoam",
|
||||
"oceanPaintedFoamSampler",
|
||||
"outdoorMap",
|
||||
"outdoorMapSampler",
|
||||
"population",
|
||||
"populationSampler",
|
||||
"reflectionProbe",
|
||||
"reflectionProbeSampler",
|
||||
"shadowmapSamplerSpot",
|
||||
"shadowmapSamplerSun",
|
||||
"shadowmapSpot",
|
||||
"shadowmapSun",
|
||||
"skyMap",
|
||||
"skyMapSampler",
|
||||
"specularMap",
|
||||
"specularMapSampler",
|
||||
"ssao",
|
||||
"ssaoSampler",
|
||||
"worldMap",
|
||||
"worldMapSampler",
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace T4
|
||||
{
|
||||
void MaterialConstantZoneState::ExtractNamesFromZoneInternal()
|
||||
{
|
||||
for (const auto* zone : ZoneRegistry::GetRegistryForGame(GameId::T4)->Zones())
|
||||
{
|
||||
for (const auto* techniqueSetInfo : zone->m_pools.PoolAssets<AssetTechniqueSet>())
|
||||
{
|
||||
const auto* techniqueSet = techniqueSetInfo->Asset();
|
||||
|
||||
for (const auto* technique : techniqueSet->techniques)
|
||||
{
|
||||
if (technique)
|
||||
ExtractNamesFromTechnique(technique);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned MaterialConstantZoneState::HashString(const std::string& str) const
|
||||
{
|
||||
return Common::R_HashString(str.c_str());
|
||||
}
|
||||
|
||||
void MaterialConstantZoneState::ExtractNamesFromTechnique(const MaterialTechnique* technique)
|
||||
{
|
||||
if (!ShouldDumpFromStruct(technique))
|
||||
return;
|
||||
|
||||
for (auto passIndex = 0u; passIndex < technique->passCount; passIndex++)
|
||||
{
|
||||
const auto& pass = technique->passArray[passIndex];
|
||||
|
||||
if (pass.vertexShader && pass.vertexShader->prog.loadDef.program)
|
||||
ExtractNamesFromShader(pass.vertexShader->prog.loadDef.program, pass.vertexShader->prog.loadDef.programSize);
|
||||
|
||||
if (pass.pixelShader && pass.pixelShader->prog.loadDef.program)
|
||||
ExtractNamesFromShader(pass.pixelShader->prog.loadDef.program, pass.pixelShader->prog.loadDef.programSize);
|
||||
}
|
||||
}
|
||||
|
||||
void MaterialConstantZoneState::AddStaticKnownNames()
|
||||
{
|
||||
for (const auto* knownConstantName : KNOWN_CONSTANT_NAMES)
|
||||
AddConstantName(knownConstantName);
|
||||
for (const auto* knownTextureDefName : KNOWN_TEXTURE_DEF_NAMES)
|
||||
AddTextureDefName(knownTextureDefName);
|
||||
}
|
||||
} // namespace T4
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/T4/T4.h"
|
||||
#include "Material/AbstractMaterialConstantZoneState.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace T4
|
||||
{
|
||||
class MaterialConstantZoneState final : public AbstractMaterialConstantZoneStateDx9
|
||||
{
|
||||
protected:
|
||||
void ExtractNamesFromZoneInternal() override;
|
||||
void ExtractNamesFromTechnique(const MaterialTechnique* technique);
|
||||
void AddStaticKnownNames() override;
|
||||
[[nodiscard]] unsigned HashString(const std::string& str) const override;
|
||||
};
|
||||
} // namespace T4
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "Game/T4/Font/FontDumperT4.h"
|
||||
#include "Game/T4/Image/ImageDumperT4.h"
|
||||
#include "Game/T4/Material/MaterialJsonDumperT4.h"
|
||||
#include "Game/T4/XAnim/XAnimDumperT4.h"
|
||||
#include "Game/T4/XModel/XModelDumperT4.h"
|
||||
#include "Localize/LocalizeDumperT4.h"
|
||||
@@ -17,6 +18,7 @@ void ObjWriter::RegisterAssetDumpers(AssetDumpingContext& context)
|
||||
{
|
||||
RegisterAssetDumper(std::make_unique<xanim::DumperT4>());
|
||||
RegisterAssetDumper(std::make_unique<xmodel::DumperT4>());
|
||||
RegisterAssetDumper(std::make_unique<material::JsonDumperT4>());
|
||||
RegisterAssetDumper(std::make_unique<image::DumperT4>());
|
||||
RegisterAssetDumper(std::make_unique<sound::LoadedSoundDumperT4>());
|
||||
RegisterAssetDumper(std::make_unique<map_ents::DumperT4>());
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#options GAME (IW3, IW4, IW5, T5, T6)
|
||||
#options GAME (IW3, IW4, IW5, T4, T5, T6)
|
||||
|
||||
#filename "Game/" + GAME + "/Material/MaterialJsonDumper" + GAME + ".cpp"
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
#define FEATURE_IW5
|
||||
#define HAS_WATER
|
||||
#define GAME_LOWER "iw5"
|
||||
#elif GAME == "T4"
|
||||
#define FEATURE_T4
|
||||
#define HAS_WATER
|
||||
#define GAME_LOWER "t4"
|
||||
#elif GAME == "T5"
|
||||
#define FEATURE_T5
|
||||
#define HAS_WATER
|
||||
@@ -153,7 +157,7 @@ namespace
|
||||
}
|
||||
|
||||
jTextureDef.semantic = static_cast<TextureSemantic>(textureDef.semantic);
|
||||
#if defined(FEATURE_T5) || defined(FEATURE_T6)
|
||||
#if defined(FEATURE_T4) || defined(FEATURE_T5) || defined(FEATURE_T6)
|
||||
jTextureDef.isMatureContent = textureDef.isMatureContent;
|
||||
#endif
|
||||
|
||||
@@ -231,7 +235,7 @@ namespace
|
||||
|
||||
assert(structured.alphaTestDisabled
|
||||
|| structured.alphaTest == GFXS_ALPHA_TEST_GT_0
|
||||
#if defined(FEATURE_IW3) || defined(FEATURE_IW4) || defined(FEATURE_IW5)
|
||||
#if defined(FEATURE_IW3) || defined(FEATURE_IW4) || defined(FEATURE_IW5) || defined(FEATURE_T4)
|
||||
|| structured.alphaTest == GFXS_ALPHA_TEST_LT_128
|
||||
#elif defined(FEATURE_T5)
|
||||
|| structured.alphaTest == GFXS_ALPHA_TEST_GE_255
|
||||
@@ -241,7 +245,7 @@ namespace
|
||||
jStateBitsTableEntry.alphaTest = JsonAlphaTest::DISABLED;
|
||||
else if (structured.alphaTest == GFXS_ALPHA_TEST_GT_0)
|
||||
jStateBitsTableEntry.alphaTest = JsonAlphaTest::GT0;
|
||||
#if defined(FEATURE_IW3) || defined(FEATURE_IW4) || defined(FEATURE_IW5)
|
||||
#if defined(FEATURE_IW3) || defined(FEATURE_IW4) || defined(FEATURE_IW5) || defined(FEATURE_T4)
|
||||
else if (structured.alphaTest == GFXS_ALPHA_TEST_LT_128)
|
||||
jStateBitsTableEntry.alphaTest = JsonAlphaTest::LT128;
|
||||
#elif defined(FEATURE_T5)
|
||||
@@ -318,7 +322,7 @@ namespace
|
||||
jMaterial.textureAtlas->columns = material.info.textureAtlasColumnCount;
|
||||
|
||||
jMaterial.surfaceTypeBits = material.info.surfaceTypeBits;
|
||||
#if defined(FEATURE_T5) || defined(FEATURE_T6)
|
||||
#if defined(FEATURE_T4) || defined(FEATURE_T5) || defined(FEATURE_T6)
|
||||
jMaterial.layeredSurfaceTypes = material.info.layeredSurfaceTypes;
|
||||
#endif
|
||||
#if defined(FEATURE_T6)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#options GAME(IW3, IW4, IW5, T5, T6)
|
||||
#options GAME(IW3, IW4, IW5, T4, T5, T6)
|
||||
|
||||
#filename "Game/" + GAME + "/Material/MaterialJsonDumper" + GAME + ".h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user