DynamicMesh::SetVertexColor has no effect

blu kettle
Fri, 01 Aug 2025 06:19:13 +0000
Programming & Scripting

Hi people

im trying to update the vertex colors of a DynamicMesh but even if SetVertex works well, trying to use SetVertexColor in the same loop does absolutely nothing.

This is basically the code im using:

FDynamicMesh3 tempMesh = MeshComp->GetDynamicMesh()->GetMeshRef();


if (!tempMesh.HasVertexColors())
{
	tempMesh.EnableVertexColors(FVector3f(0.0f, 0.0f, 0.0f));
	tempMesh.EnableAttributes();
	tempMesh.Attributes()->EnablePrimaryColors();
}


for (int32 i : tempMesh.VertexIndicesItr())
{
	tempMesh.SetVertex(i, vertPos + ...);

	tempMesh.SetVertexColor(i, FVector3f(1.0f, 0.0f, 0.0f));
}


MeshComp->SetMesh(MoveTemp(tempMesh));
MeshComp->NotifyMeshUpdated();
MeshComp->UpdateCollision();

I also used a Material with vertex colors as the base color for debugging.
Trying to ask ChatGPT only gave me hallucinated pseudo-code and i didn’t find any other solution online.

Thx for your help in advance!

2 posts - 2 participants