CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

36
CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002

Transcript of CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

Page 1: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

CS 551/651Advanced Computer Graphics

Warping and Morphing

Spring 2002

Page 2: 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

Page 3: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

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

Page 4: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

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

Page 5: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

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

0;1

0.1)(

0;1

0.1)(

1

1

kn

iif

kn

iif

k

k

Page 6: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.
Page 7: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

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

Page 8: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.
Page 9: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

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

Page 10: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

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

Page 11: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.
Page 12: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.
Page 13: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

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

Page 14: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

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

Page 15: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

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:

UTS

PPTSu

TSU

PPSUt

SUT

PPUTs

)()(

)()(

)()(

0

0

0

Page 16: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

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

ijk

kknn

k

jjmm

j

iill

i

ijk

Puuk

ntt

j

mss

i

lutsP

Un

kT

m

jS

l

iPP

UuTtSsPP

)1()1()1(),,(000

0

0

Page 17: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

Examples

Page 18: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

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

Page 19: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.
Page 20: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

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

Page 21: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.
Page 22: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

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

Page 23: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.
Page 24: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

Morphing

• 2D image metamorphosis

– Coordinate Grid Approach

– Feature-Based Approach

Page 25: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

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

Page 26: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

Two-pass RenderingOverview

• Figure 3.79

Page 27: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

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

Page 28: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

Morphing Images to Intermediate

– Use scanline method to compute what pixels from source image map to a particular pixel of intermediate image

Page 29: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

Feature-Based Morphing

• Simplest case: user draws one ray on source and destination images to define morph

Page 30: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

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

Page 31: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

Local Coordinate Systems

Page 32: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

Local Coordinate Systems

• Perform similar local coordinate system computation for destination image– Build s/t axes

Page 33: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

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

Page 34: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

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

bp

dista

QQw

12

Page 35: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

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

Page 36: CS 551/651 Advanced Computer Graphics Warping and Morphing Spring 2002.

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