Presentation is loading. Please wait.

Presentation is loading. Please wait.

1/57 CS148: Introduction to Computer Graphics and Imaging Geometric Modeling CS148 Lecture 6.

Similar presentations


Presentation on theme: "1/57 CS148: Introduction to Computer Graphics and Imaging Geometric Modeling CS148 Lecture 6."— Presentation transcript:

1 1/57 CS148: Introduction to Computer Graphics and Imaging Geometric Modeling CS148 Lecture 6

2 2/57 Data Structures for Triangle Mesh CS148 Lecture 6

3 3/57 CS148 Lecture 6 Data Structure: Separate Triangles Treat each triangle separately with its own vertices typedef float Point[3]; struct Face { Point v[3]; }; mesh = Face[nFaces]; Storage: 72 bytes per vertex No notion of “neighbor triangles”: Individual triangles might not overlap with their vertices or edges f f.v 0 f.v 2 f.v 1 f’.v 0 f’.v 1 f’.v 2 f’

4 4/57 CS148 Lecture 6 Data Structure: Indexed Triangle Set Store each vertex only once; each face contains indices to its three vertices typedef float Point[3]; struct Face { int vIndex[3]; }; mesh.verts=Point[nVerts]; mesh.faces=Face[nFaces]; Storage: 12 (verts) + 24 (faces) = 36 bytes per vertex (approximate using #f = 2 #v) By removing vertex redundancy we have a notion of neighbor. However, finding a specific neighbor requires a global search. f v0v0 v2v2 v1v1 v3v3 f’

5 5/57 CS148 Lecture 6 Comparison Separate Triangles (Vertex Buffer only) + Simple – Redundant information Indexed Triangle Set (Vertex Buffer + Index Buffer) + Sharing vertices reduces memory usage + Ensure integrity of the mesh (moving a vertex causes that vertex in all the polygons to be moved) + Both formats are compact and directly accepted by GPUs + Both can represent non-manifold meshes – Neither is good at neighborhood access/modification

6 6/57 CS148 Lecture 6 Recall: Calculating Normals at Vertices for f in mesh.faces(): (v1, v2, v3) = f.ccwVertices() f.N = cross(v2-v1,v3-v1) if !areaWeighted: f.N.normalize() for v in mesh.verts(): v.N = 0 for f in v.faces(): v.N += f.N v.N.normalize() For Indexed Triangle Set, this takes O(|F|) time!

7 7/57 Starting from the Indexed Triangle Set, for each triangle we now store pointers to the three adjacent triangles, and for each vertex store a pointer to any one of its incident triangles struct Vertex { Point pt; Face *f; } struct Face { Vertex *v[3]; Face *adjF[3]; } mesh.verts=Point[nVerts]; mesh.faces=Face[nFaces]; How to find all the faces adjacent to a vertex efficiently? CS148 Lecture 6 Triangle Neighbor Representation v0v0 v1v1 v2v2 f0f0 f1f1 f2f2 F v 2.f v 1.f v 0.f

8 8/57 Finding Next Face using Triangle Neighbor CS148 Lecture 6 Find the next face clockwise around a vertex v from a face f Face *fcwvf(Vert *v, Face *f) { if( v == f->v[0] ) return adjF [1]; if( v == f->v[1] ) return adjF [2]; if( v == f->v[2] ) return adjF [0]; } Storage: 36 (indexed triangles) + 24 (face.adjF) + 4 (vert.f) = 64 bytes per vertex (still less than separate triangles) Efficiently iterate through all triangles adjacent to a vertex v0v0 v1v1 v2v2 f0f0 f1f1 f2f2 f *Edge-based representations are more general and comprehensive, such as the winged-edge, half-edge, and quad-edge data structures.

9 9/57 Subdivision CS148 Lecture 6

10 10/57 Recall: Smooth Shading The faceted silhouette cannot be smoothed by shading. CS148 Lecture 6

11 11/57 Subdivision Curves CS148 Lecture 6

12 12/57 CS148 Lecture 6 Subdivision Surfaces There exists smooth limit surfaces associated with a given input mesh ■ The exact smooth limit surface depends on the subdivision algorithm used We define a refinement operation, that takes a coarse input mesh and generates a finer output mesh that is closer to the limit surface ■ If we apply this refinement process infinitely, we will exactly achieve the target limit surface ■ However, after just a few levels of refinement, any additional changes will be visually indistinguishable

13 13/57 Refine a triangular mesh CS148 Lecture 6 Loop Subdivision Surface

14 14/57 Properties: Modifies existing vertices Applied to all triangulated surfaces Maintains higher order of continuity Loop Subdivision CS148 Lecture 6

15 15/57 CS148 Lecture 6 Subdivide Each Triangle into 4 Triangles

16 16/57 CS148 Lecture 6 Subdivide Each Triangle into 4 Triangles

17 17/57 CS148 Lecture 6 Second step: Modify the vertices Original/Even (Gray) Additional/Odd (Black) Where should the additional vertices be located? How should the original vertices be moved?

18 18/57 CS148 Lecture 6 New Vertex Locations Compute positions of added vertices from the adjacent four original vertices using mask: Without overwriting, update the original vertex positions from the six adjacent original vertices using mask: Repeat until converged

19 19/57 CS148 Lecture 6 Semi-Regular Meshes Most of the mesh has vertices with degree 6 (Regular point). If the mesh is topologically equivalent to a sphere, then not all the vertices can have degree 6 Must have a few extraordinary points (degree != 6) Extraordinary point

20 20/57 Weights at an Extraordinary Point CS148 Lecture 6 Challenge: find weights that generate a smooth surface (tangent plane continuous) Want the surface normal to be continuous This is a hard math problem! Warren weights

21 21/57 Example mesh Example CS148 Lecture 6

22 22/57 Example Add vertices CS148 Lecture 6

23 23/57 Odd vertex refinement Example CS148 Lecture 6

24 24/57 Example Odd vertex refinement CS148 Lecture 6

25 25/57 Example Even vertex refinement CS148 Lecture 6

26 26/57 Example Even vertex refinement CS148 Lecture 6

27 27/57 Example Extraordinary vertex CS148 Lecture 6

28 28/57 Example Extraordinary vertex CS148 Lecture 6

29 29/57 Example Subdivided Surface CS148 Lecture 6

30 30/57 Example Level 2 CS148 Lecture 6

31 31/57 Example Level 3 CS148 Lecture 6

32 32/57 Example Level 4 CS148 Lecture 6

33 33/57 Example Limit Surface at ordinary points, at extraordinary points CS148 Lecture 6

34 34/57 Mesh Generation CS148 Lecture 6

35 35/57 Marching Cubes Polygonization ■ Convert implicit surface to polygonal mesh ■ Render the polygons as before Two steps ■ Partition space into cells ■ Fit a polygon to the surface in each cell Gives a piecewise linear approximation of the surface in each cell CS148 Lecture 6

36 36/57 Cell polygonization Need to find the cells that actually intersect the surface A simple method is: exhaustive enumeration ■ Divide all of space into a regular grid ■ Traverse all cells, and polygonize the cells that contain the surface CS148 Lecture 6

37 37/57 Surface vertices Determine where the surface intersects the cell edges ■ 1st option: Linearly interpolate function value from cell vertices to approximate (function might not be linear) ■ 2nd option: Numerically find the zero Either will work, but option 2 can be significantly more expensive CS148 Lecture 6

38 38/57 Surface vertices Linearly interpolate function value from cell vertices to approximate the surface CS148 Lecture 6

39 39/57 Surface polygons Given the vertices of our final polygonal surface, find the polygon faces of the surface Solution: There are only a finite number of options, defined by the configurations of inside/outside of the cell’s vertices CS148 Lecture 6

40 40/57 Surface polygons Consider 2D first: 16 different possible configurations Using cell vertex inside/outside configuration to index into this table Note some of them are duplicates of others CS148 Lecture 6

41 41/57 Result: Surface polygons CS148 Lecture 6

42 42/57 Surface polygons In 3D, there are 256 configurations, which can be reduced to 15 cases. CS148 Lecture 6

43 43/57 Ambiguity in Marching Cubes Some configurations are ambiguous Solution? ■ Sample more ■ Refine the cell ■ Simple solution: just sample once more in the middle of the cell or CS148 Lecture 6

44 44/57 Another Solution CS148 Lecture 6 Split a cube into six tetrahedra, and find surface vertices and polygons in each tetrahedron

45 45/57 Marching tetrahedra CS148 Lecture 6 + Unambiguous + Less cases – More elements (more edges)

46 46/57 Voronoi Diagram Split the space into regions consisting of the set of points closest to a particular seed point Every edge is a part of the perpendicular bisector of two points CS148 Lecture 6

47 47/57 Voronoi Diagram Generation A simple way to generate the Voronoi diagram 1.Incrementally add points 2.Calculate all the perpendicular bisectors between the existing points and the newly added point 3.Remove each section of the perpendicular bisector lines that trespasses other Voronoi regions CS148 Lecture 6

48 48/57 Voronoi Diagram & Delaunay Mesh For every Voronoi edge (red), there exists a Delaunay edge (black) between the two corresponding points They are the dual graph to each other In 2D, the Delaunay mesh is a triangle mesh CS148 Lecture 6

49 49/57 Delaunay Mesh CS148 Lecture 6 In a 2D Delaunay triangulation, the circumcircle of every triangle contains no other points This property leads to high-quality elements (long, thin elements are avoided as much as possible) This is also a good property for a surface mesh in 3D

50 50/57 Improving and Existing Mesh CS148 Lecture 6 Edge-Flipping In-Circle Test - for a pair of adjacent triangles, test whether the circumcircle of one triangle contains the fourth point Flip the edge to make it locally-Delaunay

51 51/57 Incremental Algorithm – Sampling CS148 Lecture 6 Sampling the boundary sampling density inversely proportional to the distance to the medial axis more samples for higher curvature regions Sampling the interior sampling density as continuous as possible, including the boundary and the interior

52 52/57 Incremental Algorithm CS148 Lecture 6 Consider adding sample points one at a time 1.Find the triangle which the newly added point is inside (a giant bounding triangle can be used to guarantee that you can always find a triangle that contains the point) 2.Split that triangle into three triangles 3.For each of the three new triangles. do In-Circle test for it and its outer edge adjacent triangle; flip the edge if the test fails 4.For every flipped edge, its neighbors should also be tested recursively 5.Delete triangles outside the object

53 53/57 Generating a surface mesh CS148 Lecture 6 In 2d, we can extract the outer edges to form a polygon In 3d, we can extract the surface faces to form an object’s surface The 3D volume needs sampling points on the interior, and meshing in 3D is generally significantly harder than in 2D. E.g. Delaunay gives poor quality elements in 3D (unlike 2D)!

54 54/57 3D object surface is technically 2D CS148 Lecture 6 Meshing on the surface directly requires geodesic distances Instead, flatten a 3D mesh to 2D, use 2D Delaunay Hard to flatten exactly -- but could approximately flatten, then the result is approximately Delaunay Need to sew up boundary regions to make a continuous mesh – leads to poor quality elements

55 55/57 3D object surface is technically 2D CS148 Lecture 6 Cut the object to flatten it, and add new sample points (blue) along the cut Generate the Delaunay with incremental algorithm connecting both original (black) and new (blue) sampling points sew up the boundary edges (reconnect blue points) Retest/remesh to improve the mesh, especially near the boundary edges

56 56/57 3D Sampling Evenly sampling is not efficient and cannot capture details Usually need more points to represent higher curvature regions Similar to 2D… CS148 Lecture 6

57 57/57 3D In-Circle Test CS148 Lecture 6 Once we get a 3D mesh, the In-Circle test can be used to improve it, especially near the boundaries where it was sewn together Need 3D version of the In-Circle test Use an ellipse to approximate the mapped circle in 2D plane Given three vertices on a curved surface, consider the infinite set of spheres through the three vertices. The centers of all the spheres lie on a single line. Choose the sphere whose center is on the surface and define In-Circle test as inside that sphere.


Download ppt "1/57 CS148: Introduction to Computer Graphics and Imaging Geometric Modeling CS148 Lecture 6."

Similar presentations


Ads by Google