Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GLSL Tessellated Environment - Gaps Between Patches

So I have been writing a program that uses a tessellation shader and a height map to draw an environment. It starts out as a 32x32 plane, and when it gets more tessellated the heights of each square vertex are determined by the height map.

I want it so that the closer the patch is to the camera, the more tessellated it gets. However, I have discovered that this causes gaps between patches. If a patch is more tessellated than one next to it, the different resolutions cause gaps.

Here, a picture is worth a thousand words: Tessellated EnvironmentTessellated Environment

If two patches have the same resolution then there are no gaps. How can I get around this problem? I'm completely stuck.

like image 488
danglingPointer Avatar asked May 08 '14 00:05

danglingPointer


2 Answers

The UV coordinates along the edges need to vary uniformly for this to be seamless. When done at the same level of subdivision there are some pretty reliable invariance guarantees. However, this rarely happens when the two edges are sub-divided at different rates.

Technically what you have is known as a T-Junction. It occurs because two surfaces that are supposed to share an edge actually diverge slightly. The insertion of a new displaced vertex creates two primitives, neither of which share an edge with the one primitive belonging to the adjacent patch.

You need to make the outer tessellation level identical for patches that share edges*:

   http://http.developer.nvidia.com/GPUGems2/elementLinks/07_tessellation_08.jpg

   *As shown in this diagram from GPU Gems 2

like image 157
Andon M. Coleman Avatar answered Nov 01 '22 02:11

Andon M. Coleman


I am sure you are already familiar with Continuous Level Of Detail problem. Searching for this in the web gives several methods solving the gap problem. One such site is here, where I copied the picture below.

One thing interesting in your case is that the tesselation does not seem to increment / decrement in 2^n fashion. So, for your case, maybe adding faces to the four boundaries of each block of terrain mesh, acting as curtains, might be the only feasible solution.

If you look at the picture below, you'll see the boundaries have vertical faces. Side effect is, if the gap is big enough, then it might be seen as a cliff. You'll need to adjust the tessellation between detail levels to minimize this side effect.

enter image description here

like image 29
Keugyeol Avatar answered Nov 01 '22 02:11

Keugyeol