Some of the work will be done outside of ModelDoc, "Blender" is recommended as we'll be using its "Source Export Tools", more specifically a modified version of Rectus' Source tools, made by Moonded on GitHub (on the right you can download the latest version under "Releases").
The first step will require you to mark which part of the mesh will be affected by the Proxy, this will be the actual piece of cloth:
- In "Scene Properties", under "Source Engine Exportables" and "Float Maps", add
cloth_enableby pressing the +
- Select the desired part of the mesh
- Assign the selected mesh to the "cloth_enable" vertex group
You're done with the main mesh, you can now export it (although it's suggested you keep it, as you're going to need it to create the Proxy), the only format that currently supports cloth physics is ".DMX", its version is also important, this being "Binary 3" (or any higher version) and "Model 22".
The "Proximity mesh" ("Proxy" for short) is a cheap mesh that's used for cloth simulation.
Cloth nodes are generated based on the Proxy's vertices, which are used to deform the main mesh, it is important to keep the Proxy as low-poly as possible without compromising functionality.
While one can be made from scratch, it is highly recommended you make one by duplicating it from the original mesh, this way all of the vertex groups are preserved, which are supremely important for this process.
- Select the mesh assigned to the "cloth_enable" vertex group
- Duplicate it, in Blender, this is done with ⇧ shift+d, press "mouse 2" to leave the mesh in place.
- Separate the duplicated mesh from the main mesh, in Blender, this is done with P > Selection, this will become the Proxy
- Lower polycount, In Blender (2.8+) you have the option to un-subdivide mesh with ctrl+e > Un-Subdivide
- If the resulting mesh seems to differ slightly in shape, you can add the "Shrinkwrap" modifier and select the main mesh as target, the vertices will be projected onto the nearest surface for greater accuracy
The cloth will also need to stay fixed onto the model, else it will fall off, to do this we use another Vertex group called "cloth_goal_strength_v2", as the name implies, it's used for "strength" or "stiffness", the value you assign to the vertices is indicative to how much they'll follow their original parent bones, with 0 being none at all and 1 being fully, these will serve as your cloth's anchor point. Since the proxy is the one that's used for the simulation, the main mesh will not use this vertex group.
- Create a new Vertex group called
cloth_goal_strength_v2by adding it in the same way as step 1 of "Setting Up"
- Select which vertices will remain fixed
- Assign the selected vertices to the "cloth_goal_strength_v2" vertex group
With this, your proxy is done, export it with the same .DMX version you used earlier to export.
The 2 Vertex groups we used are the only ones that are required, but multiple additional vertex groups exist, most of which have an unknown function, you can view the full list here, on the Valve Developer Community.
After having placed both models in the correct folders, and having added the aforementioned main mesh inside MoodelDoc, you'll need to add a "ClothProxyMeshFile":
- +Add >
- Select your proxy
- Check the
Add Bones To Render Meshbox
This will generate the cloth nodes, which also serve as bones, keep them to a minimum, in this case having too many cloth nodes may yield the opposite effect and result in worse cloth physics, especially for small meshes.
With this, the cloth is technically done, however, it is highly recommended to add "Cloth Parameters".
Cloth parameters will define how the cloth behaves, although a model can have multiple *"ClothProxyMeshFile"*s, only a single "ClothParams" can be used at a time, and it's shared between all proxies, the first instance of "ClothParams" will be used and the rest will be ignored.
- +Add >
ClothParams, alternatively, you can right click the "ClothProxyMeshList" to quickly add "ClothParams", and even any additional "ClothProxyMeshFile" if needed
- Check boxes and pull sliders to your liking
ClothParams include many options to control the cloth, some of which were too subtle or unclear to know what they do with certainty, while some others are just educated guesses, any contribution or correction is appreciated.
|Stretchiness||Controls the stretchiness||0→inf|
|Extra Iterations||Additional simulation checks||0→inf|
|Extra Goal Iterations||Unknown||0→inf|
|Extra Pressure Iterations||Unknown||0→inf|
|Goal Strength Bias||Goal strength is globally added/subtracted||-1→1|
|Default Gravity Scale||Cloth gravity||-inf→inf|
|Fast Drag||Air drag for quick movements||-inf→inf|
|Slow Drag||Air drag for subtle movements||-inf→inf|
|Internal Pressure||Amount of air inside the mesh, requires model to be 3D||-inf→inf|
|Windage Tangent||Amount of wind generated from the mesh, requires Internal Pressure||-inf→inf|
|Ground Friction||Friction between cloth and the world||?→inf|
|World Collision Penetration||Unknown||?→?|
|Add World Collision Radius||Radius for collision check between cloth and the world is added/subtracted||-inf→inf|
|Volumetric Solve Amount||Unknown||?→?|
|Minimal Bend||Prevents cloth to bend over a certain amount||0→1|
|Follow the Lead||Unknown||0/1|
|Force World Collision On All Nodes||Unknown||0/1|
|Collide With World Hulls||Allows cloth collision with the world||0/1|
|Collide With World Meshes||Unknown||0/1|
|Collide With World Capsules And Spheres||Seemingly allows cloth collision with physics shapes, to verify||0/1|
|Rigid Edge Hinges||The edges of 2D meshes will keep some shape||0/1|
|Soft Skin Animation||Unknown||0/1|
|Bend Only Springs||Unknown||0/1|
|Immovable Object (hint)||Unknown||0/1|
Cloth doesn't collide with Physics Shapes, instead, it has its own Cloth Shapes, these 3 being
You can add and modify them as you would with Physics Shapes, however, ClothShapeCapsule differs, being able to change the radius of each point instead of the capsule as a whole, making it arguably the best shape.