How can i texture my terrain exactly like this?

how can i texture my terrain like this? and how can i get the dirt, rock and now blend like how the second image has with the outlines. i have basic knowledge of slope and height select and i plan to use this in a game engine.