Cloth Simulation CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Slides:



Advertisements
Similar presentations
Real-Time Game Physics
Advertisements

5. Using Newton’s Laws. Newton’s Third Law 3 Law of Action and Reaction Forces always occur in equal and opposite pairs A B A acts on B B acts on A.
1 Computer Graphics Physical simulation for animation Case study: The jello cube The Jello Cube Mass-Spring System Collision Detection Integrators.
Integration Techniques
Particle Systems CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.
Chapter 15: Kinetics of a Particle: Impulse and MomentumTextbook: Engineering Mechanics- STATICS and DYNAMICS- 11th Ed., R. C. Hibbeler and A. Gupta Course.
1Notes. 2 Building implicit surfaces  Simplest examples: a plane, a sphere  Can do unions and intersections with min and max  This works great for.
1Notes  Textbook: matchmove 6.7.2, B.9. 2 Match Move  For combining CG effects with real footage, need to match synthetic camera to real camera: “matchmove”
1Notes  Text:  Motion Blur A.3  Particle systems 4.5 (and 4.4.1, 6.6.2…)  Implicit Surfaces  Classic particle system papers  W. Reeves, “Particle.
Department of Physics and Applied Physics , F2010, Lecture 17 Physics I LECTURE 17 11/8/10.
Interactive Animation of Structured Deformable Objects Mathieu Desbrun Peter Schroder Alan Barr.
1cs426-winter-2008 Notes  If you’re interested, read Bridson, Hourihan, Nordenstam, “Curl noise for procedural fluid flow”, SIGGRAPH ‘07.
Game Physics Chris Miles. The Goal To learn how to create game objects with realistic physics models To learn how to simulate aspects of reality in order.
1cs426-winter-2008 Notes  Course project: Will be due at the end of the term You can do it in pairs Create an animation that combines an algorithm for.
1cs533d-term Notes  list Even if you’re just auditing!
Physics of Rolling Ball Coasters
Cloth Simulation CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.
Particle Systems CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.
1cs533d-term Notes. 2 Poisson Ratio  Real materials are essentially incompressible (for large deformation - neglecting foams and other weird composites…)
1cs533d-term Notes  Typo in test.rib --- fixed on the web now (PointsPolygon --> PointsPolygons)
Semester Physics 1901 (Advanced) A/Prof Geraint F. Lewis Rm 560, A29
Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg.
1cs426-winter-2008 Notes  Sorry about missed classes  Assignment 2: matchmove and particles  Final project.
1cs426-winter-2008 Notes. 2 Velocity fields  Velocity field could be a combination of pre-designed velocity elements E.g. explosions, vortices, …  Or.
Computer graphics & visualization Rigid Body Simulation.
Chapter 4 Dynamics: Newton’s Laws of Motion
Spring Forces and Simple Harmonic Motion
Linear Momentum and Collisions
Multimedia System and Networking UTD Slide- 1 University of Texas at Dallas B. Prabhakaran Particle Systems.
PHY131H1S - Class 17 Today: Review for Test 2!.
Vectors and Two-Dimensional Motion
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Physically Based Animation.
© 2007 Pearson Prentice Hall This work is protected by United States copyright laws and is provided solely for the use of instructors in teaching their.
Physically Based Animation and Modeling
Chapter 3 Vectors and Two-Dimensional Motion. Vector vs. Scalar Review All physical quantities encountered in this text will be either a scalar or a vector.
Game Physics – Part I Dan Fleck Coming up: Rigid Body Dynamics.
CHAPTER 13 Kinetics of Particles: Energy and Momentum Methods.
Chapter 7 Energy of a System. Introduction to Energy A variety of problems can be solved with Newton’s Laws and associated principles. Some problems that.
When the axis of rotation is fixed, all particles move in a circle. Because the object is rigid, they move through the same angular displacement in the.
Introduction to Procedural Methods, Particles Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Monday, March.
Chapter 8 Potential Energy. Potential energy is the energy associated with the configuration of a system of objects that exert forces on each other This.
Potential Energy ~March 1, 2006.
Dynamics: Newton’s Laws of Motion. Concepts Force Newton’s First Law of Motion Mass Newton’s Second Law of Motion Newton’s Third Law of Motion Weight.
Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan.
Dynamics: Newton’s Laws of Motion
Forces in Two Dimensions
© 2007 Pearson Prentice Hall This work is protected by United States copyright laws and is provided solely for the use of instructors in teaching their.
Particle Systems Derived from Steve Rotenberg, UCSD.
Particle Systems. Applications Particle systems are broadly defined for: Explosion Cloth Fluid And more… It is integrated into many animation software,
Rigid Body Dynamics CSE169: Computer Animation
© 2005 Pearson Prentice Hall This work is protected by United States copyright laws and is provided solely for the use of instructors in teaching their.
More on Particles Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, March 24, 2004.
Dynamics: Newton’s Laws of Motion. Force A force is a push or pull. An object at rest needs a force to get it moving; a moving object needs a force to.
© 2014 Pearson Education, Inc. This work is protected by United States copyright laws and is provided solely for the use of instructors in teaching their.
Game Technology Animation V Generate motion of objects using numerical simulation methods Physically Based Animation.
Advanced Games Development Game Physics CO2301 Games Development 1 Week 19.
Graphics for Games Particle Systems CO2301 Games Development 1 Week 23.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Sect. 9.2: Impulse & Momentum
Topic 2.2 Extended B – Applications of Newton’s second.
What is statics? Lecture 1
Dynamics: Newton’s Laws of Motion
Physics: Principles with Applications, 6th edition
Cloth Simulation 12/05/2015 PPGCC – Linha de Pesquisa SIV
Dynamics: Newton’s Laws of Motion (Ch. 12)
Physically Based Animation and Modeling
Physics: Principles with Applications, 6th edition
Physics: Principles with Applications, 6th edition
Presentation transcript:

