2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-03-05 12:33:02 +00:00

fix: technique loading tech flags

This commit is contained in:
Jan Laupetin
2026-03-01 00:56:56 +01:00
parent 5a126157f8
commit b2f51b2ae1
5 changed files with 64 additions and 11 deletions

View File

@@ -151,6 +151,22 @@ namespace
}
ConvertMaterialArgs(pass, commonPass, memory, context);
pass.customSamplerFlags = static_cast<decltype(MaterialPass::customSamplerFlags)>(commonPass.m_sampler_flags);
}
bool AnyDeclHasOptionalSource(const MaterialTechnique& technique)
{
for (auto passIndex = 0u; passIndex < technique.passCount; passIndex++)
{
const auto& pass = technique.passArray[passIndex];
if (!pass.vertexDecl)
continue;
if (pass.vertexDecl->hasOptionalSource)
return true;
}
return false;
}
void UpdateTechniqueFlags(MaterialTechnique& technique, const techset::CommonTechnique& commonTechnique)
@@ -165,6 +181,9 @@ namespace
{
technique.flags |= TECHNIQUE_FLAG_4;
}
if (AnyDeclHasOptionalSource(technique))
technique.flags |= TECHNIQUE_FLAG_8;
}
MaterialTechnique* ConvertTechnique(const techset::CommonTechnique& commonTechnique, AssetCreationContext& context, MemoryManager& memory)
@@ -176,15 +195,15 @@ namespace
technique->name = memory.Dup(commonTechnique.m_name.c_str());
// Take common flags and apply further logic
technique->flags = static_cast<decltype(MaterialTechnique::flags)>(commonTechnique.m_flags);
UpdateTechniqueFlags(*technique, commonTechnique);
technique->passCount = passCount;
for (auto passIndex = 0u; passIndex < passCount; passIndex++)
ConvertMaterialPass(technique->passArray[passIndex], commonTechnique.m_passes[passIndex], context, memory);
// Take common flags and apply further logic
technique->flags = static_cast<decltype(MaterialTechnique::flags)>(commonTechnique.m_flags);
UpdateTechniqueFlags(*technique, commonTechnique);
return technique;
}