370 likes | 593 Views
CS 551/651 Advanced Computer Graphics. Warping and Morphing Spring 2002. Deforming Objects. Changing an object’s shape Usually refers to non-simulated algorithms Usually relies on user guidance Easiest when shape number of faces and vertices is preserved Define the movements of vertices.
E N D
CS 551/651Advanced Computer Graphics Warping and Morphing Spring 2002
Deforming Objects • Changing an object’s shape • Usually refers to non-simulated algorithms • Usually relies on user guidance • Easiest when shape number of faces and vertices is preserved • Define the movements of vertices
Moving Vertices • Time consuming to define the trajectory through space of all vertices • Instead, control a few seed vertices which in turn affect nearby vertices
Defining Vertex Functions • If vertex i is displaced by (x, y, z) units • Displace each neighbor, j, of i by • (x, y, z) * f (i, j) • f (i,j) is typically a function of distance • Euclidean distance • Number of edges from i to j • Distance along surface
Vertex Displacement Function • i is the (shortest) number of edges between i and j • n is the max number of edges affected • (k=0) = linear; (k<0) = rigid; (k>0) = elastic • Figure 3.55
2-D Grid Deformation • 1974 film “Hunger” • Draw object on grid • Deform grid points • Use bilinear interpolation to recompute vertex positions on deformed grid • Draw example on board • Figure 3.57
Polyline Deformation • Draw a piecewise linear line (polyline) through the geometry • For each vertex compute • Closest polyline segment • Distance to segment • Relative distance along this segment • Deform polyline and recompute vertex positions
Global Deformations • Alan Barr, SIGGRAPH ’84 • A 3x3 transformation matrix affects all vertices • P’=M(P) .dot. P • M(P) can taper, twist, bend… • Figure 3.65 3.66
Free-Form Deformation (FFD) • Sederberg, SIGGRAPH ’86 • Position geometric object in local coordinate space • Build local coordinate representation • Deform local coordinate space and thus deform geometry
FFD • Similar to 2-D grid deformation • Define 3-D lattice surrounding geometry • Move grid points of lattice and deform geometry accordingly • Local coordinate system is initially defined by three (perhaps non orthogonal) vectors
Trilinear Interpolation • Let S, T, and U (with origin P0) define local coord axes of bounding box that encloses geometry • A vertex, P’s, coordinates are:
Volumetric Control Points • Each of S, T, and U axes are subdivided by control points • A lattice of control points is constructed • Bezier interpolation of move control points define new vertex positions
Using FFDs to Animate • Build control point lattice that is smaller than geometry • Move lattice through geometry so it affects different regions in sequence • Animate mouse under the rug, or subdermals (alien under your skin), etc. • Figure 3.74
Using FFDs to Animate • Build FFD lattice that is larger than geometry • Translate geometry within lattice so new deformations affect it with each move • Change shape of object to move along a path • Figure 3.75
Animating the FFD • Create interface for efficient manipulation of lattice control points over time • Connect lattices to rigid limbs of human skeleton • Figure 3.77 • Physically simulate control points
Morphing • 2D image metamorphosis • Coordinate Grid Approach • Feature-Based Approach
Coordinate Grid • Source and destination images • Overlay upon both a 2-D lattice of points • Points along edges must remain on edges • Internal points can be in different positions • Same number of points in both • Points define movement of pixels
Two-pass RenderingOverview • Figure 3.79
Morphing Images to Intermediate • First stretch in x direction and then in y direction • Auxiliary lattice has x coordinates from source and y coordinates from intermediate lattice
Morphing Images to Intermediate • Use scanline method to compute what pixels from source image map to a particular pixel of intermediate image
Feature-Based Morphing • Simplest case: user draws one ray on source and destination images to define morph
Local Coordinate Systems • Let the root of the ray in source image be the coordinate system origin • Let the ray in source image correspond to the v axis (unit length) • Construct perpendicular to this ray for u axis • Every pixel (x, y) of image now mapped to (u, v) using projection to u/v axes
Local Coordinate Systems • Perform similar local coordinate system computation for destination image • Build s/t axes
Mapping Destination to Source • (x, y)dest --- (s, t) • (s, t) --- (u, v) • (u, v) --- (x, y)source • Color (x, y)dest with (x, y)source
Necessary Details • More than one line • Perform mapping for all line segments • Weight each line segment’s contribution to averaged color value • Q2 – Q1 = distance of line segment • dist is distance from pixel to line • a and b are user specified
Necessary Details • Mapping from destination to pixel to source pixel will not land on pixel centers • Aliasing results… • Use quadrilateral centered at source (u, v) location to sample multiple pixels and average
Assignment 2 • Due 2 weeks from today • Implement Beier-Neely morphing using fltk and OpenGL • http://www.hammerhead.com/thad/morph.html • Details online tonight