UVcoordinates specify a small piece of texture (as seen from the top) must fit on a large piece of real estate (as seen from the side). Aha, I thought, the solution is simple - just fix the coordinates and all should be fine. After doing the work, the flat areas of the terrain become seriously damaged. This is because all the adjustments adds up and the sum causes a distortion of the textures on the flat areas in the terrain. I'm sure there is a simple mathematical explanation for this, but you'd have to ask someone else for it ;-).
Little did I know this was a know issue. See this forum topic for a small discussion and a better description of the problem. So I reverted back to the original
UVcoordinates. However, I decided to change the multi-texture decision so that the rock texture is preferred when the gradient reaches some threshold. The gradient is easy to measure -- the smaller the Y component of the normal, the steeper is the slope.
Choosing the rock texture as the one for steep slopes gives you this code:
TexWeights.Z = 1.0f - _vertices[x + y * _width].Normal.Y;. As you can see from the image on the right, the slopes look a bit more realistic.
On another topic -- the download of the code I published from my previous blog did not work well. I republished the code here. The available code does not contain the changes mentioned here. Maybe I'll publish again later.