I’m working on a terrain-type component and I’m having trouble working out some of the details for applying materials to it. I’m able to generate arbitrary shapes based on the code from the Procedural Mesh Generation wiki tutorial and have now managed to apply single materials to the rendered mesh in UnrealEd.
What I’m trying to work towards is a terrain where there are, for example, 3 possible materials (rock, grass and sand for example). Each vertex in the procedural terrain can provide a set of three weights for how much of each material should be present. These weights should then be smoothly interpolated across the triangle so the fragment shader can mix the components together to create a smooth transition between texture types.
In order to do the blending I will use something like the layered materials or the landscape materials. However, in those examples the blending is done on a per-pixel level in the texture UV space and use either alpha masks or the RGBA components of a mask texture. I want the material information to be passed from the procedural mesh to the material, possibly via a custom component in the buffer (like an OpenGL ‘in’ parameter).
Does UE4 support this sort of information passing (via a custom FLocalVertexFactory/FVertexBuffer/FDynamicMeshVertex combination maybe?) for each vertex or am I on the wrong track for this first step?
The alternative solution would be to misuse the vertex colour and encode the weights into that in some way but I would like something a bot more flexible.
Thanks for any help you can provide.