Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  (7.0.3) Updating skin constraints for noobs
#4
(20-01-2026, 11:35 AM)CptnFabulous Wrote: Gotcha. I presume that the ObiSkinnedCloth is not generating the necessary batches, because there’s no skin data present on the mesh for it to work with?

In this case we’ll have to make code to procedurally skin the cloth meshes, as they’re entirely procedurally generated (edited by the user) at runtime. I imagine the simplest solution is to, for each vertex, calculate bones within a certain distance (or the points inbetween the bones for things like limbs), and reference those bones’ index in the added bone weights.

Yes, that's the basic way to do it: for each bone, pick the N closest vertices (typically N = 4) and assign a weight based on some normalized function of distance (could be the distance itself or some smooth falloff function that gives more relative importance to closer vertices). The way to normalize the weights so that they add up to 1 and vertices don't move more than they should is to calculate the sum of the distances or falloffs for each vertex, and then divide each one by the sum. Something like:

Code:
foreach vertex v:
   foreach bone b:
      vertexWeights[v].Add(FancyFalloffFunction(Distance(v, b)));

foreach vertex v:
   vertexWeights[v].Sort();      // sort weights
   vertexWeights[v].Resize(N); // keep only the N highest weights (N closest bones)

foreach vertex v:
   sum = 0;
   foreach weight w in v:
       sum += vertexWeights[v][w];  // accumulate sum of all weights for this vertex
   foreach weight w in v:
       vertexWeights[v][w] /= sum;   // divide by sum to make sure all weights add up to 1.


Caveats:
#1) - note that this may cause the cloth to clip trough the character, since body vertex weights and cloth vertex weights won't necessarily match and they'll deform differently. This isn't much of a problem if you have a full-body collider setup that can prevent the clipping.

It's worth noting that in the *ideal* case of having a skinned garment that doesn't clip trough the body, skin constraints can prevent clipping without the need for colliders, since each cloth vertex is constrained to move "in front of" the skinned position: if the skinned cloth mesh doesn't clip the body, the simulation won't either.

#2) - using euclidean distance between vertices and bones may not work well in some cases, for example pants: vertices belonging to one leg might actually be closer to the opposite leg's bones and become skinned to the wrong leg. In cases like these you'd want a more sophisticated solution like voxel heat diffusion:
https://www.wolfire.com/blog/2009/11/vol...-skinning/
https://bronsonzgeb.com/index.php/2021/0...-skinning/

This measures distances between bones and vertices inside the volume of the body, preventing "gap closing" in areas like armpits and legs.


(20-01-2026, 11:35 AM)CptnFabulous Wrote:
Weightings could be calculated on either proximity, or perhaps vertical position, as the higher fabric would potentially stretch to support the weight of the lower one.

Don't make vertex/bone weights depend on vertical position. You can however make the skin constraints' "skin radius" depend on it, forcing cloth vertices near the shoulders to keep closer to their skinned position, and giving more freedom of movement  to cloth vertices further down the body.

(20-01-2026, 11:35 AM)CptnFabulous Wrote: [color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]Can this be done after simulation starts? The way our system works currently, the garments are made of several flat meshes, that are wrapped around the body and stitched together through the simulation. If not, I’ll have to make code that modifies the meshes themselves to fit around the body. Fortunately I already spent some time working on this to try and solve a different problem, but I’ll still need to allocate time to finish it.

You can do this by allowing the simulation to run for a while against a t-posed mannequin, then baking the resulting cloth mesh(es) (look for the BakeMesh() method), then performing skinning and adjusting the skin constraints to use the newly generated skin data.

let me know if you need further help,

kind regards
Reply


Messages In This Thread
RE: (7.0.3) Updating skin constraints for noobs - by josemendez - 23-01-2026, 09:11 AM