3d eecs 487: interactive computer graphicsweb.eecs.umich.edu/.../lectures/41-procmodphysanim.pdfeecs...
TRANSCRIPT
EECS487:InteractiveComputerGraphicsLecture41:IntroductiontoProceduralModelingandAnimation• Fractals• Dynamics• Particlesystems• Behavioralanimation
ProceduralModelingConstructs3Dmodelsusingalgorithms• formodelsthataretoocomplex(ortedious)tocreatemanually,e.g.,• landscapes,mountains,clouds,planets• trees,plants,ecosystems• buildings,cities• usuallydefinedbyasmallsetofdata,orrules,thatdescribestheoverallpropertiesofthemodel,e.g.,treesdefinedbybranchingpropertiesandleafshapes• modelisthenconstructedbyanalgorithm• toaddvarietyandrealism,• ofteninvolvesfractalgeometry• oftenincludesrandomness• e.g.,asingletreepatterncanbeusedtomodelanentireforest
Schulze
Self-SimilaritySelf-similar:• viewingscalenotapparentfromobjectappearance• objectfeaturesarestatisticallysimilarbetweenobjectpartsandtheoverallobject• forexample,wealwaysseeajaggedlinenomatterhowclosewelookatacoastline
• infinitedetails:looksgoodandnaturalateveryresolution• achievedusingrandomnumbersandfractionaldimension
Usuallygeneratedbyrecursivelyapplyingthesameoperation(orsetofoperations)toanobject
Yu,Merrell
RandomnessMakesmodelsmoreinteresting,natural,andlessuniformand“clean”
Duetothediscreteandfinitenatureofcomputers,wecanonlygeneratepseudo-randomnumbers,basedonsomeinitialseedvalue
• pseudo-randomsequencesarerepeatable,simplybyresettingtheseedvalue• adifferentseedvaluegeneratesadifferentsequenceofpseudo-randomnumbers
• forrepeatability,becarefulofdynamiceventseffectingtheuseofthepseudo-randomsequence
Schulze
FractalDimensionMeasuresthe“roughness”ofobject• morejaggedobjectshavelargerfractaldimension
UseHausdorffvarianttoapproximatefractaldimension:• subdivideobjectintoself-similarpieceswithscalingfactors• countnumberofpieces(n)coveredbyoriginalobject• fractaldimensiond = log(n)/log(s)• e.g.,SierpinskiTriangle• takeatriangle• scaledownto½• make3copiesandarrangeintoatriangleoforiginalsize
• repeatforever• d = log(3)/log(2) = 1.58
Yu,Merrell
ProceduralTerrainModelingLandscapesareoftenconstructedasheightfields
Want:aheightfunctiony = h(x)Randommidpointdisplacement• startwithsomeinitialfigure(e.g.,lineortriangle)• splitatmidpointsandaddrandomdisplacement• recurse,decreasingthemagnitudeofdisplacements(byafactor0 < f < 1)
1DExample:
Yu,Merrell
2DExample
Yu
L-Systems
DevelopedbyA.Lindenmayer,abiologist,in1968tomodelgrowthpatternsofalgaeandplantsGrammar-basedfractal-likemodels,a.k.a.,“graftals”Basedonparallelstring-rewritingrules• describeanobjectbyastringofsymbols• andasetofproduction/rewritingrules• incorporatenotionssuchasbranching,pruning,…
Schulze,Yu
L-SystemsExtensions
Bracketed:save/restorestate(forbranches)
Parametric:productiongovernsbyparameter,e.g.,changecoloratcertainlevelofrecursion
Stochastic:randomlychooseoneofseveralproductionrulesprovidedforasymbol
Contextsensitive:productionbasedonneighboringsymbols
Hodgins
L-SystemsDefineagrammar:G = {V, S, ω, P}• V:alphabet,setofsymbolsthatcanbereplaced(variables)• S:setofsymbolsthatremainfixed(constants)• ω:axiom,stringofsymbolsdefininginitialstate• P:production/rewritingrulesExample:• V:A,B • S:• +:turnleft• -:turnright• [:pushstateontostack• ]:popstatefromstack• ω:B • P:B→A[+B][-B]
Schulze,Kuffner
ParametricL-SystemTurtlegraphics:• F:drawforward• f:moveforward• +:turnleftbyangle//parameter• -:turnrightbyangle//parameter• [:pushcurrentstateontostack• ]:popcurrentstatefromthestack
Koch’sSnowflake• angle(2π)/6 //parameter• axiomF • productionrule:F→F+F--F+F
Start:F Generation1:F+F--F+F Generation2:• F+F--F+F+F+F--F+F--F+F--F+F+F+F--F+F
Generationn:
TurtleGraphicsKoch’sIsland:• angle(2π)/4 • axiomF+F+F+F • productionrule:F→F+F-F-FF+F+F-F
Tree:• angle(2π)/16• axiom++++FS• productionrule:S→+[FS]-[FS]-[FS]
L-SystemsforPlantsL-systemscancapturealargenumberofplantspecies,thoughdesigningrulesforspecificspeciesisnoteasySeealgorithmicbotany.org/papers/• afree200pagesebook• coversmanyvariantofL-systemsanddifferentplanttypes
Hodgins
L-SystemforCities
real generated
Streetsystem:• startwithasinglestreet• branchandextendwithparametricL-system• parameters:goalsandconstraints• goalscontrolstreetdirection,spacing• constraintsallowforparks,bridges,roadloops
Hodgins
Parish01
L-SystemforCities
Buildings:• buildingshapesarerepresentedasCSGoperationsonsimpleshapes
Hodgins
Mülleretal.06 Wonkaetal.03
Parish&Müller01
Keyframing:interpolatesmotionfrom“key”positions+ perfectcontrol canbetedious norealism
Procedural:solvesequationstocomputemotion+ realisticmotion+ automaticgeneration• onceyouhavetheprogram,youcangetlotsofmotion
difficulttocontrol hardtotellastorywithpurelyproceduralmeans• mostlyusedforsupportingbackground/effects
Motion
McMillan
ProceduralAnimation
Usingaprocesstocontroloranimatesomeattribute,includingshape(modeling),oftheobject
Steps:• programsomerulesforhowthesystemwillbehave
• choosesomeinitialconditionsfortheworld
• runtheprogram,maybewithuserinputtoguidewhathappens
• programoutputstheposition/shapeofthesceneovertime
Chenney
ProceduralAnimationPhysically-basedanimation• dynamics:movements
• pointmassparticlesystems
• spring-mass:animatingtheshapeandreactionofcloth
• fluidflow:waterwaves
Behavioralanimation
• birdorfishflocking
• crowdanimation
Physically-basedAnimation
Kinematic(keyframing):describesmotionwithoutconsideringcausesleadingtomotion• considersonlyposes
Dynamics(procedural):considersunderlyingforces• inversedynamics:• givenprescribedmotion,whataretheforcesandtorquesrequired?
• forwarddynamics:• computemotionfrominitialconditionsandphysicallaws:• givenforcesandtorques,whatisthemotion?
Funkhouser09,Hodgins,Funge99
InverseDynamicsGivenprescribedmotion,whataretheforcesandtorquesrequired?
Activecharacter:characterhasinternalsourceofenergy
Animatorspecifiesconstraints:• character’sphysicalstructure• e.g.,articulatedfigure
• character’stask• e.g.,jumpfromheretothereintimet
• otherphysicalstructurespresent• e.g.,floortopushoffandland
• motionrequirements• e.g.,minimizeenergy
Funkhouser,Lasseter
InverseDynamicsComputersolvesforthe“best”physicalmotionsatisfyingconstraints
Example:objectwithjetpropulsion
• x(t):positionofobjectattimet
• f(t):propulsionforceattimet
• equationofmotion:mx” − f − mg = 0
• task:movefromatobfromt0tot1withminimumjetfuel,minimizewithx(t0) = aandx(t1) = b
• solvewithiterativeoptimizationmethod
Funkhouser
f (t)2t0
t1
∫ dt
Witkin&Kass
InverseDynamicsAdvantages:• animatorsdon’thavetospecifydetailsofphysicallyrealisticmotionwithsplinecurves• easytovarymotionsduetonewparametersand/ornewconstraints
Forexample,adaptingmotion:
originaljump heavierbaseFunkhouser,Witkin&Kass
E.g.,withstatemachines
Challenges:• specifyingconstraintsandobjectivefunctions• avoidinglocalminimaduringoptimization• retargetingmotiontonewcharacters• needalargervarietyofmotions(notjustwell-definedsportmotions)• real-timeperformance
ControllingMotion
Funkhouser,Hodgins
compression decompression flight1 flight2 landinghorse
compression
decompression
flight1
flight2
entry
E.g.,withstatemachines
Challenges:• specifyingconstraintsandobjectivefunctions• avoidinglocalminimaduringoptimization• retargetingmotiontonewcharacters• needalargervarietyofmotions(notjustwell-definedsportmotions)• real-timeperformance
ControllingMotion
Funkhouser,Hodgins
compression decompression flight1 flight2 landinghorse
compression
decompression
flight1
flight2
entry
ForwardDynamics
Funkhouser,Hodgins,McAllister
Giveninitialconditionsandphysicallaws,whatisthemotion?• initialconditions:mass,forces,torques
• applyphysicallaws,e.g.,Newton’slaws,Hook’slaw,etc.
• simulatephysicalphenomena:• gravity,momentum(inertia),friction,collisions,elasticity,solidity,flexibility,fracture,explosion,fluidflow,aerodynamics(drag/viscosity,turbulence)
• motioncomputedusingnumericalsimulationmethods• particlesystems• rigidbodies• soft-objects(spring-mass)• fluid
HowtoRenderFire?
Gilles
Texturemappingpolygonsisfastandacceptableforshort-livedeffects• overlayaflamepointwithaseriesoftexturedpolygons• forenhancedrealism,wecouldintroducesecondarylightsourcesatthefire
Problems:• hardtosustainforlongperiods• hardtospreadorchangeshape• notranslucency
ParticleSystems
Gilles,Funkhouser
Approximateflame,andotheramorphousobjects,byadiscretesetofsmallparticlesSingleparticlesareverysimple,justpointmasswithattributes:• mass,position• velocity,forces• color,temperature,shape• lifetime
Largegroupscanproduceinterestingeffects:• rockets:fireworks• clouds:waterdrops
x = (x, y, z)
v
ParticleSystems
Gilles,Funkhouser,Reeves
Foreachframe:• createnewparticlesaccordingtoaprobabilitydistributionandassignattributes• deleteanyexpiredparticles• updateparticlesbasedonattributesandphysics• numericalsolutionstoODE• renderparticles:motionblur,compositing
Wheretocreateparticles?• predefinedsources• surfaceofshape• whereparticledensityislow,etc.
ParticleSystems
Funkhouser,Gilles,McAllister
Whentodeleteparticles?• predefinedsink• surfaceofshape• wheredensityishigh• lifetime• random
Example:water• newparticlescreatedeachframe• thenumbercreatedperframeisnormallydistributed• eachparticlehasinitialdownwardvelocity• again,normallydistributed• oneachsuccessiveframe,eachparticleisactedonby“wind”forcetotheright
Impact
Treuille
?
Davidhazy
Static:• radius• mass(m)• racquetinfo
Dynamic:• position(x)• velocity(v)• rotation?
Newtonianparticles:F = m a• Fandaarevectors• givenFandpositionattimet,x(t),howdoesthepositionchangetox(t+1)?
DifferentialEquations
Witkin&Baraff
Differentialequationsdescribetherelationbetweenanunknownfunctionanditsderivatives
Solvingadifferentialequationmeansfindingafunctionthatsatisfiestherelation,plussomeadditionalconstraints
OrdinaryDifferentialEquation(ODE):• “ordinary”:functionofonevariable• partialdifferentialequation(PDE):morevariables
Discretetime:x t +1( ) = f x t( ),t( )Continuoustime:
dx t( )dt
= f x t( ),t( )positionvelocity
x =
xyz!x!y!z
⎡
⎣
⎢⎢⎢⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥⎥⎥⎥
DifferentialEquations
Funkhouser,Durand
Computingparticlemotionrequiressolvinga2nd-orderdifferentialequation:
Instead,addvariablevtoformcoupled1st-orderdifferentialequations:
Foranimation,wantaseriesofvaluesx(ti), i = 0, 1, 2, …• samplesofthecontinuousfunctionx(t)
x = F(x, x,t)m
v = x, v = F(x,v,t)m
notation!x fordx / dt
f(x, t)isavectorfielddefinedeverywhere• e.g.,avelocityfield
• itmaychangebasedont• x(t)isapaththroughthefield:• usuallynoanalyticalsolution
PathThroughaField
x(t) = x0 + f (x,t)dtt0
t
∫
x(t)
howtocompute?
Sincewe’reworkinginfixed-frameintervals,wecanuseasimpleapproximation(Euler’smethod):• definestepsizeh
• givenx0 = x(t0),takestep:�t1 = t0 + h�x(t1) = x0 + h f(x0, t0)
• piecewise-linearapproximationofthecurve• stepsizecontrolsaccuracy:smaller,moreaccurate• mayneedtotakemanysmallstepsperframe
SolvingtheIntegration
Durand
f(x, t)
f(x0, t)
x0
SolvingtheIntegration
Durand
Euler’smethodisthesimplestnumericalmethod
ConsidertheTaylorexpansionofx(t):
theequationforEuler’smethodsimplydisregardshigher-ordertermsandreplacesthefirstderivativewiththeflowfieldfunction�theerrorisontheorderofO(h2)Consequences:Euler’smethodisinaccurateandunstable
x t + h( ) = x t( ) + hdxdt
+ h2
2d 2xdt 2
+
Euler’sMethod:InaccurateTomovealongacircle:Movingalongtangent,e.g.,Euler’smethodx(ti) = xi−1 + h f(xi−1, ti−1) spiralsoutward,canleavecurve,nomatterhowsmallhis• smallerh willjustdivergemoreslowly
x = f (x,t) = −yx
⎛
⎝⎜⎞
⎠⎟
Durand
x(t) =r cos(t + h)r sin(t + h)
⎛
⎝⎜
⎞
⎠⎟
Euler’sMethod:UnstableConsiderthefollowingsystem:Exactsolutionisdecayingexponential:Limitedstepsize:Ifkisbig,hmustbesmall
Durand
x = −kx, x(0) = 1x = x0e
−kt
xi = xi−1 − h kxi−1( ) = (1− hk)xi−1
h ≤ 1/k, okh > 1/k, oscillates±h > 2/k, explodes
�
SolvingtheIntegration
HowcanweimproveuponEuler’smethod?
ByaddinganothertermfromtheTaylor’sexpansionofx(t):Considertwoalternatives:• theTrapezoidmethod• theMidpointmethodbothhaveerrorsontheorderofO(h3)
x t + h( ) = x t( ) + hdxdt
+h2
2d 2xdt 2
+
TrapezoidMethodx(ti) = xi−1 + h f(xi−1, ti−1)
Problem:approximatedfvariesfromactualfIdea:considerfatthearrivalofthestepand
compensateforvariationf1
a
b
Durand
Letf0 = f(x0, t0)f1 = f(x0 + hf0, t0 + h)
Thena = hf0, b = hf1, x(t0 + h) = x0+ (a + b)/2 + O(h3)x(t0 + h) = x0+ h(f0 + f1)/2 + O(h3) Thisisthetrapeziodmethod,a.k.a.improvedEuler’smethod
MidpointMethodx(ti) = xi−1 + h f(xi−1, ti−1)
Problem:approximatedfvariesfromactualfIdea:considerfathalfstepandcompensateforvariation
Durand
ChooseΔx = h/2 f(x0, t0)thenrearrangeasbefore,letf0 = f(x0, t0)
fmid = f(x0 + h/2 f0, t0 + h/2)thenx(t0 + h) = x0+ hfmid + O(h3)Thisisthemidpointmethod,a.k.a.,2nd-orderRunge-Kutta
fm
Comparison
Midpoint:• ½Eulerstep• evaluatefmid• computestepusingfmid
Trapezoid:• Eulerstep(a)• evaluatef1• computestepusingf1(b)• average(a)and(b)
Notexactlythesameresult,butsameorderofaccuracy
f1a
b
Durand
Higher-OrderRunge-Kutta4thorder:popularbecauseordershigherthan4thneedmorestagesthanorderstocompute
k1 = hf (x0 ,t0 )
k2 = hf (x0 +k12,t0 +
h2)
k3 = hf (x0 +k22,t0 +
h2)
k4 = hf (x0 + k3,t0 + h)
x(t0 + h) = x0 +16k1 +
13k2 +
13k3 +
16k4 +O(h
5 )
order 1 2 3 4 5 6 7 8stages 1 2 3 4 6 7 9 11
Treuille
Forcesactingontheparticlesystemisasumofanumberofthings
Forcefields:• gravity:constantdownwardforceproportionaltomassf = −mg,�g: gravitationalconstant,9.78 m/sec2onEarth
• otherparticles:particlesmutuallyattract/repell
• attractiveforce:
• repulsiveforce:
• bewareO(n2)complexity!
MaytheForce...
O’Brien,Durand
v0
m g
f = Gm1m2dd 3
f = −krdd 3
pi
pj
Collisionswithenvironment,otherparticles• detection:potentiallargenumberneeded,usehierarchicalboundingvolumes• response:particleshapeandsizeneeded• duetotemporalaliasing,sub-framecalculationrequiredsoasnottomisscollisiontime
Collisions
Durand
v
p
v’n
vvn
vt
vn = (v�n)nvt = v − vn
v’−krvn
vt
v’ = vt − krvnkr:coeficientof
restitution
MissedCollisionsWanttodetectcollisionwhen (x−p)•n < ε, ε ≥ 0 Oftencollisiondetectedwhenv�n < 0
Solution:backtrack• computeintersectionpoint• ray-objectintersection!• computeresponsethere• reconstructforremainingfractionaltimestep
Othersolution/hack:• projecttosurfacepointclosesttoobject
fixing
backtracking
Durand
vp
nx
Simplerendering:• projectparticlestoviewframe• blendparticleprojectionwithframebuffercontent(translucency)
Particlecolor:• makecolorafunctionofage• makecolorafunctionoftemperature• requiresotherODEstogoverntheseproperties
ParticleSystemsRendering
Gilles
SmokeParticleSystem
ConstantlycreateparticlesParticlesmoveupwards,withPerlinturbulenceaddedDrawthemaspartiallytransparentcirclesthatfadeovertime
Chenney
Pre-renderbitmapoffireball
Real-timerenderedglow
Animatedglowingparticles
Quake
Gilles
TreesinAndreandWallyB.
LotsoftreesEachtreebranchesrecursivelyLeavesasparticles• millionsofparticles• needasimplemodelforshadingeach
ShadingModelforTrees
Ambient• dependentonhowdeepinthetreeda• independentoflightposition
Diffuse• dependentondistanceddinsidethetree,inthedirectionoflight
Shadowed• ifbelowplane,onlyambientused
Spring-MassSystems
Modelobjectsassystemsofspringsandmasses
Thespringsexertforces,controlledbychangingtheirrestlength
Areasonable,butsimple,physicalmodelformuscles
Advantage:goodlookingmotionwhenitworks
Disadvantage:expensiveandhardtocontrol
Chenney
Manytypesofcloth• verydifferentproperties• notasimpleelasticsurface• wovenfabricstendtobeverystiff• anisotropic
Resolutionofmeshiscritical
Computationofcollisionsisexpensive
Cloth
Hodgins,Breen,Popovic
stretchspringsshearspringsbendsprings
ChallengesforPhysically-BasedAnimation
ExpensiveandnotnecessarilyrealisticWhatpiecesofphysicsarenecessaryforappearance?Howtogiveanimatorcontrol?• howtogiveartistsanddirectorstheresultstheywant?
Chenney,Hodgins
PerceptualHacksViewerscanbeprettyoblivioustothingslikeincorrectbouncesandcan’texactlypredicthowthingsbreakJustmakesureobjectsdon’tgothroughwallsShiftemphasisfromphysicalaccuracytofast-and-looks-good
Hodgins
BehavioralAnimation
Definerulesforthewayanobjectbehavesandinteracts• programsimplementtherules• objectsrespondtotheirchangingenvironment
Classicexample:“boids”(CraigReynolds)• emergentbehavior:flocking• reallyjustaparticlesystemwithabitofperceptionandabitofbrainpower
Hodgins
Flocking
Eachboidperceivesneighborsinaneighborhood
Eachboid’sbehaviorisasimplefunctionofnearbyboids:• separationforce• steertoavoidcrowdinglocalteammates,keepminimumdistance
• alignmentforce• alignvelocities
• cohesionforce• movetowardsaveragepositionofneighbors
http://www.red3d.com/cwr/boids/http://www.riversoftavg.com/downloads.htm
AnimationSummary(brief)
Technique ControlTimetoCreate
ComputationCost
Interactivity
Key-Framed Excellent Poor Low Low
MotionCapture
Goodattimeofcreation,afterthatpoor
Medium Medium Medium
Procedural Poor Poortocreateprogram
High High
Chenney
HowAreMoviesAnimated?
Keyframingmostly
Articulatedfigures,inversekinematics
Skinning• complexdeformableskin,muscle,skinmotion
Hierarchicalcontrols• smilecontrol,eyeblinking,etc.• keyframesforthesehigher-levelcontrols
Ahugetimeisspentbuildingthe3Dmodels,itsskeletonanditscontrols
Durand
MixingTechniquesApplyphysicalsimulationofsecondarymotionontopofkey-framedprimarymotion• particularlyappropriateforcloth,hair,water• useparticlesystemsfor“fuzzy”objects
Mixmotion-captureandphysics:• motion-capturedpersonkicksaballwhichisthenphysicallysimulatedfortrajectory
Chenney