Real-Time Cloth Simulation on Virtual Human Character Using Enhanced Position Based Dynamic Framework Technique

: Cloth simulation and animation has been the topic of research since the mid-80's in the field of computer graphics. Enforcing incompressible is very important in real time simulation. Although, there are great achievements in this regard, it still suffers from unnecessary time consumption in certain steps that is common in real time applications


Introduction:
Computer graphics is, in recent time, extensively applied in education, entertainment, and even in the military.A number of research focus in the area of computer graphics is geared towards advancing computer graphics to serve other areas of computer science in need of models and animation.The earliest models to exist in computer graphics was created by Fabian et al. (1).He created a simulated naval aircraft model.One of such models trending in the graphics industry is cloth models.Cloth simulations play an important role in representing a computer-generated character in a simulated world (2,3,4).Despite many years of research, cloth simulation and animation remain an important topic in the field of computer graphics and multimedia tools.As the application industry of graphics advances, the yearn for quality of the results widens.Usually, researchers try to achieve quality through employing cloth simulation methods such as physical, geometric, hybrid and data-driven methods.However, the challenge is in the trade-off between realism and efficiency.For applications which require off-line simulations, like in movies, efficiency can be compromised over achieving a more realistic cloth simulation.The real-time applications such as virtual reality in computer games or the garment simulation industry, the reverse is the case (5).The latter is of interest in this paper.
The simulation of cloth in virtual environment is difficult and efforts to achieve realism have existed for a decade.Early efforts were in the practical recreation of the mechanical conduct of material.Its advances are towards reproduction of virtual articles of clothing on engineered characters.While modeling is advantageous to cloth recreation on enlivened virtual characters, virtual prototyping of piece of cloth model also benefits the industry.The mechanical models are more suitable for modelling the rigorous nature of cloth due to their root in the creation of deformable structures for mechanical buildings.Cloth presents great deal of difficulties because of the flexible nature of cloth material and the expected behavior of wrinkling, overlaying unto itself, and responding to wind direction.Therefore, for the graphics industry to achieve realism and effectiveness in cloth simulation, there is need for a mechanical deformation model that can create the mechanical properties of cloth material.However, due to the natural and exceptional deformable nature of cloth material, it is expected that the mechanical representation of a cloth must be sufficiently exact, that is, be able to reveal the nonlinearities and the enormous irregularities in a material.As a result, achieving utmost realism might prove challenging.
The fit of cloth to an avatar, is yet another significant problem in cloth simulation.Cloth fabric, which can take different material properties, should firmly wrap around a body.In literature, it takes techniques that can effectively distinguish the geometrical change that different fabric structure exhibits, and integrates into the mechanical model.As much of the computational complexity required in cloth simulation is as much needed in fitting the cloth to a body for quality of result.However, in attaining such realism, calculation speed and effectiveness of the cloth simulation model is substantially crucial in application of the end result.
Therefore, this paper aims at implementing real-time simulation of cloth meshes on game characters to aid cloth authoring.The contributions makes is in achieving modelling and animation of virtual human characters with realistic cloth movements in real-time using the position based dynamics (PBD) approach.Particularly, the focus is on synthesizing animation to virtual human character movements which can be made possible through PBD (6).The research utilized the open-source library that is made available in (5).The research further analyzes state-of-the-art real-time cloth simulators such as Syflex, APEX cloth, and Havok cloth which provide cloth simulation solutions for games.The analysis is on the bases of the simulator's workflow; cloth authoring using 3D graphics packages (like Maya, 3DS max and Unity), and plug-in to a game development environment like unity developer environment(UDE), where simulation tests can be performed in real-time.
The rest of this paper is organized as follows: Section 2 reviews previous work.Presented in Section 3 is the proposed method and in Section 4 is the experimental result and discussions which include images and testing protocol for real-time and state of art cloth simulators.Finally, Section 5 concludes the study and outlines several possible recommendations for further research.

Previous Work
Due to the growing need for realistic animations, cloth simulation has become an emerging topic of interest in the graphics industry.Since clothes do not consist of internal controllers its behavior may be passive to the surrounding environment (7).Physical based simulations are helpful in analysing and modelling the behaviour of clothes.In this work (8) the physical based simulation is approached from the perspective of low-dimensional linear subspaces like the principal component analysis, which represent the basis vector of the current pose of body and state of cloth, termed the temporal adaptive bases.For creating the low-dimensional bases of the pose space, (5) employed insight from a simulation train data to learn the pose space.However, this approach of learning from simulated data limits the actual dynamics of body pose and cloth state in cloth simulation.For instance, cloth wrinkles follow a semi-rigid shift in the directions of their folds and might be difficult to model using the principal component analysis.Hence, other bases vectors might suffice.Salazar et al. (2010) work focused on quantitatively analyzing the applications of cloth simulations with the multi-processor CUDA on GPU architecture.They further studied the number of iterations a collision treatment requires for axisaligned bounding box hierarchies (9).Chenfanfu Jiang (2017) proposed a unique combination known as the Lagrangian/Eulerian approach that manages to select and retain the most essential aspects of these views (10).Their approach is for a real-time performance, and for that they considered only efficiency.The simulation software used is the PhysX and Bullet (11).
On the simulation software, most solutions provided by the graphics development companies are mostly plugin created on 3D packages like Maya, Unity or 3DS Max and solutions further exported as assets in formats readable by the game engine.An existing cloth simulator known as Shroud, with cutting-edge technologies, has been developed by CloakWorks.The powerful features of Shroud can be maximized via plugin to a game's engines and can simplify the creation of highperformance and overly realistic cloth in Unitypowered games.Also, methods such as hybrid, data driven, GPU implementation, position based dynamics and light weight CPU methods that in literature have been used to achieve real-time performance in cloth simulation (12).However, these methods are tailored towards either accuracy, efficiency or stability.This constitutes a challenge in the achievement of realism and the much-needed efficiency for real-time cloth simulation.It might not be a challenge in offline cloth simulations because only mechanical accuracy and realism is important.On the other hand, the real-time simulations require visual realism which is dependent on efficiency.In literature, PBD has been known to overcome the limitations of other methods.Also, it was used for PhysX real-time cloth (11).And it is recently used in Bullet engine.Therefore, this paper explores PBD.In subsequent section, the basic concept of position-based dynamics for cloth simulation will be discussed in detail.

Proposed Method
Though much research effort has been made in cloth simulation, dynamically preserving cloth overlays and wrinkles is still a challenging task.This section explains the technical aspects of research.Since it is aimed at real-time performance, the algorithms are chosen to be as efficient as possible.This method was proven by the MAGIC-X center at University of Technology Malaysia.Constant density can be enforced by implementing a system where non-linear constraints are solved with one constraint per-particle.Each constraint consists of the particle's position and the positions of adjacent particles, which collectively is represented as{   , … ,   }.
As explained by (6), every dynamic object in the simulation is represented by a set of N vertices and M constraints.The vertex i in [

Raised Cosine Function (RCF)
The raised cosine function (RCF) ( 13) is adopted for determining the list of constraints   +   and estimation of positions {   , … ,   }as in (5).By using the RCF, the estimate positions can be modified in such a way that all the constraints of a given cloth fabric, both in a static and dynamic position, is satisfied.The resulting system of equation is non-linear.The influence of RCF on{   , … ,   }. range and each vertex, is as expressed: where p is the parameters towards a direction, 1297129712971297 is maximum displacement between points in the influence region, w is the weight of parameters on a specific region, ∆p is the displacement of the control points provided by the value of parameter j, which is a set of parameters to be incremented for virtual human animation.
To deform parameters at the region of influence ( 1) is applied as the controlled coordinates are moved.This implies that the order of implementation is important because the effect is instantly visible, that is, the modified position at each step of the constraint projection is required to be available for the ensuing constraint projection process.

Constraints Projection
Constraints are used to determine new velocities and positions of each vertex of a cloth.It takes stretching, bending, or external forces such as gravity, and collision avoidance, to generate constraints.The cloth simulation algorithm realizes new velocities and positions by point projection using constraint function of any of these constraint events.As much as interested in the projections, the angular and linear momentum should also be conserved.The constraint is derived as follows.
∑   ∆  = 0 (2) Where ∆  is the displacement of indices by the projection to satisfy the constraints.results in a centered mass.To ensure that the angular momentum is conserved, the constraint is modified as follows.
∑   ×   ∆  = 0 (3) Where   is the distance of   to an arbitrary common influence region and all indices are treated to have equal mass.The research estimates density estimation using Poly6 kernel and further show how density constraint can be incorporated into in most of the CPU powered games.Then the PBD is used to find a particle position correction ∆p which satisfies the constraint.Since projection is along the direction of maximal change, the direction will be perpendicular to rigid body modes.Also, the gradient, ∇, is in similar direction.Here, linear and angular moments are automatically conserved if the correction ∆ is chosen to be along and given equal masses.Therefore, given p, the correction∆ is chosen such that ( + ∆) = 0.This is estimated for each vertex point, as follows: The scaling factor, s, is the same for all points.Moreover, the corrections can be weighed by the inverse mass if each of the point is of different mass.However, if a point is fixed, the mass of the point is simply set to infinity.With an inverse mass of 0, it translates to corrections = 0, and the estimate position remaining the same, that is, the point is at origin.Therefore, Equation ( 4) can be replaced by: ∆  =   ∇  () (5) Finally, the cloth model on human avatar, as shown in Fig. 1, is formed from:

Damping
To preserve the rigid body modes of the object, global damping is applied.The algorithm is presented as a flowchart in Fig. 2.

Figure 2. Global damping that added to the object
For clarity   =   −   , and   ̅ is a 3 × 3 matrix with the property   ̅ =   , and   is bounded by [0, 1] which is the damping coefficient.The objective is to preserve the rigid body modes of the object because in the extreme case where   = 1, the set of vertices behave like a rigid body, thus, only the global motion endures.For arbitrary values of   , the velocities are globally dampened without affecting the global motion of the vertices.

Cloth Representation
Algorithm 1 provides an outline to the simulation loop.The research presents the PBD with the exception that each constraint is solved independently in a raised cosine deformation function (RCDF).As part of the constraint solving loop, collision constraint detection will be performed.As earlier identified, stretch and bending constraints are two types of static constraints that can reproduce natural cloth behavior.These constraints represent the stretchy and bendy nature which characterizes a cloth.The stretching constraint is added as a distance constraint function because distance constraints preserve the stretching behavior of cloth.For the bending constraint, there are two methods; dihedral bending constraint Muller et al (2007) and other one is called Triangle bending constraint as proposed by (11).These methods are discussed subsequently.

Stretch Constraint
The stretch constraint is similar to a spring, it maintains the particles within a minimum distance that connects it.Thus, it addresses the stretchstiffness of cloth.By implication, the constraint has to be projected throughout the simulation unconditionally, thereby resulting in equality constraint.The constraint function is as expressed as follows and its property demonstrated in Fig. 3.

Bending Constraint
The bending model which was proposed by Kelager et al. (2010), began with the idea of collapsing a triangle using as few and cheap operations as possible (11).By this, potential energy can be introduced where possible and uses the centroid of a triangle (see illustration in Fig. 5) for defining a constraint.The three medians meet exactly at the centroid in a ratio 2:1.In order to collapse the triangle while conserving the linear and angular momenta, the base line vertices are displaced by ½ (v-c) and whereas v is updated as v = c.The distance between the edge of the triangle v and the centroid c is used to generate the constraint function as follows: where  is a global bending parameter, ℎ 0 is the length of rest, and  = 1 3 ⁄ ( 0 +  1 + ), which is the center of medians of the triangle, is the inequality projection constraint whose projection is evaluated only when Ctriangle < 0.

Collision Constraints
Unlike the stretch and bending constraints, collisions are dynamic constraints created in PBD which changes at every time step.In cloth simulation, collision is of three perspectives; plane collision, sphere-capsule collision and self-collision.The plane collision detection is used to check the collision of the object with the floor to keep the cloth from falling infinitely.Once a contact collision is established the point may be moving in a velocity towards the surface or away from the surface.Thus, a further check is done to determine if the velocity is away from the surface (11).
The sphere-capsule collision uses collision volume to create a game character.This type of collision which generates bounding capsules on game characters' body parts is mostly appropriate for game characters and is commonly found in most of the CPU powered games.It is important to note that the sphere-capsule collision performs detection based on a negligibly radius assigned to the sphere that represents the cloth particles.The self-collision also termed point triangle collision requires spatial partitioning.It detects particles and triangles of itself or other cloth meshes.Therefore, wind usually acts on faces instead of individual particle, but uses the surface normal at each point to modify face.The effect of self-collision is as illustrated in Fig. 6 and the force which acts on the face of the triangle is expressed as:  The research used static and animated character meshes to cloth the human avatar by considering the physics parameters which are manipulated based on the asset imported for desired outputs.Further, the real-time performance is analyzed by considering the number of particles in the system, the quantity of cloth constraints and the presence of self-collision.The human avatar is an animated mesh modelled to wear a cloth constructed using 1218 particles without selfcollision and dynamically exhibit motion through dance animation.The reason is to reflect different characteristics of cloth on motion.The research utilizes a frame rate of 6 FPS, which is twice the original FPS to achieve unaltered cloth response and the performance runs at a speed above 40 FPS.To estimate neighbors, MPEG4 as adopted in Ali et al. ( 2018) is used (5).The resulting output of the process on the animated mesh is illustrated in Fig. 7.

Figure 7. Results achieved through the proposed method
Cloth simulation with self-collision turned on.The system has 1030 particles and 6470 cloth constraints which simulated at 20 FPS.Since dance animation is used to reflect the nature of cloth in the presence of wind, the research simulated wind effect on the cloth.For continuity of comparison of results in this area, the research simulated wind effect using our proposed method and compare it with results of wind simulation sing Apex PhysX cloth simulation by NVIDIA.As can be observed in Fig. 8, Apex PhysX is not stable at less than 10 substeps per frame (∆t = 0.0016 s) whereas with our proposed method stability is achieved in a single timestep (∆t = 0.020 s).Also, to show a comparison with respect to compressibility, the research rans Apex PhysX with 10 sub-steps and 4 iterations and with ours the research rans 4 sub-steps and 10 iterations per sub-step.In this way, each performs a total of 50 iterations per frame.Our motive is to demonstrate that our proposed method can accomplish similar results as with Apex PhysX at higher time-steps.In essence the research is able to demonstrate the per step expenses of grid constructions and neighbour findings over more density iterations.Further, the research presents in Fig. 9 the convergence of our proposed method over multiple iterations.The graph which is a plot of density against the number of frames in the simulation suggests a promising outcome of the proposed method.The results demonstrate that the level of compression of our proposed method is comparable to Apex PhysX, though ours uses a larger time step (see in Fig. 10).However, to circumvent this shortcoming, each phase of the algorithm can be made completely parallel though the use of parallel architectures like the GPUs.The use of a PBD based approach shows to be beneficial for the simulation of deformable cloth entity and is shown to make simulation run at faster rate.Now on plugin, the options to set the physics property of the cloth are provided within the Unity plugin and aids in the preview of the simulation to ease the authoring process.However, a few shortcomings are identified: 1) when the scene is loaded back, the settings should also be loaded back to enable resume of work to most current state, 2) texture maps can be used to represent attachment points on cloth mesh rather than importing their position data, because it can become inefficient when working with larger assets, and 3) the cloth is currently attached to the moving capsule but should instead be attached to the animated mesh.
The image on the left is Havok Previewer application that previews the assets imported from Havok Cloth authoring tool.The image on right is the developed application that simulates and visualizes the assets imported from the Maya cloth Authoring tools.As illustrated in Fig. 11