Cloth Simulation CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004

Cloth Simulation Cloth simulation has been an important topic in computer animation since the early 1980’s It has been extensively researched, and has reached a point where it is *basically* a solved problem Today, we will look at a very basic method of cloth simulation. It is relatively easy to implement and can achieve good results. It will also serve as an introduction to some more advanced cloth simulation topics.

Cloth Simulation with Springs We will treat the cloth as a system of particles interconnected with spring-dampers Each spring-damper connects two particles, and generates a force based on their positions and velocities Each particle is also influenced by the force of gravity With those three simple forces (gravity, spring, & damping), we form the foundation of the cloth system Then, we can add some fancier forces such as aerodynamics, bending resistance, and collisions, plus additional features such as plastic deformation and tearing

Cloth Simulation Particle Spring-damper

Particle

Euler Integration Once we’ve computed all of the forces in the system, we can use Newton’s Second Law (f=ma) to compute the acceleration Then, we use the acceleration to advance the simulation forward by some time step Δt, using the simple Euler integration scheme

Physics Simulation General Physics Simulation: 1. Compute forces 2. Integrate motion - Repeat

Cloth Simulation 1. Compute Forces For each particle: Apply gravity For each spring-damper: Compute & apply forces For each triangle: Compute & apply aerodynamic forces 2. Integrate Motion For each particle: Apply forward Euler integration

Uniform Gravity

Spring-Dampers The basic spring-damper connects two particles and has three constants defining its behavior Spring constant: k s Damping factor: k d Rest length: l 0

Spring-Damper A simple spring-damper class might look like: class SpringDamper { float SpringConstant,DampingFactor; float RestLength; Particle *P1,*P2; public: void ComputeForce(); };

Spring-Dampers The basic linear spring force in one dimension is: The linear damping force is: We can define a spring-damper by just adding the two:

Spring-Dampers To compute the forces in 3D: Turn 3D distances & velocities into 1D Compute spring force in 1D Turn 1D force back into 3D force

Spring-Damper Force We start by computing the unit length vector e from r 1 to r 2 We can compute the distance l between the two points in the process

Spring-Dampers Next, we find the 1D velocities

Spring-Dampers Now, we can find the 1D force and map it back into 3D

Aerodynamic Force In the last lecture, we defined a simple aerodynamic drag force on an object as: ρ: density of the air (or water…) c d : coefficient of drag for the object a: cross sectional area of the object e: unit vector in the opposite direction of the velocity

Aerodynamic Force Today we will extend that to a simple flat surface Instead of opposing the velocity, the force pushes against the normal of the surface Note: This is a major simplification of real aerodynamic interactions, but it’s a good place to start

Aerodynamic Force In order to compute the aerodynamic forces, we need surfaces to apply it to We will add some triangles to our cloth definition, where each triangle connects three particles

