Below, you will find information on how to set up a VCloth 2.0 attachment. Keep in mind that finding a well-suited parameter set takes time and a lot of testing/playing around. Always test your actual configuration against the animations you have. As a rule of thumb, the faster the character or any body part moves, the more fine-tuned the setup should be; and the more animations you want to play on the character, the more time-consuming the setup is, since you have to test more configurations.
In the following paragraphs, the use of cloth within CRYENGINE is described. After being exported from Maya, the cloth is set up entirely within the Character Tool.
Before you continue, you need to set up your cloth in Maya and export it as a *.skin file. This exporting process is described in detail on the following page: Maya - Export VCloth to CRYENGINE.
Since the cloth needs to be skinned according to the used character, you cannot simply change clothes between characters if they have different joints - in this case you have to re-skin the cloth to each character separately (see How To - Export VCloth from Maya to CRYENGINE).
Make sure to load a level, or the VCloth attachment may not render properly.
1. First, load your character without cloth as usual into the Character Tool:
2. Add a new attachment:
3. Name the Attachment and set Type to VCloth 2.0 Attachment:
4. Scroll down to the Debug sub-menu and add the renderMeshName, the skin-binding, the simMeshName, the simBinding and the material file:
(you can also change the according *.cdf file directly, which is basically an *.xml file, if that suits you better)
In case you might want to change the according *.cdf file directly - the content belonging to the VCloth would look anywhere something similar to this:
<Attachment Type="CA_VCLOTH" AName="MyCloth" forceSkinning="0" forceSkinningFpsThreshold="25" forceSkinningTranslateThreshold="1"
checkAnimationRewind="1" disableSimulationAtDistance="10" disableSimulationTimeRange="0.5" timeStep="0.0070000002" timeStepMax="50"
numIterations="5" collideEveryNthStep="2" collisionMultipleShiftFactor="0" gravityFactor="0.1" stretchStiffness="1" shearStiffness="0" bendStiffness="0" bendStiffnessByTrianglesAngle="0" pullStiffness="0" friction="0" rigidDamping="0" springDamping="0"
springDampingPerSubstep="0" collisionDampingTangential="0" longRangeAttachments="0" longRangeAttachmentsAllowedExtension="0"
longRangeAttachmentsMaximumShiftFactor="0.25" longRangeAttachmentsShiftCollisionFactor="0.5" resetDampingFactor="0" resetDampingRange="3"
translationBlend="0" rotationBlend="0" externalBlend="0" maxAnimDistance="0" filterLaplace="0" isMainCharacter="1" renderMeshName="" Binding=""
simMeshName="" simBinding="" Material="" debugDrawVerticesRadius="0.0099999998" debugDrawCloth="1" debugDrawLRA="0" debugPrint="0" hide="0"/>
5. Now save your character file and reload it - the cloth should now be visible with the default parameters set.
VCloth needs an additional, explicit collision proxy setup. Thus, cloth behavior can be fine-tuned according to the characters and animations and collision handling can be executed efficiently.
Collision handling for cloth is an expensive process. Thus, make sure to only set up proxies that are really needed. The fewer proxies, the faster the collision handling.
Collision handling is fulfilled by using Lozenges as collision proxies - these are flexible geometric objects which can be set up using only four numbers. Using Lozenges, spheres, capsules, boxes and other geometrical objects can be described. To see how Lozenges can be setup in CRYENGINE, see this link: Setup Lozenge.
To visualize your proxies, enable Secondary Animation -> Cloth Proxies in the Display Options menu:
3. For Type, select ProxyAttachment
4. For Purpose, choose Cloth
5. Select a Joint that will be the parent of the Proxy. Now your attachment should look similar to this:
6. Set Transformation and Lozenge Parameters according to your character. You can use the mouse in the viewport to transform the proxy directly on the character.
7. Finally, your scene should look similar to the image below:
Now repeat the process for all body parts that are needed for collision handling of the cloth.
The collision handling algorithm ensures that the vertices of the cloth are never inside of one of the Lozenge Collision Proxies. Thus, you have to make sure that the Lozenges are approximating the character appropriately. For the best results, it is recommended to set up the Lozenges in such a way that the character lies entirely within the proxies. Keep in mind that the vertices of the cloth will always be on top of the proxies, whereas the edges might intersect the proxies. If a vertex lies within one proxy before collision handling (e.g. due to fast movements of body parts), the vertex is projected onto the surface of the proxy.
Always test your proxy setup with the character’s animation. During animations, problems with your proxy setup will become quickly obvious. As a rule of thumb it is better to create rather rough, big proxies than trying to approximate the characters pose very accurately. Big proxies work better during animation. Eventually, a rough proxy setup works surprisingly well in practice. Also, if you are using boxes as proxies, always use a Lozenge radius to round the box edges. Otherwise, cloth vertices might get stuck on the hard edges and not move smoothly over the edges.
In the picture above, no collision proxies have been set. The cloth is only held by attached vertices and is not interacting with the body (see intersections with legs).
In the picture above, a rough proxy setup (left) ensures cloth interaction with the body. Hands normally result in intersection problems (especially while the character is running); big proxies might solve this problem in practice. However, due to the complexity of movements and sometimes intersections with the body, to improve stability, it is often recommended to not use proxies for hands at all.
A simple floor proxy moves with the characters and works well for flat surfaces.
Rather rough proxies normally work better in all possible situations than filigree, accurate ones.
VCloth 2.0 does not handle self-collision of cloth. Proper self-colliding cloth is expensive, often unstable in certain situations and mostly simply not needed nor worth the performance hit. Normally, situations of self-collisions can be avoided by using attached/constraint cloth vertices (e.g. in case of arm wrinkles). Other, special cases like two skirts lying on top of each other, are not possible to simulate with VCloth. If you need such special cases, you will have to design those cloth pieces using the standard animation and skinning approaches.
The default settings are pretty safe and should at least result in a stable simulation - although the resulting cloth would be very elastic. A detailed description of all parameters is given here, but the most important ones are discussed below.
Let’s tweak the parameters for better results (also keep in mind that you have to set up some collision proxies, as described above in Collisions.
Now check out some animations on your character, how does the cloth behave?
These are the most important parameters. Ideally, it should be possible to set up a proper cloth using only the above-mentioned parameters.
If your cloth is hi-res and still too elastic, you should try out the NNDC - Nearest Neighbor Distance Constraints, this is a sophisticated algorithm to decrease elasticity strongly. It might work, or not - that depends on the topology of your cloth. But if it works, you can normally decrease the values in Stiffness and Elasticity and more importantly for performance, the number of Coll./Stiffness Iterations.
If you use Nearest Neighbor Distance Constraints (NNDC), keep in mind:
The following table gives you an overview of the most important performance considerations in relation to parameter settings. VCloth simulation performance strongly depends on your configuration.
Context/Parameter | Value/Size | Performance | Ideal Value Range |
---|---|---|---|
Simulation Mesh | Less vertices | higher | ca. 500 - 1500 |
No. of Coll./Stiffness Iterations | Smaller | higher | 3-4 |
No. of collision proxies | Smaller | higher | 8 -12 |
Nearest Neighbor Distance Constraints | Enable | Equal, but much stiffer cloth possible | Enable If cloth flickers, you need to disable this value and tweak stiffness via Stiffness and Elasticity values and increase no. of iterations with Coll./Stiffness Iterations. |
Left: Original
Middle: ca_DebugSWSkinning enabled [skinning]
Right: ca_DrawCloth = 2 [simulation] (Result depends on Attachment Debug Parameters)
To visualize simulation data, please make sure ca_DrawCloth is set to 2.
The effect of each of these parameters is described below.
Ensure console Variable ca_DrawCloth is set to 2.
Change Radius of Drawn Vertices
Color Encoding: green (unconstrained), green to blue (intensity of confinement), Red (fully constrained).
Different Draw Vertices Radius Sizes: 0.01 (left), 0.02 (middle), 0.04 (right) - colors indicate the strength of confinement
Ensure console Variable ca_DrawCloth is set to 2.
Using this parameter, a detailed visualization of generated simulation data can be enabled.
Left: Stretch links (Parameter: 1); Right: Stretch, Shear, Bend links (Parameter: 4)
Bending triangles
In the above picture, all edges between two neighboring triangles are drawn, as well as all normals of each triangle.
Ensure console Variable ca_DrawCloth is set to 2.
Using this parameter, a detailed visualization of generated Nearest Neighbor Distance Constraints data can be enabled.
Left: Parameter: 1 - Closest attached Vertex (if vertex is attached, or no connection is found (e.g., disconnected islands), a red line is drawn to the right); Middle: Parameter: 2 - Closest attached Vertex, ordered by distance);
Right: Parameter: 3 - Next neighbor on the way to closest attached vertex - if this connectivity is not resulting in kind of straight lines, Nearest Neighbor Distance Constraints should be disabled.
Ensure console Variable ca_DrawCloth is set to 2.
This parameter shows some detailed values:
For more information on how to use VCloth, check the following pages:
VCloth 2.0