7 )Figure 3 .Figure 4
Figure 3. Projection of the constraint between      and minimum distance d Figure 4 below illustrates the behaviour of the PBD cloth model for various stiffness values for the two constraints.In case (a) the cloth is stretchy for a stretching stiffness value of 0.5 in case (b) the cloth looks good with high stiffness stretching constraint and low stiffness bending constraint.

Figure 4 .
Comparison of real time cloth behaviour based on the constraint stiffness

Figure 5 .
the inverse mass for triangle, w, where  =    +   1 + 2  .The triangle bending model (a) The intersection point of the three medians is the centroid c.The radius of curvature is represented by the length h from the centroid to the tip of the triangle.By employing the length difference, a simple geometric constraint can be formulated.(b) The triangle in a collapsed state where the vertices have been displaced along the direction of the center median (11).
=  * (, ) *  (10) where c = wind strength, d = wind direction n = the normal of the face at a point.

Figure 6 .
The direction of forces wind (a) Apex PhysX cloth simulation by NVIDIA Developer (b) The direction of forces acting on a triangle face due to wind Experimental Results For the experiment, the APEX clothing, APEX C and NCCA Graphics Library.The APEX clothing (PhysX Clothing) library is used which is primarily for cloth authoring in real-time simulation of dynamic clothing in the development of game character.The APEX C is part of an NVIDIA APEX framework, while NCCA Graphics Library is an open-source library for actualizing shading, and acts as a storage container for graphical data such as vectors, matrices, and faces.

Figure 8 .
Figure 8. Convergence of our method over multiple iterations

Figure 9 .
Figure 9. Results achieved through forward and backward movements.

Figure 10 .
Figure 10.Density during the bunny drop simulation.Our algorithm retains compressibility comparable to PCISPH at time steps twice higher.Colour key: red stands for rest density, Green stands for Apex PhysX and Blue represents our method.
, the image (a) is Havok previewer application that previews the assets imported from Havok Cloth authoring tool.The image on (b) is the developed application simulated image.(a) (b) Figure 11.(a) Havok asset viewer and (b) the developed real time simulator Application with cloth resolution: 20X40 at 20 iterations

The steps of simulated dynamic object 1:for all indices I 2:Initialize 𝒙
Constraint function defines the relationship between the particles involved in the constraint.{ 1 . .  } is the list of indices corresponding to the particles involved in the constraint.  represents the strength of constraint ranging from 0 to 1.The constraint j with type equality is satisfied if   ( 1 , … ,   ) = 0 and type inequality is satisfied if   ( 1 , … ,   ) = 0 ≥ 0. The steps of simulated dynamic object algorithm are defined below. =   , ,   =    ,   =    ⁄ 3: for all indices  do  ←   + ∆    (  ) 4: damp Indices(  , … ,   ) 5: for all indices  do   ←   + ∆