Thursday 18 December 2008

Slippery slopes

I could not help but see an opportunity to fix the degradation that occurs at the steep slopes in the terrain created in the previous blog. This degradation occurs because the UV coordinates 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 UV coordinates. 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.

No comments:

Post a Comment