Real-Time Rendering——16.5 Simplification简单化

Mesh simplification, also known as data reduction or decimation, is the process of taking a detailed model and reducing its triangle count while attempting to preserve its appearance. For real-time work this process is done to reduce the number of vertices stored and sent down the pipeline. This can be important in making the application scalable, as less powerful machines may need to display lower numbers of triangles. Model data may also be received with more tessellation than is necessary for a reasonable representation. Figure 16.16 gives a sense of how the number of stored triangles can be reduced by data reduction techniques.

网格简化,也称为数据缩减或抽取,是获取详细模型并减少其三角形数量,同时试图保留其外观的过程。对于实时工作,这个过程是为了减少存储和发送到流水线的顶点的数量。这对于应用程序的可伸缩性非常重要,因为功能较弱的机器可能需要显示较少数量的三角形。模型数据也可以用比合理表示所需更多的镶嵌来接收。图16.16给出了如何通过数据简化技术来减少存储三角形的数量。

Figure 16.16. In the upper left is a heightfield of Crater Lake rendered with 200,000 triangles. The upper right figure shows this model simplified down to 1000 triangles in a triangulated irregular network (TIN). The underlying simplified mesh is shown at the bottom. (Images courtesy of Michael Garland.)

图16.16。左上角是火山口湖的高地,由20万个三角形渲染而成。右上图显示了简化为不规则三角网(TIN)中1000个三角形的模型。底层的简化网格显示在底部。(图片由迈克尔·加兰提供。)

Luebke [1091, 1092] identifies three types of mesh simplification: static, dynamic,and view-dependent. Static simplification is the idea of creating separate level of detail (LOD) models before rendering begins, and the renderer chooses among these.This form is covered in Section 19.9. Offline simplification can also be useful for other tasks, such as providing coarse meshes for subdivision surfaces to refine [1006, 1007].Dynamic simplification gives a continuous spectrum of LOD models instead of a few discrete models, and so such methods are referred to as continuous level of detail (CLOD) algorithms. View-dependent techniques are meant for where the level of detail varies within the model. Specifically, terrain rendering is a case in which the nearby areas in view need detailed representation while those in the distance are at a lower level of detail. These two types of simplification are discussed in this section.

Luebke [1091,1092]确定了三种类型的网格简化:静态、动态和视图相关。静态简化的思想是在渲染开始之前创建单独的细节层次(LOD)模型,渲染器在这些模型中进行选择。该表格包含在第19.9节中。离线简化也可以用于其他任务,例如为细分曲面提供粗网格以进行细化[1006,1007]。动态简化给出了一系列连续的LOD模型,而不是一些离散的模型,因此这种方法被称为连续细节层次(CLOD)算法。视图相关技术适用于模型中细节层次变化的情况。具体来说,地形渲染是这样一种情况,即视图中的附近区域需要详细的表示,而远处的区域则需要较低的细节级别。这两种类型的简化将在本节中讨论。

16.5.1 Dynamic Simplification动态简化

One method of reducing the triangle count is to use an edge collapse operation, where an edge is removed by moving its two vertices to coincide. See Figure 16.17 for an example of this operation in action. For a solid model, an edge collapse removes a total of two triangles, three edges, and one vertex. So, a closed model with 3000 triangles would have 1500 edge collapses applied to it to reduce it to zero faces. The rule of thumb is that a closed triangle mesh with v vertices has about 2v faces and 3v edges. This rule can be derived using the Euler-Poincar´e formula that f − e + v = 2 for a solid’s surface (Section 16.4.3).

减少三角形数量的一种方法是使用边折叠操作,通过移动两个顶点使其重合来移除边。参见图16.17中的操作实例。对于实体模型,边塌陷总共会删除两个三角形、三条边和一个顶点。因此,具有3000个三角形的闭合模型将应用1500次边塌陷,以将其减少到零个面。经验法则是,具有v个顶点的闭合三角形网格具有大约2v个面和3v个边。该规则可通过欧拉-庞加莱公式推导得出,即固体表面的f − e + v = 2(第16.4.3节)。

Figure 16.17. On the left is the figure before the uv edge collapse occurs; the right figure shows point u collapsed into point v, thereby removing triangles A and B and edge uv. 

图16.17。左边是uv边塌陷发生前的图;右图显示了点u折叠成点v,从而移除了三角形A和B以及边uv。

