Page 1 of 2

Blender bendy bones and deformation cages for joints

PostPosted: Fri Oct 05, 2018 9:08 pm
by blindsaypatten
Some time ago Blender added bendy bones, which allow you to bend objects. Here's a simple example where a bendy bone is used to bend a cylinder:

The usual skeleton types cause problems at joints where the surface collapses on the side that gets compressed:

By placing a bendy bone at a joint the collapse can be mitigated. I placed a bendy bone at a knee joint, with one end attached to (parented) the upper leg bone and the other end attached to the lower leg bone. This prevents the collapse:

I suspect that it could be improved further by playing with the placement and weight painting, which I didn't spend much time on. Part of the problem is just the granularity of the mesh, it can be hard to keep a smooth mesh.

Just for illustration, here is the knee joint with the bones displayed as bendy bones. I'm not sure why they get displayed so wide here.


A nice point of this approach is that the animation code isn't affected at all, the bendy bones are controlled by the regular bones without even needing drivers.

With slightly less bend the bendy knee isn't distorting at all while the regular knee has already started to collapse:

Re: Using Blender bendy bones for joints like knees

PostPosted: Sat Oct 06, 2018 7:30 am
by bogdan666
I've solved the collapsing knee joint problem by changing the bone weights around the knee bend and for keeping the knee volume I'm using the Dual Quaternion Skinning Algorithm ( "preserve volume" in blender terms).

But Dual Quaternion has it's own problems, mainly in the armpit area, if you want to make a pose with raised arms, because it keeps volume, where it should not.
The only solution is to make a shape key for each armpit.

But if you still want to use the Linear Skinning Method, you will have to make even more shape keys (for every joint you want to twist or bend), because of volume loss problems.
I don't know what's better: Linear Skinning Method+Shape Keys or Dual Quaternion Skinning+Shape Keys, but I'm inclined to say that the second approach is better, because it needs fewer shape keys.

Re: Using Blender bendy bones for joints like knees

PostPosted: Sun Oct 07, 2018 1:05 am
by blindsaypatten
I tried using preserve volume but the effect seemed minimal. Do you need to do more than click the box in the Armature modifier?

However I rediscovered the Corrective Smooth modifier which is very effective.
Using Corrective Smooth: without preserve volume, with preserve volume, and using a bendy bone.

I think the bendy bone looks a little better when the angle is 90 degrees, the back of the default rig has started to collapse, but probably not worth the work for most purposes. Corrective Smooth is the key.
Comparing default and bendy bone at 90 degree bend.

Re: Using Blender bendy bones for joints like knees

PostPosted: Sun Oct 07, 2018 8:52 am
by bogdan666
You only need to change the weights of bones in the knee area by reducing the weights slightly+smoothen the mesh by clicking on the smooth button in the weight tools+preserve volume. (to activate the button, click the "vertex selection masking for painting" button, while in weighting mode)

The Corrective Smooth modifier works only inside of blender, but my method works even in Unreal Engine etc., because you can't export the blender modifiers out of blender. However it will be ok, if you only want to do renders inside of blender.

I've uploaded a character, which has my weight mod+smoothening applied. The legs look now even smoother with sitting poses+the hip area has now more volume with extreme poses. (legs up)

If you want to add this modification to your custom made MakeHuman char, you have to make a MakeHuman char with the default rig (has most bones), append my char to your character blender file and finally transfer the weights from my character to yours. As a result you will get all the modifications.

Link to the weight mod char: viewtopic.php?f=4&t=16392

Re: Using Blender bendy bones for joints like knees

PostPosted: Sun Oct 07, 2018 6:34 pm
by blindsaypatten
Thanks for the links and the blender files, having the blender file makes it so much easier to see what's going on.

What I see is that by avoiding overlap in the weight painting of the two sides of the joint the surfaces attached to the bones simply pierce one another instead of forming an ugly indentation. The downside is that you still see the crease on the outsides of the joint.
KneeCircled.jpg (16.01 KiB) Viewed 5094 times

I was doing the same thing a year ago, viewtopic.php?f=3&t=14183 we had a five page thread about it but in the end no one knew how to change the weights in MakeHuman ;)

Mostly for the sake of feeling that I tried everything, I decide to try out mesh deformation cages, which are used in BlenRig 5, which are supposed to produce very good results.

As a starting point I just made a cylinder that encased a leg mesh. I used a stupidly high resolution cage mesh, one of the beauties of mesh deform cages is that you don't need fine meshes, and that because the mesh is low res it is relatively easy to make corrective shape keys as needed. The other wonderful thing is that they are reusable, the same deformation mesh can be fitted to any humanoid body without redoing the shape keys, you just need to line up the joints. In theory you should be able to run the cage mesh through makeclothes and have it automatically fitted to any model. I had hoped to do that with the BlenRig cage mesh but it turned out that mesh contains triangles around the major joints because triangles behave better under deformation, a triangle is always planar while quads often become non-planar when deformed.

