1 / 51

18 - Cloth Simulation

cs7057: Real-time Physics. 18 - Cloth Simulation. Demo. Curtain demo (with code) in processing http ://www.openprocessing.org/visuals/? visualID=20140 Also see (with Kinect ) http:// www.vimeo.com/20964926. Cloth. Flexible material consisting of a network of natural or artificial fibres

dunn
Télécharger la présentation

18 - Cloth Simulation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. cs7057: Real-time Physics 18 - Cloth Simulation

  2. Demo Curtain demo (with code) in processing http://www.openprocessing.org/visuals/?visualID=20140 Also see (with Kinect) http://www.vimeo.com/20964926

  3. Cloth • Flexible material consisting of a network of natural or artificial fibres • Basic behaviour: • Stretch/Compression:Displacement along warp or weft direction. • Can't compress at all. • Stretched to a limit of 10 percent. • Shear:Displacement along diagonal directions. • Bend:Curvature of cloth surface. • Easy to bend.

  4. Properties of Cloth • Drape • Wrinkle/Buckling • Hard to simulate because it has, • Many primitives and/or nodes at model, • High degree of freedom at those nodes, • Not perfectly elastic, has stiffness against stretch, • Variety of properties. • Collision detection is also hard; same reasons. • Must decide between Simple Model vs. Realism. • Often modelled as elastically deformable solids • However cloth behaviour is different from normal elastic models: Non linear response to strain

  5. Equations of Motion External Forces (Newton II) Internal Forces • e.g. Gravity State update Euler example: Damping (dissipation of mechanical energy)

  6. Structural Model • Point masses e.g. Particle system: • Specify "distance" constraint using flexible spring model: • Structural springs : Sheet-like property • Shearsprings : Resist shearing • Bend(flexion) springs : Resist bending + + + = Point Masses Structural Springs Shear Springs Bending Springs

  7. Problems with Basic Model Elongation of springs at pinned corners is much higher than other springs (>100%). Locally concentrated deformation (super elastic behaviour) - hardly ever occurs in woven fabrics Also high oscillation: can be solved by damping but looks like cloth is soaked in oil

  8. Increasing Stiffness Small timestep • Obvious solution to reducing super elastic effect but has problems • High stiffness can lead to instability: • Must take more shorter time steps to ensure stability • Leads to more processing time for same length of animation • Critical stiffness value KC • Dependent on natural period of oscillation T0 Large timestep

  9. Constraining Deformations • The “Rigid Cloth” Technique by Provot • Goal: avoid super elastic effect without decreasing Dt • Solution • Simulate Mass-spring systems as usual • Calculate deformation rate of each spring • Iff deformation rate > critical deformation rate tC • Apply “dynamic inverse procedure” to limit deformation to tC • E.g. If tC= 0.1, springs do not ever exceed 110% length See a code example here: http://www.xbdev.net/physics/Verlet/index.php

  10. Practical Example Taken from: http://www.xbdev.net/physics/Verlet/index.php void SatisfyConstraints()       {             const intnumIterations = 10;              for (inti=0; i<numIterations; i++)             {                   for (int k=0; k< m_numConstraints; k++)                   {                         // Constraint 1 (Floor)                         if (g_floorCollisions)                               for (int v=0; v<m_numPoints; v++)                               {                                 if (m_points[v].curPos.y < 0.0f) m_points[v].curPos.y = 0.0f;                               }                          // Constraint 2 (Cloth)                         Constraint* c = &m_constraints[k];                         D3DXVECTOR3& p0 = m_points[c->index0].curPos;                         D3DXVECTOR3& p1 = m_points[c->index1].curPos;                         D3DXVECTOR3 delta = p1-p0;                         float len = D3DXVec3Length(&delta);                         float diff = (len - c->restLength) / len;                         p0 += delta*0.5f*diff;                         p1 -= delta*0.5f*diff;                   }                    // Keep these two points contraints to there original position                   float gap = g_gap; m_points[0].curPos          = D3DXVECTOR3(0,                g_disOffFloor, 0); m_points[g_width-1].curPos  = D3DXVECTOR3((g_width-1)*gap,  g_disOffFloor, 0);             }       }        void Update(float dt)       { VerletIntegrate(dt); SatisfyConstraints();       } We could do something more complicated here

  11. Verlet Integration • Originated in molecular dynamics (central difference approximation: find x based on previous frame and next frame) • A velocity-free formulation (velocity implicitly represented by current and previous positions) • in code (store current x and previous x): • x = 2*x – x_prev + a *h^2; • x_prev = x; • Not always accurate but fast and stable • Everything depends on position – so good for constraints (e.g. Rag dolls, cloth) See: Jakobsen GDC 2001 talk: Advanced Character Physics http://www.floatingorigin.com/mirror/jacobson_01.shtml

  12. Results (1) After 200 frames of animation Applied to structural and shear springs Applied to structural springs

  13. Results (2) “Rigid” Technique tC= 0.05 Basic Spring-Mass High Stiffness Low Stiffness

  14. Other Techniques • Baraff & Witkin: Large time steps in cloth simulation • Uniform triangular mesh • Continuum model: solve internal energy equations • Implicit Integration: System of equations solved by modified Conjugate Gradient method • Adaptive time step – leads to graceful degradation David Baraffand Andrew Witkin, “Large steps in cloth simulation” SIGGRAPH '98

  15. Other Techniques • Desbrun et al: Cloth as IK • Hybrid approach • Mass-spring system: Force based simulation • Solve with Inverse Kinematics to ensure stiffness • Implicit Euler integration Mathieu Desbrun, Peter Schroder, and Alan Barr. “Interactive animation of structured deformable objects” In Proceedings Graphics interface 1999.

  16. Other Techniques • Cloth on the GPU • Particle collision and update can be done in shaders (several papers on this) • Overview of cloth onGPU: • For every particle, apply external forces • In each relaxation step, for each cloth particle • a) Evaluate the spring constraints and forces • b) For every intersectable scene geometry, check for collisions and solve collisions by moving the particle out of collided volume. Cyril Zeller. Cloth Simulation - White Paper, nVidia. http://portal.acm.org/citation.cfm?id=1187158 http://developer.download.nvidia.com/whitepapers/2007/SDK10/Cloth.pdf

  17. Other Techniques • Geometric solution on GPU • Assume tightly stretched over surface apply geometric techniques to fake effects such as wrinkling JörnLoviscach. Wrinkling coarse meshes on the GPU. In Proceedings of Eurographics2006.

  18. Other Techniques • Tonnes of other techniques! • See the following recent review: • M. AdilYalçın, CansınYıldız “Techniques for animating Cloth” unpublished survey, Bilkent University. 2009. • http://www.cs.bilkent.edu.tr/~cansin/projects/cs567-animation/cloth/cloth-paper.pdf

  19. References • Seminal paper on easy spring-mass cloth simulation (N.B. not the first cloth paper): • Xavier Provot: “Deformation Constraints in a Mass-Spring Model to Describe Rigid Cloth Behaviour” • http://graphics.stanford.edu/courses/cs468-02-winter/Papers/Rigidcloth.pdf • Useful math and integration: • Michael Hauth: “Numerical Techniques for Cloth Simulation” Siggraph 2003 Course Notes (The math required for cloth) • http://www.gris.uni-tuebingen.de/people/staff/mhauth/tutorials/Vis03/SIG2003Tut29lNumerics.pdf

  20. cs7057: Real-time Physics 19 - Deformable Object Collisions

  21. Applications • Most common: • Characters • Cloth • Also: • Deformable solids • Fluids • Destruction • Sound Synthesis

  22. Differences from Rigid Bodies • Self-collisions: Rigid bodies do not self-collide • Contact points: can often simulate (convex) rigid bodies with just 1 contact pt • Pre-processing: acceleration through spatial data structures such as BVH, distance fields, spatial hashing, cannot be pre-generated for deformable objects or require constant update • Contact model: more detail required for accurate simulation e.g. penetration depth, more detailed manifold model • Performance: higher demands on efficiency for deformable, may require different granularity of data

  23. Main Techniques • Bounding volume hierarchies (slides 22 – 35) • Distance Fields (slides 36) • Spatial Partitioning • Image-space techniques • Stochastic Methods

  24. BVH Basic Algorithm: traverse(A,B) if A and B do not overlap then return end if if A and B are leaves then return intersection of primitives enclosed by A and B else for all children A[i] and B[j] do traverse(A[i],B[j]) end for end if • Main components: • Generation • Update • Traversal • arity of BVH (num children) • Overlap test

  25. BVH # children per node • Studies have shown that better performance obtained for deformable objects with 4-ary and 8-ary trees [Larsson 01][Mezger 03] Binary Trees 4-ary Trees

  26. BVH Construction • Split/merge to generate the tree • With rigid bodies: minimize overlap (reduces redundancy) • With deformable: avoid clustering of faces that are very close to each other in initial state but not close based on connectivity • use merge regions based on topology (regularise based on number of primitives) [VMT94, VMT95] • [Pro97] top down split into imbricatingzones • Construction may need to be done on the fly

  27. BVH Hierarchy Update • BVH needs to be updated in every frame of simulation • Hierarchy Update: • Refit • about 10x faster than rebuilding [van den Bergen 1997] • no significant performance loss if topology is conserved • Rebuild • tighter bounds and less overlap between nodes • Bottom-up usually better if many deep nodes are typically reached [Larsson et al 2001] • Omit update for some frames: [Mezger et al 2003] • inflate nodes by d and don’t update unless nodes move by greater than d

  28. BVH Node Update Updating Larson et al propose a hybrid technique that combines breadth-first and depth-first traversal for deformable object Bounding volumes Thomas Larsson and Tomas Akenine-Möller, Collision Detection for Continuously Deforming Bodies, Eurographics 2001.

  29. BVH Refitting - Bounded Deformations • If BVH’s are superpositions of displacement fields, update has little cost [James et al 04] (next slide)

  30. BD-Trees Bounded Deformation Tree, or BD-Tree, can perform collision detection with reduced deformable models at costs comparable to collision detection with rigid objects James and Pai. BD-Tree: Output-Sensitive Collision Detection for Reduced Deformable Models. SIGGRAPH 2004.

  31. BD-Tree Update • Preprocess: • Compute Bounding Box of leaves • Compute parent BB in bottom-up order • Use wrapped hierarchy tree: each level covers geometry covered by its children (does not just bound its children) • At Run Time – Refit Tree • Refitting AABB takes constant time - Ten times faster than rebuilding it • Refitted tree has more overlap James and Pai. BD-Tree: Output-Sensitive Collision Detection for Reduced Deformable Models. SIGGRAPH 2004.

  32. K-Dop Update

  33. Morph Update • In animation intermediate frames are generated by blending/morphing between 2 targets • Construct a BVH for one of the targets and fit to other targets • All BV’s of tree are stored for each target (nodes not created/removed) Morph-aware hierarchy creation Larson & Moller “Efficient collision detection for models deformed by morphing” The visual computer 19, 2-3 (2003)

  34. Self-Collisions • Particularly important for cloth • Basic solution: BVH tested against self • Some problems: Neighbouring BVH’s always overlap

  35. Self-collision detection • Examine curvature: • find n with which dot product of normals is position; • If n exists AND projection of object in direction of n does not overlap then no self-intersection [Volino et al 94] • Normal cones [Provot 97] • bounding cone encapsulates range of normals in a region • cull areas of low curvature from self-collision processing

  36. CCD • Continuous collision detection is important for some rigid bodies: • Cloth: typical thin primitives (easily tunnelled through) • Surgery simulations: accurate physics is vital for interaction • Various techniques (not detailed here) • Typically create time-space bound covering t0->t1 • extended to cloth [Bridson 2002] • Calculate BV that encloses BVs in t0->t1 [Eckstein 99] • Adaptive step size + robust root detection [Grabner 03] • Velocity cones [Mezger 03] • Sort vertices radially and check outer ones [Fahn 99]

  37. BVH – AABB • Axis Aligned Bounding Box Advantages: • Easiest to compute • Easiest to check for interference • They do not provide the best fitting volume, but this concept becomes a bit fuzzy for deformable objects Best fit : sphere Best fit : box

  38. AABB Trees • Problem statement: the surface of an object is tessellated with polygons • The hierarchy of boxes can be quickly updated using the following property: • Let Sm(R) be the smallest AABB of a region R and r1, r1 two regions. • The hierarchy is updated in O(n) time • Note: this is not the same as rebuilding the hierarchy refitting rebuilding [Van Den Bergen 1998] Public domain library: http://www.win.tue.nl/~gino/solid/index.html

  39. Distance Fields • Specify (signed) distance to a closed surface for all points in the field (3D grid) • Surface is the zero level set • Allows fast evaluation of distances and normals: constant time • Independent of complexity of object

  40. Distance Fields • Distance values calculated at each grid and then tri-linearly interpolated • Resolution problems: uniform grids are expensive • Many techniques for improvimg storage: Uniform 3d grid, Octree, BSP-tree • E.g. Adaptive Sampling (ADF): If trilinear interpolation does not provide sufficiently good approximation sub divide grid cell • Often only look at only small band around surface Fuhrman, Sobottka, Gross. “Distance Fields for Rapid Collision Detection in Physically Based Modeling”. International Conference on Computer Graphics and Vision. Graphicon 2003. S. Fisher, M. Lin. “Deformed Distance Fields for Simulation of Non-Penetrating Flexible Bodies”. EG Symposium on Comptuer Animation 2001.

  41. GPU Distance Fields Generation [HKL 99] Use hardware for fast voronoi diagrams AvneeshSud, Miguel A. Otaduy, and DineshManocha. “DiFi: Fast 3D Distance Field Computation Using Graphics Hardware”

  42. Spatial Subdivision • Amongst oldest techniques • in molecular dynamics for deformable collision detection [Lev66] • In robotics [Mirtich 97] • Commonly used: Uniform grid, BSP or octrees • Spatial hashing [Tur90] • Hierarchical Spatial subdivision [Mirtich 97] • Hierarchical spatial hashing [Teschner et al 2003] • Hybrid Spatial and object subdivision [GLGT98]

  43. Hierarchical Spatial Hashing • Employ a hash function to map 3D grid cells to a hash table • 3D grid cells of vertices mapped to hash table • Map information on all grid cells touched by a tetrahedron to hash table • Check vertices and tetrahedra for intersections • If vertex penetrates tetrahedron intersection is detected • If vertex and tetrahedron belong to same object – self-collision TESCHNER M., HEIDELBERGER B., MUELLER M., POMERANETS D., GROSS M.: Optimized spatial hashing for collision detection of deformable objects. In Proceedings of Vision, Modeling, Visualization VMV’03

  44. Image-Space Techniques • Commonly process projections of objects to accelerate queries • Generally do not require pre-processing • Suitable for environments with objects which have large dynamic deformations • Topology changes just as easy to deal with • Often can be accelerated on GPU • Work with any data structure than can be rendered • Accuracy dependent on image space discretization resolution • Simple technique for image space collision test: • Render front and back of convex object into depth buffer and use for interval testing • does not consider concave objects, self-collisions

  45. Layered depth Image Extend this idea to layered depth images (an image based rendering technique), which store multiple pixels along each line of sight. Not restricted to convex objects. HEIDELBERGER B., TESCHNER M., GROSS M.: Detection of collisions and self-collisions using image-space techniques. In Proc. Of WSCG’04 2004

  46. [VSC01] Cloth simulation in image space: • Avatar rendered from front and back to approximate volume • Used to detect penetrating cloth particles • [LCN99] Intersection of surgical tool with tissue: use picking (stencil buffer) to detect intersections • [HZLM01] Collision detection and proximity tests

  47. LDI Intersection Testing • Check AABBs of pair of objects. If intersecting: • Compute LDI representation of each object within the bounding box intersection • Check if volumes intersect • Detect vertices/primitives that penetrate another object • Can be extended to self collisions HEIDELBERGER B., TESCHNER M., GROSS M.: Real-time volumetric intersections of deforming objects. In Proc. VMV’03

  48. Stochastic Techniques • Inexact collision detection • Coarse function of object occupancy taken • Calculate the probability of a collision having occurred between objects/primitives • Justifications • Polygonal models are only an approximation • Animation quality depends more on real-time response than collision detection • Humans do not distinguish between physically-correct and physically-plausible behaviour (see next lecture) • Trade-off precision vs performance • N.B. Also applicable to rigid bodies

  49. Average-Case Technique [KZ03] • BVH stored with containment info (how full of primitives) • Shallow tree: i.e. Each BVH leaf may contain several primitives • During traversal: when colliding BV node is found calculate probability of actual collision (approximate measure based on num. primitives in intersection volume) Average-case algorithm traverse(A;B) while q is not empty do A,B  q.pop for all children Ai and Bj do P  Pr(Ai,Bj) if Pr(Ai,Bj) is large enough then return “collision” else if Pr(Ai,Bj) > 0 then q.insert(Ai,Bj ;Pr(Ai,Bj))

  50. Random Selection of Tested Primitives • Exploit temporal coherence by keeping track of closest features (Lin Canny) • Track at coarse level when far apart • Switch to coarser level when probability of collision increases

More Related