Coloring a vertex in custom mesh component

After following the custom mesh tutorial that rama wrote:

Then adding color to it, with much guidance from the forum posts

I havn’t been able to colour the verticies, something in Opengl ive found an easy task. The reason I want to do this, is to make a custom lighting (based on the height, sun position, etc)

Here is a screenshot of the problem, the vertex colour values I create in the custom dynamic mesh are set to (255,0,0), however the colours never change when I change the variables.

I figured out the problem…
It had nothing to do with the code, it was that the material did not use the vertex colour data. (I was used to the default behaviour being vertex colour is used, not exactly sure how the default material behaviour is in ue4)
Also there should be a way to do this with different variables, not just colour component. Material properties etc. Not exactly sure how atm.

1 Like

I’ve been trying to get this to work and I’m confused about if I’m starting the procedural mesh the right way. I use CreateMeshSection on my proceduralMeshComponent object. It takes an array of verts/ faces, and some other stuff too. My procedural mesh spawns in my level, but does not have the material I apply to it. I’ve also tried doing the vertex colors material you post above and it’s not rendering the red color it should be (still just grey).

Am I starting the procedural mesh the right way? I see above you use GenerateMeshSceneProxy. What is the order of how you spawn this object? For me it’s

//.h
UProceduralMeshComponent* mesh;
//.cpp
mesh = CreateDefaultSubobject(TEXT("ProceduralMesh"));
	RootComponent = mesh;
//Set the material
mesh->SetMaterial(0, Cast(StaticLoadObject(UMaterial::StaticClass(), NULL, *FString(UISC::florMTLoc + materials[0]))));
//Fill the arrays up with vertices/ and then fill the face array....
//Call CreateMeshSection
mesh->CreateMeshSection(2, noWalkVerts, noWalkTris, pathNorms, pathUVs, noWalkColors, pathTangs, false);

This gets me to where the mesh is spawning in the level. I can see the prescribed material listed in its details panel, but still it is only grey. Any ideas?