% $ # " ! Efficient Visualization of Triangulations Efficient Visualization of Triangulations 1/28 Motivation We want to visualize Huge data sets in 3D. NASA SRTM Mission: Elevation model of 30m resolution between 60 and -60 degrees latitude 12Tb of raw data! ASCI Project: Simulation of nuclear explosions. Generates terabytes of raw data which need to be visualized. These amounts of data are not manageable even with the Need intelligent methods! world’s fastest computers Efficient Visualization of Triangulations 2/28 Goals For real-time rendering of triangle surfaces we want: Fast rendering Few triangles Efficient data structures Efficient algorithms Good-looking meshes Valid triangulation (ch.2) Delaunay (ch.4) Efficient Visualization of Triangulations 3/28 Means To achieve our goals we will look at the following Efficient data structures Indexed triangulations. Triangle strips/fans. Data reduction. Refinement/Decimation View-dependent Level of Detail Binary Tree Triangulations Hierarchical TIN’s Progressive Meshes Efficient Visualization of Triangulations 4/28 Notes on 3D Rendering All vertex data in the triangulation must be transformed before visualization. (x1,y1,z1) (x2,y2,y3) (x3,y3,z3) M 00 M01 M02 M03 P00 P01 P02 P03 M 10 M11 M12 M13 P10 P11 P12 P13 M 20 M21 M22 M23 P20 P21 P22 P23 M 30 M31 M32 M33 P30 P31 P32 P33 GL_MODELVIEW_MATRIX GL_PROJECTION_MATRIX We want to do as few vertex transforms as possible! Efficient Visualization of Triangulations 5/28 Efficient Visualization of Triangulations $ " # ! " ! ! ! ! " ! (4,3,1) ! (2,6,0) (0,4,0) $ $ (−2,6,0) % Triangle rendering in OpenGL 6/28 Indexed triangle structure 0 1 Idx 2 10 9 3 12 11 4 13 8 7 5 6 Efficient Visualization of Triangulations 0 1 2 3 4 5 6 7 8 9 10 11 12 13 Coords (−2,6,0) (2,6,0) (4,3,1) (6,0,3) (5,−3,5) (2,−7,3) (0,−7,3) ..... Triangles [0,10,1] [1,10,2] [2,10,12] [2,12,3] [3,12,4] [4,12,13] [4,13,5] [13,6,5] .... 7/28 % # ! # # # ! ! Efficient Visualization of Triangulations ! # " $ $ $ # " ! ! Indexed rendering in OpenGL 8/28 Efficient Visualization of Triangulations % " ! # " $ $ $ # ! # ! # # % # ! # ! $ $ $ # " ! ! Indexed Rendering (cont.) An even simpler way... 9/28 Shared Edges Our triangles share common edges Efficient Visualization of Triangulations Ideally: triangles need only specify vertices When moving from one triangle to its neighbor we already know two of the three vertices 10/28 Advantages We already use an indexed structure with minimum vertex transforms, so why bother? Vertex sharing will probably not handle the entire vertex array. Index data takes resources too! Memory usage Bus traffic Function calls Efficient Visualization of Triangulations 11/28 Triangle Strips Traverse the triangles in a zig-zag pattern: 2 0 4 Triangles [0,1,2] [2,1,3] [2,3,4] [4,3,5] ... 6 1 3 5 8 % # ! % " 7 Efficient Visualization of Triangulations 12/28 Triangle Fans Rotate about a central vertex 3 2 4 1 Triangles 0 [0,1,2] [0,2,3] [0,3,4] [0,4,5] [0,4,6] # ! % % " 6 5 Efficient Visualization of Triangulations 13/28 Triangle Strip Algorithms Simple overview of an algorithm 1. Choose a starting triangle. 2. Choose a direction (crossing edge) 3. Extend the strip or fan in the chosen direction 4. Repeat from (2) until you reach a triangle with no forward connections. 5. Repeat from (1) until all triangles have been visited. We need a data structure with adjacency information (see ch. 3). For strips we choose alternating right and left crossing edges. For fans we always choose the same crossing edge direction. Efficient Visualization of Triangulations 14/28 Choosing the start triangle Two heuristics: 1. Choose the least connected triangle (fewest neighbors). 2. Choose any triangle. The first strategy seems to produce longer strips. It has been shown that producing optimal length strips from a general triangle mesh is an NP-hard problem. Efficient Visualization of Triangulations 15/28 Cutting Corners Some times we may cheat a bit instead of starting a new triangle strip: Two Strips (10 indices) [0,1,2,3,4] [4,3,5,6,7] 0 4 2 Triangles [0,1,2] [2,1,3] [2,3,4] [4,3,3] [4,3,5] [5,3,6] [5,6,7] 5 1 3 7 Single Strip (9 indices) [0,1,2,3,4,3,5,6,7] 6 The degenerate triangle will usually be skipped by the OpenGL driver. We save one vertex compared to starting a new strip. Efficient Visualization of Triangulations 16/28 Data Reduction We want to display as much detail as possible with as few triangles as possible. For a surface model certain parts of the surface usually have more detail than others. Need to throw away input data that doesn’t contribute significantly to the shape of the surface. Efficient Visualization of Triangulations 17/28 Data reduction example Efficient Visualization of Triangulations 18/28 Error Measure How do we determine what input data points are significant? We need an Error Measure. One simple error measure is the vertical distance from a reference surface, for example the surface consisting of all the input points except the one in question. be the elevation on the reference surface, and Let let be the elevation of the data point in question. indicates the error we do if we skip a certain data point. Efficient Visualization of Triangulations 19/28 Error Tolerance When we have an error measure we can set the maximum error we can tolerate in our model. We denote this the error tolerance, , and we include all data points . where m, we need to use all data I.e if we set tolerance points that lie further than 2.0m from the reference surface. Efficient Visualization of Triangulations 20/28 Reducing triangulations Two general approaches: Refinement: Start with a coarse mesh, add details where appropriate. Decimation: Start with a detailed mesh. Remove superfluous data. a set of input points in . - points in the set Some notation: - Piecewise linear function over the current triangulation. Efficient Visualization of Triangulations 21/28 Refinement Triangulation Efficient Visualization of Triangulations 22/28 Refinement Algorithm then if do repeat for all end if end for then if Add vertex to triangulation end if until Efficient Visualization of Triangulations 23/28 Implementation notes Start with the convex hull or a bounding rectangle of the input points. Keep an array of error values. Update only within the influence area of the inserted point. May also use max number of vertices as a stop criterion instead of tolerance. Efficient Visualization of Triangulations 24/28 Decimation Triangulation Conceptually “inverse” of refinement. Start with a full triangulation and remove points with Efficient Visualization of Triangulations 25/28 Decimation Algorithm then if do from triangulation repeat for all Remove end if Put back in triangulation end for then if Remove vertex from triangulation end if until Efficient Visualization of Triangulations 26/28 Comparison Refinement depends on number of vertices in the reduced mesh. Decimation depends on number of vertices in the full mesh. Decimation is a heavier process. Decimation generally gives better results (fewer points at the same tolerance). Efficient Visualization of Triangulations 27/28 Comparison(2) (a) Refinement (b) Decimation δ>ε 1 δ<ε 2 δ>ε δ>ε 3 Efficient Visualization of Triangulations 28/28