Integrating github/staging through commit 5f214be
This commit is contained in:
@@ -114,7 +114,7 @@ namespace AZ
|
||||
if (auto* serialize = azrtti_cast<SerializeContext*>(context))
|
||||
{
|
||||
serialize->Class<ModelAssetBuilderComponent, SceneAPI::SceneCore::ExportingComponent>()
|
||||
->Version(25); // [ATOM-14876]
|
||||
->Version(26); // [ATOM-14992]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,6 +375,8 @@ namespace AZ
|
||||
{
|
||||
ProductMeshContentList lodMeshes = SourceMeshListToProductMeshList(context, sourceMeshContentList, jointNameToIndexMap, morphTargetMetaCreator);
|
||||
|
||||
PadVerticesForSkinning(lodMeshes);
|
||||
|
||||
// By default, we merge meshes that share the same material
|
||||
bool canMergeMeshes = true;
|
||||
|
||||
@@ -881,6 +883,61 @@ namespace AZ
|
||||
return productMeshList;
|
||||
}
|
||||
|
||||
void ModelAssetBuilderComponent::PadVerticesForSkinning(ProductMeshContentList& productMeshList)
|
||||
{
|
||||
// Check if this is a skinned mesh
|
||||
if (!productMeshList.empty() && !productMeshList[0].m_skinWeights.empty())
|
||||
{
|
||||
// First, do a pass to see if any mesh has morphed colors
|
||||
bool hasMorphedColors = false;
|
||||
for (ProductMeshContent& productMesh : productMeshList)
|
||||
{
|
||||
if (productMesh.m_hasMorphedColors)
|
||||
{
|
||||
hasMorphedColors = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (ProductMeshContent& productMesh : productMeshList)
|
||||
{
|
||||
size_t vertexCount = productMesh.m_positions.size() / PositionFloatsPerVert;
|
||||
|
||||
// Skinned meshes require that positions, normals, tangents, bitangents, all exist and have the same number
|
||||
// of total elements. Pad buffers with missing data to make them align with positions and normals
|
||||
if (productMesh.m_tangents.empty())
|
||||
{
|
||||
productMesh.m_tangents.resize(vertexCount * TangentFloatsPerVert, 1.0f);
|
||||
AZ_Warning(s_builderName, false, "Mesh '%s' is missing tangents and no defaults were generated. Skinned meshes require tangents. Dummy tangents will be inserted, which may result in rendering artifacts.", productMesh.m_name.GetCStr());
|
||||
}
|
||||
if (productMesh.m_bitangents.empty())
|
||||
{
|
||||
productMesh.m_bitangents.resize(vertexCount * BitangentFloatsPerVert, 1.0f);
|
||||
AZ_Warning(s_builderName, false, "Mesh '%s' is missing bitangents and no defaults were generated. Skinned meshes require bitangents. Dummy bitangents will be inserted, which may result in rendering artifacts.", productMesh.m_name.GetCStr());
|
||||
}
|
||||
|
||||
// If any of the meshes have morphed colors, padd all the meshes so that the color stream is aligned with the other skinned streams
|
||||
if (hasMorphedColors)
|
||||
{
|
||||
if (productMesh.m_colorCustomNames.empty())
|
||||
{
|
||||
productMesh.m_colorCustomNames.push_back(Name{ "COLOR" });
|
||||
}
|
||||
|
||||
if (productMesh.m_colorSets.empty())
|
||||
{
|
||||
productMesh.m_colorSets.resize(1);
|
||||
}
|
||||
|
||||
if (productMesh.m_colorSets[0].empty())
|
||||
{
|
||||
productMesh.m_colorSets[0].resize(vertexCount * ColorFloatsPerVert, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ModelAssetBuilderComponent::GatherVertexSkinningInfluences(
|
||||
const SourceMeshContent& sourceMesh,
|
||||
ProductMeshContent& productMesh,
|
||||
|
||||
Reference in New Issue
Block a user