Terrain patch border issue

Started by
2 comments, last by raRaRa 9 years, 4 months ago

Hello, I'm working on a procedural terrain engine.

I'm generating a height map for each terrain patch (QuadTree node) and the vertices are lifted up in the vertex program, but the patches have small cracks on the borders. This is happening because the neighbour terrain patch has its own height map and mesh, so the vertices on the borders don't match up perfectly. Please note that I have the same LOD level on all patches at the moment.

One potential fix I can come up with is adding 1 pixel padding on the height map, where the one pixel border is fetched from the neighbour height map. That way the vertices on the edges will be lifted properly. But I've never come across any article talking about this issue, so I'm wondering if I'm doing something fundamentally wrong.

This was never a problem on the CPU side, because the vertices on the border got the same noise value for the given X Y Z input. However, now on the GPU side I'm feeding it with the corners of the terrain patch and then the GPU is interpolating between those corner values, which is the input to the noise function.

Any clues or suggestions on how I can do this properly?

Thanks!

Advertisement

The general way I've seen people deal with this issue is just adding the 1 pixel padding so your patches overlap at the borders. If you look into World Machine's tiling functionality - that's exactly what it does to solve this problem.

I had a similar issue with terrain patch borders in my hobby engine where the GPU interpolated the edges of my patches in a wonky way. After panicking and failing miserably with different texture addressing modes in my heightmap texture sampler, I got finally it: make the heightmap texture for a terrain chunk include one extra value on each side (i.e. make the texture contain N+2 values for a chunk of size N in both dimensions) and modify the texture coordinates in vertices accordingly (i.e. "skip" the outermost values outside the actual terrain chunk). The seams I had disappeared completely.

EDIT: And I think this is what AdeptStrain suggests come to think of it. Oh well...

Thanks for all the replies. I ended up having one pixel padding on my heightmap and it solves the problem. However, on my procedural planet this becomes an issue between cube faces.

Let's take one cube face as an example. The cube face coordinates are X = [-1.0, 1.0] Y = [-1.0, 1.0] and Z = 1.0 and with padding it would be something like -1.1 to 1.1 and then it doesn't match the coordinates on the neighbour cube face.

I could do some if statements in the shader, e.g. if X is under -1.0 then it must belong to a different face. I would love to avoid that.

Something tells me I don't need padding for the heightmap and I'm going to investigate it further. Any helpful tips are more than welcome.

This topic is closed to new replies.

Advertisement