Creating Clothing including Customization Morphs

This process will detail the workflow to create clothing, using Max Garment maker, and Cloth modifier, and will include automatic skinning, and extracting morph targets to match character body part customizations, like body muscle size etc.. using Max’s SkinWrap, and custom Max scripts.

 

The meshes will also be imported into Unity, and re-targeted to 4 unique characters, that were customized using morph targets, and rendered using their LOD meshes.

Clothing_40

The version of Unity I use is 4.1 2f1, which does not support blend shapes, so the morph targets will be extracted to their own FBX, for each skinned mesh, all using custom MAXScript scripts.

This document will outline in as much detail, if not more, what the process is.

The process to create clothes is very well detailed and plenty of tutorials exist on the web and in Autodesks documentation and tutorials page. But I will detail the process I use here, which is pretty standard for creating cloth in Max.

The first step, is to rotate and position the character model, on X=-90 degrees, so that the model faces the top view, and to use the top view, to outline the pattern, of the clothes, using splines.

Where my method differs from the usual tutorials, is I use mirror to mirror the other side of the pattern, and ensuring that my vertices are centered on X=0, and my pivot is also located on X=0.

This way I am certain my clothes are 100% symmetrical, as is my character model.

Be sure to weld all vertices, after attaching the mirrored copy.

The next step is to select and ‘break’ the vertices, that will form the beginning and end points, of the seams, that will seam the front and back panels of the clothing, this can be done now, and does not have to be done twice *(one for each panel, front and back) later, after creating the mirror on Z=0.

Then ensure the center vertices are on X=0, and the pivot is on X=0, then mirror and attach the spline on X, creating a copy.

 

Once this is done, the entire spline must be mirrored again, this time on the Z axis, and move the copied spline so that it has it’s own space *(does not overlap anywhere), in the top view, attach the splines again, to form a single editable spline, and then add the garment maker modifier on it.

When this is done, the character model, can be rotated back to X=0. *( to face the front view)

 

Added the garment maker modifier, will subdivide the spline, for cloth like folding.
Added the garment maker modifier, will subdivide the spline, for cloth like folding.

The next steps are not required, but useful, it will alllow the front and back panels, to be easily snapped into place, and the further adjustment will be required to perfectly align them where they need to be, before seams can be created to let the cloth modifier know, how to seam the cloth up in the simulation.

Points have been marked on the model.
Points have been marked on the model.

From the garment maker rollout, click the Figure button, and then click the character model, then *( use a front view ), click the ‘Mark points on figure’ button, and a little box figurine will appear in the top left corner of the viewport, it will contain asterixes at specific body parts, with the red asterix indicating where you should click to mark that corresponding point, on the character.

As the points/locations are clicked on the character, the next body part astrerix will turn red, when it returns to the default, middle of chest asterix, right click in the view port to stop. Max will remember the locations *(even after removing the cloth modifier later on), and any further or new garments, can reuse these locations, without having to re set them.

 

Positioning the panels.
Positioning the panels.

To position the garments/panels, go to the panels subobject level, in garment maker, select the front panel in the viewport, then click the ‘Top at neck’ radio button, then click the ‘Front Center’ button, in the garment maker rollout, this will set the initial position of the front panel, do the same for the back panel, but click the ‘Back Center’ button.

The last step is to ensure the clothes are at the proper X and Z positions, I do this by selecting garment maker parent object, and then position the entire spline, on X=0, and where I think the neck should be, make sure to also position the panels as close to the character as possible, without it intersecting anywhere whatsoever, as that will affect the cloth simulation later on.

Once this is done, the seams can be created.

 

To create seams, go into the seams subobject mode, of the garment maker, and select both the front and corresponding back seam, that will be joined together, to form the shirt, and click ‘Create Seam’, if the seam lines are not parallel to each other, click ‘Reverse Seam’.

There must be no seams where the clothes, should form holes, like at the neck, around the waist, around the arms, around the legs/ankles.

That is why the vertices that originally make up those locations, are not joined, or ‘broken’ in the previous steps, when making the pattern.

 

Options for simulating cloth
Options for simulating cloth

Then exit subobject mode, add the cloth modifier, above the garment maker, and click the ‘Object properties’ button, in the cloth rollout.

The cloth modifier works by you telling it what is your clothing/fabric mesh, and type *(like cotton/rubber/etc..), and what is the ‘collision object’/character, that the clothing should wrap around, to provide the cloth modifier with this information, simply select the clothes mesh/spline from the list, under ‘Objects in Simulation’, and tick the ‘Cloth’ radio button, on the top right hand side, of the dialog.

Then optionally choose a fabric preset, I used ‘Cotton’ in this example. Not very exciting.

Then click the ‘Add Objects’ button, and choose the character mesh, it will be auto selected after added in the left hand list, then tick the ‘Collision Object’ radio button, in the bottom right hand , I set the offset to 0.3, the offset is simply how far away in Units *(I use CM by default for everything) the fabric should try and stay, but this will almost always intersect in any case, but not to worry , that is fixed very quickly and easily.

Then click ‘OK’ to  exit the dialog.

Make sure the ‘Gravity’ button is not enabled, at the bottom of the cloth rollout, for the initial simulation.

The initial simulate local
The initial simulate local

At the top of the cloth rollout, click the ‘Simulate Local’, give it a few seconds, and then click it again to stop, or press ‘Esc’.

Things to look for in this phase is, there should be no bad intersections, between the cloth and the character, and the seams do not have to join up at all, in fact, it’s almost always better that they don’t, as the next step, will fix this very easily.

