Advanced omputer Graphics (Spring 213) S 283, Lecture 6: Quadric Error Metrics Ravi Ramamoorthi To Do Assignment 1, Due Feb 22. Should have made some serious progress by end of week This lecture reviews uadric error metrics and some points regarding implementation http://inst.eecs.berkeley.edu/~cs283/sp13 Resources Garland and Heckbert SIGGRAPH 97 paper Garland website, implementation notes (in thesis) Notes in this and previous lectures Surface Simplification: Goals (Garland) Efficiency (7 to 1 faces in 15s in 1997) High uality, feature preserving (primary appearance emphasized rather than topology) Generality, non-manifold models, collapse disjoint regions Simplifications Algorithm Outline Pair contractions in addition to edge collapses Previously connected regions may come together 1
Quadric Error Metrics Based on point-to-plane distance Better uality than point-to-point d d c a d b a b c Background: omputing Planes Each triangle in mesh has associated plane ax + by + cz + d = For a triangle, find its (normalized) normal using cross products Plane euation? n = n = AB A AB A a b c n i v A i v = d = A i v Quadric Error Metrics Sum of suared distances from vertex to planes: Δ v = Dist(v,p) 2 v = x y z 1 p, p = a b c d Dist(v,p) = ax + by + cz + d = p T v Quadric Error Metrics Δ = (p T v) 2 p = v T pp T v p = v T pp T p v = v T Qv ommon mathematical trick: uadratic form = symmetric matrix Q multiplied twice by a vector Quadric Error Metrics Simply a 4x4 symmetric matrix Storage efficient: 1 floating point numbers per vertex Initially, error is for all vertices Quadric Error Metrics 2 nd degree polynomial in x, y and z Level surface (v T Qv = k) is a uadric surface Ellipsoid, paraboloid, hyperboloid, plane etc. 2
Quadric Visualization Ellipsoids: iso-error surfaces Smaller ellipsoid = greater error for a given motion Lower error for motion parallel to surface Lower error in flat regions than at corners Elongated in cylindrical regions Using Quadrics Approximate error of edge collapses Each vertex v has associated uadric Q Error of collapsing v 1 and v 2 to v is v T Q 1 v +v T Q 2 v Quadric for new vertex v is Q =Q 1 +Q 2 Using Quadrics Find optimal location v after collapse: 11 12 13 14 Q' = 12 22 24 13 33 34 14 24 34 44 min v' T Q'v' : = = = v' x y z Using Quadrics Algorithm Outline Find optimal location v after collapse: 11 12 13 14 12 22 24 v' = 13 33 34 1 1 11 12 13 14 v' = 12 22 24 13 33 34 1 1 1 3
Algorithm Summary Final Algorithm ompute the Q matrices for all the initial vertices Select all valid pairs ompute the optimal contraction target v for each valid pair. The error v T (Q 1 +Q 2 )v of this target vertex becomes the cost of contracting that pair Place all pairs in a heap keyed on cost with minimum cost pair on the top Iteratively remove the least cost pair, contract this pair, and update the costs of all valid pairs of interest Results Results Original Quadrics Original Quadrics 1k tris 1 tris 25 tris 25 tris, edge collapses only Additional Details Preserving boundaries/discontinuities (weight uadrics by appropriate penalty factors) Preventing mesh inversion (flipping of orientation): compare normal of neighboring faces, before after Has been modified for many other applications E.g. in silhouettes, want to make sure volume always increases, never decreases Take color and texture into account (followup paper) See paper, other more recent works for details Implementation Tips Incremental, test, debug, simple cases Find good data structure for heap etc. May help to visualize error uadrics if possible hallenging, but hopefully rewarding assignment 4
Issues or uestions? Questions? All the material for assignment covered Start early, work hard Rest of unit NURBs (today if time permits) Subdivision (next lecture) Outline Rational Splines Quadratic rational splines NURBs (briefly) Parametric patches (briefly) Parametric Polynomial urves A parametric polynomial curve of order n: x(u) = y(u) = i= a i u i Advantages of polynomial curves Easy to compute Infinitely differentiable everywhere n n i= b i u i Rational Splines an t represent certain shapes (e.g. circles) with piecewise polynomials Wider class of functions: rational functions Ratio of polynomials an represent any uadric (e.g. circles) exactly Mathematical trick: homogeneous coordinates Ratio of 2 polynomials in 3D euivalent to single polynomial in 4D Rational Splines Standard deasteljau Example: creating a circular arc with 3 control points A B (,1) (1,1) (???) (1 t)a+ tb (,) Polynomial spline: parabolic arc Rational spline: circular arc 5
Rational deasteljau A B w w A B Homogeneous deasteljau wa A wb B w w A B wa wb (1 t)w A A + tw B B (1 t)w A + tw B (1 t)w A A + tw B B (1 t)w A + tw B (1 t) waa + twbb (1 t) wa+ twb Non-rational splines simply have all weights set to 1 instead Outline Rational Splines Quadratic rational splines NURBs (briefly) Parametric patches (briefly) Evaluation: Rational Splines Add an extra weight coordinate Multiply standard coords of control point by weight (essentially the same as the use of homogeneous coords) Apply standard deasteljau or other evaluation alg. Divide by final value of weight coordinate Essentially the same as perspective division/dehomogenize Rational because of final division: Rational polynomial at the end (ratio of two polynomials) Quadratic Bezier urve Example: uarter-circle arc, weight midpoint Smaller w: pulled away from middle control point Larger w: pulled towards middle control point (,1;1) (,1;w) Quadratic Bezier urve General Bezier Formula for uadratic? A B w c = (1 t)2 A w c (1 t) 2 (,1;1) (,1;w) Polynomial spline: parabolic arc Rational spline: result depends on w Polynomial spline: parabolic arc Rational spline: result depends on w 6
Dependence of curve on w A B w c w c = (1 t)2 A (1 t) 2 Mid-Point (t = ½? ) A B w c w c = (1 t)2 A (1 t) 2 For w very large, curve pulled toward middle control point, get a section of a hyperbola For w = 1 (standard spline), standard parabola For w < 1, positive, curve moves away from middle control point For w =, curve becomes a straight line When is curve part of a circle? (homework) W very large A B w c w c = (1 t)2 A (1 t) 2 W = 1 (non-rational spline) A B w c w c = (1 t)2 A (1 t) 2 (,1;>>1) (,1;1) Polynomial spline: parabolic arc W < 1 A B w c w c = (1 t)2 A (1 t) 2 W = A B w c w c = (1 t)2 A (1 t) 2 (,1;w) (,1;w) Rational spline: result depends on w Straight Line 7
Outline Rational Splines Quadratic rational splines NURBs (briefly) Parametric patches (briefly) NURBS Non-uniform (vary time interval per segment) Rational B-Splines an model a wide class of curves and surfaces Same convenient properties of B-Splines Still widely used in AD systems Polar Forms: ubic Bspline urve NURBS For Uniform B-splines, uniform knot vector (below) For non-uniform, only reuire non-decreasing, not necessarily uniform (can be arbitrary) 1 1 1 2 Uniform knot vector: -2, -1,, 1, 2,3 Labels correspond to this -2 1 1 2 3 Outline Rational Splines Quadratic rational splines NURBs (briefly) Parametric patches (briefly) Parametric Patches Each patch is defined by blending control points FvDFH Figure 11.44 8
Parametric Patches Point Q(u,v) on the patch is the tensor product of curves defined by the control points Q(,) Q(,1) Q(u,v) Q(1,) Q(1,1) Watt Figure 6.21 Parametric Bicubic Patches Point Q(u,v) defined by combining control points with polynomial blending functions: P 1,1 P 1,2 P 1,3 P 1,4 P 2,1 P 2,2 P 2,3 P 2,4 Q(u,v) = UM M T V T P 3,1 P 3,2 P 3,3 P 3,4 P 4,1 P 4,2 P 4,3 P 4,4 U = u 3 u 2 u 1 V = v 3 v 2 v 1 Where M is a matrix describing the blending functions for a parametric cubic curve (e.g., Bezier, B-spline, etc.) Summary Splines still used commonly for modeling Start with simple spline curves (Bezier, uniform non-rational B-splines) Discussed extension to rational curves (add homogeneous coordinate for rational polynomial) Brief discussion of NURBs: widely used Brief discussion of Parametric patches for modeling surfaces (rather than curves) 9