CS-C3100 Computer Graphics Spline Surfaces, Subdivision Surfaces vectorportal.com
Trivia Assignment 1 due this Sunday! Feedback on the starter code, difficulty, etc., much appreciated Put in your README in the submission 2
Awesome Interactive Spline Intro http://www.ibiblio.org/e-notes/splines/intro.htm 3
See something? Say something! 4
Representing Surfaces Triangle meshes Surface analogue of polylines, this is what GPUs draw Tensor Product Splines Surface analogue of spline curves Subdivision surfaces Implicit surfaces f(x,y,z)=0 Procedural e.g. surfaces of revolution, generalized cylinder From volume data (medical images, etc.) 5
Triangle Meshes What you ve used so far in Asst 1 Triangle represented by 3 vertices Pro: simple, can be rendered directly Cons: not smooth, needs many triangles to approximate smooth surfaces (tessellation) 6
Smooth Surfaces? P(t) = (1-t) 3 P 1 + 3t(1-t) 2 P 2 + 3t 2 (1-t) P 3 + t 3 P 4 What s the dimensionality of a curve? 1D! What about a surface? 7
How to Build Them? P(u) = (1-u) 3 P 1 + 3u(1-u) 2 P 2 + 3u 2 (1-u) P 3 + u 3 P 4 (Note! We relabeled t to u) 8
How to Build Them? Here s an Idea P(u) = (1-u) 3 P 1 + 3u(1-u) 2 P 2 + 3u 2 (1-u) P 3 + u 3 P 4 (Note! We relabeled t to u) 9
Here s an Idea P(u, v) = (1-u) 3 P 1 (v) + 3u(1-u) 2 P 2 (v) + 3u 2 (1-u) P 3 (v) + u 3 P 4 (v) Let s make the Pis move along curves! v=0 v=1 10
Here s an Idea P(u, v) = (1-u) 3 P 1 (v) + 3u(1-u) 2 P 2 (v) + 3u 2 (1-u) P 3 (v) + u 3 P 4 (v) Let s make the Pis move along curves! v=0 v=1 11
Here s an Idea P(u, v) = (1-u) 3 P 1 (v) + 3u(1-u) 2 P 2 (v) + 3u 2 (1-u) P 3 (v) + u 3 P 4 (v) Let s make the Pis move along curves! v=0 v=1/3 v=1 12
Here s an Idea P(u, v) = (1-u) 3 P 1 (v) + 3u(1-u) 2 P 2 (v) + 3u 2 (1-u) P 3 (v) + u 3 P 4 (v) Let s make the Pis move along curves! v=0 v=1/3 v=2/3 v=1 13
Here s an Idea P(u, v) = (1-u) 3 P 1 (v) + 3u(1-u) 2 P 2 (v) + 3u 2 (1-u) P 3 (v) + u 3 P 4 (v) Let s make the Pis move along curves! v=0 v=1/3 v=2/3 v=1 14
Here s an Idea P(u, v) = (1-u) 3 P 1 (v) + 3u(1-u) 2 P 2 (v) + 3u 2 (1-u) P 3 (v) + u 3 P 4 (v) Let s make the Pis move along curves! A 2D surface patch! s=0 s=1/3 s=2/3 s=1 15
Tensor Product Bézier Patches In the previous, Pi(v) were just some curves What if we make them Bézier curves too? 16
Tensor Product Bézier Patches In the previous, Pi(v) were just some curves What if we make them Bézier curves too? Each u=const. and v=const. curve is a Bézier curve! Note that the boundary control points (except corners) are NOT interpolated! v=0 v=1 v=2/3 17
Tensor Product Bézier Patches A bicubic Bézier surface 18
Tensor Product Bézier Patches Note that only the 4 corners are interpolated! The Control Mesh 16 control points 19
Bicubics, Tensor Product P(u,v) = B1(u) * P 1 (v) + B2(u) * P 2 (v) + B3(u) * P 3 (v) + B4(u) * P 4 (v) P4,1 P3,2 P4,2 P4,3 P4,4 Pi(v) = B1(v) * Pi,1 + B2(v) * Pi,2 + B3(v) * Pi,3 + B4(v) * Pi,4 P3,1 P2,1 P2,2 P2,3 P3,3 P2,4 P3,4 P1,4 P1,1 P1,2 P1,3 20
Bicubics, Tensor Product P(u,v) = B1(u) * P 1 (v) + B2(u) * P 2 (v) + B3(u) * P 3 (v) + B4(u) * P 4 (v) Pi(v) = B1(v) * Pi,1 + B2(v) * Pi,2 + B3(v) * Pi,3 + B4(v) * Pi,4 P (u, v) = = 4 i=1 4 i=1 B i (u) 4 j=1 4 j=1 P i,j B j (v) P i,j B i,j (u, v) B i,j (u, v) =B i (u)b j (v)
Bicubics, Tensor Product P(u,v) = B1(u) * P 1 (v) + B2(u) * P 2 (v) + B3(u) * P 3 (v) + B4(u) * P 4 (v) Pi(v) = B1(v) * Pi,1 + B2(v) * Pi,2 + B3(v) * Pi,3 + B4(v) * Pi,4 P (u, v) = 4 4 B i (u) P i,j B j (v) 16 control points Pi,j i=1 j=1 16 2D basis functions Bi,j = 4 i=1 4 j=1 P i,j B i,j (u, v) B i,j (u, v) =B i (u)b j (v)
Recap: Tensor Bézier Patches Parametric surface P(u,v) is a cubic polynomial of two variables u & v Defined by 4x4=16 control points P1,1, P1,2... P4,4 Interpolates 4 corners, approximates others 23
Tensor Product Bézier Patches Defined by 4x4=16 control points P1,1, P1,2... P4,4 Basis are product of two Bernstein polynomials: B1(u)B1(v); B1(u)B2(v);... B4(u)B4(v) 24
Questions? 25
Tangents and Normals for Patches P(u,v) is a 3D point specified by u, v The partial derivatives P/ u and are 3D vectors Both are tangent to surface at P P/ v 26
Tangents and Normals for Patches P(u,v) is a 3D point specified by u, v The partial derivatives P/ u and are 3D vectors Both are tangent to surface at P Normal is perpendicular to both, i.e., n =( P/ u) ( P/ v) P/ v n is usually not unit, so must normalize! 27
Questions? 28
Recap: Matrix Notation for Curves Cubic Bézier in matrix notation point on curve (2x1 vector) P(t) = x(t) y(t) x 1 x 2 x 3 x 4 y 1 y 2 y 3 y 4 Geometry matrix of control points P1..P4 (2 x 4) = 1 3 3 1 0 3 6 3 0 0 3 3 0 0 0 1 Spline matrix (Bernstein) Canonical power basis 1 t t 2 t 3 29
Hardcore: Matrix Notation for Patches Not required, but convenient! x coordinate of surface at (u,v) P (u, v) = 4 B i (u) 4 i=1 j=1 P i,j B j (v) P x (u, v) = P1,1 x.. P1,4 x (B 1 (u),...,b 4 (u)).. P4,1 x.. P4,4 x Row vector of basis functions (u) 4x4 matrix of x coordinates of the control points Column vector of basis functions (v) B 1 (v). B 4 (v) 30
Hardcore: Matrix Notation for Patches Curves: Surfaces: P (t) =GBT(t) P x (u, v) =T (u) T B T G x BT(v) T = power basis B = spline matrix G = geometry matrix A separate 4x4 geometry matrix for x, y, z 31
Super Hardcore: Tensor Notation You can stack the G x, G y, G z matrices into a geometry tensor of control points I.e., G k i,j = the k:th coordinate of control point Pi,j A cube of numbers! P k (u, v) =T l (u) B i l G k ij B j m T m (v) Einstein summation convention : Repeated indices are summed over (here l, m, i, j) Definitely not required, but nice! :) See http://en.wikipedia.org/wiki/multilinear_algebra 32
33
Tensor Product B-Spline Patches Bézier and B-Spline curves are both cubics => Can change between representations using matrices Consequently, you can build tensor product surface patches out of B-Splines just as well Still 4x4 control points for each patch 2D basis functions are pairwise products of B-Spline basis functions Sliding window of 4x4 points Yes, simple! 34
Tensor Product Spline Patches Pros Smooth Defined by reasonably small set of points Cons Harder to render (usually converted to triangles) Tricky to ensure continuity at patch boundaries Extensions Rational splines: Splines in homogeneous coordinates NURBS: Non-Uniform Rational B-Splines Like curves: ratio of polynomials, non-uniform location of control points, etc. 35
Utah Teapot: Tensor Bézier Splines Designed by Martin Newell 36
Cool: Displacement Mapping Not all surfaces are smooth... 37
Cool: Displacement Mapping Not all surfaces are smooth... Paint displacements on a smooth surface For example, in the direction of normal Tessellate smooth patch into fine grid, then add displacement D(u,v) to vertices Heavily used in movies, more and more in games 38
Displacement Mapping Example? Smooth base surface Displaced Surface zbrushcentral 39
Displacement Mapping Video Here, input triangles are also dynamically tessellated by the GPU http://www.youtube.com/watch?v=xdlc6taqc20 40
Subdivision Surfaces Start with polygonal mesh Subdivide into larger number of polygons, smooth result after each subdivision Lots of ways to do this. The limit surface is smooth! 41
Corner Cutting Slide by Adi Levin 42
Corner Cutting 3 : 1 1 : 3 Slide by Adi Levin 43
Corner Cutting 44
Corner Cutting Slide by Adi Levin 45
Corner Cutting Slide by Adi Levin 46
Corner Cutting Slide by Adi Levin 47
Corner Cutting Slide by Adi Levin 48
Corner Cutting Slide by Adi Levin 49
Corner Cutting A control point The limit curve The control polygon Slide by Adi Levin 50
A control point It turns out corner cutting (Chaikin s Algorithm) produces a quadratic B- Spline curve! (Magic!) The limit curve The control polygon Slide by Adi Levin 51
Corner Cutting A control point It turns out corner cutting (Chaikin s Algorithm) produces a quadratic B- Spline curve! (Magic!) The limit curve (Well, not totally unexpected, remember de Casteljau) The control polygon Slide by Adi Levin 52
Subdivision Curves and Surfaces Idea: cut corners to smooth Add points and compute weighted average of neighbors Same for surfaces Special case for irregular vertices vertex with more or less than 6 neighbors in a triangle mesh Warren et al. 53
Assignment 2: Loop Subdivision (Named after Charles Loop) 2 9 3 1 6 5 4 8 54
Assignment 2: Loop Subdivision The input mesh 2 9 3 1 6 5 4 8 55
Assignment 2: Loop Subdivision First step: insert vertices in the middle of all edges 2 19 9 23 20 18 3 22 21 6 10 12 1 11 16 15 17 5 14 4 13 8 56
Assignment 2: Loop Subdivision Then compute positions for new vertices Weighted combinations of the connected old vertices Need adjacency information (details in handout) p 11 = 1 8 p 5 + 1 8 p 6+ 3 8 p 1 + 3 8 p 4 w=1/8 6 w=3/8 1 11 5 w=1/8 4 w=3/8 57
Assignment 2: Loop Subdivision Then compute new positions for all old vertices! Again weighted combinations of nearby old vertices Need to find all n connected vertices p 0 1 =(1 nb) p 1 + B(p 2 + p 9 + p 5 + p 4 + p 6 + p 3 ) w=b 2 9 w=b B = ( 3 8n, n > 3 3 16, n =3 w=b 3 w=b 6 1 5 w=b w=1-nb 4 w=b 58
Assignment 2: Loop Subdivision Finally, split all input triangles into four: 2 19 9 23 20 18 3 22 21 6 10 12 1 11 16 15 17 5 14 4 13 8 59
Assignment 2: Loop Subdivision This becomes the new base mesh for next round 60
Assignment 2: Loop Subdivision Pictures Input mesh 61
Assignment 2: Loop Subdivision 1st level of subdivision 62
Assignment 2: Loop Subdivision 2nd level of subdivision etc. 63
Flavors of Subdivision Surfaces Catmull-Clark Quads and triangles Generalizes bicubics to arbitrary topology! Loop, Butterfly Triangles Leif Kobbelt Doo-Sabin, sqrt(3), biquartic... and a whole host of others Used everywhere in movie and game modeling! See http://www.cs.nyu.edu/~dzorin/sig00course/ 64
Subdivision Curves and Surfaces Advantages Arbitrary topology Smooth at boundaries Level of detail, scalable Simple representation Numerical stability, well-behaved meshes Code simplicity Little disadvantage: Procedural definition Not parametric, not implicit Tricky at special vertices 65 Warren et al.
Subdivision + Displacement zbrushcentral 66
Subdivision + Displacement Final Model Epic Games Control Mesh 67
ZBrush Modeling Session http://www.youtube.com/watch? v=i8livwn8zmq 68
Questions? 69
The remainder is for extra credit in Assignment 2! 70
Specialized Procedural Definitions Surfaces of revolution Rotate given 2D profile curve Generalized cylinders Given 2D profile and 3D curve, sweep the profile along the 3D curve Assignment 1 extras 71
Surface of Revolution 2D curve q(u) provides one dimension Note: works also with 3D curve Rotation R(v) provides 2nd dimension v s(u,v) s(u,v)=r(v)q(u) where R is a matrix, q a vector, and s is a point on the surface 72
General Swept Surfaces Trace out surface by moving a profile curve along a trajectory. profile curve q(u) provides one dim trajectory c(u) provides the other Surface of revolution can be seen as a special case where trajectory is a circle s q c s(u,v)=m(c(v))q(u) where M is a matrix that depends on the trajectory c 73
General Swept Surfaces How do we get M? Translation is easy, given by c(v) What about orientation? Orientation options: Align profile curve with an axis. Better: Align profile curve with frame that follows the curve s q c s(u,v)=m(c(v))q(u) where M is a matrix that depends on the trajectory c 74
Normals for Swept Surfaces Need partial derivatives w.r.t. both u and v n =( P/ u) ( P/ v) Remember to normalize! One given by tangent of profile curve, the other by the trajectory s q c s(u,v)=m(c(v))q(u) where M is a matrix that depends on the trajectory c 75
Frames on Curves: Frenet Frame Frame defined by 1st (tangent), 2nd (curvature) and 3rd (torsion) derivatives of a 3D curve Looks like a good idea for swept surfaces... 76
Frenet: Problem at Inflection! Normal flips! Bad to define a smooth swept surface An inflection is a point where curvature changes sign 77
Smooth Frames on Curves Tangent is assumed reliable Build triplet of vectors include tangent orthonormal coherent over the curve Idea: use cross product to create orthogonal vectors exploit discretization of curve use previous frame to bootstrap orientation See Assignment 1 instructions! 78
Questions? 79
Implicit Surfaces Implicit definition: f(x,y,z)=0 e.g. for a sphere: x 2 +y 2 +z 2 =R 2 Often defined as metaballs with seed points f(x,y,z)=f1(x,y,z)+f2(x,y,z)+... where fi depends on distance to a seed point Pi P1 P2 From Blinn 1982 80
Implicit Surfaces Pros: Can handle weird topology for animation Easy to do sketchy modeling Some data comes this way (medical & scientific data) Cons: Does not allow us to easily generate a point on the surface 81
Implicit Surfaces Most common method to generate mesh from isosurface: Marching Cubes (see link for details) 82
Questions? 83
Point Set Surfaces Given only a noisy 3D point cloud (no connectivity), can you define a reasonable surface using only the points? Laser range scans only give you points, so this is potentially useful? 84
Point Set Surfaces Alexa et al. 2001 85
Point Set Surfaces Modern take on implicit surfaces Cool math: Moving Least Squares (MLS), partitions of unity, etc. Ohtake et al. 2003 Not required in this class, but nice to know. 86
Questions? 87
That s All for Today Further reading on subvision curves and surfaces http://www.cs.nyu.edu/~dzorin/sig00course/ Guilherme Marconi 88