Home > 未分类 > Terrain Geomorphing in the Vertex Shader 译文(2)

Terrain Geomorphing in the Vertex Shader 译文(2)

Terrain Geomorphing in the Vertex Shader(2)

In order to create the lightmap, the normals for each point in the heightmap have to be calculated first. This can be done by creating two 3d-vectors, each pointing from the current height value to the neighboring height positions. Calculating the cross product of these two vectors gives the current normal vector, which can be used to calculate a diffuse lighting value. To get better results, including static shadows, advanced terrain data editing software such as Wilbur [Slay95] or Corel Bryce should be used.

为了建立光照图,需要先计算高度图每一点的法向量。建立23d向量,分别从当前高度指向邻近的2个位置。计算它们的叉积,得到当前法向量,以用于计算散射光。为了得到更好的结果如静态阴影等,则需要使用高级地形编辑软件,如Wilbur[Slay95]Corel Bryce等。

The heightmap is split into 17*17 values sized parts called patches. The borders of neighboring patches overlap by one value (e.g. value column 16 is shared by patch 0/0 and patch 1/0). Geometry for each patch is created at runtime as a single indexed triangle strip. A patch can create geometry in 5 different tessellation levels ranging from full geometry (2*16*16 triangles) down to a single flat quad (2 triangles, see Figure 2) for illustration. Where needed degenerate triangles are inserted to connect the sub-strips into one large strip [Eva96].

高度图被划分为17*17单位大小的小块,称为缀片。相邻缀片的边界有1单位的重叠(如第16列被缀片0/00/1共用)。每个缀片的几何构造在运行时建立为一个有索引的三角形带。缀片能够在5个不同的镶嵌水平上建立几何构造,从全几何构造(2*16*16个三角形)到一个四边平板(2个三角形,图2)。在需要的位置插入退化三角形,连接三角形分带成为一个大的整带。

In order to connect two strips the last vertex of the first strip, and the first vertex of the second strip have to be inserted twice. The result is triangles which connect the two strips in the form of a line and are therefore invisible (unless rendered in wireframe mode). The advantage of connecting small strips to one larger strip is that less API calls are needed to draw the patch. Since index vertices are used and a lot of today’s graphics hardware can recognize and automatically remove degenerate triangles the rendering and bandwidth overhead of the degenerate triangles is very low.

连接两个三角形带时,前一个三角带的最后一个顶点和后一个三角带的第一个顶点需要插入2次。所产生的连接三角形实际上是线段的形式因此不可见(除非使用Wireframe网格渲染模式)。连接小三角形带变成大带的一个好处是减少绘制缀片的API调用。由于使用了索引顶点,而当前许多图形硬件都能够识别并自动移除退化三角形,所以退化三角形的渲染和带宽开销都非常小。

2

Figure 2: Same patch tessellated in different levels ranging from full geometry (level 0) to a single quad (level 4)

Calculating the Tessellation Level of a Patch

计算缀片的镶嵌等级

Before a frame is rendered each patch is checked for its necessary tessellation level. It’s easy to see from Figure 2 that the error of each patch increases as the number of vertices is reduced. In a pre-processing step, for each level the position of the vertex with the largest error (the one which has the largest distance to the corresponding correct position, later on called "maxerror vertex") is determined and saved together with the correct position.

渲染帧之前,首先检查每个缀片所需的镶嵌级别。从图2中可以看出,随着顶点数的减少,每个缀片的误差都增大了。在预处理阶段,计算每个级别具有最大误差的顶点位置(与对应的正确位置距离最大,后面称之为“最大误差顶点 maxerror vertex”)并与正确位置保存在一起。

When determining the level at which to render, all saved "maxerror vertices" are projected into the scene and the resulting errors calculated. Finally the level with the largest error below an application defined error bound is chosen. In order to create a specific level’s geometry only the "necessary" vertices are written into the buffers. For example to create level 0 all vertices are used. Level 1 leaves out every second vertex reducing the triangle count by a quarter. Level 2 uses only every fourth vertex and so on.

在决定渲染级别时,所有保存的最大误差顶点被投影到场景上,计算产生的误差。最后,选择小于程序定义的误差阈值的最大误差级别。为了建立一个特定的几何级别,只将“必要”的顶点注入缓存。例如,建立级别0,所有顶点都被用到,而级别1消去了所有偶数顶点,三角形数量下降到1/4。第二级别只是用了所有4整数倍的顶点,等等。

Connecting Patches

缀片间连接

If two neighboring patches with different tessellation levels were simply rendered one next to the other, gaps would occur (imagine drawing any of the patches in Figure 2 next to any other). Another problem are t-vertices, which occur when a vertex is positioned on the edge of an other triangle. Because of rounding errors, that vertex will not be exactly on the edge of the neighboring triangle and small gaps only a few pixels in size can become visible. Even worse, when moving the camera these gaps can emerge and disappear every frame which leads to a very annoying flickering effect.

对于具有不同的镶嵌级别的两个相邻的缀片,如果简单地将它们绘制在一起,则会发生空缺(设想将图2中的任2个缀片绘制到一起)。另一个问题是T-顶点,即一个顶点位于另一个三角形的边上的情况。由于误差的存在,该顶点将不会精确地位绘制邻接三角形的边上,因而发生数个像素大小的可见小空缺。更坏的情况是,当移动摄像机时这些空缺可能一会显现一会消失,产生恼人的闪变效应。

To solve both problems it is obvious that each patch must know its neighbors’ tessellation levels. To do so, all tessellation levels are calculated first without creating the resulting geometry and then each patch is informed about its neighbors’ levels. After that each patch updates its geometry as necessary. Geometry updating has to be done only if the inner level or any of the neighbors’ levels changed. To close gaps and prevent t-vertices between patches a border of "adapting triangles" is created which connects the differently sized triangles (see Figure 3). It is obvious that only one of two neighboring patches has to adapt to the other. As we will see later on in the section "Geomorphing", it is necessary for the patch with the finer tessellation level (having more geometry) to adapt.

为了解决这些问题,显然每个缀片都需要知道其邻接缀片的镶嵌级别。因此,所有的镶嵌级别在建立几何之前首先计算,通知每个缀片其邻居的级别。随后每个缀片根据需要更新它的几何构型。几何构型的更新仅当任一邻近缀片的级别发生改变时。为了闭合缺口和防止t-顶点,需要建立一列“适配三角形”,以连接不同尺寸的三角形(如图3)。显然,两个邻接缀片中只有一个需要更新,以适应另一个。正如我们即将在“几何变形”中看到的,需要具有较好级别(更复杂几何构型)的缀片去适应。

 

3a

 

3b

Figure 3a: T-vertices at the border of two patches

 

Figure 3b: T-vertices removed

 

Figure 3a shows the typical case where T-vertices occur. In Figure 3b those "adapting triangles" at the left side of the right patch are created to avoid T-vertices. Although these triangles look like being a good candidate for being created by using triangle fans, they are also implemented using strips, since fans cannot be combined into bigger fans as can be achieved with strips.

3a显示典型的T-顶点的产生。在图3b中,右边缀片的左侧建立了“适配三角形”以消除了T-顶点。虽然这些三角形看似能够使用三角形扇良好地建立起来,但实际上它们是通过三角形带实现的,因为小的三角形扇不能组合成大扇,而三角带可以。

<-未完待续->

Advertisements
Categories: 未分类
  1. 一名研一学生
    2011年04月21日 at 9:25 am

    你好:
    你对这篇论文的翻译非常好,可我只能看到译文(4),不知剩下的你翻译了没有,我非常希望能看到。如果有的话,希望可以发到我的邮箱里,谢谢!

  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: