Terrain LOD and Cracks

Sep 19, 2011 at 4:42 PM
Edited Sep 19, 2011 at 4:44 PM


As Reach profile restricts textures to 2048x2048, i was thinking of using several of those and create the terrain out of 4 textures.

However, when doing so, there are gaps between the patches. (See in the image)

terrain gaps

I tried to disable the LOD on the DrawableSurface.

Tried to enable LOD and setting


Patches[i].LevelOfDetail = 0;


to get the best level of detail, however this didn't help. How to get around this?

I found that skirts are a solution, however i have no idea how to implement them.



Sep 20, 2011 at 3:59 AM

The gap in your image seems to be caused by texture filtering rather then the difference of adjacent terrain geometries, I haven't come up with a quick solution for that.

Besides the above argument, manually create 4 terrains and place them adjacently is certainly going to cause problems when working with dynamic level of detail, as each terrain would have no idea of its neighbors, there's no way for it to figure out the correct geometry to snap to its neighbors.

The solution to your problem is to create 1 giant terrain. To walkaround with texture size limitaion, here are some recommended ways:

1. Write your own heightmap importer (and processor likely) that converts the colors into a Heightmap (see the implementation of heightmap processor, it should not be hard to do that)

2. Convert the heightmap texture into a *.raw format and import that using the built-in RawImporter, that importer has no size limitation.

Finally, you should not set Patch.LevelOfDetail directly, the set method is internal because when DrawableSurface.UpdateLevelOfDetail is called, the lod of each patch is updated based on eye position and the current LodStart/LodEnd settings. If you don't want Lod, just set LodEnabled to false.

Hope that helps


Sep 20, 2011 at 7:44 AM
Edited Sep 20, 2011 at 1:01 PM

Hello yufeih,

I think you misunderstood a little. The terrain size is ok with me, i just want to use a higher resolution texture on it.

What i was doing here is i've used 4 basic effects to render different textures to different patches.



I wasn't intending to set Patch.LevelOfDetail directly. I did that just in order to test if the LOD is causing the issues.

I'm rendering the terrain separately, as it seems that Scene class can't render it. Material property is always null after Draw method of the scene although I create a BasicMaterial at terrain initialization. Maybe i'm setting it somehow wrong.





I was able to solve the issue by using PointWrap sampler state, but now it appears a bit crappy :(

>The gap in your image seems to be caused by texture filtering rather then the difference of adjacent terrain geometries, I haven't come up with a quick solution for that

How about a slow solution, what needs to be done?

Sep 20, 2011 at 1:22 PM
Edited Sep 20, 2011 at 1:28 PM

Sorry for the misunderstood :-(

After some digging, I was able to eliminate the gap without sacrificing the beauty of linear sampling. It requires a little modification of DrawableSurface, I'll change that later.

The key is to set texture filtering to LinearClamp and make sure the texture coordinates of each patch ranges exactly from 0 to 1. This is how most 2D games tiles their textures without introducing glitches.

The reason why linear wrap would fail is that the color of the border pixels is determined by 2 (or 4) adjacent pixels, one of them unfortunately wraps to the other side of the image. The gap won't appear for seamless textures as the opposite side of a seamless texture will have approximately the same color.

But the currently ConvertVertexType callback cannot tell which patch the vertex resides, you might have to wait until I've added that info to the callback handler :-)


Sep 20, 2011 at 1:55 PM

It's ok. It was I who expressed myself incorrectly.

Thanks yufeih for all you effort.