Preventing penetration

Overview

In cloth simulation that involves vigorous movement in action games and the like, the problem that often comes up is the penetration of the cloth into the legs and body.
For example, in the image below, the skirt unintentionally penetrates the thigh.

It is possible to improve this problem by using a new function, Surface Penetration / Collider Penetration.
The following image is an example of applying Surface Penetration.
Notice that the cloth does not penetrate the thighs.

Two skinning types

Before setting up the feature, you first need to know the structure of the mesh to be applied.
Here we take a skirt as an example.
First, it is important whether the skirt contains the weight of the main bones or not.
Two types are shown below.

 

When the weight of the main bone is included
The first pattern is that the skirt already contains the weights of the main bones such as feet and is designed to follow the animation.

With this pattern, the skirt doesn’t break even if you animate it as shown above.
If you lift your legs, the skirt will have weights and the shape will change.
In this case, blending the cloth simulation with the original movement of the skirt is the strongest and best looking result.
This is achieved through Suface Penetration.
To achieve a skirt that does not collapse, we recommend using this method.

 

When the weight of the main bone is not included
The second pattern is when the skirt does not contain bone weights such as feet.

With this pattern, the foot pops out of the skirt when you animate like the one above.
The same applies if you raise your foot.
In this case, colliding can be covered to some extent by the collider’s collision judgment, but if you make a vigorous movement, you will inevitably penetrate.
Collider Penetration is effective in this pattern.
By setting Collider Penetration, you can prevent particles of the skirt from being tied up with the nearest collider and accidentally turning to the back side of the collider.
Conversely, we do not recommend using Surface Penetration for this mesh pattern.

 

For Bone Cloth

Although we discussed MeshCloth above, penetration constraints can also be set on BoneCloth.
In the case of BoneCloth as well, it is necessary to use Surface Penetration / Collider Penetration properly depending on whether the bone itself is deformed by animation or not.
For example, it is recommended to use Surface Penetration when the bone is deformed and the skirt does not collapse according to the animation, and Collider Penetration otherwise.

 

Surface Penetration

Surface penetration constraints let you set the distance that particles can penetrate in the specified axes (XYZ).
This allows you, for example, to limit the skirt so that it doesn’t get inside too much.
This function is almost the same as Surface Penetration of Unity standard cloth (Unity Cloth).

In the figure above, the blue line shows the particle’s normal and the orange line shows the distance it can penetrate.
In this example, each particle is restricted so that it cannot penetrate more than a certain amount in the negative Z direction.

The inspector uses the following parameters.

item description
Max Connection Depth Sets the maximum depth of the parameter that applies the penetration constraint.
Penetration Axis Specifies which axis of the particle can penetrate.
Penetration Distance Specifies the distance that particles can penetrate.
You can specify a curve for each depth.
Moving Radius Specifies the maximum radius that particles can move.
Particles can only move inside a sphere of this radius, which is adjacent to the maximum penetration distance.
You can specify a curve for each depth.

The created penetration data can be confirmed by checking [Penetration] on the cloth monitor.

You can also check the particle / vertex axis by checking [Particle Axis] or [Vertex Axis] on the cloth monitor.

The axes are X = red, Y = green, Z = blue, as in the Unity gizmo.

Next is a Gif with Surface Penetration applied to this skirt.
Notice that the skirt does not penetrate the legs and that the cloth simulation is applied on it.

The cloth parameter set this time can be downloaded from the following.
* Please unzip the zip file and load the json file inside as a preset.

surface_penetration_skirt_preset

 

 

Collider Penetration

Collider penetration constraints let you specify the distance that particles can penetrate to the nearest collider.
This data is created at design time.
This will prevent particles from inadvertently getting behind the collider during execution.
Please note that Collider Penetration is a replacement for Surface Penetration.
As a result, Collider Penetration is not as robust as Surface Penetration.
If Surface Penetration is available, we recommend using it.

In the figure above, the orange line points to the collider that connects.
Particles are restricted so that they cannot move behind the tied collider.

The inspector uses the following parameters.

Item description
Max Connection Depth Sets the maximum depth of the parameter that applies the penetration constraint.
Connection Distance When searching for a collider that a particle connects to, specify its maximum search distance.
Penetration Distance Specifies the distance that particles can penetrate.
You can specify a curve for each depth.
Moving Radius Specifies the maximum radius that particles can move.
Particles can only move inside a sphere of this radius, which is adjacent to the maximum penetration distance.
You can specify a curve for each depth.
Penetration Ignore Collider List Specifies colliders to ignore as connections.

The Collider Penetration is connected to the colliders, so don’t forget to set up your collider list.

The created penetration data can be confirmed by checking [Penetration] on the cloth monitor.

Next is a Gif with Collider Penetration applied to a skirt with no foot weight.
Notice that the skirt does not penetrate the legs and that the cloth simulation is applied on it.
Also note that the behavior of Surface Penetration is almost the same.

The cloth parameter set this time can be downloaded from the following.
* Please unzip the zip file and load the json file inside as a preset.

collider_penetration_skirt_preset

 

This completes the settings.