The edge collapse process is reversible. By storing the edge collapses in order,we can start with the simplified model and reconstruct the complex model from it.This characteristic can be useful for network transmission of models, in that the edgecollapsed version of the database can be sent in an efficiently compressed form and progressively built up and displayed as the model is received [768, 1751]. Because of this feature, this simplification process is often referred to as view-independent progressive meshing (VIPM).

边缘塌陷过程是可逆的。通过按顺序存储边折叠,我们可以从简化的模型开始,并从中重建复杂的模型。该特征对于模型的网络传输是有用的,因为数据库的边折叠版本可以以有效压缩的形式发送,并且随着模型被接收而逐渐建立和显示[768,1751]。由于这一特点,这一简化过程通常被称为视图独立渐进网格(VIPM)。

In Figure 16.17, u was collapsed into the location of v, but v could have been collapsed into u. A simplification system limited to just these two possibilities is using a subset placement strategy. An advantage of this strategy is that, if we limit the possibilities, we may implicitly encode the choice made [516, 768]. This strategy is faster because fewer possibilities need to be evaluated, but it also can yield lowerquality approximations because a smaller solution space is examined.

在图16.17中,u被折叠到v的位置,但是v也可以被折叠到u。一个简化系统只限于这两种可能性,它使用一个子集放置策略。这种策略的一个优点是,如果我们限制可能性,我们可以隐含地编码所做的选择[516,768]。这种策略更快,因为需要评估的可能性更少,但它也可以产生更低质量的近似,因为检查的解空间更小。

When using an optimal placement strategy, we examine a wider range of possibilities.Instead of collapsing one vertex into another, both vertices for an edge are contracted to a new location. Hoppe [768] examines the case in which u and v both move to some location on the edge joining them. He notes that to improve compression of the final data representation, the search can be limited to checking the midpoint. Garland and Heckbert [516] go further, solving a quadratic equation to find an optimal position, one that may be located off of the edge. The advantage of optimal placement strategies is that they tend to give higher-quality meshes. The disadvantages are extra processing, code, and memory for recording this wider range of possible placements.

当使用最佳放置策略时,我们会检查更广泛的可能性。一条边的两个顶点都收缩到一个新位置,而不是将一个顶点折叠到另一个顶点。Hoppe [768]研究了u和v都移动到连接它们的边上的某个位置的情况。他指出,为了改进最终数据表示的压缩,可以将搜索限制在检查中点。Garland和Heckbert [516]走得更远,通过解二次方程找到一个最佳位置,该位置可能位于边缘之外。最佳放置策略的优点是它们倾向于给出更高质量的网格。缺点是需要额外的处理、代码和内存来记录更大范围的可能位置。

To determine the best point placement, we perform an analysis on the local neighborhood.This locality is an important and useful feature for several reasons. If the cost of an edge collapse depends on just a few local variables (e.g., edge length and face normals near the edge), the cost function is easy to compute, and each collapse affects only a few of its neighbors. For example, say a model has 3000 possible edge collapses that are computed at the start. The edge collapse with the lowest cost-function value is performed. Because it influences only a few nearby triangles and their edges, only those edge collapse possibilities whose cost functions are affected by these changes need to be recomputed (say, 10 instead of 3000), and the list requires only a minor bit of resorting. Because an edge-collapse affects only a few other edge-collapse cost values, a good choice for maintaining this list of cost values is a heap or other priority queue [1649].

为了确定最佳的点放置,我们对局部邻域进行分析。由于几个原因,这个位置是一个重要且有用的特性。如果边塌陷的成本仅取决于几个局部变量(例如,边长和边附近的面法线),则成本函数很容易计算,并且每个塌陷仅影响它的几个邻居。例如,假设一个模型有3000个可能的边折叠,这些折叠是在开始时计算的。执行具有最低成本函数值的边折叠。因为它只影响几个附近的三角形和它们的边,所以只有那些成本函数受这些变化影响的边折叠可能性需要重新计算(比如说,10个而不是3000个),并且列表只需要少量的重新排序。因为边折叠只影响少数其他边折叠成本值,所以维护成本值列表的一个好选择是堆或其他优先级队列[1649]。

Some contractions must be avoided regardless of cost. See an example in Figure 16.18. These can be detected by checking whether a neighboring triangle flips its normal direction due to a collapse.

有些宫缩是必须避免的,无论代价如何。参见图16.18中的例子。这些可以通过检查相邻三角形是否由于折叠而翻转其法线方向来检测。

