How can i texture my procedurally generated mesh?

I already applied a material to the procedurally generated terrain that has its vertices generated by a perlin noise function in c++, the thing is i want to make the terrain to have different textures based on the height of the vertices.
Like the unreal engine terrain that can be multilayered with different textures.

I think terrain materials may fail you here. From my understanding terrain geometry generated by the editor traditionally uses a height-field for it’s displacement, from there it generates a planar projection for the uvs. Terrian layers work on a similar masking technique where you paint in different masks. The editor probably won’t apply painting tools to anything other than a landscape mesh though.


If the painting tools are crucial for you, you might hack around the issue by spitting out a heightfield from your generated mesh, importing that as a landscape (that you could hide later on), painting your terrain layers onto the landscape, then figuring out where the landscape tool is stuffing it’s layer textures, re-projecting those onto your original geometry, and using them as masks inside the material editor.

Alternatively, if your hang-up is strictly related to the material’s calculation, and you aren’t worried about painting tools, you should check out the Absolute World Position node inside the material editor. If your generated mesh is sufficiently wrangle-able, you may be able to just do the math directly in the material editor and construct your layers manually.

Im not using painting tools, im trying to pass to height of the vertices in its material and then decide wich texture should be applied at that vertex location

Also thx for response :slight_smile:

Help, any results?