Birdoggydog's Builds

Fitting a garment in every animation clip while it's grown

Posing body and garment with my own skinning in numpy, lifting cloth where skin pokes through, and why 14 of 22 dwarf and orc pieces now pass and 8 don't.

The orc now wears a shirt, and 14 more dwarf and orc garments pass the rule that no skin shows through the cloth in any clip. Installed pieces went from 17 to 25 of 31 on the dwarf and from 23 to 29 of 31 on the orc. Eight pieces still fail, so the dwarf is still bare-chested. I haven’t solved this one.

38 seconds, captioned: the dwarf and the orc in the game wearing what is installed now, the orc in a shirt for the first time, and the eight pieces that fail left off.

Why were 22 pieces still failing?

After the first dwarf and orc pass, 22 of the 62 pieces still had skin standing out through the cloth in some animation clip. I picked “Yes: a pass for all 22 failing pieces”, shirts first. None of them was a lack of room. Each fault was one to four points of a low-poly body, at the edge of a garment or between two of its rings, that are skinned to different bones than the cloth next to them and swing out of it in one clip. Making the cloth bigger didn’t move any of them.

How does the fit work?

The clips are played while the garment is grown, not only afterwards by the check. The module is tools/blender/lib/wear_fit.py. It doesn’t ask Blender to evaluate each frame. It does its own linear blend skinning in numpy: every second frame of every clip except the deaths is stored once per body, as the skin’s posed points and normals and the bones’ posed matrices. A skinned garment is posed with the weights it will be exported with, a rigid plate on its slot’s bone, and a paired plate on both sides.

Then it asks the wear check’s question. A skin point under the outfit counts as proud when a ray out along its normal hits nothing and a ray back through it hits a garment face, and it’s a fault when it stands out more than 4 mm times the body’s scale. Where one does, the corners of the nearest face and of the face behind the point are lifted by what it stands proud, less half the limit. The direction is the skin’s normal at that point, turned back to rest by the bones of each corner, and never in. The points beside a lifted one go half as far, so it’s a swell and not a spike. That repeats for up to 6 rounds, and no point moves more than 20 mm times the body’s scale.

A lift along a vector beats one along the rest normal as a single number. I tried the scalar one and it was worse at the shoulders, where the bones turn the normal a long way between rest and a clip.

Why is each body grown twice?

A plate must never be checked without the shirt under it, and a trouser leg not without the boot over its hem. So each garment is fitted in the company of every outfit it is worn in. The trouble is that the garments of a higher layer aren’t grown yet when a lower one is fitted. So a body whose rows ask for this is grown twice in one run. The first build only keeps each garment as grown. The second fits each one among the others, those already fitted as they now are and the rest as the first build left them, and it’s the second that is exported. A third build fixed nothing more.

Fitting only the failing pieces didn’t work either. The orc’s boot stayed at 18.7 mm because the face that was touching it was a trouser hem, which belonged to a piece that passed and wasn’t being fitted.

If a point is still proud after the rounds, because it swings along the cloth past a hem and not into it, it’s marked stuck. The garment is fitted again from the start without the lifts made for it, so nothing is moved for nothing, and the point is left and reported in the model’s manifest.

The pass is only asked for by the dwarf’s and the orc’s garments. The four other races’ 124 models came out of a rebuild with the same bytes, and a second build of the 62 dwarf and orc models gives the same bytes too.

What didn’t work?

The eight pieces left are each one point of the body that no lift covers: the dwarf’s shirt, lab coat, fitted vambrace, strapped pauldron, ceramic shoulder and fitted pauldron, and the orc’s fitted pauldron and plate shoe. The worst are the dwarf’s inner elbow (11.5 mm in the claw attack), its neck root (5.4 mm in a hit), the armpit’s front point (7.8 mm over 14.6 cm2 in an attack) and the orc’s armpit (12.8 mm in two idles).

Things I tried on them and dropped:

  • Moving the body’s points in (the dwarf’s elbow by 8 and 6 mm, its armpit by 6, the orc’s armpit by 9 and ankle by 6). The cloth is grown off the skin, so it followed the dent, and new faults showed up: the dwarf’s shoulder at 8.6 mm and upper arm at 7.9 mm, the orc’s shoulder at 16.3 mm. The points’ weights aren’t outliers among their neighbors, so smoothing them is no cure.
  • Giving the cloth over a stuck point that point’s weights. That gave 8 fault places on the dwarf instead of 4.
  • Lifting each point’s twin across a paired plate so the plate stays symmetric. Three other pieces then failed: the dwarf’s fitted pauldron at 5.4 mm, its rerebrace at 7.6 mm and the orc’s boot at 4.9 mm.

That last one is the lopsided plate. The dwarf’s fitted pauldron passed the fit check, then was refused at the import check, which holds a paired plate to the same width on both sides to 1 mm. The lifts are made one side at a time, so it came out 184.8 mm from the middle on one side and 189.7 mm on the other. I’ve filed that as its own item.

What’s left?

What’s left is the body’s shape at the inner elbow, the neck root and the armpit. The next try is a ring more points on the dwarf’s body there, which is its own whole pipeline and not a number on a garment. I have to decide whether to do that. I also have to decide whether the dwarf’s plate, which is jagged at the back of the shoulder, is good enough as it is. On the sheets the dwarf’s shirt and coat sleeves also read stepped, with a pointed flare at each elbow.

Also done

  • 14 pieces went through every step of the model pipeline and were installed: the dwarf’s two cuirasses, plackart, rerebrace, strapped vambrace, boot, shoe and plate shoe, and the orc’s shirt, ceramic arm band, rerebrace, ceramic shoulder, boot and gloves.
  • The tests garment_skin (828 checks), garment_people (77) and model_pipeline (1505) pass, and the suite run by word at the landing was 14 tests with none failing.