![Page 1: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/1.jpg)
CS559: Computer Graphics
Lecture 24: Shape ModelingLi Zhang
Spring 2010
![Page 2: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/2.jpg)
Polygon Meshes• A mesh is a set of polygons connected to form an
object• A mesh has several components, or geometric
entities:– Faces– Edges
• the boundary between faces– Vertices
• the boundaries between edges, • or where three or more faces meet
– Normals, Texture coordinates, colors, shading coefficients, etc
• What is the counterpart of a polygon mesh in curve modeling?
![Page 3: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/3.jpg)
OpenGL and Vertex Indirectionstruct Vertex {
float coords[3];}struct Triangle {
GLuint verts[3];}struct Mesh {
struct Vertex vertices[m];struct Triangle triangles[n];
}
glEnableClientState(GL_VERTEX_ARRAY)glVertexPointer(3, GL_FLOAT, sizeof(struct Vertex),
mesh.vertices);glBegin(GL_TRIANGLES)
for ( i = 0 ; i < n ; i++ ){
glArrayElement(mesh.triangles[i].verts[0]); glArrayElement(mesh.triangles[i].verts[1]); glArrayElement(mesh.triangles[i].verts[2]);
}
glEnd();
![Page 4: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/4.jpg)
Normal Vectors in Mesh• Normal vectors give information about the true
surface shape• Per-Face normals:
– One normal vector for each face, stored as part of face (Flat shading)
struct Vertex {float coords[3];
}struct Triangle {
GLuint verts[3];float normal[3];
}struct Mesh {
struct Vertex vertices[m];struct Triangle triangles[n];
}
![Page 5: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/5.jpg)
Normal Vectors in Mesh• Normal vectors give information about the true
surface shape• Per-Vertex normals:
– A normal specified for every vertex (smooth shading)
struct Vertex {float coords[3];float normal[3];
}struct Triangle {
GLuint verts[3];}struct Mesh {
struct Vertex vertices[m];struct Triangle triangles[n];
}
![Page 6: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/6.jpg)
Other Data in Mesh• Normal vectors give information about the true
surface shape• Per-Vertex normals:
– A normal specified for every vertex (smooth shading)• Per-Vertex Texture Coordstruct Vertex {
float coords[3];float normal[3];float texCoords[2];
}struct Triangle {
GLuint verts[3];}struct Mesh {
Vertex vertices[m];Triangle triangles[n];
}
![Page 7: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/7.jpg)
Other Data in Mesh• Normal vectors give information about the true
surface shape• Per-Vertex normals:
– A normal specified for every vertex (smooth shading)• Per-Vertex Texture Coord, Shading Coefficientsstruct Vertex {
float coords[3];float normal[3];float texCoords[2], diffuse[3], shininess;
}struct Triangle {
GLuint verts[3];}struct Mesh {
Vertex vertices[m];Triangle triangles[n];
}
![Page 8: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/8.jpg)
Issues with Polygons• They are inherently an approximation
– Things like silhouettes can never be perfect without very large numbers of polygons, and corresponding expense
– Normal vectors are not specified everywhere
• Interaction is a problem– Dragging points around is time consuming– Maintaining things like smoothness is difficult
• Low level representation– Eg: Hard to increase, or decrease, the resolution– Hard to extract information like curvature
![Page 9: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/9.jpg)
In Project 3, we use Sweep Objects
• Define a polygon by its edges• Sweep it along a path• The path taken by the edges form a surface - the sweep surface• Special cases
– Surface of revolution: Rotate edges about an axis– Extrusion: Sweep along a straight line
![Page 10: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/10.jpg)
General Sweeps• The path maybe any curve
![Page 11: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/11.jpg)
General Sweeps• The path maybe any curve• The polygon that is swept may be transformed as
it is moved along the path– Scale, rotate with respect to path orientation, …
Cube Twisted Cube
![Page 12: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/12.jpg)
General Sweeps• The path maybe any curve• The polygon that is swept may be transformed as it is
moved along the path– Scale, rotate with respect to path orientation, …
• One common way to specify is:– Give a poly-line (sequence of line segments) as the path– Give a poly-line as the shape to sweep– Give a transformation to apply at the vertex of each path
segment• Texture Coord? • Difficult to avoid self-intersection
![Page 13: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/13.jpg)
Klein Bottle
Torus
Klein Bottle
![Page 14: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/14.jpg)
Mobious Strip
Non-orientable surfaces
![Page 15: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/15.jpg)
Change Topology when Sweeping
![Page 16: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/16.jpg)
Spatial Enumeration• Basic idea: Describe something by the space it
occupies– For example, break the volume of interest into lots
of tiny cubes• Data is associated with each voxel (volume element),
binary or grayscale.• Works well for things like medical data (MRI or CAT
scans, enumerates the volume)
![Page 17: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/17.jpg)
Spatial Enumeration• Basic idea: Describe something by the space it
occupies– For example, break the volume of interest into lots
of tiny cubes• Data is associated with each voxel (volume element),
binary or grayscale.• Works well for things like medical data (MRI or CAT
scans, enumerates the volume)
• Problem to overcome:– For anything other than small volumes or low
resolutions, the number of voxels explodes– Note that the number of voxels grows with the cube
of linear dimension
![Page 18: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/18.jpg)
Quadtree Idea
![Page 19: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/19.jpg)
Octrees (and Quadtrees)• Build a tree for adaptive voxel resolution
– Large voxel for smooth regions– Small voxel for fine structures
• Quadtree is for 2D (four children for each node)• Octree is for 3D (eight children for each node)
![Page 20: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/20.jpg)
Rendering Octrees• Volume rendering renders octrees and associated data
directly– A special area of graphics, visualization, not covered in this
class• Can convert to polygons:
– Find iso-surfaces within the volume and render those– Typically do some interpolation (smoothing) to get rid of
the artifacts from the voxelization
![Page 21: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/21.jpg)
Rendering Octrees• Typically render with colors that indicate
something about the data
One MRI slice Surface rendering with color coded brain activity
![Page 22: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/22.jpg)
Parametric surface• Line Segments (1D) -> polygon meshes (2D)• Cubic curves (1D) -> BiCubic Surfaces (2D)
– Bezier curve -> Bezier surface
![Page 23: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/23.jpg)
Bilinear Bezier Patch• Define a surface that passes through a, b, c, d?
Looks familiar?
![Page 24: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/24.jpg)
Biquadratic Bezier Patch• Define a surface that passes a 3x3 control lattice.
u
v
p(u,0) = (1-u)2 p00 + 2(1-u)u p10 + u2 p20
p(u,1) = (1-u)2 p01 + 2(1-u)u p11 + u2 p21
p(u,2) = (1-u)2 p02 + 2(1-u)u p12 + u2 p22
p(u,v) = (1-v)2 p(u,0) + 2(1-v)v p(u,1) + v2 p(u,2)
![Page 25: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/25.jpg)
Bicubic Bezier Patch• 4x4 control points?
• Demo: http://www.nbb.cornell.edu/neurobio/land/OldStudentProjects/cs490-96to97/anson/BezierPatchApplet/index.html
• Connecting Bezier Patches, demo on the same page.
![Page 26: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/26.jpg)
De Casteljau algorithm in 2D
p100(u,v) = Bilinear(p00, p10, p01, p11; u, v)
p110(u,v) = Bilinear(p10, p20, p11, p21; u, v)
p101(u,v) = Bilinear(p01, p11, p02, p12; u, v)
p111(u,v) = Bilinear(p11, p21, p12, p22; u, v)
p100(u,v) = Bilinear(p00, p10, p01, p11; u, v)
![Page 27: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/27.jpg)
Different degree in different directions
u
v
![Page 28: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/28.jpg)
General Formula for Bezier Patch• If we have contronl points pi,j on a m by n lattice,
• Properties– Invariant to affine transform– Convex combination,– Used for intersection
![Page 29: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/29.jpg)
General Formula for Bezier Patch• If we have contronl points pi,j on a m by n lattice,
• Surface Normal
![Page 30: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/30.jpg)
Issues with Bezier Patches• With Bézier or B-spline patches, modeling
complex surfaces amounts to trying to cover them with pieces of rectangular cloth.
• It’s not easy, and often not possible if you don’t make some of the patch edges degenerate (yielding triangular patches).
• Trying to animate that object can make continuity very difficult, and if you’re not very careful, your model will show creases and artifacts near patch seams.
• Subdivision Surface is a promising solution.
![Page 31: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/31.jpg)
Subdivision Surface• From a coarse control mesh to smooth mesh with
infinite resolution
![Page 32: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/32.jpg)
Example: Toy story 2
![Page 33: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/33.jpg)
Subdivision CurveWe have seen this idea before
Shirley, Figure 15.15, The limiting curve is a quadratic Bezier Curve
RTR 3e, Figure 13.29, The limiting curve is a quadratic B-spline
![Page 34: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/34.jpg)
Subdivision Curves: Approximating
Initial (Control) Curve:
For each iteration k+1, add two vertices between:
Approximating: Limit curve is very smooth (C2), but does not pass through control points
![Page 35: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/35.jpg)
Subdivision Curves: Interpolating
Initial (Control) Curve:
For each iteration k+1, add two vertices between:
Interpolating: for 0<w<1/8, limit curve is C1, and passes through control points
![Page 36: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/36.jpg)
Subdivision Curves: Interpolating• Handling Boundary Cases
![Page 37: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/37.jpg)
Subdivision Surfaces
Extend subdivision idea from curves to surfaces
RTR, 3e, figure 13.32
![Page 38: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/38.jpg)
Basic Steps
![Page 39: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/39.jpg)
Loop Subdivision
• Regular vertex: valence = 6• Irregular vertex: valence != 6• Irregular vertices can only be initial vertices.
![Page 40: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/40.jpg)
Loop Subdivision
![Page 41: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/41.jpg)
Loop Subdivision
C2 for regular verticesC1 for irregular vertices
![Page 42: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/42.jpg)
Limiting Surface• Position and tangent of a vertex of the limiting
surface can be computed directly
∞
![Page 43: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/43.jpg)
Sqrt(3) subdivision
![Page 44: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/44.jpg)
Sqrt(3) subdivision
![Page 45: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/45.jpg)
Sqrt(3) subdivision
C2 for regular verticesC1 for irregular vertices
![Page 46: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/46.jpg)
Sqrt(3) subdivision
![Page 47: CS559: Computer Graphics Lecture 24: Shape Modeling Li Zhang Spring 2010](https://reader035.vdocuments.us/reader035/viewer/2022062322/56649f055503460f94c19d7c/html5/thumbnails/47.jpg)
Sqrt(3) vs Loop
+ slower triangle growth rate+ better for adaptive subdivision- Edge flipping adds complexity- Less intuitive at first few iterations