Home > 未分类 > Terrain Geomorphing in the Vertex Shader( 4)

Terrain Geomorphing in the Vertex Shader( 4)



One problem with geometry management using level of detail is that at some point in time vertices will have to be removed or added, which leads to the already described "popping" effect. In our case of geo-mipmapping, where the number of vertices is doubled or halved at each tessellation level change, this popping becomes very visible. In order to reduce the popping effect geo-morphing is introduced. The aim of geo-morphing is to move (morph) vertices softly into their position in the next level before that next level is activated. If this is done perfectly no popping but only slightly moving vertices are observed by the user. Although this vertex moving looks a little bit strange if a very low detailed terrain mesh is used, it is still less annoying to the user than the popping effect.


It can be shown that only vertices which have odd indices inside a patch have to move and that those vertices on even positions can stay fixed because they are not removed when switching the next coarser tessellation level. Figure 6a shows the tessellation of a patch in tessellation level 2 from a top view. Figure 6b shows the next level of tessellation coarseness (level 3). Looking at Figure 6b it becomes obvious that the vertices ‘1’, ‘2’ and ‘3’ do not have to move since they are still there in the next level. There are three possible cases, in which a vertex has to move:


  • Case ‘A’: The vertex is on an odd x- and even y-position.
    This vertex has to move into the middle position between the next left (‘1’) and the right (‘2’) vertices.
  • Case ‘B’: The vertex is on an odd x- and odd y-position.
    This vertex has to move into the middle position between the next top-left (‘1’) and the bottom-right (‘3’) vertices.
  • Case ‘C’: The vertex is on an even x- and odd y-position.
    This vertex has to move into the middle position between the next top (‘2’) and the bottom (‘3’) vertices.
  • A’情形:顶点在X方向索引号为奇数,y方向为偶数:该顶点将移动到下一级的左(‘1’)和右(‘2’)点的中点
  • B’情形:顶点在X方向为奇数,y方向也为奇数:该顶点将移动到下一级的左上(‘1’)和右下(‘3’)点的中点
  • C’情形:顶点在X方向为偶数,y方向为偶数:该顶点将移动到下一级的上(‘2’)和下(‘3’)点的中点

Things become much clearer when taking a look at the result of the morphing process: after the morphing is done the patch is re-tessallated using the next tessellation level. Looking at Figure 6b it becomes obvious that the previously existing vertex ‘A’ had to move into the average middle position between the vertices ‘1’ and ‘2’ in order to be removed without popping.






Figure 6a: Fine geometry with morphing vertices


Figure 6b: Corresponding coarser tessellation level. Only odd indexed vertices were removed




Although the geometry’s creation is very fast and we are rendering the mesh using only a small number of long triangle strips (usually about some hundred strips per frame), there are quite a lot of optimizations we can do to increase the performance on the side of the processor as well as the graphics card.


As described in the section "Materials" we use a multi-pass rendering approach to apply more than one material to the ground. In the common case most materials will be used only in small parts of the landscape and be invisible in most others. The alpha-channel of the material’s lightmap defines where which material is visible. Of course it’s a waste of GPU bandwidth to render materials on patches which don’t use that material all together (where the material’s alpha channel is completely zero in the corresponding patch’s part).


It’s easy to see, that if the part of a material’s alpha-channel which covers one distinct patch is completely set to zero, then this patch does not need to be rendered with that material. Assuming that the materials’ alpha channels won’t change during runtime we can calculate for each patch which materials will be visible and which won’t in a pre-processing step. Later at runtime, only those passes are rendered, which really contribute to the final image.


Another important optimization is to reduce the number of patches which need to be rendered at all. This is done in three steps. First a rectangle which covers the projection of the viewing frustum onto the ground plane is calculated. All patches outside that rectangle will surely not be visible. All remaining patches are culled against the viewing frustum. To do this we clip the patches’ bounding boxes against all six sides of the viewing frustum. All remaining patches are guaranteed to lie at least partially inside the camera’s visible area. Nevertheless, not all of these remaining patches will necessarily be visible, because some of them will probably be hidden from other patches (e.g. a mountain). To optimize this case we can finally use a PVS (Potentially Visible Sets) algorithm to further reduce the number of patches needed to be rendered.

另一重要的优化是:从根本上减少需要渲染的缀数量。这通过3个步骤来实现。首先计算一个包含了视见体在地形上的投影的矩形,该矩形外所有缀片为不可见。剩下的缀片通过视见体进行剔除。我们用视见体的六个面去剪裁缀片的包围盒。确保所有留下的缀片都至少有一部分位于摄像机的可见区域内部。但是,这不保证它们都可见,因为有些可能被其他缀片遮挡(如一座山)。为了继续优化,我们最终使用了PVSPotentially Visible Sets,潜在可见集合)算法来进一步减少需要渲染得缀片数量。

PVS [Air91, Tel91] is used to determine, at runtime, which patches can be seen from a given position and which are hidden by other objects (in our case also patches). Depending on the type of landscape and the viewers position a lot of patches can be removed this way. In Figure 7 the camera is placed in a valley and looks at a hill.

PVS[Air91, Tel91]被用于在运行时确定哪些缀片可见,哪些被其他物体(在此即其他缀片)遮挡。根据地形特征和观察点位置,可以移除许多缀片。在图7中,摄像机位于山谷而朝向一座山。







Figure 7a: Final Image


Figure 7b: Without PVS


Figure 7c: With PVS


Figure 7b shows that a lot of triangles are rendered which do not contribute to the final image, because they are hidden by the front triangles forming the hill. Figure 7c shows how PVS can successfully remove most of those triangles. The nice thing about PVS is that the cost of processing power is almost zero at runtime because most calculations are done offline when the terrain is designed.


In order to (pre-) calculate a PVS the area of interest is divided into smaller parts. In our case it is obvious to use the patches for those parts. For example a landscape consisting of 16×16 patches requires 16×16 cells on the ground plane (z=0). To allow the camera to move up and down, it is necessary to have several layers of such cells. Tests have shown that 32 layers in a range of three times the height of the landscape are enough for fine graded PVS usage.


One problem with PVS is the large amount of memory needed to store all the visibility data. In a landscape with 16×16 patches and 32 layers of PVS data we get 8192 PVS cells. For each cell we have to store which of all the 16×16 patches are visible from that cell. This means that we have to store more than two million values. Fortunately we only need to store one bit values (visible/not visible) and can save the PVS as a bit field which results in a 256Kbyte data file in this example case.




Figure 8: PVS from Top View. Camera sits in the valley in the middle of the green dots


Figure 8 shows an example image from the PVS calculation application where the camera is located in the center of the valley (black part in the middle of the green dots). All red dots resemble those patches, which are not visible from that location. Determining whether a patch is visible from a location is done by using an LOS (line of sight) algorithm which tracks a line from the viewer’s position to the patch’s position. If the line does not hit the landscape on its way to the patch then this patch is visible from that location.

8显示了PVS计算的一个例子。摄像机位于山谷中央(中间的黑色、绿点部分)。红点表示从摄像机点不可见的位置。判断一个缀片是否可见采用了LOSLine of sight,视线)算法。它从观察者所在位置跟踪一条线到缀片所在位置。如果该线在途中没有碰撞到地面,则该缀片可见。

To optimize memory requirements the renderer distinguishes between patches which are active (currently visible) and those which aren’t. Only those patches which are currently active are fully resident in memory. The memory footprint of inactive patches is rather low (about 200 bytes per patch).



Categories: 未分类
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: