Half-Life: Alyx

Half-Life: Alyx

Not enough ratings
Source 2 Cloth Guide - Cloth Bones Ver.
By Kurgan
This Guide Details how create almost cloth in S2 with a mesh that has cloth bones pre-built into it, serving as an alternative to weight painting cloth in S2 via blender.
   
Award
Favorite
Favorited
Unfavorite
Basic Setups - Cloth Nodes + Springs
To start off, you need a model that has bones weighed specifically for cloth and cloth only. For this Guide, I'll be using a model from Like a Dragon: Infinite Wealth, specifically one of the protagonists, Ichiban.

To start off, we need to look at the model itself first in order to know what nodes to properly put where. The reason for this is that usually most models that have bones or bone chains for cloth normally have the root of the chain ( The First Bone In the Hierarchy ) always set as a static bone, this is to prevent the whole chain from becoming 'loose' and falling straight to the ground as it's only parented indirectly to another bone, but not weighted to that bone specifically.

Below I've already textured Ichiban. Collapsing his bone Hierarchy in ModelDoc, we can see the following:




The bones I've selected on the right correspond to the bones on the mesh that are specifically meant to control the physics of the cloth in game. Selecting them has also selected every bone down the chain in the bone hierarchy.

With this settled, now we need to create Cloth springs that form a chain. To do so, right click the root of each chain and select "Add Cloth Springs"


The bones I've selected on the right correspond to the bones on the mesh that are specifically meant to control the physics of the cloth in game. Selecting them has also selected every bone down the chain in the bone hierarchy.

With this settled, now we need to create Cloth springs that form a chain. To do so, right click the root of each chain and select "Add Cloth Springs"





Do this for every root bone that you have for cloth in the skeleton, once done you should have a big mess of cloth nodes on the left side in your Asset Hierarchy Viewer. Now worry not, because this is the least of your concerns, the next step is where the real fun beings.

Basic Setups - Goal Strengths
When you compile your model, the cloth nodes will immediately fall to the ground and stretch out in a big jumbled mess. You'll know it when you see and that's the sign that you're right on track from this step on. Now, you need to find the CLOTHNODE along the ROOT of each of the cloth spring chains. In this case, The bone i'm looking for on Ichiban's model is jk_nsos_<side>_1_1_dm_phy, where <side> is either r ( Right ) or l ( Left ). Let's say I select the left bone, so now I should be seeing something like this:



Now what you wanna do is tick the option that says "Static"



This will cause that selected node to become static. It will still be recognized as a clothnode, mind you, but it will not move during any of the cloth sims.

Repeat this process for the root bone in every chain until all the root bones in the chain are static. Once that's done, we can move on to the next part; fixing the jumbled mess that the cloth nodes created from random rotations.

In order to ensure that your cloth bones don't look like a mangled mess, select ALL clothnodes in the Asset Hierarchy, then goto the option that says Transform Adjustment and set it to "Auto-Detect".

Once you do that, your cloth bones should now be less mangled than they were before. But don't click away just yet ( If you did, that's alright. Just reselect all the clothnodes again) as the cloth on your model will still be drooping down soggy to the ground, in order to fix this issue we need to adjust the goal strength of these bones. The goal strength of a clothnode defines how far it can stray from its goal i.e its static position when not being simulated. Since we're only setting things up so far, what we want to do is go to the option that says "Goal Strength" and set it to a value of 0.4.



Once that's done, your cloth should now look a little more manageable and not droop completely down to the ground.
( Optional ) Optimizing Goal Strengths
If you want a more realistic feel to your cloth than a floppy mess, you can optionally adjust the Goal Strength of each clothnode in descending order down the cloth chain. Suppose you have a chain of bones as follows, so that means we'll set the goal strengths as such:

Bone_Root - 0.8
Bone_1 - 0.75
Bone_2 - 0.7
Bone_3 - 0.65
Bone_4 - 0.6
Bone_5 - 0.55
Bone_6 - 0.5
Bone_7 - 0.45
Bone_8 - 0.4
Bone_9 - 0.4 ( Don't go below a goal strength of 0.4 otherwise the cloth tips will be stupidly floppy )
The Fun Begins - ClothQuads and ClothTris
So far we've only been dealing with chains and clothnodes, making sure that each one is set up properly. This is the part where I scream into your earlobes and tell you buckle up, because from here on out stuff will really get weird and difficult to grasp, so remember to pay attention to everything I say.

Previously, We setup springs of cloth nodes into chains that individually work from one another, the result is that they flop around and stretch unnaturally, working like individual chains / ropes instead of an entire rigid body. But fear not, because S2 comes with a powerful tool that helps address this issue: Clothquads and ClothTris.

ClothQuads are as the name implies, it is a quad spring inbetween four cloth nodes that causes these nodes to function as a plane / rigid surface instead of individual chains. The reason we use ClothQuads and not Springs is because ClothQuads take the average of each Clothnode and uniformly moves the chains together while also keeping them loosely coupled with one another, simulating an actual rigid body.

ClothTris are the same thing but instead of Four, it works off 3 Clothnodes, this can happen usually when the skeleton has a set of cloth chains that are shorter from the one before it, causing a deficiency by one clothnode in the rigid body.

As stated before, ClothQuads work off of 4 points, so that means you need 4 Clothnodes. Now you're probably thinking how would I be able to use 4 Clothnodes? Won't I mess it up? Fret not, I got you covered. What you basically need to do is pick a chain of clothnodes, and look at neighboring chains. So suppose you have a bone setup like this:

B_C_1_1 B_C_2_1 B_C_3_1
B_C_1_2 B_C_2_2 B_C_3_2
B_C_1_3 B_C_2_3 B_C_3_3

Notice how you can see the gaps between them? Think of these as cloth chains, independent from one other. In this case since we're handling ClothQuads, we need to pick 4 Bones and join them together into a quad. If you're following so far, then that means we Pick the clothnodes as such from the above setup, say between chain 1 ( B_C_1 and B_C_2 ):

B_C_1_1 links with B_C_2_1
B_C_1_2 links with B_C_2_2

You'll set it up like this from that chain, but now notice how there's a bone that's missing from it? making a Quad between the First Two bones of the First Chain and the First Two bones of the Second Chain excluded 2 bones at the end of each chain, but worry not, because in theory all you have to do is take the last two clothnodes in the previous chain and link them up with the next to as such:

B_C_1_2 links with B_C_2_2
B_C_1_3 links with B_C_2_3

This all might look complex but it's actually stupidly easy, you'll get the hang of it once you put it into practice, which I will show you how. But that's for later, if you noticed I haven't highlighted how cloth Tris'd do the trick. Let's say I have the following hierarchy:

B_C_2_1
B_C_1_2 B_C_2_2 B_C_3_2
B_C_1_3 B_C_2_3 B_C_3_3

In the previous cases, we had a consistent number of bones across each chain, but here we have an inconsistent number of bones. The center Chain has one more bone than the neighboring chains, for such cases we use ClothTris. ClothTris exist to solve issues where there's a discrepancy within the bone hierarchy itself. For ClothTris, the simplest thing to do is to take a three bone approach, that would be we link the bones as such:

B_C_1_2 Links Diagonally B_C_2_1
B_C_1_2 Links Directly B_C_2_2

Now with the Theoretical stuff behind it out of the way, lets get into the meat of this sections; How to actually use them. First off, lets tackle Quads; On my model, I'm doing to look for 4 bones that identically neighbor one another in terms of length down the chain. Suppose I pick the following quad:



Now i'll note the names of the bones down and pull out the actual ClothQuad node. Click on + Add and then Search for ClothQuad. Once that node is in, I'll setup the quad for the bones noted down earlier. If you did them correctly, you should notice something like this:



This indicates that the Quad was successfully created and in the right way, now the center of this quad ( The Average of all four Clothnodes in the quad ) will be treated as the clothnode itself, thus causing both chains to move together instead of independently from one another. Now, what I'll do is I'll take the last two nodes that I set up in this chain and inherit them into the next quad as such:



Remember, use the tail bones as the top bones in the subsequent quads. Now, if you did it correctly, you should have something like this:



Notice the white line in between both quads? This Overlap of quads ensures that no 'sneaky' spot or gap is left in between the quads, thus preventing issues like incorrectly bent vertices. Now that the quads have been dealt with, I'll show you how to work with triangles. Going down the same chain, I'm presented with this dilemma:



Remember How I made mention that you can have cases where a chain is inconsistent with one of its neighbors? This is one of those cases, but it is also relatively easy to solve. Like before, Note down the bone names and + Add but this time, search ClothTri. Once that Node is in, what you wanna do is set up your nodes as such:



And bingo, problem solved.
With all that, this section is concluded. Following these same steps, I've gone ahead and setup the entire jacket with the same quads and tris. The result is as follows:



Now this looks really reminiscent of the actual term "Mesh" doesn't it? That's the sort of rigid body you should be expecting if you have clothchains in a skeleton. As one last step, select all cloth nodes and set their collision Radius to something as small as 0.5 and we can proceed to the final part of this tutorial.
Final Touch Ups - Collisions
Now that you've ( Hopefully ) setup the quads on your model, we can get to the next stage where we actually get the cloth to not collide with the mesh itself. See, Source 2 has collision shapes that, when added to a model, prevent cloth from phasing through. It's pretty self explanatory as to what it does so I'll just get into how to set them up. Basically what you want to do is goto + Add and add a Cloth Collision shape, these shapes come in a trio; A box, Sphere and Capsule. For this tutorial, I've used Collision spheres and set them up in such a way that the cloth maintains its distance from ichiban's body to respectable distance:



As a result, you can see that the cloth doesn't touch the mesh even though now it's animated.



So now if he runs like a goofy ahh mfer:



The cloth will majestically flow behind him.
Troubleshooting - Common Mistakes:
Help!!!1 The Clothquads can't recognize the bone names

That's because it's not looking for the bones, it's looking for the CLOTHNODES that are on the bone. If there isn't one, create a clothnode and copy the NAME of the CLOTHNODE and shove it into the clothquad / tri.

HALPPP!!!!111 The cloth droops too much
That's probably because you set the goal strength too low and you didn't make the root bone in the chain static. Make sure that Goal Strengths don't go Below 0.4 or they'll be really floppy.
Conclusion
And with that, I bid thee farewell dear reader! I hope this tutorial manages to help you in your sweet ahh endeavors in making High quality Addons to shove into the HL:A workshop! ( ISTG if you flood HL:A with FNAF garbage like gmod's workshop suffered it, I will find where you live and I will blow up your fridge. )