Also note this mesh is not optimized, and I would not use it as is, that will also be fixed and symmetry applied a bit later.

 

The clothing is not complete, as seams are still visible.
The clothing is not complete, as seams are still visible.

To fix the clothing, so that it completely fits, untick the ‘Use Sewing Springs’ and re-enable the Gravity button, under the cloth rollout, then click the ‘Simulate Local’ again.

This will sew the clothes so that ir fits the character, and no more seems should be visible, although the clothing will probably intersect the character, but that will also be fixed shortly.

Currently the clothes mesh will contain too many vertices, collapse the stack, remove the cloth modifier from the character *(Max auto adds it), and I apply symmetry on the clothes, collapse it, weld all vertices, and scale themesh up slightly, so that it does not intersect the character anymore, the last step is to reset the XForm, to reset the matrices, and ensure the scaling matrix is set to the identity.

I also apply a multires, and bring the vertex count down to about 30%, so that it is well under 1K. And then ensure the mesh is still symmetriucal, and fix any issues where the mesh has turned edges, or intersecting geometry.

The next step is UV Mapping, this is done very easily by adding an ‘Unwrap UVW’ modifier, and then simply using Quick Pelt, and arranging the UV’s so that they are within the UV bounds, in the UV editor.

The next steps are to clone / copy  and export the low res clothes mesh, including any morph targets required for character customization, this is done quite easily using my custom ‘Skin Accessory To Head’ MAXScript, which provides the capability, to assign a SkinWrap, and point to the Hi res character mesh, as the driver.

I use MutliRes again, to bring the vertex count down to about between 30 and 50%, of the clothes mesh, that will usually bring it down to well under 500 vertices, usually about 200 odd.

I then convert the SkinWrap to Skin, making sure to tick ‘Weight All Points’, and then select the skeleton of the character, and the clothes mesh, and export it to an FBX. The FBX should be tested in Motionbuilder, or whatever to ensure that it was done correctly, this is done by simply opening the FBX in Mobu, characterizing for biped, and creating control rig for FK/IK, and moving a few limbs around. That is not saved, just for testing.

The next step is to export the morph targets, for the low res clothes, to it’s own FBX, this is done by removing the Skin modifier on the clothes, and re-enabling the SkinWrap modifier from earlier, running the ‘Skin Accessory To Head’ dialog again, and choosing the ‘Extract All Morph Targets’ option, this will go through each of the characters customization morph targets, and set each one individually to 1.0, and extract a snapshot of the current clothes mesh, which is SkinWrapped to the character, thereby creating a morph target, to be used in Unity, all of those meshes/morph targets are then exported to a single FBX, which I also open in Mobu to check, they will not contain any skinning information, as all I need are the vertices positions, in model space, for my morph system to work.

The morph targets, created from MAXScript, moved around in Mobu
The morph targets, created from MAXScript, moved around in Mobu

In total, there are 36 morph targets, which may or may not contribute to the clothes deformation, that will be filtered out and optimized by my morphing system in Unity, and only affected vertices, and their indices will be cached and re-used, per skinned mesh.

The next steps are pretty similar for the HiPoly version of the clothes mesh, I only need 2 versions of LOD for clothes, as I set the material as well, to bumped specular, specular or diffuse in Unity, also based on the materials defined LOD parameters, when more than 20 or 30 characters are in the scene, all using this LOD system, the FPS is still way above 100, while animating each character individually using Mecanim which is where it should be.

Firstly, the HiPoly clothes mesh, is the same mesh from which the low poly mesh was originally cloned/copied from, I apply the SkinWrap modifier, and point to the character as the driver, all automated via the same dialog as above. I also apply a Shell modifier, apply symmetry, collapse all vertices again, but I do not re UV map, as I can reuse the same UV’s, the inside is not important for the clothes, as it must just not look hollow, this will double the vert count of the clothes to about 1K, which is perfect, works 100% in my game, with more than 30 characters actively in the scene.

Then convert the SkinWrap to Skin, using the button on the SkinWrap modifier, and make sure to tick ‘Weight All Points’, then export the skeleton and the hi poly clothes mesh, to FBX.

I then open and test the skinned mesh in Mobu, using biped, and FK/IK, and not saving those test changes.

The next step is to remove the skin modifier from the clothes mesh, re-enable the SkinWrap modifier, export all morph targets, to their own FBX, by using my dialog again, which will go through the characters customization morph targets *(36 in total) and snapshot and export all hi poly clothes meshes, unskinned, to a single FBX.

I then open in Mobu, and check the vert counts of a few, to ensure that the process worked, if any of the vert counts do not match, the Unity morph scripts will throw an exception and indicate which meshes do not match with the base mesh.

I then complete the texturing for the clothes in MudBox, using the low poly mesh as the model, because the hipoly mesh will not be importable to MudBox, as the inner shell’s UV’s overlap, and will cause issues, but in Unity, it will not be a problem at all, and will import and render 100%.

If you need the inside to be fancy and have it’s own UV’s, simply Unwrap UVW the mesh, and re-export the skinned mesh with skeleton, and re-export the morph targets using the dialog.

Takes about 20 seconds.

 

Checking the texture on the HiPoly in Max
Checking the texture on the HiPoly in Max

The final step is to import into Unity, when exporting from Max, do not split normals, and when importing into Unity, do not calculate or import normals, the custom Unity scripts will automatically calculate and cache normals and tangents for the clothes at runtime, when equipped.

The clothes have and LOD system , so meshes, and their materials, will differ based on distance from the camera.

Leave a Reply