cs 7057 Realtime Physics 18 Cloth Simulation Demo
- Slides: 51
cs 7057: Real-time Physics 18 - Cloth Simulation
Demo Curtain demo (with code) in processing http: //www. openprocessing. org/visuals/? visual. ID=20140 Also see (with Kinect) http: //www. vimeo. com/20964926
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.
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
Equations of Motion External Forces (Newton II) Internal Forces e. g. Gravity State update Euler example: Damping (dissipation of mechanical energy)
Structural Model Point masses e. g. Particle system: ¯ Specify "distance" constraint using flexible spring model: Structural springs : Sheet-like property Shear springs : Resist shearing Bend (flexion) springs : Resist bending + Point Masses + Structural Springs + Shear Springs = Bending Springs
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
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 T 0 ¯ Large timestep
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 t. C Apply “dynamic inverse procedure” to limit deformation to t. C E. g. If t. C = 0. 1, springs do not ever exceed 110% length See a code example here: http: //www. xbdev. net/physics/Verlet/index. php
Practical Example void Satisfy. Constraints() { const int num. Iterations = 10; for (int i=0; i<num. Iterations; i++) { for (int k=0; k< m_num. Constraints; k++) { // Constraint 1 (Floor) if (g_floor. Collisions) for (int v=0; v<m_num. Points; v++) { if (m_points[v]. cur. Pos. y < 0. 0 f) m_points[v]. cur. Pos. y = 0. 0 f; } // Constraint 2 (Cloth) Constraint* c = &m_constraints[k]; D 3 DXVECTOR 3& p 0 = m_points[c->index 0]. cur. Pos; D 3 DXVECTOR 3& p 1 = m_points[c->index 1]. cur. Pos; D 3 DXVECTOR 3 delta = p 1 -p 0; float len = D 3 DXVec 3 Length(&delta); We could do float diff = (len - c->rest. Length) / len; something more p 0 += delta*0. 5 f*diff; complicated here p 1 -= delta*0. 5 f*diff; } // Keep these two points contraints to there original position float gap = g_gap; m_points[0]. cur. Pos = D 3 DXVECTOR 3(0, g_dis. Off. Floor, 0); m_points[g_width-1]. cur. Pos = D 3 DXVECTOR 3((g_width-1)*gap, g_dis. Off. Floor, 0); } } void Update(float dt) { Verlet. Integrate(dt); Satisfy. Constraints(); } Taken from: http: //www. xbdev. net/physics/Verlet/index. php
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
Results (1) After 200 frames of animation Applied to structural springs Applied to structural and shear springs
Results (2) “Rigid” Technique t. C = 0. 05 Basic Spring-Mass Low Stiffness High Stiffness
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 Baraff and Andrew Witkin, “Large steps in cloth simulation” SIGGRAPH '98
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.
Other Techniques Cloth on the GPU ¯ Particle collision and update can be done in shaders (several papers on this) Overview of cloth on. GPU: ¯ ¯ 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, n. Vidia. http: //portal. acm. org/citation. cfm? id=1187158 http: //developer. download. nvidia. com/whitepapers/2007/SDK 10/Cloth. pdf
Other Techniques Geometric solution on GPU ¯ Assume tightly stretched over surface apply geometric techniques to fake effects such as wrinkling Jörn Loviscach. Wrinkling coarse meshes on the GPU. In Proceedings of Eurographics 2006.
Other Techniques Tonnes of other techniques! See the following recent review: ¯ M. Adil Yalçın, Cansın Yıldız “Techniques for animating Cloth” unpublished survey, Bilkent University. 2009. http: //www. cs. bilkent. edu. tr/~cansin/projects/cs 567 animation/cloth-paper. pdf
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/cs 468 -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. unituebingen. de/people/staff/mhauth/tutorials/Vis 03/SIG 2003 Tut 29 l. Nu merics. pdf
cs 7057: Real-time Physics 19 - Deformable Object Collisions
Applications Most common: ¯ Characters ¯ Cloth Also: ¯ Deformable solids ¯ Fluids ¯ Destruction ¯ Sound Synthesis
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 pregenerated 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
Main Techniques 1. Bounding volume hierarchies (slides 22 – 35) 2. Distance Fields (slides 36) 3. Spatial Partitioning 4. Image-space techniques 5. Stochastic Methods
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
BVH # children per node Binary Trees 4 -ary Trees Studies have shown that better performance obtained for deformable objects with 4 -ary and 8 -ary trees [Larsson 01][Mezger 03]
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) [VMT 94, VMT 95] [Pro 97] top down split into imbricating zones Construction may need to be done on the fly ¯
BVH Hierarchy Update BVH needs to be updated in every frame of simulation Hierarchy Update: ¯ Refit about 10 x 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
BVH Node Updating Larson et al propose a hybrid technique that combines breadth-first and depthfirst traversal for deformable object Bounding volumes Thomas Larsson and Tomas Akenine-Möller, Collision Detection for Continuously Deforming Bodies, Eurographics 2001.
BVH Refitting - Bounded Deformations If BVH’s are superpositions of displacement fields, update has little cost [James et al 04] (next slide)
BD-Trees Bounded Deformation Tree, or BDTree, 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.
BD-Tree Update Preprocess: ¯ ¯ ¯ Compute Bounding Box of leaves Compute parent BB in bottomup 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.
K-Dop Update
Morph Update In animation intermediate frames are generated by blending/morphing between 2 targets ¯ Morph-aware hierarchy creation ¯ 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) Larson & Moller “Efficient collision detection for models deformed by morphing ” The visual computer 19, 2 -3 (2003)
Self-Collisions Particularly important for cloth Basic solution: BVH tested against self Some problems: Neighbouring BVH’s always overlap
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
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 t 0 ->t 1 extended to cloth [Bridson 2002] Calculate BV that encloses BVs in t 0 ->t 1 [Eckstein 99] ¯ Adaptive step size + robust root detection [Grabner 03] ¯ Velocity cones [Mezger 03] ¯ Sort vertices radially and check outer ones [Fahn 99]
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
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 r 1, r 1 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
Distance Fields Specify (signed) distance to a closed surface for all points in the field (3 D grid) ¯ Surface is the zero level set Allows fast evaluation of distances and normals: constant time Independent of complexity of object
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 3 d 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.
GPU Distance Fields Generation [HKL 99] Use hardware for fast voronoi diagrams Avneesh Sud, Miguel A. Otaduy, and Dinesh Manocha. “Di. Fi: Fast 3 D Distance Field Computation Using Graphics Hardware”
Spatial Subdivision Amongst oldest techniques ¯ ¯ in molecular dynamics for deformable collision detection [Lev 66] In robotics [Mirtich 97] Commonly used: Uniform grid, BSP or octrees ¯ ¯ Spatial hashing [Tur 90] Hierarchical Spatial subdivision [Mirtich 97] Hierarchical spatial hashing [Teschner et al 2003] Hybrid Spatial and object subdivision [GLGT 98]
Hierarchical Spatial Hashing Employ a hash function to map 3 D grid cells to a hash table 3 D 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 1. 2. 3. 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
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
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
[VSC 01] Cloth simulation in image space: ¯ ¯ Avatar rendered from front and back to approximate volume Used to detect penetrating cloth particles [LCN 99] Intersection of surgical tool with tissue: use picking (stencil buffer) to detect intersections [HZLM 01] Collision detection and proximity tests
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
Stochastic Techniques Inexact collision detection ¯ ¯ Justifications ¯ ¯ Coarse function of object occupancy taken Calculate the probability of a collision having occurred between objects/primitives 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 physicallyplausible behaviour (see next lecture) Trade-off precision vs performance N. B. Also applicable to rigid bodies
Average-Case Technique [KZ 03] 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))
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
Recommended Reading Collision Detection for Deformable Objects ¯ ¯ ¯ M. Teschner, S. Kimmerle, B. Heidelberger, G. Zachmann, Laks Raghupathi, A. Fuhrmann, Marie-Paule Cani, François Faure, N. Magnetat-Thalmann, W. Strasser, P. Volino Computer Graphics Forum, Volume 24, Number 1, page 61 --81 - March 2005 http: //wwwevasion. inrialpes. fr/Publications/2005/TKHZRFCFMSV 05/STARmain. pdf
- Physics investigation ideas
- Monte carlo simulation particle physics
- Cac realtime
- Realtime optimization
- Simple online and realtime tracking
- Realtime iep
- Realtime big data
- Real-time system definition
- Realtime it
- Realtime interaction
- Halthywa
- Realtime etl
- Realtime forex
- Realtime diagnostics
- Rendering realtime compositing
- Real time messaging protocol
- Ad hoc realtime
- Realtime aps software
- Realtime it
- Realtime it
- Realtime networks
- Rtim orchestration
- Cos operating system
- Eva rov
- Real time characteristics of embedded operating systems
- Alyac realtime service
- Rational rose realtime
- Realtime database push
- Copthorne hotel
- Realtime media
- Realtime
- Lightning realtime
- Realtime mobile communication
- Rendering realtime compositing
- Frankfurt realtime
- Realtime communications
- Ams realtime weather maps central
- Realtime streaming protocol
- Solar cloth system
- Understanding the visual arts
- Old man's cloth el anatsui
- Pressing meaning
- Cloth in my right mind
- Warp knitted
- Ags linens
- Smallest unit of any cloth is
- 4 tailed bandage
- Cloth tape in surveying
- Target sewing machines
- Slidetodoc.com
- Krystal klear cloth
- Why did gandhi encourage indians to weave their own cloth?