How can i texture my procedurally generated mesh s based on the height of the vertices?

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.

Please help me

doesn’t work for procedural mesh

Have a look at this: