Importing and skinning clothing/hair in Maya::
- Inspect all clothing items. All surfaces that are associated with the same mesh and will be solved by cloth must be part of the same surface and physically connected to each other by shared vertices. For instance if you had buttons or a zipper head that were combined with the surface but not actually geometrically connected then those buttons and zipper wouldn’t follow the mesh when solved dynamically despite sharing the same bind and being technically part of the same object.
- Run a cleanup on your surfaces selecting non-manifold geometry. Anything that you missed visually will be selected.
- Bind your skins:
- Insure that the skinning method is Classic Linear (Unreal doesn’t support dual quaternion)
- Weight paint the clothes so the mesh clips through as little as possible during deformation.
- Paint your skin weights making sure to move your character around ensuring that you get good deformation.
- Pose the character in semi-extreme poses to see where clipping occurs, refine weighting.
- IMPORTANT!: Go through each surface and insure that each mesh has its own material. Unreal recognizes different meshes bound to the same skeleton by the materials that have been assigned to them. Insure that all materials follow the proper naming convention: M_CharacterName_MeshName.
- When you the character into Unreal we will need to retarget the skeleton. Unreal uses a specific naming convention to automatically find the joints, if your bones don’t use this naming convention then you will have to manually associate the bones. There is a python script called sm_rename_skeleton.py here:
Load that script in a python script window in your script editor. Select all of the code and hit the number pad enter button. That will open a window that allows you to run a script that will take the specified prefix in the joint names and then rename all skeletal joints that Unreal considers in retargeting. Note, a prefix is automatically loaded but may not be exactly what is in your scene. Insure that the prefix that you enter into the interface is exactly the same as is in your joint hierarchy. Now select the reference locator of your skeleton and run the script. If you have used the script successfully then the joints affected will have names like: root, pelvis, thigh_r.
- At this point, save your scene as: characterName_WithClothes_WholeSurfaces.
- Now Save a copy called: characterName_WithClothes_DeletedFaces.
- Delete all faces that are hidden by higher layers of clothing:
- Open up your quick selection set and select all faces within
- Delete faces
- Select all of your geometry and delete non deformation history.
- Save your scene.
Exporting/importing your character:
- All rigging and animation should be removed from the character’s skeleton for export as the skeletal mesh.
- Optimize your scene.
- Now select the group node with your skins and the reference locator for your skeleton and export selection options FBX. The default settings should be fine.
- Import your FBX into your Unreal project
Retargeting for Animation:
- Go to your skeleton tab and on your Skeleton Tree tab there is a little totally overlookable dropdown menu:
- Click on that and then check Show Retargeting Options
- Right click on the root and then click Recursively Set Translation Retargeting Skeleton
- Left click on root and set it to Animation, set pelvis to Animation Scaled.
- Under the Retargeting Manager set the retargeting to humanoid. If you used the renaming script mentioned above in the Maya section then all joints should have been automatically populated the correct retargeting information. If you didn’t use that script you will have to go through and manually set each of your joints to their respective position in the hierarchy of the humanoid rig.
- Import an animation by importing it just as you would another character, but by default the importer will want to use your existing character’s skeleton. Deselect that so that it looks like this :
- Under the Retargeting Manager do the same process of assigning bones that you did for the character you are working on. If you didn’t have the opportunity to run the renaming script you can open the FBX up in Maya and run it there then re-export.
- Right click on the animation file in your content browser and Retarget Animation Assets→ Duplicate Anim Assets and Retarget. This editor will allow you to retarget animation.
- Assign the animation to your character in the scene through the details panel.
- the Unreal cloth tutorial has some outdated information and could be a lot more detailed. Definitely look on their website for guidance, but just know that there are some holes. https://docs.unrealengine.com/en-us/Engine/Physics/Cloth/Overview
- Double click on your skeleton mesh to open up the editor for it.
- Edit the Physics objects:
- First go to the physics tab and adjust/remove the collision objects for your character,
- Delete all of the default physics bodies and save your asset. We will come back to creating these later for now they just get in the way.
Create the Cloth Data:
- Go back to your Mesh tab
- Use Section Selection to select the mesh you want to convert to a clothing asset.
- Right Click and choose Create Clothing Data from Section.
- Do not check Remove from Mesh. The mesh just flies away if you have this checked.
- Be sure to name it something useful, it automatically populates a name from the shader but the last bit should be changed to reflect the item you are working with.
- Assign the clothing data to the surface. Right click and Apply Clothing Data, but also look in your asset details panel under LOD 0. The shader that is currently assigned to the object that has been selected will have its Highlight box checked. Under the Clothing dropdown select the appropriate clothing asset which is of course properly named and easy to identify because you followed the previous steps. Now you are ready to paint. Open the Cloth Paint tool.
Painting Cloth Weight:
- You have to make the appropriate selection from the Clothing Data field at the top of the clothing window
- Start painting at very low values, periodically holding the h button on your keyboard to see how the cloth is hanging. For better or worse the brush penetrates through all layers of the painted surface. This is great for hair, but not necessarily great for layers of cloth that are part of the same surface (like collars). There is no way to turn off this brush’s penetration feature so plan accordingly when deleting faces or repositioning surfaces prior to import.
- The default map that you are painting on is the distance map. This controls how far away the verts can get from their skinned position.
- Anything that you want to be completely controlled by the skin weight should be pink (a value of 0).
- Although all of the masks allow you to paint on the same scale (0-100) the values for each map vary in what they actually do. The default map seems to be a value that relates to the coordinate system. A value of 1 over a vertex means that the vertex can move up to 1 centimeter from its animated position.
- To create other masks click the plus sign on the right of the Masks tab. You can then right click and change the mask to effect a different channel of the cloth.
- Anim drive multiplier returns the surface to it’s skinned position more rapidly. These values seem to be percentage based. Values from 50 to 100 work well.
- Backstop Distance is how far a vert can get from its skinned position. These values seem to also be actual distances of the coordinate system. Oddly this value seems to do the same thing that default value does, the only difference being that it is directly connected to backstop radius.
- Backstop radius works in conjunction with backstop distance. Any overlapping positive values stiffens the surface by driving the vertices away from each other. Again this map appears to be related to world coordinate values. This map can actually puff the surface out as it drives the verts away from each other. Relevant values for this mask depends largely on the density of your surface. The tighter your verts the smaller this value will have to be. Probably values between .25 and 1.5.
- Create Physics Bodies:
- These are imprecise and as far as cloth is concerned are designed to drive the cloth away during character movement. They don’t work well as surfaces for the cloth to lay against as they are very simple shapes. If you are getting penetrations from lower levels of geometry you may be able to block the surface from penetrating too deep but you run the risk of having the cloth surface lay awkwardly away from the underlying surface that it should look like it is colliding with. Hopefully at some point we will be able to use custom colliders for cloth. As of now custom colliders only work for dynamics like ragdoll physics.
- When creating physics bodies for collision you will find some settings in the details panel called Body Creation (should be lower right hand side of window). Turn off Auto Orient to Bone, a setting that is so very inaccurate I don’t even know where to begin. Set to capsule or sphere whatever works best for your area.
- Select the bone that you want to create the physics object for and then hit the Add Bodies button. Re-generate Bodies resets whatever mesh you currently have selected.
- The collision is not exactly the bounds of the object. The actual affected field is an inch or so out away from the physics object.
- Test your cloth painting with animation to find out where it is failing.