Figure 16.18. Example of a bad collapse. On the left is a mesh before collapsing vertex u into v. On the right is the mesh after the collapse, showing how edges now cross. 

图16.18。严重崩溃的例子。左侧是将顶点u折叠为v之前的网格,右侧是折叠之后的网格,显示了边现在如何交叉。

The collapse operation itself is an edit of the model’s database. Data structures for storing these collapses are well documented [481, 770, 1196, 1726]. Each edge collapse is analyzed with a cost function, and the one with the smallest cost value is performed next. The best cost function can and will vary with the type of model and other factors [1092]. Depending on the problem being solved, the cost function may make trade-offs among speed, quality, robustness, and simplicity. It may also be tailored to maintain surface boundaries, material locations, lighting effect, symmetry along an axis, texture placement, volume, or other constraints.

折叠操作本身是对模型数据库的编辑。用于存储这些折叠的数据结构被很好地记录[481,770,1196,1726]。使用成本函数分析每个边折叠,然后执行具有最小成本值的边折叠。最佳成本函数可以并且将随着模型类型和其他因素而变化[1092]。根据所解决的问题,成本函数可以在速度、质量、健壮性和简单性之间进行权衡。它还可以被定制以保持表面边界、材料位置、照明效果、沿轴线的对称性、纹理位置、体积或其他约束。

We will present Garland and Heckbert’s quadric error metric (QEM) cost function [515, 516] in order to give a sense of how such functions work. This function is of general use in a large number of situations. In contrast, in earlier research Garland and Heckbert [514] found using the Hausdorff distance best for terrain simplification,and others have borne this out [1496]. This function is simply the longest distance a vertex in the simplified mesh is from the original mesh. Figure 16.16 shows a result from using this metric.

我们将介绍加兰和赫克伯特的二次误差度量(QEM)成本函数[515,516],以便给出这样的函数如何工作的感觉。这个函数在很多情况下都是通用的。相比之下,在早期研究中,Garland和Heckbert [514]发现使用Hausdorff距离最适合地形简化,其他人也证实了这一点[1496]。这个函数就是简化网格中的顶点到原始网格的最长距离。图16.16显示了使用这一指标的结果。

For a given vertex there is a set of triangles that share it, and each triangle has a plane equation associated with it. The QEM cost function for moving a vertex is the sum of the squared distances between each of these planes and the new location. More formally,

对于一个给定的顶点,有一组共享它的三角形,每个三角形都有一个与之相关的平面方程。移动折点的QEM成本函数是每个平面与新位置之间距离的平方之和。更正式地说,

is the cost function for new location v and m planes, where ni is the plane i’s normal and di its offset from the origin. 

是新位置v和m平面的成本函数,其中ni是平面i的法线 并且di是它相对于原点的偏移量。

An example of two possible contractions for the same edge is shown in Figure 16.19.Say the cube is two units wide. The cost function for collapsing e into c (e → c) will be 0, because the point e does not move off of the planes it shares when it goes to c. The cost function for c → e will be 1, because c moves away from the plane of the right face of the cube by a squared distance of 1. Because it has a lower cost, the e → c collapse would be preferred over c → e.

图16.19给出了同一条边的两种可能收缩的例子。假设立方体的宽度是两个单位。将e折叠成c (e → c)的成本函数将为0,因为点e在到达c时不会离开它共享的平面。c → e的成本函数将为1,因为c离开立方体右侧面的平面的距离为1的平方。因为成本较低,e → c折叠比c → e折叠更可取。

Figure 16.19. The left figure shows a cube with an extra point along one edge. The middle figure shows what happens if this point e is collapsed to corner c. The right figure shows c collapsed to e. 

图16.19。左图显示了一个边上有一个额外点的立方体。中间的图显示了如果点e折叠到角c会发生什么。右图显示了c折叠到e。

This cost function can be modified in various ways. Imagine two triangles that share an edge that form a sharp edge, e.g., they are part of a fish’s fin or turbine blade. The cost function for collapsing a vertex on this edge is low, because a point sliding along one triangle does not move far from the other triangle’s plane. The basic function’s cost value is related to the volume change of removing the feature, but is not a good indicator of its visual importance. One way to maintain an edge with a sharp crease is to add an extra plane that includes the edge and has a normal that is the average of the two triangle normals. Now vertices that move far from this edge will have a higher cost function [517]. A variation is to weight the cost function by the change in the areas of the triangles.

这个成本函数可以用各种方式修改。想象两个三角形共享一条边,形成一条锐边,例如,它们是鱼鳍或涡轮叶片的一部分。折叠该边上的顶点的成本函数很低,因为沿着一个三角形滑动的点不会远离另一个三角形的平面。基本功能的成本值与移除特征的体积变化有关,但不是其视觉重要性的良好指标。保持边缘有明显折痕的一种方法是添加一个额外的平面,该平面包括边缘并具有两个三角形法线的平均值。现在,远离该边的顶点将具有更高的成本函数[517]。一种变化是通过三角形面积的变化来加权成本函数。

Another type of extension is to use a cost function based on maintaining other surface features. For example, the crease and boundary edges of a model are important in portraying it, so these should be made less likely to be modified. See Figure 16.20.Other surface features worth preserving are locations where there are material changes, texture map edges, and color-per-vertex changes [772]. See Figure 16.21.

另一种类型的扩展是使用基于保持其他表面特征的成本函数。例如,模型的折痕和边界边在描绘它时很重要,因此应该尽量不要修改它们。见图16.20。其他值得保留的表面特征是材料变化、纹理贴图边缘和逐顶点颜色变化的位置[772]。参见图16.21。

Figure 16.20. Mesh simplification. Upper left shows the original mesh of 13,546 faces, upper right is simplified to 1,000 faces, lower left to 500 faces, lower right to 150 faces [770]. (Images c 1996 Microsoft. All rights reserved.) 

图16.20。网格简化。左上显示了13,546个面的原始网格,右上简化为1,000个面,左下简化为500个面,右下简化为150个面[770]。(图片c 1996微软。保留所有权利。)

Figure 16.21. Mesh simplification. Top row: with mesh and simple gray material. Bottom row:with textures. From left to right: the models contain 51,123, 6,389, and 1,596 triangles. The texture on the model is maintained as possible, though some distortion creeps in as the triangle count falls.(Images c 2016 Microsoft. All rights reserved.)

图16.21。网格简化。顶行:带有网格和简单的灰色材质。底行:带纹理。从左到右:模型包含51,123, 6,389和1,596个三角形。模型上的纹理被尽可能地保持,尽管随着三角形数量的减少会有一些扭曲。(图片c 2016微软。保留所有权利。)

One serious problem that occurs with most simplification algorithms is that textures often deviate in a noticeable way from their original appearance [1092]. As edges are collapsed, the underlying mapping of the texture to the surface can become distorted. Also, texture coordinate values can match at boundaries but belong to different regions where the texture is applied, e.g., along a central edge where a model is mirrored. Caillaud et al. [220] survey a variety of previous approaches and present their own algorithm that handles texture seams.

大多数简化算法存在的一个严重问题是,纹理经常明显偏离其原始外观[1092]。随着边的塌陷,纹理到曲面的基本映射可能会发生扭曲。此外,纹理坐标值可以在边界处匹配,但是属于应用纹理的不同区域,例如,沿着模型被镜像的中央边缘。Caillaud等人[220]调查了各种以前的方法,并提出了他们自己的处理纹理接缝的算法。

Speed can be another concern. In systems where users create their own content,such as in a CAD system, level of detail models need to be created on the fly. Performing simplification using the GPU has met with some success [1008]. Another approach is to use a simpler simplification algorithm, such as vertex clustering [1088, 1511]. The core idea of this approach is to overlay the model with a three-dimensional voxel grid or similar structure. Any vertices in a voxel are moved to a “best” vertex location for that cell. Doing so may eliminate some triangles, when two or more of each triangle’s vertices land in the same location, making it degenerate. This algorithm is robust, the connectivity of the mesh is not needed, and separate meshes can easily be aggregated into one.However, the basic vertex clustering algorithm rarely gives as good a result as a full QEM approach. Willmott [1890] discusses how his team made this clustering approach work in a robust and efficient manner for the user-created content in the game Spore.

 速度可能是另一个问题。在用户创建他们自己的内容的系统中,例如在CAD系统中,需要动态地创建细节层次的模型。使用GPU执行简化已经取得了一些成功[1008]。另一种方法是使用更简单的简化算法,如顶点聚类[1088,1511]。这种方法的核心思想是用三维体素网格或类似结构覆盖模型。体素中的任何顶点都被移动到该单元的“最佳”顶点位置。这样做可能会消除一些三角形,当每个三角形的两个或多个顶点位于同一位置时,会使其退化。该算法是鲁棒的,不需要网格的连通性,并且分离的网格可以很容易地聚合成一个。然而,基本的顶点聚类算法很少给出像全QEM方法那样好的结果。Willmott [1890]讨论了他的团队如何使这种聚类方法以一种健壮和有效的方式为游戏孢子中用户创建的内容工作。

