ADD: vertex small fix

This commit is contained in:
2025-12-03 15:00:19 +09:00
parent f152f26cd1
commit 01b28174be
3 changed files with 30 additions and 10 deletions

View File

@@ -612,8 +612,24 @@ std::optional<std::shared_ptr<LoadedGLTF> > loadGltf(VulkanEngine *engine, std::
});
}
// Generate tangents if missing and we have UVs
if (!hasTangents)
// Generate tangents only when needed for normal mapping.
// If the bound material has no normal map, we can skip TBN generation.
bool materialHasNormalMap = false;
if (p.materialIndex.has_value())
{
size_t matIndex = p.materialIndex.value();
if (matIndex < gltf.materials.size())
{
materialHasNormalMap = gltf.materials[matIndex].normalTexture.has_value();
}
}
else if (!gltf.materials.empty())
{
// Primitives without an explicit material fall back to material 0.
materialHasNormalMap = gltf.materials[0].normalTexture.has_value();
}
if (!hasTangents && materialHasNormalMap)
{
size_t primIndexStart = newSurface.startIndex;
size_t primIndexCount = newSurface.count;