Random Terrain Material

If you want to produce the actual texture, look how to write texture pixels in Unity, or use a RenderTexture to draw the texture all at once.

If you just want to paint the splatmaps (e.g, mix existing textures differently), look up modifying terrain splatmaps.

You can also look at some of my code where I modify the splatmaps in my grenade ground deformation example in my TerrainDamager scene in my MakeGeo project. More info here: