Quick viewing(Text Mode)

Advanced 3D Computer Graphics

Advanced 3D Computer Graphics

Advanced 3D

Prof. Dr. Renato Pajarola Information & Computer University of California Irvine ICS 186b, October 20. 2000

1 Polygonal Meshes Polygonal meshes are (still) the most common representations of 3D for interactive render- ing. Even complicated smooth surfaces are often approximated as a collection of planar . Also more complicated modeling primitives such as and curved surfaces, or solid modeling constructions used in advanced modeling applications, or rendering systems such as ray-tracing often have to be tessellated for interactive rendering or further processing. Furthermore, today’s graphics hardware is optimized for fast processing of meshes. Handling triangle meshes is sufficient in the sense that planar polygons can easily be triangulated to form a collection of covering exactly the same planar region. If not specified otherwise, we refer to triangle meshes in this section. 1.1 Mesh Representation

1.1.1 Mesh properties To talk about triangle meshes it is important to define the following few terms that are very often used, and that characterize a triangle mesh. Incidence is defined between vertices, edges, and faces. All faces sharing an are incident to that edge, all faces sharing a vertex are incident to that ver- tex, all edges sharing a vertex are incident to that vertex, and vice versa. Definition 1.1 The boundary or boundaries of a mesh is defined by the set of edges that have only one incident . Definition 1.2 A mesh is called if the surrounding of every on the is homeo- morphic, or topologically equivalent to a disk, or half-disk if the point is on the boundary. Definition 1.3 The genus of a closed manifold surface (with no boundaries) is defined as the number of topologically different closed paths (cycles, or loops) on the surface that cannot be contracted along the surface to a singular point. Sometimes this is also referred to as the number of handles of the . Definition 1.4 A mesh is called orientable if a consistent orientation of the vertices of the planar faces exists such that the two vertices of each edge are ordered oppositely for the incident faces. A polygonal mesh is also often called matching or conforming if every edge has exactly two incident faces, or one if the edge is on the boundary. A mesh is not matching if there exist so called T-vertices that lie exactly on an edge but are not an endpoint of that edge. Even if T-vertices are manifold with respect to the surface , they are regarded as a singularity since they form a boundary of col- linear edges. Non-matching triangulations can also create rendering artifacts when using vertex nor- mals for properties. Most of the time a triangulation is assumed to be matching.

Mesh Representation

Boundary edges Non-manifold vertex Non-manifold edge

Non-orientable mesh Shape of genus 1 The Euler formula of planar graphs with V vertices, E edges, F faces, and C connected components is given by VE– +1F = + C . For planar triangulations – one component, orientable, manifold, matching – where each edge is shared by two faces, and each face has three edges 2E = 3F one can get the relation for vertices and faces as V –22F = , thus there are roughly twice as many faces as vertices in a typical triangular mesh (and three times as many edges as vertices). 1.1.2 Indexed face list The indexed face list is a very simple structure to represent a polygonal mesh M consisting of n ver- tices V = {v1, v2, …, vn} and m faces F = {f1, f2, …, fm}. Since each k-sided planar face can uniquely be defined by its k vertices (i.e. ordered counter clockwise), a list of k indices into the list of vertices can be used to represent one face. For triangle meshes an indexed face list consists of an array of ver- tices each having three coordinates, and an array of faces each having three indices into the vertex array.

faces vertices xyz f1 v1 vk

vi v f f vi vj vk i

vk vj

vj

Since triangle meshes have about m = 2·n faces, each triangle has to index 3 vertices, and n vertices can be indexed by log2n bits, the indexed triangle list requires 6·n·log2n bits to represent the inci-

2

Mesh Representation dence relations, or connectivity of the triangle mesh. Additionally, 3·n·q bits are required to store the 3D vertex coordinates with fixed resolution of q bits, this is also called the geometry information. 1.1.3 Half-edge data structure While representing the mesh structure exactly, the indexed face list does not provide an efficient way of traversing the mesh, or accessing adjacent elements through incidence relations. Given a vertex, it is very time consuming to find all incident faces or edges, or given a triangle it is complicated to retrieve its incident triangle on a particular edge. Mesh traversal and neighbor finding are very important operations on polygonal meshes and efficiently supported by the half-edge data structure. The half-edge data structure represents a polygonal mesh as a list of vertices, and a list of directed half-edges, each k-sided planar face is represented by k consecutive entries in the half-edges array. Each entry h[i] in the half-edge array has to following fields: h[i].s - index of start vertex of the half-edge h[i]. - index of reverse half-edge of adjacent face incident upon this edge h[i].n - index of the half-edge that follows in counter clockwise ordering h[i].p - index of the previous half-edge

h.r

h.n h h.s h.p

For triangular meshes with all 3-sided faces, the next and previous pointers h.n and h.p can be omit- ted, since organizing the 3 half-edges of each face consecutively in the array allows for simple mod- ulo arithmetic to access next and previous edges (but we will keep the notation): h[i].n = (i + 1) MOD 3 + 3 (i DIV 3) h[i].p = (i + 2) MOD 3 + 3 (i DIV 3) Faces are also easily indexed, edge i belongs to face i DIV 3, and the first half-edge of face j is j · 3. Given such a half-edge data structure, most incidence relations can easily be accessed without searching all list elements. For simplicity we will abbreviate array indexing h[i].s by h.s in the fol- lowing examples. • vertices of and edge are given by h.s and h.n.s (note that using h.r.s will not work for edges on the boundary of the mesh!) • index of adjacent face upon h is given by h.r DIV 3 • rotating counter clockwise around the start vertex of h is performed by h = h.p.r • clockwise about start vertex is performed by h = h.r.n Operations accessing the reverse half-edge index must always be performed very carefully for meshes with boundaries, and special cases must handle boundary conditions. Building a half-edge data structure from an indexed face input list can also be done very efficiently as follows: 3 Mesh Representation

1. Copy or keep the vertex array. 2. Read the indexed faces list and initialize the half-edge triples per face with the correct start- ing vertices. 3. Read the indexed faces list again, and create an auxiliary edge list with 3 entries per face, however, each such entry consists of both endpoints of the edge and an index to the half- edge created in the previous step. The vertex indices of the two endpoints are stored with the smaller vertex index first, and the larger vertex index in the second field. 4. Order the auxiliary edge list lexicographically according to the two vertex indices of each entry. Thus shared edges between two faces will now be adjacent in the auxiliary , and the reverse half-edge information can be completed for every half-edge. Omitting the reverse information that can be recomputed when loading the data-structure, the half- edge structure needs exactly the same storage for representing a mesh as the indexed face list. If it includes the reverse information, a mesh with n vertices would require 6·n (log2n + log26n) bits on average. Doubly-connected edge list The doubly-connected edge list (DCL) often used in computational geometry and graph methods consists of three set of records: one for vertices, one for faces, and one for half-edges. Each vertex v stores its coordinates, and a pointer to an arbitrary half-edge that has v as its origin. Each face stores one pointer to a outside bounding half-edge (and a list of half-edge pointers to inner boundaries of holes). Each half-edge stores a pointer to its origin vertex, a pointer to its reverse (twin) edge, and a pointer to the face it bounds, as well as two pointers to the next and previous half-edges bounding the same face. The half-edge data structure is a simplified version of the DCL without vertex-to-edge and face-to- edge relations, and omitted face pointer per edge. Face to edge relations are rather captured by con- secutively ordering and grouping the half-edges that bound a particular face. Winged-edge list The winged-edge data structure, another commonly used graph or mesh representation, stores for each edge pointers to its endpoints, the two faces sharing the edge, and the four incident edges that bound the same faces. Each vertex has a pointer back to one incident edge, and each face also points to one bounding edge.

E4 V1 E5

F1 E1 E3 F2

E2 V2

4 Mesh Representation

1.1.4 Triangle strips Triangle strips are a more efficient representation of triangle meshes when using hardware acceler- ated rendering with limited fast and random access to vertex coordinates. Typically, the hardware of a graphics rendering pipeline can only hold a few vertices in high-speed registers, and must access others from standard memory on the graphics board or even from main memory of the computer. Triangle strips order the vertices data and triangle connectivity information such that reuse of vertex coordinates in registers is optimized. Triangle strips consist of a sequence of vertices of which every subsequence of 3 vertices defines a triangle. That means that the two last vertices of the previous triangle can be reused with one new vertex to form the next triangle. Thus two consecutive triangles always share an edge, and the order- ing of the vertices around the surface must alternate from one to the next triangle. The repre- sentation cost is 2 vertex indices to start a triangle strip, and 1 vertex index per triangle in the triangle strip, thus 2n · log2n + 2k · log2n bits if the mesh consists of k triangle strips. Every vertex is indexed at least twice in this representation. The strict rule of alternating vertex ordering, and that every subsequence of three vertices must define a valid triangle limit the use of basic triangle strips – stripification may produce large number of fairly short triangle strips. Using generalized triangle strips that can change the alternating order rule using additional modifiers, allows to encode fans and produce longer triangle strips. Neverthe- less, each vertex is still referenced at least twice in a triangle mesh.

4 6 4 2 3

8 3 5 7 12 5 1 9 10 6 11 Generalized triangle strip using: R=restart, O=replace oldest, M=replace middle R1,O2,O3,O4,M5,M6 12 or using swap operations: 1,2,3,4,swap,5,swap,6 Basic triangle strip: 1,2,3,4,5,6,7,8,9,10,11,12

Even using the restricted basic triangle strips, the swap effects of generalized triangle strips can be simulated by repeating vertices. The triangle-fan example from the figure can be represented as a tri- strip 1,2,3,2,4,2,5,6 with an additional vertex repetition per swap operation. Therefore, because we can have at most one swap operation per triangle, the representation requires at most 2 vertex indices per triangle, and 2 vertices to start a triangle strip, thus 4n · log2n + 2k · log2n bits for k trian- gle strips. Thus with vertex repetition to simulate swap operations each vertex is referenced at least twice, and at most 4 times (if not part of the start triangle of a triangle strip). The sliver triangles cre- ated by vertex repetition, triangles of the form s,t,s, are usually not a problem for hardware acceler- ated rendering.

5 Mesh Simplification1

1.2 Mesh Simplification1

1.2.1 Due to high-resolution devices, high-precision surface modeling and tesselation, and large scale and detailed surface extraction from remote sensing and 3D , the size of polygo- nal meshes may easily exceed real-time rendering capacity in common . Given an input mesh M, mesh simplification aims at significantly reducing the number of geometric primitives used to render the simplified mesh M’ with |M’| < |M| without sacrificing intolerable geometric or visual accuracy. Simplification may not only introduce an approximation error, but may also reduce visual artifacts. (Suggested reading: [HG97,CMS98,LT99]) The simplification, or -of-detail (LOD) can depend on a variety of parameters such as: • distance to viewer (zoom factor) • angular distance from view-direction • desired frame redraw rate • file size • geometric approximation tolerance threshold • tolerated deviation in screen projection

1.2.2 Polyline simplification example In a simple 2D example we can study the problem of finding the optimal approximation of a of size n using only k < n line segments, and the error is calculated as the maximal minimum distance between the original and the simplified polygon. For this problem it has been shown that a simple divide and conquer strategy, starting with one initial -segment connecting the ends of the given polygon, provides the best compromise between time cost and optimization.

6 Mesh Simplification1

input polygon initial approximation 1st subdivision 2nd subdivision 3rd subdivision final approximation This technique of starting with an initial crude approximation, and increasing the number of geomet- ric elements successively is also referred to as a refinement method rather than a simplification method. 1.2.3 Approximation error A very important for approximations is the error metric used to quantify the approximation accuracy. There are two main categories of error metrics for mesh simplification: • Object-space error metrics compute the approximation error based on distance functions on the 3D mesh geometry. • Image-space error metrics calculate the approximation error based on the deviation of the rendered .

image-space error metrics object-space error metrics

image 3D space

It also useful to review the L2 and L∞ norms in this context that are commonly used to specify the () () approximation error. The L2 norm is X 2 = ∑ dx , and L∞ refers to X ∞ = MAXxX∈ dx using the distance function d(x). xX∈

Geometric approximation is often computed as a L2 or L∞ norm of a distance metric in 3D (object- space), or possibly also in the 2D view-projection (image-space). Various distance metrics produc- ing different results can be used such as: • Euclidean distance of removed vertices to simplified mesh (see also Hausdorff distance, and Quadric error metric below) • change in silhouette edges

7 Mesh Simplification1

