Why terrain mesh consists of elements of unequal size and has vertical walls?

Started by
7 comments, last by Gian-Reto 9 years, 8 months ago

Hello

I have created my first terrain in Unity using Heightmap.I used a heightmap created in Photoshop.

Actually the terrain looks fine. It has only two glitches:

1. On the bounds of the terrain it has vertical walls which - according to the heightmap shouldn't be there. Why such thing occured there?

2. The terrain looks like it has mesh which density becomes larger as it gets closer to the bounds. Is it normal? I am afraid that it can slow down framerate.

Below are the images.

Terrain props:

[attachment=23118:terrain props.PNG]

Heightmap:

[attachment=23115:HeightMap.png]

Vertical walls:

[attachment=23117:VerticalWall.PNG]

Terrain mesh:

[attachment=23116:StrangeHeightmapMesh.PNG]

Advertisement

The field heightmap resolution reads 1025 although your texture is 1024 pixels wide. Maybe that is the problem with the wall.

The field heightmap resolution reads 1025 although your texture is 1024 pixels wide. Maybe that is the problem with the wall.

I tried with the image 1025x1025 and the result was the same.

After I rescaled my map so some of the heightmap is white vertical walls disappeared. But still I do not understand why the mesh is more dense at the bounds.

Altough I have not dabbled to much with the terrain settings (hey, don't fix it if it ain't broken), I'll try to stab in the dark here a little bit:

Could this have to do with the Terrain LOD System? Does the shown density stays the same when you move around the camera? Even in Edit mode, terrain LOD System will kick in to keep up a constant FPS Rate.

The fact that this higher density areas are only visible in the foreground, is somehow pointing in this direction.

If you play around with the pixel error settings, does that change anything for you? AFIAK, the lower the pixel error, the higher the Terrain Resolution. 5 is the default value, so I guess you haven't played around with it yet?

Are there active cameras around the bounds that could cause the Terrain LOD System to increase the LOD Level for that areas? (makes little sense to me if the picture was taken in the Scene view, but hell, stranger things have happened).

About adding pure white fixing the walls: Height maps should always range from pure white at the highest point to pure black at their lowest. You scale the height map to the actual min and max height later, but that image should use to full range of greys. To properly fix it, check the histogram of the image in Photoshop and adjust the image levels (or hit auto-levels) so that the entire range is used. Be careful not to clip the whites and blacks as you will create flat spots on the terrain.

For your wall, as others have pointed out, you specified different resolutions which can cause effects like that. Sounds like you got that figured out.

For the third image in your post, Gian-Reto is correct that it comes from the dynamic LOD system. To reduce processing it automatically downsamples the mesh for the less critical areas. Exactly how critical an area is depends on several factors, including its depth, but also how prominently it is displayed on the screen (such as mountain peaks in the distance) and the mathematically-accumulated visual error. Whenever they switch between depths there adjacent region needs to be broken up carefully to avoid t-junctions.

Picture found online of a t-junction in terrain:

T-Junction.jpg

It has to break up the mesh a certain way to prevent tiny holes, or to prevent some slight flickering, which can occur at boundaries.

Finally, for your other settings, you have a fairly dense texture map. Usually you want somewhere around 2-4 meters per pixel, then use models to represent critical things on the terrain. You've got about 0.67 meters per pixel, which means you'll be spending more processing time on rendering. It is not a wrong value, but it can mean additional LOD processing, additional draw calls, and additional rendering effort on the terrain. Given the tradeoff most games prefer to spend the effort on game models rather than the ground.

As you are just learning those settings are fine, but as you gain experience and your scenes become more complicated you will eventually need to make decisions about where to spend your computing power. Decreasing the terrain density is an easy tradeoff, since dense terrains and especially dense control textures can consume quite a lot of resources.

For now, even though the many options are confusing when you start out just know that there are good reasons for the choices and they become important details in bigger projects.

Thanks a lot. Now I know where were the issues :]

Finally, for your other settings, you have a fairly dense texture map. Usually you want somewhere around 2-4 meters per pixel, then use models to represent critical things on the terrain. You've got about 0.67 meters per pixel, which means you'll be spending more processing time on rendering. It is not a wrong value, but it can mean additional LOD processing, additional draw calls, and additional

About that: AFAIK, one easy fix can be to set the pixel error setting to a higher number. Your Terrain will now look less detailed (most probably because the Terrain LOD Systems uses lesser LOD Levels), but the amount of processing power spent on the terrain can decrease dramatically.

Tested that myself and the difference is staggering between pixel error of 1, 5, or 9. Both in Visual impact, and processing power saved.

Not saying this is better than adjusting the heightmap the Terrain is generated from, its just a good temporary option to reduce the amount of horsepower wasted on your terrain if your FPS are low.

This topic is closed to new replies.

Advertisement