This page introduces the components provided by the Deform Plugin. These components are the means in which the user sets up the simulations and communicates with the underlying physics engine.
The Deform Manager component works as a link between Unity and the Deform Dynamics physics engine. In the Deform Manager, the user can set global properties of the simulation. Fundamentally, the manager retrieves information about the scene in Unity, and sends it to the physics engine. The physics engine then sends the updated information back to the manager, which delegates it out to the objects which have been affected by the simulation.
Please note that there should only be one Deform Manager per scene.
The Deform Manager contains the following parameters:
- Solver iterations: The number of solver iterations that should be run each frame. With a higher value, the simulation is more accurate, at the expense of performance.
- Timesteps per frame: The number of timesteps that should be made during one frame. This value can be raised to increase the quality of moving characters, and self collisions, at the expense of performance.
- Timestep: The amount of time that should be simulated in one timestep.
- Gravity: The global gravity of the scene. This gravity is not connected to the gravity in the physics tab of the project settings. If you want the same gravity for both the Unity specific objects and the Deform plugin objects you will have to change these two values manually. By default, they are the same.
- Wind: The global wind of the scene.
- Air friction: The amount of damping exerted by the air.
- Laplacian iterations: How many times laplacian damping is applied for each time step. It affects performance negatively.
- Laplacian damping: The laplacian damping coefficient. It dampens the velocity, giving a "heavier" dynamic behaviour to the cloth. Note that Laplacian iterations must be set to 1 or higher for the damping to be considered.
- Self collisions: Whether the cloth should be able to collide with itself and other clothes or not.
- Ignore intersecting particles: If this option is enabled, particles which are overlapping at initialization are discarded from the self-collision mechanism. This option is only valid if Self collisions are enabled.
- Sample surface: Enabling surface sampling results in better self-collisions when the triangles of the simulated DeformBody objects are of varying size.
- Kinetic friction: The amount of kinetic friction used for self-collisions.
- Static friction: The amount of static friction used for self-collisions.
- Computation type: Decides whether CPU (single-core), CPU_MULTI (multi-core) or GPU_CUDA should be used to drive the simulation.
The Deform Manager component contains the following buttons:
- Pause / Resume Simulation: Toggles the simulation between "running" and "paused". If "paused" is toggled before starting the simulation, the simulation will start paused.
- Step Simulation: This button is only visible when the simulation is "paused". When pressed, this button advances the simulation one by one frame.
The Deform Body component is used to define objects that should be simulated, such as cloths. All objects which have a Deform Body attached, will send the mesh data defined in the Mesh filter or Skinned Mesh Renderer to the simulation. The Deform Body requires a Mesh filter or a Skinned Mesh Renderer to be present in the same object. The Skinned Mesh Renderer should be used if you want the correct motion vectors when using Temporal anti-aliasing.
The Deform Body contains the following parameters:
Distance stiffness: The distance stiffness specifies how strict the distance constraints are enforced. With a low distance stiffness value, the cloth appears stretchier.
Bending stiffness: Bending is an essential property to simulate, when aiming to create believable cloth simulations. This constraint governs the angle between two particles in relation to two other particles.
Mass: The total mass in grams of the DeformBody.
Merge Close Vertices: If this option is enabled, vertices with the same position will be merged. When a mesh has UV seams, Unity automatically splits the vertices in the seams during import. If you experience clothes falling apart, try to enable this option.
Base Mesh: This mesh is used to specify the rest values of the deformable body. The physics engine will try to deform the body into this configuration. If this parameter is empty, the plugin will use the mesh in the Mesh filter/Skinned Mesh Renderer as base. This parameter can be useful when you want to simulate a cloth from a deformed starting pose, but still want the dynamic behavior of the undeformed mesh. Please note that the Base Mesh must contain the same amount of vertices as the mesh in the Mesh filter/Skinned Mesh Renderer.
The Deform Body component contains the following buttons:
- Fixed vertices: This enables you to paint which vertices should be fixed. For a more in-depth explanation, please read Vertex painting.
- Kinetic friction: This enables you to paint kinetic friction for each vertex. A slider where the coefficient value can be set will appear, along with the Vertex paint editor.
- Static friction: This enables you to paint static friction for each vertex. A slider where the coefficient value can be set will appear, along with the Vertex paint editor.
- Self collision masks: The Vertex paint editor will appear, along with four buttons of different color, enabling you to paint the vertices with different colors. Vertices with different colors will not collide against each other. White vertices will collide with all other vertices.
- External collision masks: The Vertex paint editor will appear, along with four buttons of different color, enabling you to paint the vertices with different colors. This collision mask has to be used together with the collision mask in the Deform Collider Mesh. If the vertices of the deform body and the vertices of the Deform Collider Mesh have different colors, they will not collide. White vertices will collide with everything. If you are more interested in this functionality, please read the tutorial Using collision masks.
Deform Body Volumetric
The Deform Body Volumetric component is used to create deformable bodies that preserve their volume, such as pillows. This component contains the same parameters as the Deform Body, as well as the ones presented in this section.
Mesh: The volumetric mesh to use. Currently, only meshes using the .mesh format are supported. To add a mesh you want to use, you have to add it to the Assets > Deform Assets > Streaming Assets folder.
Volume stiffness: Determines the strength of the volume conservation.
Deform Body Inflatable
The Deform Body Inflatable allows for creating deformable objects from closed meshes that can be inflated and deflated. This component contains the same parameters as the Deform Body, but also adds the Pressure scale parameter.
- Pressure scale: Determines how much internal pressure should be applied to the object. If this value is set to 1, the object will maintain its original volume. If it is greater than 1, the object will inflate and if it is less than 1 the object will deflate. Note that a negative pressure scale is possible, in which case the object will eventually be turned inside out.
Deform Patch Creator
The Deform Patch Creator component is a tool you can use to easily create a cloth patch, optimized for simulation. The Deform Patch Creator needs a Mesh filter and a Mesh Renderer component. If these components are not present in the GameObject, the patch creator will add them automatically. What the patch creator does is to fill the Mesh filter with a mesh of the properties specified in the parameters.
The Deform Patch Creator contains the following parameters:
Size: The spatial dimensions of the patch.
Resolution: The polygonal resolution of the longest side of the patch. For example, if you specify 100 as the resolution of a square patch, the resulting patch will contain 10 000 vertices.
The Deform Patch Creator component contains the following buttons:
- Create patch: Sets the mesh of the Mesh filter to be a patch with the properties specified.
In this section, we will briefly explain the common functionality and parameters of the Deform colliders. The colliders can either be superimposed on an existing mesh in the scene, or they can show a simple mesh by themselves.
The following parameters are common for all Deform Colliders:
Kinetic friction: The kinetic friction of the collider [0-1]. This is the friction between moving surfaces.
Static friction: The static friction of the collider [0-10]. This is the friction between non-moving surfaces.
Show collider in editor: If the collider bounds should be visible in the editor.
Show collider in game: If the collider should be visible in game.
In Game Material: The material that the collider should use. Only available if Show Collider In Game is enabled.
Bias: How much smaller the render mesh should be compared to the actual collider bounds. This is used to prevent Z-fighting.
Please note that the colliders used in order to affect the simulated objects have the prefix Deform. You cannot use the built in Unity colliders to achieve collisions with the simulated objects. Furthermore, two-way interaction is currently not supported by the physics engine, meaning that the simulated objects will be affected by the colliders, but the colliders will not be affected by the simulated objects.
Deform Collider Box
The Deform Collider Box component can be used to simulate collisions against boxes. It can be created by right-clicking in the Hierarchy window, and navigate to Deform Dynamics > Deform Collider > Box.
The extents of the box collider are defined using the scale of the Transform component. Moving and rotating the box collider works as with any other GameObject. To increase the performance of the box collider, consider enabling Axis Aligned. Note that box colliders marked as axis aligned cannot be rotated.
To the left: The parameters of a box collider. To the right: A cloth falling upon a box collider.
Deform Collider Plane
The Deform Collider Plane component can be used to simulate collisions against infinite planes. It can be created by right-clicking in the Hierarchy window, and navigate to Deform Dynamics > Deform Collider > Plane.
The plane collider is defined only by its position and a normal. Moving the plane collider works as with any other GameObject, but rotating the collider also affects the normal of the plane.
Deform Collider Sphere
The Deform Collider Sphere component can be used to simulate collisions against spheres. It can be created by right-clicking in the Hierarchy window, and navigate to Deform Dynamics > Deform Collider > Sphere.
The size of the sphere collider is determined by the size of the Radius parameter. Moving and rotating the sphere collider works as with any other GameObject.
To the left: The parameters of a sphere collider. To the right: A cloth falling upon a sphere collider.
Deform Collider Capsule
The Deform Collider Capsule component can be used to simulate collisions against capsules. It can be created by right-clicking in the Hierarchy window, and navigate to Deform Dynamics > Deform Collider > Capsule.
The capsule collider consists of three parts; two half-spheres at the ends and one cylinder between them. The shape and position of the capsule can be defined in one of two ways:
- Length: The shape is defined by the Length between the half-spheres and the radii of the two half-spheres. The position is determined by the Transform position.
- Transforms: The shape is defined by two endpoints (represented as Transforms) and the radii of the two half-spheres. The position is implicitly determined by the position of the endpoint Transforms.
Which representation to choose depends on the context. If a capsule collider should follow two points that are moving, the Transforms representation is the most convenient one. For a static capsule or a capsule that should be moved via a script, the Length representation is more appropriate.
Top left: A capsule collider defined by the length. Top right: A capsule collider defined between two transform points. Bottom left: Example of a capsule collider defined with a length. Bottom right: Example of a capsule collider defined between two transform points, in this case, Empty game objects, with one manually moving.
Deform Collider Mesh
To achieve the best possible results, the mesh should adhere to the following criteria:
- The triangles of the mesh should have approximately the same size.
- The mesh should not contain more than 6000-8000 vertices.
- The mesh should be closed and convex.
- It is very important that the vertex order is correct (CCW).
- The mesh cannot be too thin. The mesh has to have some volume.
If your mesh doesn't fulfill the first two criteria, the Use Proxy feature can be used to quickly generate a mesh that does. For more details see Remesher.
Example: A dress on a moving character. The Deform Collider Mesh component has been added to the GameObject containing the SkinnedMeshRenderer. A proxy mesh is used to improve performance.
Please refer to the tutorial Using the mesh collider for a more detailed explanation of how to use the mesh collider in practice.
The Deform Seam component defines a number of vertices that should be sewed together, and how. It is created by clicking Create seam in the Sewing Editor. You can select it in the Hierarchy window. We recommend you to do the Sewing two patches together tutorial if you are interested in this component.
The Deform Seam component contains the following parameters:
Priority: The priority in which the sewing should happen. If seam A has priority 0 and seam B has priority 1, seam B will only be sewed together when sew A has finished.
Damping: Decides if the simulation should be dampened until the sewing has been finished.
Distance Stiffness: The distance stiffness of the seam.
Bending Stiffness: The bending stiffness of the seam.
Show Lines In Editor: Decides if the sew lines should be visible in the Scene view.
Deform FBX Exporter
The Deform Exporter component makes it possible to record simulations and take snapshots. The results are stored in .fbx files, which can be imported in a variety of 3d programs, such as Autodesk 3ds Max and Blender. The animation will be saved to a point cache. In 3ds Max you can use the point cache modifier to import the animation. You can add the Deform Exporter to any GameObject containing a Deform Body or Deform Body Volumetric.
The Deform Exporter component contains the following functionality:
File path: The path where the resulting fbx file will be saved. Choose the path by pressing the [...] button.
Record animation to .fbx: Starts the recording of the animation. If you want to record the simulation from the beginning, also press Record animation to .fbx before starting the simulation. This button can, however, be pressed at any time during the simulation, thereby enabling a delayed start of the recording.
Create .fbx snapshot: Creates an FBX file with only the mesh at the time the button was pressed.
Please refer to the tutorial Exporting a simulation for a more detailed explanation of how to use the deform exporter in practice.
Deform Mesh Asset Generator
The Deform Mesh Asset Generator component makes it possible to save the current configuration of a cloth to a mesh asset file within your project. You can add the Deform Exporter to any GameObject containing a Deform Body or Deform Body Volumetric. This can be useful to quickly improve the initial configuration of clothed characters.
The Deform Mesh Asset Generator component contains the following functionality:
File path: The path where the resulting asset file will be saved. Choose the path by pressing the [...] button. Note that this path must be within the project file system.
Generate mesh asset: When this button is pressed, a mesh asset will be saved to the specified path with the exact configuration that is currently present in the simulation.
Please refer to the second part of the tutorial Saving and loading a garment configuration for a more detailed explanation of how to use the Deform Mesh Asset Generator in practice.
Deform Modifier Bend
This is a component to modify a mesh so that it is easier to sew around objects, such as arms or legs. It will manipulate the vertex positions of a mesh, in the same way as a common bend modifier works in other modeling tools. When a mesh is modified, and then simulated, the original rest values of the mesh will be used. This means that the bend modifier will not affect the simulation, only give a modified initial position more suited for certain types of situations.
The Deform Modifier Bend component contains the following functionality:
Bend Axis: The axis along which the bending will occur.
Symmetry Axis: The axis along which the bending will be mirrored.
Limit: The bending starts at this distance from the axis.
Angle: The amount of bending that should take place.
The Deform Modifier Bend component contains the following buttons:
Select vertices to bend: Allows the user to paint which vertices the bending should be applied upon.
Apply bending: When modifying values in the component, a preview will be visible as a wireframe. Once this button is pressed, the mesh will get the same configuration as the preview.
Please refer to the tutorial Creating one-piece sleeves for a more detailed explanation of how to use the Deform Modifier Bend component in practice.
Deform Seam Importer
The Deform Seam Importer can be used to import seams exported from CLO/MD. This component should be added to a game object that already has a DeformBody. By pressing "Load seams" a DeformSeam object will be created and added to the scene. Note that this feature is experimental and will be changed in the future.
This is a component that is attached to patterns that are imported using the DXF-importer. The component triangulates a shape into triangles of the size specified. If the component detects a change in the pattern, such as scaling, it indicates that the triangulation can be redone, providing a better triangulation.
The Deform Exporter component contains the following functionality:
Num Triangles: The desired number of triangles.
Triangulate: Triangulates the shape. The button is yellow when the shape should be retriangulated, and grayed out if not.
Deform Body Proxy
This component will exactly mimic the behavior of a Deform Body. This means that you can create proxies of the Deform Body, and place them anywhere in your scene without having to simulate multiple objects. Please note that you as a user have to add either Mesh filter and Mesh Renderer components or a Skinned Mesh Renderer component depending on what the source object uses. In short, if the source Deform Body uses a Mesh filter and Mesh Renderer to render the cloth, the proxy object also need to contain these components.
The Deform Body Proxy component contains the following parameters:
- Source: The Deform Body that should act as the source object of this proxy. The vertices of the source object will be copied to this object.
Please refer to the tutorial Using proxy meshes for a more detailed explanation of how to use the proxy object in practice.
This component can be added to a Deform Body component in order to skin the body or parts of it to a Deform Collider Mesh. The vertices of the Deform Body will then be mapped to the closest point on the mesh, and follow it's movements. This can be used to get a glue effect on parts of the cloth which should not slide too much, such as the end of sleeves or a dress in the waist.
The Deform Skinning component contains the following functionality:
Mesh collider: The Deform Collider Mesh that the specified vertices should be skinned to.
Full Skinning: Whether or not to use full skinning. If full skinning is used, every particle of the deform body will be skinned to the specified Deform Collider Mesh, with the specified skinning strength.
Full Skinning Strength: The strength of the full skinning. This can be modified in real-time.
Skinned vertices: Opens up a Vertex Paint Editor where you can select which vertices should be skinned.
Please refer to the tutorial Using skinning for a more detailed explanation of how to use skinning in practice.
This component can be added to a Deform Body component in order to be able to pick and drag the cloth around. It can also limit how far away from the initial position the cloth can be pulled.
The Deform Picking component contains the following functionality:
Picking Enabled: Whether or not the cloth should be pickable.
Limit Pull Distance: Whether or not to limit the pull distance from the intitial pick position.
Max Pull Distance: The amount that the the cloth can be pulled away from the initial pick position.
This component makes it possible to map the vertices of any mesh to a Deform Body. This can for example be used to apply the motion of a simpler mesh to a more complex one that can't easily be simulated.
The Deform Mapping component can be added to any GameObject that has a MeshFilter or a SkinnedMeshRenderer. The only parameter is Map To, which is the DeformBody to map the given mesh to. To get the best result possible, the mesh should be carefully superimposed onto this DeformBody in the scene.
Here we list custom editors that can be used from the plugin.
Vertex paint editor
The vertex paint editor can be activated from several parts of the plugin. In order to paint friction or fixed vertices on the Deform Bodies, you can navigate to Deform Dynamics > Paint. If you want to paint collision masks, you have to activate the vertex paint editor from the Deform Body or Deform Collider Mesh you want the paint. Also, the Deform Skinning component utilizes the vertex paint editor to specify which vertices should be skinned.
When the vertex paint editor is active, it is exposed in the Scene view. Use your mouse cursor and left click to paint the vertices.
The vertex paint editor contains the following functionalities:
Brush radius: Sets the size of the vertex paintbrush radius.
Particle size: Sets the size of the particles.
Erase: Makes the brush remove already painted vertices.
Apply on all vertices: Applies the current settings to all vertices of the DeformBody.
Clear layer: Removes all painted vertices on the current layer.
Close vertex paint editor: Exits the vertex paint editor.
Example of when fixed vertices are painted using the vertex paint editor
It is possible to select multiple Deform Body objects and paint them simultaneously. To paint all objects in the scene, navigate to Deform Dynamics > Paint and select the type of data you would like to paint.
The sewing mode is activated by navigating to Deform Dynamics > Sewing in the menu bar. To create a Deform Seam, the start and end-points, visualized as green and red spheres respectively, must be defined on the contour of the Deform Bodies that you want to sew together. This will form two lines (lines A and B). Between these two lines, the sewing will occur. When both the start and end-point has been set for the two lines, the seam is created by pressing the Create seam button. We recommend you to do the Sewing two patches together tutorial if you are interested in this functionality.
When sewing is active, a Sewing editor will be exposed in the lower right corner of the Scene view. The Sewing editor contains two modes: Vertex mode and Contour mode.
Vertex mode: In this mode, each start and end-point of lines A and B can be selected individually.
Contour mode: In this mode, the user can select the lines A and B of entire sides of the contour.
Sphere size: The size of the spheres visualizing the contour points.
Contour break threshold: The angular threshold at which the contour should stop.
Use shortest path: Whether or not the seam line should take the shortest path from the start point to the end point.
Reverse A / Reverse B: After a seam line has been defined, this button can be used to switch its direction.
Create seam: Creates a seam between line A and B. This button is only enabled when both lines have been defined.
Reset: Resets all the start and endpoints. Press this button if you want to start over.
Close sewing editor: Exits the sewing mode.
To optimize the topology of a mesh for simulation, triangles of similar size and shape should be used. To generate a mesh with this kind of topology, open the DeformRemesher tool by selecting Deform > Remesh from the Unity Editor menu.
By changing the Remeshed vertex count parameter, you can decide to use a higher or lower resolution than the Input mesh. When pressing the Remesh button, a new mesh will be generated with the specified vertex count. To save the mesh to disk, set a filepath and press Save mesh asset. The resulting mesh can be used anywhere meshes can be used in Unity, for example as input to a DeformBody or a DeformColliderMesh.