Turning a surface’s original geometry into a normal map for bump mapping is an idea related to simplification. Small features such as buttons or wrinkles can be represented by a texture with little loss in fidelity. Sander et al. [1540] discuss previous work in this area and provide a solution. Such algorithms are commonly used in developing models for interactive applications, with a high-quality model baked into a textured representation [59].

将曲面的原始几何体转换为法线贴图以进行凹凸贴图是一种与简化相关的想法。纽扣或褶皱等小特征可以用保真度损失很小的纹理来表示。Sander等人[1540]讨论了这一领域以前的工作,并提供了一个解决方案。这种算法通常用于开发交互式应用的模型,将高质量的模型烘焙成纹理表示[59]。

Simplification techniques can produce a large number of level of detail (LOD) models from a single complex model. A problem found in using LOD models is that the transition can sometimes be seen if one model instantly replaces another between one frame and the next [508]. This problem is called “popping.” One solution is to use geomorphs [768] to increase or decrease the level of detail. Since we know how the vertices in the more complex model map to the simple model, it is possible to create a smooth transition. See Section 19.9.1 for more details.

简化技术可以从单个复杂模型生成大量细节层次(LOD)模型。使用LOD模型时发现的一个问题是,如果一个模型在一帧和下一帧之间立即替换另一个模型,则有时可以看到过渡[508]。这个问题叫做“爆音”一种解决方案是使用地貌[768]来增加或减少细节层次。因为我们知道更复杂模型中的顶点如何映射到简单模型,所以创建平滑过渡是可能的。更多详情见第19.9.1节。

One advantage of using view-independent progressive meshing is that a single vertex buffer can be created once and shared among copies of the same model at different levels of detail [1726]. However, under the basic scheme, a separate index buffer needs to be made for each copy. Another problem is efficiency. Because the order of collapses determines the triangle display order, vertex cache coherency is poor.Forsyth [481] discusses several practical solutions to improve efficiency when forming and sharing index buffers.

使用独立于视图的渐进网格的一个优点是,单个顶点缓冲区可以一次性创建,并在不同细节层次的相同模型副本之间共享[1726]。但是,在基本方案下,需要为每个副本创建一个单独的索引缓冲区。另一个问题是效率。因为折叠的顺序决定了三角形的显示顺序,所以顶点缓存的一致性很差。Forsyth [481]讨论了在形成和共享索引缓冲区时提高效率的几种实际解决方案。

Mesh reduction techniques can be useful, but fully automated systems are not a panacea. The problem of maintaining symmetry is shown in Figure 16.22. A talented model maker can create low-triangle-count objects that are better in quality than those generated by automated procedures. For example, the eyes and mouth are the most important part of the face. A naive algorithm will smooth these away as inconsequential. Retopology is a process where edges are added to a model to keep various features separate when modeling, smoothing, or simplification techniques are applied. Simplification-related algorithms continue to be developed and automated as possible.

网格简化技术可能是有用的,但全自动系统不是万能的。保持对称的问题如图16.22所示。一个有天赋的模型制作者可以创造出比自动化程序生成的物体质量更好的低三角形数的物体。例如,眼睛和嘴巴是面部最重要的部分。一个简单的算法会把这些当作无关紧要的事情处理掉。在应用建模、平滑或简化技术时,重新拓扑是将边添加到模型中以保持各种特征分离的过程。与简化相关的算法仍在继续开发,并尽可能实现自动化。

Figure 16.22. Symmetry problem. The cylinder on the left has 10 flat faces (including top and bottom). The middle cylinder has 9 flat faces after 1 face is eliminated by automatic reduction. The right cylinder has 9 flat faces after being regenerated by the modeler’s faceter.

图16.22。对称问题。左边的圆柱体有10个平面(包括顶部和底部)。在通过自动缩减消除1个面后,中间圆柱体有9个平面。由建模者的刻面器重新生成后,右圆柱体有9个平面。

猜你喜欢

转载自blog.csdn.net/m0_37609239/article/details/127203058
今日推荐