Apply Shape Key to Armature

Discussions about MakeHuman, Blender and MPFB. It is ok to ask for general Blender support here, even if it isn't directly related to MakeHuman

Apply Shape Key to Armature

Postby woodcat » Mon Sep 06, 2021 2:02 pm

Greetings!

The problem is as follows. A model is being prepared in Blender 2.93 for import into the game engine (Godot). It must contain Shape Keys to change the shape and an armature for the animation corresponding to that shape.

Everything is clear with the shape of the model. The base model is imported from MakeHuman, then the target model and transferred as Shape Keys to the base model. There is no problem here.

But when the Shape Key is applied, the armature doesn't change. It stays the same.

Image Image

When scaling, you can see that the armature bones are not reduced proportionally, but fit the new shape.

Image

Question: how can I change the armature, like apply Shape Key to it? How is this done in MakeHuman?
Curiosity killed the cat, but satisfaction brought it back.
User avatar
woodcat
 
Posts: 71
Joined: Sun Sep 27, 2015 7:53 pm
Location: Moscow

Re: Apply Shape Key to Armature

Postby joepal » Tue Sep 07, 2021 5:53 am

You'll need some python in order to do this. This in its turn requires metadata.

Basically the algorithm is:

* Apply shape key
* Find joint cubes (they're part of the hidden helper geometry)
* Calculate center of each joint cube
* Have a metadata file specifying where each bone's head and tail should be, specified as joint cube name or vertex number
* Move the bone's head and tail to match the calculated center of the joint cubes (or to the vertex position)

This fitting algorithm is implemented in MPFB2, although the refit button doesn't take the rig into account yet.

The bone fitting algorithm is in https://github.com/makehumancommunity/m ... ies/rig.py

The metadata is in https://github.com/makehumancommunity/m ... fault.json

The available strategies for bone (head/tail) placement in the metadata are:

* CUBE: place at center of joint cube with specified name
* VERTEX: place at coordinate of specified vertex
* MEAN: place at the coordinate mean between two specified vertices
Joel Palmius (LinkedIn)
MakeHuman Infrastructure Manager
http://www.palmius.com/joel
joepal
 
Posts: 4140
Joined: Wed Jun 04, 2008 11:20 am

Re: Apply Shape Key to Armature

Postby woodcat » Tue Sep 07, 2021 10:54 am

Thank you for your comprehensive answer.

joepal wrote:This fitting algorithm is implemented in MPFB2, although the refit button doesn't take the rig into account yet.

As far as I understand, applying such an algorithm would be very hard on the game engine? If the characters will be a few hundred or thousands.

Is there some simpler algorithm, albeit less accurate, that can be used in a game engine?
Curiosity killed the cat, but satisfaction brought it back.
User avatar
woodcat
 
Posts: 71
Joined: Sun Sep 27, 2015 7:53 pm
Location: Moscow

Re: Apply Shape Key to Armature

Postby joepal » Thu Sep 09, 2021 2:33 pm

Hmm. I guess you could pre-calculate the joint positions for a number of typical characters. I mean, if pretty much all old male characters have the same body shape and only vary the face and, for example, the size of the belly, then the joints would still be in roughly the same position.

Then you could store the bone locations in a few static arrays instead of calculating these dynamically.
Joel Palmius (LinkedIn)
MakeHuman Infrastructure Manager
http://www.palmius.com/joel
joepal
 
Posts: 4140
Joined: Wed Jun 04, 2008 11:20 am

Re: Apply Shape Key to Armature

Postby woodcat » Fri Sep 10, 2021 8:06 am

joepal wrote:Hmm. I guess you could pre-calculate the joint positions for a number of typical characters.

The idea was that the character could grow smoothly while growing up.

I was going to animate the size of the skeleton and the ratio of bones. It went something like this:

Image
0001-0100.mkv File size: 459.11KB

No problem with rig growth, but the position and size of the bones separately, unfortunately, is not animated — no access.

One option is to break it down into "stages of growth" and, as you said, prescribe them pre-calculated rigs. But then you have to either greatly reduce the possibility of customizing the characters, or the animation will be crooked (if the steps of the calculated rigging will be little), or these rigging must be well, very much…

I'll meditate on this problem some more. Image
Curiosity killed the cat, but satisfaction brought it back.
User avatar
woodcat
 
Posts: 71
Joined: Sun Sep 27, 2015 7:53 pm
Location: Moscow

Re: Apply Shape Key to Armature

Postby woodcat » Fri Sep 10, 2021 8:33 pm

And one more question...

How many mesh targets are there in MH models?

Suddenly it turns out that in Blender you can mix different rigs per model. This is what I got when I mixed a grown-up and a child's rig:

Image
0001-0100_2.mkv File size: 793.41KB

It doesn't look very elegant in the middle of the animation. Perhaps it would look better if I put in another target rig.
Curiosity killed the cat, but satisfaction brought it back.
User avatar
woodcat
 
Posts: 71
Joined: Sun Sep 27, 2015 7:53 pm
Location: Moscow

Re: Apply Shape Key to Armature

Postby joepal » Sat Sep 11, 2021 8:54 am

There are about 1.4k target files in MPFB2, since I excluded some. Not all of these move joint cubes obviously, but many of them do.

Anyway, I implemented the refitting algorithm fully now, so that the refit button also refits the rig. Profiling this, I got 96ms for refitting the default skeleton. Part of this is reading and parsing the JSON file with the rig definition from disk though.

If all data is already in memory, my guess is you squeeze in up to 20 refittings of the default rig per second using the MPFB2 algorithm. This might be good enough for animating a single character, but will obviously become a bit too heavy for an animation if you need several characters in parallel.
Joel Palmius (LinkedIn)
MakeHuman Infrastructure Manager
http://www.palmius.com/joel
joepal
 
Posts: 4140
Joined: Wed Jun 04, 2008 11:20 am

Re: Apply Shape Key to Armature

Postby woodcat » Sat Sep 11, 2021 7:23 pm

joepal wrote:There are about 1.4k target files in MPFB2

Oh, mein Gott!

Anyway, I implemented the refitting algorithm fully now, so that the refit button also refits the rig.

Thank you very much for the nice work done!

There are small problems... I'll probably describe them in the MPFB 2 thread.

This might be good enough for animating a single character, but will obviously become a bit too heavy for an animation if you need several characters in parallel.

Yes, a few characters… up to a hundred in the beginning…

The idea is to break the project into two branches in the medium term: a small number of quality characters (about a dozen or two) and a mass population with simplified models (thousands). But I'd like to start simple: an uncomplicated rig and a few characters.

There was a task, to transform in animation one reference rig into another. The adult rig into a child's rig. This is what I got, only one leg is done:

Image

0001-0100_3.mkv File size: 593.12KB

The problem is that when you apply "Armature deform", everything gets twisted…

Shape transform.jpg

This idea doesn't seem to be viable. Apparently we'll have to go back to mixing animations, but the engine doesn't take it well…

Unfortunately, I'm not qualified to work with Ruthon, I'm just at the beginning of programming. :(

For now, there's an idea to break up the animation into stages of maturation, in which you can implement smooth growth without artifacts and distortions. For example, from 1 year to 13,5 and then to 25; then to 50-60, and finally to 90. The engine will load only one model for the character corresponding to the current stage and change to the next, when reaching the right age. We may have to drastically reduce the number of character settings. If the game will be in demand, over time, you can expand its capabilities.
Curiosity killed the cat, but satisfaction brought it back.
User avatar
woodcat
 
Posts: 71
Joined: Sun Sep 27, 2015 7:53 pm
Location: Moscow

Re: Apply Shape Key to Armature

Postby woodcat » Sun Oct 10, 2021 11:21 am

I won't open a new thread, since it's kind of a continuation.

Question: How many basic body morphs are there?

To elaborate: The default adult body is imported into Blender (25 years MH). Then a minimal child body (1 year old) is imported and applied as a shape key. If you change the influence of the shape key smoothly, the shape of the body doesn't match the body imported from MH.

For example, if the full transformation is 100 frames, then on frame 66 (100 — adult body), at the height corresponding to 13.5 years, it looks like this (the imported body is highlighted; the interpolated body is not highlighted):

Shape transform_13.5w.jpg

How many intermediate shapes of the whole body are needed and in which places, so that the result in Blender would coincide with MH?
Curiosity killed the cat, but satisfaction brought it back.
User avatar
woodcat
 
Posts: 71
Joined: Sun Sep 27, 2015 7:53 pm
Location: Moscow

Re: Apply Shape Key to Armature

Postby joepal » Sun Oct 10, 2021 1:43 pm

Although almost all targets and macro modifiers are symmetric, age is not. Age is split up into sections:

* 0.0 - 0.187499 = baby morphig to child
* 0.1875 - 0.49999 = child morphing to young
* 0.5 - 1.0 = young morphing to old

That is, 100% applied macro targets are:

* 0.0 = baby
* 0.1875 = child
* 0.5 = young
* 1.0 = old

For other macro modifiers, you usually have a symmetric two-way or three-way split. For example muscularity is split into:

* -1.0 = minmuscle
* 0.0 = avgmuscle
* 1.0 = maxmuscle

While gender is split into:

* 0.0 = female
* 1.0 = male

Unfortunately, this also means that most conceivable combinations results in a specific target. Thus you have, for example, female-young-maxmuscle-averageweight-minheight.target for a young female who is very musclular, of average weight and very short. If the muscle slider is between max and average, you'd get a mix between the aforementioned target and female-young-averagemuscle-averageweight-minheight.target

So to answer the question, there are 348 macro targets to mix. But all of these cannot live together if you use MH or MPFB to do the morphing. You cannot have a mix between baby and old targets, nor a mix between maxmuscle and minmuscle.
Joel Palmius (LinkedIn)
MakeHuman Infrastructure Manager
http://www.palmius.com/joel
joepal
 
Posts: 4140
Joined: Wed Jun 04, 2008 11:20 am

Next

Return to Blender and MPFB

Who is online

Users browsing this forum: No registered users and 1 guest