set texture depending on Z position

im making a random terrain generator, i place a plane with many vertex an then i randomly modify the Z value of those vertex, the only problem with it is that i want to change the texture depending on the Z value of those vertex, for example: vertex above 2 blender units will have rock texture, vertex above 15 blender units will have snow texture, and so on, any ideas how to do this?

thanks for reading

You might want to try a node material, in the node material, you would mix multiple materials together using a mask derived from a gradient texture.

Theoretically, you should be able to rotate the supported global coordinates axis so that the gradient texture maps from top to bottom vertically rather than horizontally, the BGE also supports the node system colorramps so you can get many gradients out of a single texture.

How about a global coordinated stencil texture. each height area could display a certain type of texture according to the stencil texture mask?

Another method would be to use vertex colors and mask textures with those? With vertex colors you could even use UV-wrapped custom textures.

Interesting! Where can i learn this? Thanks!

hey thanks guys, i have never actually worked with nodes before, but i will give it a look, thanks!

Yea I agree that a stencil texture globally mapped is the right way, but I think you do not even have to use nodes, it should work with a normal materials as wekk :wink:

I am also looking for a solution for this, please let me know if you have made any progress or found any useful info.