Aerodynamic Force In order to compute our force: we will need find the velocity, normal, and area of the triangle (we can assume that ρ and c d are constants)

Aerodynamic Force For the velocity of the triangle, we can use the average of the three particle velocities We actually want the relative velocity, so we will then subtract off the velocity of the air

Aerodynamic Force The normal of the triangle is:

Aerodynamic Force The area of the triangle is: But we really want the cross- sectional area (the area exposed to the air flow)

Aerodynamic Force As the final equation requires |v| 2 an, we can reduce the math a little bit: Also, notice that:

Aerodynamic Force The final aerodynamic force is assumed to apply to the entire triangle We can turn this into a force on each particle by simply dividing by 3, and splitting the total force between them

Bending Forces If we arrange our cloth springs as they are in the picture, there will be nothing preventing the cloth from bending This may be find for simulating softer cloth, but for stiffer materials, we may want some resistance to bending

Bending Forces A simple solution is to add more springs, arranged in various configurations, such as the one in the picture The spring constants and damping factors of this layer might need to be tuned differently…

Collisions We will talk about collision detection & response in the next lecture… In the mean time, here’s a very basic way to collide with a y=y 0 plane If(r.y < y 0 ) { r.y= y 0 - r.y; v.y= - elasticity * v.y; v.x= (1-friction) * v.x;// cheezy v.z= (1-friction) * v.z;// cheezy }

Plastic Deformation An elastic deformation will restore back to its un-deformed state when all external forces are removed (such as the deformation in a spring, or in a rubber ball) A plastic deformation is a permanent adjustment of the material structure (such as the buckling of metal)

Plastic Deformation We can add a simple plastic deformation rule to the spring-dampers We do so by modifying the rest length Several possible rules can be used, but one simple way is to start by defining an elastic limit and plastic limit The elastic limit is the maximum deformation distance allowed before a plastic deformation occurs If the elastic limit is reached, the rest length of the spring is adjusted so that meets the elastic limit An additional plastic limit prevents the rest length from deforming beyond some value The plastic limit defines the maximum distance we are allowed to move the rest length

Fracture & Tearing We can also allow springs to break One way is to define a length (or percentage of rest length) that will cause the spring to break This can also be combined with the plastic deformation, so that fracture occurs at the plastic limit Another option is to base the breaking on the force of the spring (this will include damping effects) It’s real easy to break individual springs, but it may require some real bookkeeping to update the cloth mesh connectivity properly…

Ropes & Solids We can use this exact same scheme to simulate ropes, solids, and similar objects

System Stability

Conservation of Momentum As real springs apply equal and opposite forces to two points, they obey conservation of momentum Our simple spring-damper implementation should actually guarantee conservation of momentum, due to the way we explicitly apply the equal and opposite forces (This assumes that everything says within reasonable floating point ranges and we don’t suffer from excessive round-off)

Conservation of Energy True linear springs also conserve energy, as the kinetic energy of motion can be stored in the deformation energy of the spring and later restored The dampers, however are specifically intended to remove kinetic energy from the system Our simple implementation using Euler integration is not guaranteed to conserve energy, as we never explicitly deal with it as a quantity

Conservation of Energy If we formulate the equations correctly and take small enough time steps, the system will hopefully conserve energy approximately In practice, we might see a gradual increase or decrease in system energy over time A gradual decrease of energy implies that the system damps out and might eventually come to rest. A gradual increase, however, it not so nice…

Conservation of Energy There are particle schemes that conserve energy, and other schemes that preserve momentum (and/or angular momentum) It’s possible to conserve all three, but it becomes significantly more complicated This is important in engineering applications, but less so in entertainment applications Also, as we usually want things to come to rest, we explicitly put in some energy loss through controlled damping Still, we want to make sure that our integration scheme is stable enough not to gain energy

Simulation Stability If the simulation ‘blows up’ due to artificial energy gains, then it is said to be unstable The basic Euler integration scheme is the simplest, but can easily become unstable and require very small time steps in order to produce useful results There are many other integration schemes that improve this behavior We will only briefly mention these now, but might go over them in more detail in a future lecture

Integration There are many methods of numerical integration. Some examples are: Explicit Euler Implicit Euler Midpoint (Leapfrog) Crank-Nicolson Runge-Kutta Adams-Bashforth, Adams-Moulton etc…

Two-Level Integration Methods Explicit Euler: Implicit Euler Midpoint (Leapfrog): Crank-Nicolson:

Multipoint Methods Multipoint methods fit a polynomial to several values in time. Adams-Bashforth methods use only previous values, while Adams-Moulton combine these with implicitly computed future points. Second order Adams-Bashforth: Third order Adams-Moulton:

Runge-Kutta Methods The Runge-Kutta integration methods compute the value at step n+1 by computing several partial steps between n and n+1 and then constructing a polynomial to get the final value at n+1 Second order Runge-Kutta:

Cloth Stability To make our cloth stable, we should choose a better integration scheme (such as adaptive time-step fourth order Runge-Kutta) It’s actually not quite as bad as it sounds But, in the mean time, some other options include: Oversampling: For one 1/60 time step, update the cloth several times at smaller time steps (say 10 times at 1/600), then draw once Tuning numbers: High spring constants and damping factors will increase the instability. Lowering these will help, but will also make the cloth look more like rubber…

Advanced Cloth

Continuum Mechanics Real cloth simulation rarely uses springs Instead, forces are generated based on the the deformation of a triangular element This way, one can properly account for internal forces within the piece of cloth based on the theory of continuum mechanics The basic process is still very similar. Instead of looping through springs computing forces, one loops through the triangles and computes the forces Continuum models account for various properties such as elastic deformation, plastic deformation, bending forces, anisotropy, and more

Collision Detection & Response Cloth colliding with rigid objects is tricky Cloth colliding with itself is even trickier There have been several published papers on robust cloth collision detection and response methods

Integration Nobody uses forward Euler integration for cloth in the real world Modern systems use adaptive time steps, high order interpolation, and implicit integration schemes

Particle Systems

In computer animation, particle systems can be used for a wide variety of purposes, and so the rules governing their behavior may vary A good understanding of physics is a great place to start, but we shouldn’t always limit ourselves to following them strictly In addition to the physics of particle motion, several other issues should be considered when one uses particle systems in computer animation

Particles In physics, a basic particle is defined by it’s position, velocity, and mass In computer animation, we may want to add various other properties: Color Size Life span Anything else we want…

Creation & Destruction The example system we showed at the beginning had a fixed number of particles In practice, we want to be able to create and destroy particles on the fly Often times, we have a particle system that generates new particles at some rate The new particles are given initial properties according to some creation rule Particles then exist for a finite length of time until they are destroyed (based on some other rule)

Creation & Destruction This means that we need an efficient way of handling a variable number of particles For a realtime system, it’s usually a good idea to allocate a fixed maximum number of particles in an array, and then use a subset of those as active particles When a new particle is created, it uses a slot at the end of the array (cost: 1 integer increment) When a particle is destroyed, the last particle in the array is copied into its place (cost: 1 integer decrement & 1 particle copy) For a high quality animation system where we’re not as concerned about performance, we could just use a big list or variable sized array

Creation Rules It’s convenient to have a ‘CreationRule’ as an explicit class that contains information about how new particles are initialized This way, different creation rules can be used within the same particle system The creation rule would normally contain information about initial positions, velocities, colors, sizes, etc., and the variance on those properties A simple way to do creation rules is to store two particles: mean & variance (or min & max)

Creation Rules In addition to mean and variance properties, there may be a need to specify some geometry about the particle source For example, we could create particles at various points (defined by an array of points), or along lines, or even off of triangles One useful effect is to create particles at a random location on a triangle and give them an initial velocity in the direction of the normal. With this technique, we can emit particles off of geometric objects

Destruction Particles can be destroyed according to various rules A simple rule is to assign a limited life span to each particle (usually, the life span is assigned when the particle is created) Each frame, it’s life span decreases until it gets to 0, then the particle is destroyed One can add any other rules as well Sometimes, we can create new particles where an old one is destroyed. The new particles can start with the position & velocity of the old one, but then can add some variance to the velocity. This is useful for doing fireworks effects…

Randomness An important part of making particle systems look good is the use of randomness Giving particle properties a good initial random distribution can be very effective Properties can be initialized using uniform distributions, Gaussian distributions, or any other function desired

Particle Rendering Particles can be rendered using various techniques Points Lines (from last position to current position) Sprites (textured quad’s facing the camera) Geometry (small objects…) Or other approaches… For the particle physics, we are assuming that a particle has position but no orientation. However, for rendering purposes, we could keep track of a simple orientation and even add some rotating motion, etc…