How do I colour a 3D terrain based on its height?
Mapping node:
You can use the Mapping node to rotate the texture on the Y axis, making the gradient vertical.
Change the Location Z axis value so that one &quot;end&quot; of the gradient is at the tallest peak or valley of the mesh. Also ensure that the Mapping mode is set to Texture:

Result:

UV unwrapping:
You could also UV unwrap your mesh.

Enter edit mode (Tab) and select all A

Set the view to Orthographic (Numpad 5) and view your mesh from the front (Numpad 1)

Press U&gt;Project from view:


Rotate (R) the resulting UV map in the UV/Image Editor so it is standing on end: