I’m creating procedural mesh. My mesh has two sections, square and rectangle respecctively.
When I rotate/move the mesh at run time, my second section turned out to be black.
I have also tried with more than 2 sections. But 2nd Section onwards procedural mesh become black.
Here are the attached screenshots.
I had a similar issue where 50% of the faces of a procedurally generated cube were black (rather than showing their designated materials). Each face of the cube was comprised of two triangle polygons, and had a unique two-sided material (colour) applied. I was generating each mesh section in accordance with A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums (“with default options”);
DIAGNOSIS: I was able to display the other 50% of faces by inverting the order of the vertex definitions, which suggested a normal problem.
To display 100% of my faces I performed the following operations:
- generated normals for each vertex (of each mesh section);
mesh->CreateMeshSection(meshSectionIndex, vertices, triangles, normals, TArray(), TArray(), TArray(), false);
[2. duplicated each triangle polygon with an inverted vertex order (this is probably only required when a triangle polygon is defined to face inwards rather than outwards)]
[3. setting the materials as “two-sided” had no effect (this works for static meshes however)]
Note the mesh colour/material for each mesh section was defined by the following operations (rather than using vertexColors);
string materialName = “MaterialX”; //set materialName for the mesh section here
FString pathNameMaterial = generateMaterialPathName(materialName); //eg “Material’/Game/trial/MaterialX.MaterialX’”
UMaterialInterface* replacementMaterial = Cast(StaticLoadObject(UMaterialInterface::StaticClass(), NULL, *pathNameMaterial));