Introduction to Computer Graphics Modeling (3) April 27, 2017 Kenshi Takayama
Solid modeling 2
Solid models Thin shapes represented by single polygons Unorientable Clear definition of inside & outside at any 3D point Open boundaries (holes) Self-intersections Non-solid cases Klein bottle Main usage: 3D printing Physics simulation 3
Predicate function of a solid model Function that returns true/false if a 3D point p R 3 is inside/outside of the model f p : R 3 true, false The whole interior of the model: p f p = true } R 3 Examples: Sphere of radius r centered at c Box whose min & max corners are x min, y min, z min & x max, y max, z max p max f p p c < r c r f x, y, z x min < x < x max y min < y < y max z min < z < z max p min 4
Constructive Solid Geometry (Boolean operations) Union f A B p f A (p) f B (p) A B C D E Intersection f A B p f A (p) f B (p) Subtraction f A B p f A (p) f B (p) A B C CSG Tree D 5 E
Solid model represented by Singed Distance Field Shortest distance from 3D point to model surface: d p : R 3 R Signed: positive outside, negative inside Corresponding predicate describing the solid: f p d(p) < 0 Zero isosurface model surface: {p d(p) = 0} R 3 Sphere of radius r centered at c d p p c r Aka. implicit or volumetric representation c r Isosurface normal matches with direction of gradient d(p) 6
Examples of implicit functions Torus with major & minor radii R & a Not necessarily distance functions 7
Examples of implicit functions: Metaballs c 4 c 3 d i p = q i r p c i c 1 d p = d 1 p + d 2 p + d 3 p + d 4 p i c 2 d p = d 1 p + d 2 (p) d p = d 1 p d 2 (p) 8
Morphing by interpolating implicit functions d 1 p = 0 1 2 3 d 1 p + 1 3 d 2 p = 0 3 d 1 p + 2 3 d 2 p = 0 d 2 p = 0 9
Modeling by combining implicit functions 10
Visualizing implicit functions: Marching Cubes Extract isosurface as triangle mesh For every lattice cell: (1) Compute function values at 8 corners (2) Determine type of output triangles based on the sign pattern Classified into 15 using symmetry (3) Determine vertex positions by linearly interpolating function values (Once patented, now expired ) Marching Cubes: A High Resolution 3D Surface Construction Algorithm [Lorensen SIGGRAPH87] 11
Ambiguity in Marching Cubes Discontinuous faces across neighboring cells New rules to resolve ambiguity The asymptotic decider: resolving the ambiguity in marching cubes [Nielson VIS91] 12
Marching Tetrahedra Use tetrahedra instead of cubes Fewer patterns, no ambiguity Simpler implementation A cube split into 6 tetrahedra (Make sure consistent splitting across neighboring cubes) Some techniques to improve mesh quality http://paulbourke.net/geometry/polygonise/ Regularised marching tetrahedra: improved iso-surface extraction [Treece C&G99] 13
Isosurface extraction preserving sharp edges Grid size: 65 65 65 Improved version (uses function gradient as well) Marching Cubes Improved version Marching Cubes (only uses function values) Feature Sensitive Surface Extraction from Volume Data [Kobbelt SIGGRAPH01] Dual Contouring of Hermite Data [Ju SIGGRAPH02] http://www.graphics.rwth-aachen.de/isoex/ 14
CSG with surface representation only Volumetric representation (=isosurface extraction using MC) Approximation accuracy depends on grid resolution CSG with surface representation only Exactly keep original mesh geometry Difficult to implement robust & efficient Floating point error Exactly coplanar faces Notable advances in recent years Fast, exact, linear booleans [Bernstein SGP09] Exact and Robust (Self-)Intersections for Polygonal Meshes [Campen EG10] Mesh Arrangements for Solid Geometry [Zhou SIGGRAPH16] https://libigl.github.io/libigl/tutorial/tutorial.html#booleanoperationsonmeshes 15
Mesh repair Volumetric representation Decide inside/outside by shooting rays from outside Surface representation Decide inside/outside based on generalized winding number Simplification and Repair of Polygonal Models Using Volumetric Techniques [Nooruddin TVCG03] Robust Inside-Outside Segmentation using Generalized Winding Numbers [Jacobson SIGGRAPH13] 16
Surface reconstruction from point cloud 17
Measuring 3D shapes Range Scanner (LIDAR) Depth Camera Obtained data: point cloud 3D coordinate Normal (surface orientation) Structured Light Normals not available? Normal estimation Too noisy? Denoising Multi-View Stereo Typical Computer Vision problems 18
Surface reconstruction from point cloud Input: N points Coordinate x i = x i, y i, z i & normal n i = n i x, n i y, ni z, i 1,, N Output: function f(x) satisfying value & gradient constraints f i f x i = 0 f x i = n i Zero isosurface f x = 0 output surface Scattered Data Interpolation Moving Least Squares Radial Basis Function Important to other fields (e.g. Machine Learning) as well 19
Two ways for controlling gradients Additional value constraints at offset locations Simple Directly include gradient constraint in the mathematical formulation (Hermite interpolation) High-quality Value+gradient constraints Hermite interpolation Simple offsetting Modelling with implicit surfaces that interpolate [Turk TOG02] Hermite Radial Basis Functions Implicits [Macedo CGF10] 20
Interpolation using Moving Least Squares 21
Starting point: Least SQuares For now, assume the function as linear: f x = ax + by + cz + d Unknowns: a, b, c, d x (x, y, z) Value constraints at data points f x 1 = ax 1 + by 1 + cz 1 + d = f 1 f x 2 = ax 2 + by 2 + cz 2 + d = f 2 f x N = ax N + by N + cz N + d = f N x 1 y 1 z 1 1 x 2 y 2 z 2 1 f 1 f 2 A a b c c d = f x N y N z N 1 f N (Forget about gradient constraints for now) 22
Overconstrained System #unknowns < #constraints (i.e. taller matrix) cannot exactly satisfy all the constraints normal equation A c f A c A = = A f Minimizing fitting error A c f 2 = N i=1 f x i f i 2 c = A A 1 f A 23
Geometric interpretation of LSQ q r d p x q x α p y q y = β p z q z r x r y r z β α p Project r onto a plane spanned by p & q Fitting error = projection distance d 2 = αp + βq r 2 24
Weighted Least Squares Each data point is weighted by w i Importance, confidence,... Minimize the following fitting error: N i=1 w i f x i f i 2 w 1 w2 W w N x 1 y 1 z 1 1 x 2 y 2 z 2 1 A a b c c d = W f x N y N z N 1 w 1 w2 w N f 1 f 2 f N 25
Weighted Least Squares W A c = W f c = A W 2 A 1 f A W 2 26
Moving Least Squares Weight w i is a function of evaluation point x : w i x = w( x x i ) Popular choices for the function (kernel): w r = e r2 /σ 2 w r = 1 r 2 +ε 2 Larger the weight as x is closer to x i Weighting matrix W is a function of x Coeffs a, b, c, d are functions of x f x = x y z 1 a(x) b(x) c(x) d(x) A W x 2 A 1 A W x 2 f 27
Introducing gradient (normal) constraints Consider linear function represented by each data point: g i x = f i + x x i n i Minimize fitting error to each g i evaluated at x : N i=1 w i x f x g i x 2 w 1 (x) w 2 (x) w N (x) x y z 1 x y z 1 x y z 1 a b c d = w 1 (x) w 2 (x) w N (x) g 1 x g 2 x g N x Interpolating and Approximating Implicit Surfaces from Polygon Soup [Shen SIGGRAPH04] 28
Introducing gradient (normal) constraints Normal constraints Simple offsetting Input : Polygon Soup Interpolation Approximation 1 Approximation 2 Approximation 3 Interpolating and Approximating Implicit Surfaces from Polygon Soup [Shen SIGGRAPH04] 29
Interpolation using Radial Basis Functions 30
Basic idea Define f(x) as weighted sum of basis functions φ(x) : f x = N i=1 w i φ(x x i ) Unknown Basis function translated to each data point x i Radial Basis Function φ(x) : only depends on the length of x φ x = e x 2 /σ 2 φ x = 1 x 2 +c 2 (Gaussian) (Inverse Multiquadric) Determine weights w i from constraints at data points f x i = f i 31
Basic idea Notation: φ i,j = φ x i x j f x 1 = w 1 φ 1,1 + w 2 φ 1,2 + + w N φ 1,N = f 1 f x 2 = w 1 φ 2,1 + w 2 φ 2,2 + + w N φ 2,N = f 2 φ 1,1 φ 1,2 φ 2,1 φ 2,2 φ 1,N φ 2,N w 1 w 2 f 1 f 2 Φ w = f φ N,1 φ N,2 φ N,N w N f N f x N = w 1 φ N,1 + w 2 φ N,2 + + w N φ N,N = f N Solve this! 32
When using Gaussian RBF φ x = e x 2 /σ 2 Results highly dependent on the choice of parameter σ σ 小 How to obtain the as-smooth-as-possible result? 大 Scattered Data Interpolation for Computer Graphics [Anjyo SIGGRAPH14 Course] 33
Measuring function s bend : Thin-Plate Energy 2 nd derivative (=curvature) magnitude integrated over the whole domain E 2 f = x R d Δf(x) 2 dx 1D case: Laplacian operator E 2 f = f x 2 dx x R 2D case: E 2 f = x R 2 f xx x 2 + 2f xy x 2 + f yy x 2 dx 3D case: E 2 f = x R 3 f xx x 2 + f yy x 2 + f zz x 2 + 2f xy x 2 + 2f yz x 2 + 2f zx x 2 dx 34
Known theory in the math literature Of all functions satisfying f x i = f i, the minimizer of E 2 is represented as RBFs with the following basis: 1D case: φ x = x 3 2D case: φ x = x 2 log x 3D case: φ x = x FYI Finite Element Method: Find f minimizing E 2 discretized over mesh RBF: Find f minimizing E 2 analytically Scattered Data Interpolation for Computer Graphics [Anjyo SIGGRAPH14 Course] 35
Additional linear term E 2 [f] is defined using 2 nd derivative Any additional linear term p x = ax + by + cz + d has no effect: E 2 f + p = E 2 [f] Make f unique by regarding linear term as additional unknowns: f x = N i=1 w i φ x x i + ax + by + cz + d 36
With linear term f x 1 = w 1 φ 1,1 + w 2 φ 1,2 + + w N φ 1,N + ax 1 + by 1 + cz 1 + d = f 1 f x 2 = w 1 φ 2,1 + w 2 φ 2,2 + + w N φ 2,N + ax 2 + by 2 + cz 2 + d = f 2 f x N = w 1 φ N,1 + w 2 φ N,2 + + w N φ N,N + ax N + by N + cz N + d = f N φ 1,1 φ 1,2 φ 1,N x 1 y 1 z 1 1 φ 2,1 φ 2,2 φ 2,N x 2 y 2 z 2 1 Φ P φ N,1 φ N,2 φ N,N x N y N z N 1 w 1 w 2 w w N a b cc d = f 1 f 2 f f N 4 unknowns a, b, c, d added 4 new constraints needed 37
Additional constraints: reproduction of all linear functions If all data points x i, f i are sampled from a linear function, RBF should reproduce the original function Additional constraints: N i=1 w i = 0 N i=1 x i w i = 0 N i=1 y i w i = 0 N i=1 z i w i = 0 Makes the matrix symmetric φ 1,1 φ 1,2 φ 1,N x 1 y 1 z 1 1 φ 2,1 φ 2,2 φ 2,N x 2 y 2 z 2 1 φ N,1 φ N,2 φ N,N x N y N z N 1 x 1 x 2 x N 0 0 0 0 y 1 y 2 y N 0 0 0 0 P z 1 z 2 y N 0 0 0 0 1 1 1 0 0 0 0 w 1 w 2 Φ P w f w N a b cc d = f 1 f 2 f N0 0 0 0 Scattered Data Interpolation for Computer Graphics [Anjyo SIGGRAPH14 Course] 38
Introducing gradient constraints Introduce weighted sum of basis gradient φ : f x = N i=1 w i φ x x i + v i φ x x i + ax + by + cz + d Unknown 3D vector Gradient of f : f x = N i=1 w i φ x x i + H φ x x i v i + a b c Incorporate gradient constraints f x i Hermite Radial Basis Functions Implicits [Macedo CGF10] = n i H φ x = φ xx φ xy φ xz φ yx φ yy φ yz φ zx φ zy φ zz Hessian matrix (function) 39
w 1 Introducing gradient constraints v 1 1 st data point: Value constraint: f x 1 = w 1 φ 1,1 + v 1 φ 1,1 + w 2 φ 1,2 + v 2 φ 1,2 + + w N φ 1,N + v N φ 1,N + ax 1 + by 1 + cz 1 + d = f 1 w 2 v 2 Gradient constraint: f x 1 = w 1 φ 1,1 + H φ 1,1 v 1 + w 2 φ 1,2 + H φ 1,2 v 2 + + w N φ 1,N + H φ 1,N v N + φ 1,1 φ 1,1 φ 1,1 H φ 1,1 φ 1,2 φ 1,2 φ 1,2 H φ 1,2 φ 1,N Hermite Radial Basis Functions Implicits [Macedo CGF10] φ 1,N φ 1,N Φ 1,1 Φ 1,2 Φ 1,N H φ 1,N x 1 y 1 z 1 1 1 0 0 0 P 0 1 1 0 0 0 0 1 0 a b c w N = n 1 = v N a b c d f 1 n 1 40
w 1 f 1 Φ 1,1 Φ 1,2 Φ 1,N P 1 v 1 n 1 w 2 f 2 Φ 2,1 Φ 2,2 Φ 2,N P 2 v 2 n 2 = w N f N Φ N,1 Φ N,2 Φ N,N P N v N n N P 1 P 2 P N 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a b c d 0 0 0 0 41
Comparison Gradient constraints Simple offsetting with value constraints only 42
References State of the Art in Surface Reconstruction from Point Clouds [Berger EG14 STAR] A survey of methods for moving least squares surfaces [Cheng PBG08] Scattered Data Interpolation for Computer Graphics [Anjyo SIGGRAPH14 Course] An as-short-as-possible introduction to the least squares, weighted least squares and moving least squares for scattered data approximation and interpolation [Nealen TechRep04] 43
References http://en.wikipedia.org/wiki/implicit_surface http://en.wikipedia.org/wiki/radial_basis_function http://en.wikipedia.org/wiki/thin_plate_spline http://en.wikipedia.org/wiki/polyharmonic_spline 44