How to layer terrain materials like unreal 3

Material Functions may help: