1
Advanced Computer Graphics
Lecture 2: Modeling (1): Polygon Meshes
Bernhard JungTU-BAF, Summer 2007
Overview
Polygon Meshes SubdivisionPolygon Mesh Optimization
high-level: Level-of-detail, Progressive meshes low-level: Polygon strips & fans
Further readingA. Watt. 3D Computer Graphics. 3rd edition Addison-Wesley. 2000. Chapter 2.T. Akenine-Möller & E. Haines. Real-Time Rendering. AK Peters. 2002. Chapter 11,12 H. Hoppe. Progressive meshes. Proceedings ACM SIGGRAPH 1996, 99-108.
Computer Graphics Icon:Utah teapot
2
Surfaces
Polygon MeshesClassical and ubiquitous in CG
Creating polygonal objects is straightforward Visually efficient algorithms exist to produce shaded images. A machine representation, converted from other user representations such as parametric/implicit surfaces, CSG/volume
Difficulties of polygonal mesh geometric accuracyshape manipulation
Surfaces
Polygon Meshes
3
Surfaces - Polygon Meshes –
PolygonsA polygon is a many-sided planar figure composed of vertices and edges.
Vertices are represented by points (x,y).
Edges are represented as line segments which connect two points, (x1,y1) and (x2,y2).
P = { (xi , yi ) } i=1,n
E3
(x3,y3)
E2
(x2,y2)E1(x1,y1)
Surfaces - Polygon Meshes –Convex and Concave Polygons
Convex Polygon - For any two points P1, P2 inside the polygon, all points on the line segment which connects P1 and P2 are inside the polygon.
All points P = uP1 + (1-u)P2, u in [0,1] are inside the polygon provided that P1 and P2 are inside the polygon.
Concave Polygon - A polygon which is not convex.
4
Surfaces - Polygon Meshes –Simple and non simple Polygons
Simple Polygons – Polygons whose edges do not cross.
Non simple Polygons – Polygons whose edges cross.Two different OpenGL implementations may render non simple polygons differently. OpenGL does not check if polygons are simple.
Trianglepolygon guaranteed to be convex and simple
SurfacesPolygon Meshes
Mesh Representations
Independent FacesVertex and Face TableAdjacency Lists(Winged Edge)
5
Surfaces - Polygon Meshes – Mesh Representation
Independent FacesEach face lists vertex coordinates
Redundant verticesNo topology information
Surfaces - Polygon Meshes – Mesh Representation
Vertex and Face TablesEach face lists vertex references
Shared vertices, more compact representationStill no topology information
VRML: IndexedFaceSet
6
Surfaces - Polygon Meshes – Mesh Representation
Adjacency ListsStore all vertex, edge, and face adjacencies
Efficient topology traversalExtra storage
Advanced Mesh Rep: Winged Edge
Stores only some adjacency relationships; can derive others on demandLittle extra storage (fixed records)
Surfaces
SubdivisionProperties
AccurateLocal supportAffine invariantArbitrary topologyGuaranteed continuityEfficient display
used e.g. in animated movies
Pixar: Geri’s Game
7
Surfaces
Subdivision
How do you make a smooth curve?
Keep cutting the corners of the polyline until you end up with something that has no corners anymore, i.e., is smooth!
Surfaces
SubdivisionCoarse mesh & subdivision rule
Define smooth surface as limit of sequence of refinements
8
Surfaces
Subdivisione.g. “loop” subdivision rule
refine each triangle into 4 triangles by splitting each edge and connecting new vertices
Surfaces
SubdivisionDifferent refinement rules
9
Surfaces
Subdivision
All subdivision schemes have 2 steps:
1. Splitting or refinement step topological rule which introduces new vertices and modifies connectivity
2. Averaging or smoothing step geometric rule which computes the positions for new or all vertices by weighted averages
face split
vertexsplit
Surfaces
Subdivision
Quadrilateral subdivision
Computer Graphics Icon:Ivan Sutherland's Volkswagen,
Utah, late 1970ies
10
Surfaces
SubdivisionSubdivision in 3DS Max, tessellate modifier
original
1 iteration
2 iterations
4 iterations
Surfaces
Subdivision
adaptive approximation: surface is subdivided only where topology of the surface requires more detail
selection of critical mesh areas (vertices) usually by hand
loop subdivision example
11
Surfaces
Polygonal Models vs SubdivisionFrom 3DS Max Help:
You create a subdivision surface by applying a modifier to an object. Two kinds of subdivision surfaces are supported:
The HSDS modifier provides hierarchical subdivision surfaces [i.e. at multiple levels of detail]The MeshSmooth modifier provides smoothing.
Both these modifiers work best as finishing tools for models.…The HSDS modifier implements Hierarchical SubDivision Surfaces.
It is intended primarily as a finishing tool rather than as a modeling tool. For best results, perform most of your modeling using low-polygon methods, and then use HSDS to add detail and adaptively refine the model.
Surfaces
Parametric SurfacesGeneralization of parametric curvesbi-polynomial, e.g. bi-cubicparametric surfacespiecewise parametric surfacese.g. Bézier surface, NURBS-surface, …
C1-continuity requires aligning boundary curves and derivatives (difficult; a reason to prefer subdivision surfaces)
12
Surfaces
SummaryPolygon meshes
games
Subdivision surfacesmovies
Parametric SurfacesCAD/CAM
increased accuracy
slower rendering
Polygon mesh optimization
Main disadvantage of polygon meshes:often high polygon count to synthesize an object for a high quality rendition
Quote from 1976
today: objects composed of > 1000000 polygons
It makes no sense to use 500 polygons in describing an object if it covers only 20 raster units on the display … For example, when we view the human body from a very large distance, we might need to present only specks for the eyes, or perhaps a block for the head, totally eliminating the eyes from consideration
(James H. Clark, 1976)
13
Polygon mesh optimizationMesh Simplification
Reduce polygons to a level that is adequate for the quality required
Application: Level of detail approximation [Clark76, Funkhouser93]VRML: LOD node
problem: may "pop"
distancefrom viewer?
distancefrom viewer?
close far
10,000 2,000 1,000 500 250
Polygon mesh optimizationProgressive meshes [Hoppe, 96]
Idea: apply sequence of edge collapses
to build hierarchy of meshes:
edge collapseedge collapse
vvll vvrr
vvtt
vvss
vvssvvll vvrr’’
13,54613,546 500500 152152 150150
MM00MM11MM175175ecolecol00ecolecoliiecolecolnn--11
M=MM=Mnn^̂
14
Polygon mesh optimizationProgressive meshes [Hoppe, 96]
Which edges to select?simple heuristic: edges connecting close polygons with similar orientationor more complex heuristics
edge collapse is invertible!inverse operation: vertex splitcan store required vertex information in coarser meshlossless
Applicationscontinuous level of detailprogressive transmissionselective refinement, e.g. viewer dependentmesh compression
edge collapseedge collapse
vvll vvrr
vvtt
vvss
vvssvvll vvrr’’
vertex splitvertex split
Polygon mesh optimizationcontinuous level of detail
http://gts.sourceforge.net/
A multi-resolution model obtained by simplification of the original model (in the top left corner). The number of triangles are respectively 96966, 13334, 3334 and 668.
Animation of a continuous Level Of Detail model of the horse. The initial number of vertices is 32 and is increased to 10,000.
15
Triangle strips
Without strips: 8 triangles * 3 vertices = 24 verticesWith strips: use 1 vertex per triangle instead of 3 !
What we send to graphics hardware:Startup cost: v0, v1 then v2 (T0), v3 (T1), v4 (T2), v5 (T3), v6 (T4), v7 (T5), v8 (T6), v9 (T7).
9 vertices 100*9/24= 37.5% or 9/8=1.125 verts/tri
v0
v1
v2
T0
v3
T1
v4
T2
v5
T3
v6
T4
v7
T5
v8
T6
v9
T7
Triangle strips9 vertices instead of 24
100*9/24= 37.5% of data 9/8=1.125 vertices/tri
I.e., we can expect the geometry stage to run almost 3 times faster!
Definition of triangle strip makes orientation change between neighboring triangles in strip
Internally, counterclockwise order is kept consistent by traversing vertices 0-1-2, 1-3-2, 2-3-4, 3-5-4, …
v0
v1
v2
T0
v3
T1
v4
T2
v5
T3
v6
T4
v7
T5
v8
T6
v9
T7
16
Triangle stripsOpenGL: glBegin(GL_TRIANGLE_STRIP); … glEnd()
Swaps in triangle stripsWhat can we do for this case?(T3 = v2 v4 v5 )
Implement a swap!Startup cost: v0, v1 then
v2 (T0)v3 (T1)v2,v4 (T2)v5 (T3), v6 (T4)
Degenerate triangle (0-area): v2, v3, v2
v0
v1
v2
v3
v4
v5 v6
T1
T2
T3
T0
T4
17
Swaps…
cost of degenerate triangle:1 extra vertexstill cheaper than restarting triangle strip
this example: 8 sent vertices / 5 triangles = 1.6 vertices/triangle
restarting triangle strip costs more:4 vertices (2 triangles) +5 vertices (3 triangles)
(v0, v1, v2, v3, v2, v4, v5, v6)
(v0, v1, v2, v3, swap, v4, v5, v6) implemented by sending v0
v1
v2
v3
v4
v5 v6
T1
T2
T3
T0
T4
Swaps…also, hardware determines degenerate triangles efficiently and skips thesecan use swaps to connect non-connected triangles too
the idea is to avoid API call overheadhardware needs caches for this to be efficient
send these vertices: 0,1,2,3, 3,4, 4,5,6,710 vertices (sending as 2 strips: 8 vertices)if 3 and 4 are cached, then 8 vertices
v0
v1
v2
T0
v3
T1
v4
v5
v6
T2
v7
T3Generates
4 degeneratetriangles
18
How to create triangle strips from a 3D model?
manually only doable for small models, and not fun…
NVIDIA Tri Strip Library http://developer.nvidia.com/object/nvtristrip_library.htmlor make your own program
need to know triangle’s adjacencies
1. Choose a starting triangle 2. Build 3 different triangle strips; one for each edge of the triangle3. Extend these triangle strips in the opposite direction4. Choose the longest of these 3 strips5. Repeat Step 1 until all triangles are included in a strip
SGI stripping algorithm
• greedy algorithm; linear time if appropriate data structures are used• choice of starting triangle:
• original algorithm: a triangle with smallest number of neighbors (at least 1) • in practice, arbitrary choice produces almost equally good results
Triangle fans
analysis - same as for strips:without fans: 6 triangles * 3 vertices = 18 verticeswith fans: use 1 vertex per triangle instead of 3 !
in practice: harder to find long fans than strips
smaller benefit than strips
easy to convert arbitrary polygons to triangle fans
can convert every triangle fan to a triangle strip (with many swaps) - but not vice versa
v0
v1 v2
v3
v4
v5
v6
19
Vertex arrays / buffers
Idea: most efficient to transform a vertex only once (using strips or fans a vertex will be transformed once for each strip / fan the vertex is contained in)
Specifiy each vertex (position, normal, diffuse color, specular color, texture coordinates, etc.) once & send to bufferThen send (e.g., 16 bit) indices to identify vertices in bufferExample: make a buffer of 100 unique vertices
A triangle is sent as 3 indices into this buffer: 97, 5, 32This method mimimizes coyping from main memory to graphics card
OpenGL vertex arrays, DirectX vertex bufffersTriangle strips and vertex buffers are (often) fastest way to send triangles today
Summary
3D object representation propertiesAccuracyAccuracy vs. data volumeEase of editingOptimization potential
data volume, network transmission, rendering