• difference in surface normals • length of edges, size of triangles The approximation error can also be computed based on the visual difference between the rendered images of the original mesh and the simplified one (image-space). Distance and image difference functions include: • difference in (all) • covered on screen Hausdorff distance The Hausdorff distance between two A and B , using the distance function dab(), for aA∈ and bB∈ is defined as: (), ()()(), , ()(), HAB = max maxaA∈ minbB∈ dab maxbB∈ minaA∈ dba Note that this maximal distance between two shapes requires maximizing the minimal distance over both shapes. Furthermore, the maximal distance can occur anywhere on the shape.

B

A • Often, the Hausdorff distance is approximated only at the vertices of a given polygonal shape, since only the vertices may represent correct geometrical input, and the linear inter- polation in between them – the polygonal faces – is a planar approximation of a possibly smooth surface through the vertices. • This reduces the measurement to calculating distances from output points (the simplified surface) to planes (polygonal faces of the original data set). Quadric error metric The special case of calculating the distance of a point to a plane, or set of planes can efficiently be computed using matrix representations. (See also [GH97].) Given the plane parameters p= [] abcd,,, T with a2 ++b2 c2 = 1 and the point vxyz= (),,,1 , thus the parametric representation pT ⋅ v = 0 , the distance of point v to plane p is:

dvp(), = pT ⋅ v

()T ⋅ 2 ()T ⋅ ⋅ ()T ⋅ T ⋅⋅()T T ⋅⋅ And the squared distance is thus p v ===v p p v v pp v v K p v , with the quad-

a2 ab ac ad ba b2 bc bd ric K p = . ca cb c2 cd da db dc d2 The sum of squared distances of point v to a set of planes P is given by:

(), 2 ()T ⋅ 2 ()T ⋅ ()T ⋅ T ⋅⋅ T ⋅⋅ dvP ==∑ p v ∑ v p p v =∑ v K p v =v ∑ K p v pP∈ pP∈ pP∈ pP∈

8 Mesh Simplification1

Therefore, to represent the distance from a point to a set of planes, the plane quadrics Kp just have to be added, QP = ∑ K p , and the squared distance can be represented by matrix multiplication T ⋅⋅ pP∈ v QP v . • Only if P ∩ P = 0 , then QP()∪ P ⇔ Q + Q , otherwise planes {}pP∈ ∧ pP∈ will be 1 2 1 2 P1 P2 1 2 counted multiple times. 1.2.4 Simplification operations The basic idea is to reduce the number of vertices and faces to represent a given shape. Vertices of the simplified mesh do not necessarily have to be restricted to be a subset of the original input mesh, vertex positions can potentially be rearranged. Thus the most general simplification operation is to fix the number of vertices in the simplified mesh, optimize their position with respect to the input mesh, and re-triangulate the vertices to generate a piecewise linear surface that approximates the given polygonal input mesh. Vertex removal A simpler operation is to remove a vertex and re-triangulate the so created , and its dual opera- tion of inserting a vertex (in one triangle) and swapping a sequence of edges. Required information for the simplification is the vertex to be removed and a rule of re-triangulating the hole. The refine- ment is specified by the new vertex position, the triangle where to insert it, and the edges that have to be swapped to reconstruct the original mesh.

vertex removal

vertex insertion

edge swap

Triangle replacement A group of triangles M is replaced by a smaller group of triangles M’ with |M’| < |M|. Note that the boundary of both triangle sets has to be the same. This seemingly more complex simplification (and refinement) operation can be represented as a combination of vertex removals, vertex insertions, and edge swap operations. For this operation the set of triangles and vertices that are removed has to be specified as well as the newly inserted triangles and vertices.

9 Mesh Simplification1

triangle replacement

Edge collapse The edge collapse operation removes the two triangles from the mesh that share the collapsed edge, and distorts (stretches) all remaining triangles originally incident upon the endpoints of the collapsed edge. An edge collapse is specified by one edge, and the new vertex position of the collapsed edge. The dual operation vertex split inserts two new triangles between two specified edges (cut-edges) that share a vertex (split-vertex), and distorts all triangles incident upon the split-vertex. The vertex split can be specified by the split-vertex, the two cut-edges, and the new vertex positions.

edge collapse

vertex split

Vertex contraction Vertex contraction refers to an extended notion of collapsing mesh elements where a group of verti- ces and all mesh elements defined exclusively by these vertices (a connected mesh component) are contracted to one single vertex, and all remaining triangles incident to any contracted elements are distorted. The contraction simply needs to specify the group of vertices that are contracted, and the new vertex position. The expansion needs to specify the vertex to be expanded, all new vertex posi- tions, and all the removed incidence relations.

vertex contraction

vertex expansion

1.2.5 Simplification and refinement methods A progressive simplification can be achieved by repeated application of the simplification opera- tions, which requires an ordering of the operations with increasing approximation error. Simplifica-

10 Mesh Simplification1 tion operations which introduce the smallest approximation errors are performed first. The original mesh can progressively be reconstructed from the coarsest simplified mesh by inverse application of the dual refinement operations. Vertex decimation In [SZL92] a sequence of vertex removals was proposed for simplifying polygonal meshes. The error of a vertex removal was measured as the distance of the removed vertex to the average fitting plane of its adjacent vertices. This method preserves the topology of the mesh.

removed vertex distance to plane

fitting plane

Vertex insertion Similar to the polyline approximation, methods have been proposed to start with a very crude approximation of the input mesh, and new vertices which reduce the approximation error the most are incrementally inserted. The approximation error of a point is usually measured as its distance to the current coarse triangle mesh. Mesh topology is preserved using this method. Getting a very coarse mesh that can be used as a starting point to incrementally insert vertices based on their distance to the current mesh can be difficult for arbitrary 3D surfaces, but is easy for 2.5- dimensional meshes such as terrain or height-fields [Lee91]. Vertex clustering Contraction of a group of vertices based on spatial clustering has been introduced in [RB93]. The bounding box of the input mesh is recursively subdivided into smaller cells until a desired cell size is reached. All vertices within one cell are replaced by one single vertex, and the connectivity of the mesh is updated accordingly, also removing singularities in the mesh. In the basic implementation the cell size is used as an error measure, and can provide a guaranteed bound on the Hausdorff dis- tance measured at the vertices. Topology of the input mesh is typically not retained by vertex cluster- ing.

vertex clustering

More sophisticated vertex clustering can be achieved by non-uniform hierarchical spatial subdivi- sion, where the subdivision is controlled by a more accurate geometric distance error metric. Edge collapsing

11 Multiresolution Triangulations

A sequence of edge collapse operations has been proposed in [Hop96] and in many subsequent methods (see also [HG97,CMS98,LT99]) for progressively simplifying a given triangle mesh. Edges are collapsed in the order of increasing approximation error, and the error metric usually includes a geometric distance measure of the removed vertices to the simplified mesh. In [GH97] the method has been extended to more general vertex-pair contractions, allowing topological changes in the mesh, and a quadric error metric is used to measure the distance of a point to a set of planes. Care has to be taken when using edge collapses to prevent flipping of triangle normals, avoid chang- ing the concavity or convexity of edges, and control topological changes in the mesh. 1.3 Multiresolution Triangulations A multiresolution model or triangulation refers to a representation of the triangle mesh that main- tains approximations of the input mesh at different resolutions, or level-of-detail (LOD). A triangula- tion for a particular LOD can efficiently be extracted from such a multiresolution model without re- computing all approximation errors and simplification operations. In a very basic manner, the sequential simplification of a triangle mesh already represents a multiresolution model. More flexible approximations can be achieved if the simplification and refinement operations are not restricted to the complete global ordering, but if they can be applied in a partial-order to the current mesh. Typically these multiresolution meshes organize the operations hierarchically, including restrictions of partial-orders across the . 1.3.1 Strictly hierarchical triangulations In strictly hierarchical triangulations [DP95], one triangle domain is replaced by multiple triangles. Examples are ternary triangulations where one triangle is split into three, quaternary triangulations splitting each triangle into four, and binary edge- triangulations that subdivide one triangle into two.

ternary subdivision quaternary subdivision edge bisection

The ternary subdivision strategy has the problem that it creates extremely large and extremely small . Triangle such as quaternary and edge bisection that subdivide edges produce T- vertices or holes, also called cracks in the 2-manifold surface triangulation leading to non-matching triangulations. Cracks can be avoided if the neighboring triangles sharing the edge with the T-vertex

12 Multiresolution Triangulations are equally subdivided along that edge by an edge bisection. Generally these strictly hierarchical tri- angulations are created by incrementally subdividing triangles of a coarse mesh. 1.3.2 Triangle Repeated replacement of a set of triangles by a smaller group of triangles having the same boundary leads to a triangle pyramid [DeF89]. Note that independent triangle replacements, that have disjunct sets of triangles, can be performed at the same level. The triangle pyramid can be constructed start- ing with the highest resolution mesh, its triangles defining the lowest level of the triangle pyramid. Every triangle on one level is connected to all overlapping triangles of the next level (simplified set of triangles).

o n p e m q r f d i a bcd efg s g h b c k mno i k l p q r s t u v t h a l u v

O N I M K H L G E M F D ABCDEFGHI KLN O C A B

A valid triangulation defines a front in the triangle pyramid. A front containing all nodes, triangles on one level of the pyramid obviously represents a valid triangulation. The front can be moved par- tially to a different level only if it includes to complete set of triangles involved in a triangle replace- ment operation. 1.3.3 Vertex hierarchy A set of edge collapse, or vertex clustering operations define a vertex hierarchy consisting of several trees where nodes represent vertices instead of triangles, and parent-child relations represent the merging of multiple vertices into one. The top-level of the hierarchy, the root nodes of all vertex trees defines the coarsest LOD of the mesh, all leaf nodes together represent the full resolution input

13 Multiresolution Triangulations mesh. For edge collapse operations the vertex hierarchy is a set of binary trees (possibly reduced to only the root nodes for vertices that are never merged with another) [XV96,Hop97].

k

k i lac d i b h d g e b f a c ef g h l Valid triangulations are defined by a front through the vertex hierarchy that cuts every possible path from the roots to the leafs of each tree exactly once. The front containing only all root nodes repre- sents the coarsest mesh resolution, all leaf nodes form the complete input mesh. However, note that not all possible fronts represent valid triangulations due to dependencies of edge collapse operations. In the example above the edge contractions e,f and g,h are not mutually independent, a partial order has to be imposed on the two simplification operations (usually given by the construction of the edge collapse hierarchy).

14 Multiresolution Triangulations

References [CMS98] P. Cignoni, C. Montani and R. Scopigno. A comparison of mesh simplification algorithms. & Graphics, 22(1):37–54, 1998. [HG97] Paul S. Heckbert, and Michael Garland. Survey of polygonal surface simplification algo- rithms. SIGGRAPH 97 Course Notes 25, 1997. [LT99] Peter Lindstrom and Greg Turk. Evaluation of memoryless simplification. IEEE Transac- tions on and , 5(2):98–115, April-June, 1999. [SZL92] William J. Schroeder, Jonathan A. Zarge, and William E. Lorensen. Decimation of triangle meshes. In Proceedings SIGGRAPH 92, pages 65–70. ACM SIGGRAPH, 1992. [Lee91] Jay Lee. Comparison of existing methods for building triangular irregular network models of terrain from grid digital elevation models. International Journal of Geographic Information Systems, 5(3):267–285, 1991. [RB93] Jarek Rossignac and Paul Borrel. Multi-resolution 3d approximations for rendering complex scenes. In Bianca Falcidieno and Tosiyasu L. Kunii, editors, Modeling in Computer Graphics, pages 455–465. Springer-Verlag, Berlin, 1993. [Hop96] Hugues Hoppe. Progressive meshes. In Proceedings SIGGRAPH 96, pages 99–108. ACM SIGGRAPH, 1996. [Hop97] Hugues Hoppe. View-dependent refinement of progressive meshes. In Proceedings SIG- GRAPH 97, pages 189–198. ACM SIGGRAPH, 1997. [GH97] Michael Garland and Paul S. Heckbert. Surface simplification using quadric error metrics. In Proceedings SIGGRAPH 97, pages 209–216. ACM SIGGRAPH, 1997. [DeF89] Leila De Floriani. A pyramidal data structure for triangle-based surface description. IEEE Computer Graphics & Applications, 9(2):67–78, March 1989. [DP95] Leila De Floriani and Enrico Puppo. Hierarchical triangulation for multiresolution surface description. ACM Transactions on Graphics, 14(4):363–411, 1995. [XV96] Julie C. Xia and Amitabh Varshney. Dynamic view-dependent simplification for polygonal models. In Proceedings Visualization 96, pages 327–334. IEEE, Computer Society Press, Los Alamitos, California, 1996.

15