Generating a shape key to negate armature transform

Hi guys! I have run into an interesting problem, which is quite out of my level of expertise as it’s all getting quite complicated, I was wondering if a guru here knows of a solution.

So I am working on a mod for Crusader Kings 3, the game engine supports additive animations, and morphs, it does not support custom skeletons, however.

I am creating quite a complex model of cat’s whiskers with over 10 shape keys to give them variation. Due to the technical constraints, they need to be weighted to the existing head bones.

Now the problem comes in when I want to create a way of scaling them, on paper it seems simple, scale the bone and the whiskers attached scale with them! Which works for the whiskers, but it also deforms the base head model too as that has vertices weighed to it also.

So what I am trying to do is find a way to create a shape key, a counter-shape key if you will that will reverse all the vertex transforms that scaling the bones is making to the base model. So it would still be scaling the facial bones, but it would be masked by applying the counter morph at the same rate giving me the result of the whiskers scaling independently.

Now before you ask I have also tried scaling the whiskers with a blend shape, however, it only works if you make a scaled version of each blend shape which would be quite inefficient and I don’t even know if I would be able to implement such system in-game without major conflicts.

I have gotten close, by just making a new shape key and then trying to sculpt the result back to where it looks normal, but it’s never going to be exact doing it this way, and I am hoping there is a script or something that could help me accomplish this in a more systematic manner. Maybe a way to copy the global position of all vertices in the model at a certain keyframe, and move all vertices back to that position at a later keyframe irrespective to the fact that the bones have been scaled.

In the below video you can see what I mean. Scaling the whiskers deforms the whole face. In the end, you can see what I’m doing with a hand-sculpted shape key to counteract the bone scaling which works quite well. A little deformation along the way is expected and acceptable, but I want to be able to get as close as I possibly can.

I mean, it’s not impossible. Scale your bone(s) up, apply the armature as shapekey, limit the shapekey with a no-whisker vertex group, then reverse the shapekey by setting to -1 and create a new shape from mix. That’s the inverse of your armature (well, as much as a shapekey can invert armature deformation, at least.)

But I can’t see why you’d ever want to do that instead of making blend shapes for the whiskers. I can’t understand what you’re saying when you write,

I’m not sure what you mean by that. Do you mean that if you scale the whiskers up and pose some of your facial bones, that the whiskers look wrong? Yes, they will. But not half as wrong as they will if you scale the facial bones up, and pose the facial bones, and then apply a corrective shapekey to the head.

No, the issue isn’t with posing the bones, the issue is the way shape keys interact with each other. Let’s say I have 10 shape keys for different variations of the whiskers, drooping down, swept-back etc. If I make a single blend shape for long whiskers it only works for a neutral position, if I also apply drooping shape key then instead of scaling the entire mesh, it will move verts to a diagonal, which is not the result I want.

In the video above you can see what I mean. Scaling them in rest pose works fine, but as soon as I apply another shape key result is deformed, which is what you would obviously expect. In the latter half, you can see how I want it to scale with the bone.

Now like I mentioned before, I could try making a version of each of the morphs at a different scale (drooping_short, drooping_long, sweptBack_short, sweptBack_long, etc.) which I could work within blender. I just don’t know if it will work properly in-game, once all of these shape keys start interacting with one another I’m afraid it will mess things up for me. However, I will try.

What are you saying, you want to have “whisker droop” combine with “scale whiskers” actions, and have the scale whiskers action follow the droop? That’s not going to combine with bones either, not without a custom armature.

But the quickest way to see that is to try it out. The method I described above will give you an inverse of your armature as a shapekey. Then you can make two inverse face shapekeys to go along with the two actions you’re demonstrating and test out the mix.