Applying multiple materials to ProceduralMeshComponent

I’m currently experimenting with the ProceduralMeshComponent to create random terrain. My end goal is to create a proceduraly generated world made out of multiple ProceduralMeshComponent tiles/chunks/whatever combined together. So far I’ve been able to create a basic mesh but I can’t find a good way to apply materials to the mesh. I’ve seen some examples of applying a single material to the ProceduralMeshComponent but I’m looking for a way to apply multiple materials to the mesh based on some value (I saw some examples where people had used the VertexColor to store data about the vertex). Ideally I’d have each vertex also have some information such as what type of terrain it is which would control the material that is used. Eg. 0 is stone, 1 is grass, etc. Ideally I’d like to be able to blend the transitions between different terrain types.

I thought about using UVs but I thought it would require duplicated vertexes and it seemed like there were a limited number of textures that could be used with the ProceduralMeshComponent. I thought about using individual mesh sections but dividing up the randomly generated data into sections seemed very complicated and having many sections would be a performance hit (or so I’ve read). I’ve come across materials using the Material Attribute Layers but I couldn’t find any way of controlling that based on a property or parameter (such as the VertexColor).

How can I go about this? Or am I barking up the wrong tree with the ProceduralMeshComponent for procedural terrain?

I’m aware that there are existing products that can handle a lot of this but my goal here is to learn so I’m not looking for a packaged solution (although the packaged solutions are pretty awesome). Also I’m a complete noob with UE but I’m fairly competent with C++ and I have some knowledge of 3D programming (I’ve played around with some OpenGL basics).

Any help with this would be greatly appreciated, even if it’s just a nudge in the right direction :slight_smile:

I think the vertex color is a great idea. For the blend transistion, couldn’t you just use a lerp node ? (With the vertex color has the alpha blend and A & B your grass and stone texture)