mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-05-02 08:29:36 +00:00
chore: handle iw4 technique flags
This commit is contained in:
@@ -1060,13 +1060,13 @@ namespace
|
||||
// The other ones might be handled by the game in the same fashion because there is not recognizable pattern that connects the shaders with the same
|
||||
// flags
|
||||
static std::unordered_map<std::string, size_t> flagsByTechniqueName({
|
||||
{"zprepass", TECHNIQUE_FLAG_4 | TECHNIQUE_FLAG_200 },
|
||||
{"build_floatz", TECHNIQUE_FLAG_8 },
|
||||
{"build_shadowmap_depth", TECHNIQUE_FLAG_10 | TECHNIQUE_FLAG_200},
|
||||
{"build_shadowmap_model", TECHNIQUE_FLAG_10 | TECHNIQUE_FLAG_200},
|
||||
{"distortion_scale_ua_zfeather", TECHNIQUE_FLAG_100 },
|
||||
{"distortion_scale_zfeather", TECHNIQUE_FLAG_100 },
|
||||
{"distortion_scale_zfeather_dtex", TECHNIQUE_FLAG_100 },
|
||||
{"zprepass", MTL_TECHFLAG_ZPREPASS | TECHNIQUE_FLAG_200 },
|
||||
{"build_floatz", MTL_TECHFLAG_BUILD_FLOATZ },
|
||||
{"build_shadowmap_depth", MTL_TECHFLAG_BUILD_SHADOW_MAP_DEPTH_OR_MODEL | TECHNIQUE_FLAG_200},
|
||||
{"build_shadowmap_model", MTL_TECHFLAG_BUILD_SHADOW_MAP_DEPTH_OR_MODEL | TECHNIQUE_FLAG_200},
|
||||
{"distortion_scale_ua_zfeather", MTL_TECHFLAG_USES_DISTORTION_FLOATZ },
|
||||
{"distortion_scale_zfeather", MTL_TECHFLAG_USES_DISTORTION_FLOATZ },
|
||||
{"distortion_scale_zfeather_dtex", MTL_TECHFLAG_USES_DISTORTION_FLOATZ },
|
||||
{"alternate_scene_overlay", TECHNIQUE_FLAG_200 },
|
||||
{"blur_apply", TECHNIQUE_FLAG_200 },
|
||||
{"build_floatz", TECHNIQUE_FLAG_200 },
|
||||
@@ -1117,7 +1117,7 @@ namespace
|
||||
const auto& pass = technique.passArray[i];
|
||||
if (pass.vertexDecl && pass.vertexDecl->hasOptionalSource)
|
||||
{
|
||||
technique.flags |= TECHNIQUE_FLAG_20;
|
||||
technique.flags |= MTL_TECHFLAG_DECL_HAS_OPTIONAL_SOURCE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1130,16 +1130,16 @@ namespace
|
||||
switch (arg.m_arg.u.codeSampler)
|
||||
{
|
||||
case TEXTURE_SRC_CODE_RESOLVED_POST_SUN:
|
||||
techniqueFlags |= TECHNIQUE_FLAG_1;
|
||||
techniqueFlags |= MTL_TECHFLAG_NEEDS_RESOLVED_POST_SUN;
|
||||
break;
|
||||
case TEXTURE_SRC_CODE_RESOLVED_SCENE:
|
||||
techniqueFlags |= TECHNIQUE_FLAG_2;
|
||||
techniqueFlags |= MTL_TECHFLAG_NEEDS_RESOLVED_SCENE;
|
||||
break;
|
||||
case TEXTURE_SRC_CODE_FLOATZ:
|
||||
case TEXTURE_SRC_CODE_PROCESSED_FLOATZ:
|
||||
case TEXTURE_SRC_CODE_RAW_FLOATZ:
|
||||
if ((techniqueFlags & TECHNIQUE_FLAG_100) == 0)
|
||||
techniqueFlags |= TECHNIQUE_FLAG_80;
|
||||
if ((techniqueFlags & MTL_TECHFLAG_USES_DISTORTION_FLOATZ) == 0)
|
||||
techniqueFlags |= MTL_TECHFLAG_USES_FLOATZ;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -1151,7 +1151,7 @@ namespace
|
||||
{
|
||||
case CONST_SRC_CODE_LIGHT_SPOTDIR:
|
||||
case CONST_SRC_CODE_LIGHT_SPOTFACTORS:
|
||||
techniqueFlags |= TECHNIQUE_FLAG_40;
|
||||
techniqueFlags |= MTL_TECHFLAG_USES_LIGHT_SPOT_FACTORS;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include TECHSET_CONSTANTS_HEADER
|
||||
#include "Techset/CommonShaderArgCreator.h"
|
||||
#include "Techset/CommonTechniqueLoader.h"
|
||||
#include "Techset/CommonVertexDeclCreator.h"
|
||||
#include "Techset/LiteralConstsZoneState.h"
|
||||
#include "Utils/StringUtils.h"
|
||||
|
||||
@@ -211,7 +212,7 @@ namespace
|
||||
pass.customSamplerFlags = static_cast<decltype(MaterialPass::customSamplerFlags)>(commonPass.m_sampler_flags);
|
||||
}
|
||||
|
||||
bool AnyDeclHasOptionalSource(const MaterialTechnique& technique)
|
||||
bool AnyDeclHasOptionalSource(const MaterialTechnique& technique, AssetCreationContext& context)
|
||||
{
|
||||
for (auto passIndex = 0u; passIndex < technique.passCount; passIndex++)
|
||||
{
|
||||
@@ -219,36 +220,52 @@ namespace
|
||||
if (!pass.vertexDecl)
|
||||
continue;
|
||||
|
||||
#if defined(SHADERS_ARE_SUBASSETS)
|
||||
if (pass.vertexDecl->hasOptionalSource)
|
||||
return true;
|
||||
#else
|
||||
if (pass.vertexDecl->name && pass.vertexDecl->name[0] == ',')
|
||||
{
|
||||
if (techset::HasOptionalSourceByName(&pass.vertexDecl->name[1], commonRoutingInfos).value_or(false))
|
||||
return true;
|
||||
}
|
||||
else if (pass.vertexDecl->hasOptionalSource)
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void UpdateTechniqueFlags(MaterialTechnique& technique, const techset::CommonTechnique& commonTechnique)
|
||||
void UpdateTechniqueFlags(MaterialTechnique& technique, const techset::CommonTechnique& commonTechnique, AssetCreationContext& context)
|
||||
{
|
||||
#if defined(FEATURE_IW4)
|
||||
// TODO
|
||||
#elif defined(FEATURE_T6)
|
||||
std::string lowerTechniqueName(commonTechnique.m_name);
|
||||
utils::MakeStringLowerCase(lowerTechniqueName);
|
||||
|
||||
#if defined(FEATURE_IW4)
|
||||
// Not a particularly cool way to do this but...
|
||||
// the game actually does this :shrug:
|
||||
if (lowerTechniqueName == "zprepass")
|
||||
technique.flags |= MTL_TECHFLAG_ZPREPASS;
|
||||
else if (lowerTechniqueName == "build_floatz")
|
||||
technique.flags |= MTL_TECHFLAG_BUILD_FLOATZ;
|
||||
else if (lowerTechniqueName == "build_shadowmap_depth" || lowerTechniqueName == "build_shadowmap_model")
|
||||
technique.flags |= MTL_TECHFLAG_BUILD_SHADOW_MAP_DEPTH_OR_MODEL;
|
||||
|
||||
if (technique.flags & MTL_TECHFLAG_USES_FLOATZ && lowerTechniqueName.starts_with("distortion_"))
|
||||
technique.flags = (technique.flags & ~MTL_TECHFLAG_USES_FLOATZ) | MTL_TECHFLAG_USES_DISTORTION_FLOATZ;
|
||||
#elif defined(FEATURE_T6)
|
||||
// Not a particularly cool way to do this but...
|
||||
// the game actually does this :shrug:
|
||||
if (lowerTechniqueName == "zprepass" || lowerTechniqueName.starts_with("pimp_technique_zprepass_")
|
||||
|| lowerTechniqueName.starts_with("pimp_technique_layer_zprepass_") || lowerTechniqueName.starts_with("pimp_technique_buildshadowmap_"))
|
||||
{
|
||||
technique.flags |= TECHNIQUE_FLAG_4;
|
||||
technique.flags |= MTL_TECHFLAG_ZPREPASS;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (AnyDeclHasOptionalSource(technique))
|
||||
#if defined(FEATURE_IW4)
|
||||
technique.flags |= TECHNIQUE_FLAG_20;
|
||||
#elif defined(FEATURE_T6)
|
||||
technique.flags |= TECHNIQUE_FLAG_8;
|
||||
#endif
|
||||
if (AnyDeclHasOptionalSource(technique, context))
|
||||
technique.flags |= MTL_TECHFLAG_DECL_HAS_OPTIONAL_SOURCE;
|
||||
}
|
||||
|
||||
MaterialTechnique* ConvertTechnique(const techset::CommonTechnique& commonTechnique, AssetCreationContext& context, MemoryManager& memory)
|
||||
@@ -267,7 +284,7 @@ namespace
|
||||
|
||||
// Take common flags and apply further logic
|
||||
technique->flags = static_cast<decltype(MaterialTechnique::flags)>(commonTechnique.m_flags);
|
||||
UpdateTechniqueFlags(*technique, commonTechnique);
|
||||
UpdateTechniqueFlags(*technique, commonTechnique, context);
|
||||
|
||||
return technique;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user