Anyway, I started with this:

Bending it 90 degrees gave this:

Adding a very lazy shape key:

Produced this result:

Not too bad considering I didn't do a proper shape key or fine mesh fitting.

A few notes: that I didn't use an optimized mesh which should give better results, I didn't fit the mesh close to the body which would give better results, I only did the deformation bind at level 5, you would use level 7 for production but that takes several minutes of compute time to do the binding, and I didn't put any real effort into the shape key and used the default weight painting. So, I would say this approach is promising.

A blender question, when developing shape keys is there an easy way to edit the mesh in its posed state? Normally when you go into Edit Mode the mesh snaps back to the rest state. I seem to remember something like making a shape key for the posed position and then a second one for fixing the deformation... I have to look into that...

Re: Using Blender bendy bones for joints like knees

PostPosted: Mon Oct 08, 2018 12:20 pm
by bogdan666
The bent knees look better with Dual Quaternion Skinning (has more volume), the old screenshot from above (knee with red circle) is with Linear Blend Skinning. But a crease is normal to a certain degree in the real world as well.
Do mesh deformation cages even work with keyframing, loading mocap files etc. or with clothes?

For editing a mesh in pose mode:

Go to edit mode-->modifier tab.

To the right of the name "ARMATURE" there are different buttons (hover over them to see more details): Click on the buttons "display modifier in edit mode" and "Adjust edit cage to modifier result". As a result you can now
modify the mesh of a posed character.

Re: Using Blender bendy bones for joints like knees

PostPosted: Mon Oct 08, 2018 2:40 pm
by blindsaypatten
Thank you for the pointer to the buttons on the modifier tab, I knew there had to be an easy way to do it!

With regard to creases in real life... :oops:

I was looking at my own leg for a reference, and, well, naturally, sitting at the computer, I'm looking at the inside of the knee. Well, it turns out the inside and outside look quite different :o

And once the calf and thigh meet there's definitely a crease:

The problem is really more at the less extreme positions before the calf and thigh meet.

The Deformation cage is controlled by the existing armature so it works fine, without any changes, for all the usual armature-based animation techniques. The mesh has to completely enclose the vertices it will control, so with loose fitting clothing you might need to manually expand the cage to include the clothing. For things like dresses, you would probably want to create a "dress deformation cage", I haven't thought that through. You can use multiple deformation cages so that shouldn't be a problem.

Just as an experiment, I created a simple deformation cage just for one leg in Blender and used MakeClothes to get it into MakeHuman, and then exported back to Blender. The results so far are encouraging.

Deformation cage versus default skeleton

Re: Using Blender bendy bones for joints like knees

PostPosted: Mon Oct 08, 2018 5:57 pm
by blindsaypatten
In order to test mesh deformation cage portability I created three versions of a toon each with a different topology and then bound all three to the same deformation mesh. The result was pretty good:
male generic, default/none, and male1591 topologies

The significance in this case is that I had created a shape key for the deformation mesh instead of for a specific model topology. Normally I would have to make a new shape key for each model mesh topology. On top of that, the deformation mesh is pretty simple and therefore easier to make a shape key for, at least for something where the shape key doesn't need to be particularly detailed. The next step would be to try models with different dimensions. MakeHuman would handle adapting the mesh automatically, but I'm not sure how shape keys work when you morph the mesh they are on. Actually I don't even know how to copy a shape key from one mesh to another...

Re: Using Blender bendy bones for joints like knees

PostPosted: Mon Oct 08, 2018 7:13 pm
by bogdan666
It looks promising, but as for copying a shape key from a character A to a slight differently shaped character B (same rig and vertex count) it seems that the "target character B" takes on the shape of character A as a result, because the whole character is considered a shape key.

You can try it out yourself: Load a blender file with a character A with shape keys and then append a character B to it (identical rig).

Now create a base shape key for character b and afterwards select char A and hold shift+select char B-->click the bold arrow that is showing downward (below the minus symbol; in the shape key menu)
-->select "join as shapes" and you will see that everything gets messed up pretty bad. (Complete transformation of character A to character B, but shape key works correctly)

As it is now, the only solution will be to create the shape keys manually for every new character. Or is there a better method?

Re: Using Blender bendy bones for joints like knees

PostPosted: Tue Oct 09, 2018 9:34 pm
by blindsaypatten
I wasted a huge amount of time banging my head against this wall and in the end the problem was that pin button in the armature modifier panel. If you turn it off and the use the transfer shape key function the value slider will work as expected. Actually, I'm not sure but it may get turned back on by the transfer in which case you need to turn it off again.

Once that was taken care of, and once I changed the deformation cage fitting to rigid in MakeClothes, I was able to fit the cage to a significantly different character and then use the same (copied) shape key.

Using the default armature and using the deformation