G3 G8 twist bones for mhx

Issue #483 closed
Alessandro Padovani created an issue

daz studio 4.15, blender 2.92, commit 5db3509.

This is also related to #466 but I decided to open a new discussion for better handling. The purpose is to provide an automatic ik twist bone that could work the same as the G3 G8 twist bones to relax the skin. It wasn't easy because of specific limitations of the blender ik system. But luckily Bandages at blenderartists.org helped me so here it is.

https://blenderartists.org/t/ik-lock-doesnt-work/1300633

Let's take as example G8F so we get a real case to work with. I imported G8F with some jcms to show the deformations. Then compared an extreme pose where there's fk on the right and ik on the left. We see that the fk pose gets a relaxed skin because the twist bone is used, and the same happens for the equivalent ik pose.

The test scene is included g8f-twist.blend. It is not correct to attach blender files because the daz eula doesn't allow it. But I stripped away the textures and G8F is "free" anyway, so for demonstration purposes I hope this is acceptable.

Now how we get it. The first step is easy and it's to lock the ik so we get the bend bone to only bend (y locked) and the twist bone to only twist (xz locked). This was my original idea, but didn't work fine and here it is where Bandages came to rescue. The blender limit is that the ik locks don't work on the ik root bone.

https://docs.blender.org/manual/en/latest/animation/armatures/posing/bone_constraints/inverse_kinematics/introduction.html

So what we do is to duplicate the bend bone, so we have a ik bone that we use for ik, and a deform bone that we use to deform the skin. Then the deform bone follows the ik bone excluding the y rotation. That's what we want.

Please note that I used a copy rotation constraint that seems to work better because damped track relaxes the skin too much compared to the fk pose. But copy rotation requires the deform bone to be euler. While can and must have the ik bone as quaternion to avoid gimbal locks.

Comments (32)

  1. Thomas Larsson repo owner

    Eh? A copy rotation constraint in world space? Not a good idea! Try to rotate the armature in object mode and see what happens.

  2. Alessandro Padovani reporter

    Thomas that’s not the point it’s just an example, you can set it to pose space of course. The point is you get an automatic twist bone that you can then bake to export the pose to daz. Other than it being good to relax the skin with ik.

  3. Thomas Larsson repo owner

    OK, I see. I’m not completely clear what the different spaces mean, except global and local. Local with parent seems to work too.

  4. Alessandro Padovani reporter

    Thomas please get a look at the discussion on blenderartists. There Bandages recommends damped track so you may want to do some tests. As I see it copy rotation seems to work fine in our case. The issue with damped track is it relaxes too much, that may not be bad but it’s not the same as daz then.

    Unless I miss something that’s entirely possible.

    https://blenderartists.org/t/ik-lock-doesnt-work/1300633

    edit. I believe I get it. I was trying to mimic what I did with the fk pose. So damped track of course finds a “better solution” to my fk pose, that means a better twist angle, thus the more relaxed skin. So yes personally I agree damped track is the right solution for the automatic ik twist.

  5. Thomas Larsson repo owner

    Implemented in last commit without any striking problems. I’m using a copy rotation constraints, because I didn’t see your last comment until now. I will have a look at the BA discussion tomorrow, too tired to do anything more tonight.

  6. Alessandro Padovani reporter

    Me too, going to the tv right now. I find it nice that Bandages was so helpful.

  7. Alessandro Padovani reporter

    important note. Ok did some tests to understand this “rotation vs damped”. What damped does is to also use the twist channel on the bend bone. That is, there is no way to lock y for damped. That is a better solution for twist of course because this way the skin relaxes better, as also noted above. But it’s a better solution we can’t use because daz doesn’t. That is, daz doesn’t twist the bend bone.

    So I believe this is final that if we want to mimic daz we have to use copy rotation. Also because jcms may depend on it.

  8. Thomas Larsson repo owner

    I remember struggling with the copy rotation constraints when designing the mhx rig. The conclusion was that it is only useful in two cases:

    1. All three axes are used.
    2. The deform space is LOCAL and the driving bone is not transformed by a constraint.

    Here is why:

  9. Xin

    If something can be done better in Blender, it should be done better. Trying to accommodate daz in Blender doesn’t make much sense. This is another reason why I don’t like the “import pose back to daz”. Now things that could be improved in Blender (especially better rigs like this one) will be forever constrained by that.

  10. Thomas Larsson repo owner

    The bend bone constraints have been changed to damped track. I also made some related changes, which relate to issue #482. The only copy rotation constraints left either involve all three axes, or copy local rotations of an unconstrained bone.

    I agree with Xin that the mhx rig does not have to be daz compatible. It is intended for use in Blender, and I hope one day to find time to use it myself. Sending things back to DS is a completely unrelated matter. It doesn’t affect anything in Blender, and once I got the matrix algebra right it was very little effort to implement it.

  11. Alessandro Padovani reporter

    It is fine to use damped track of course. Just it doesn’t get the same deformation for the daz figures because daz doesn’t twist the bend bone that’s all. So there will be some difference in jcms when posing with mhx.

    As for copy rotation in my example g8f-twist.blend it seems to work fine I don’t get those artifacts in pose space. But as I noted in the first post we have to use euler for the deform bone, otherwise it doesn’t work with quaternion. Or may be how I used it is different from the arm example above.

    As soon as #484 is fixed I may test the new mhx with deformations.

  12. Alessandro Padovani reporter

    Thomas, below an example with rotation locks for the arms if it can be useful. That’s the same principle as the legs. It is an ik pose with pole and goal and it works fine here. Test file included rot-arm.blend. This has the advantage that deformations are the same as daz since the bend bone is not twisted.

    Didn’t use jcms but it’s fine to show the rig.

  13. Thomas Larsson repo owner

    Now I understand what you are trying to do: create an IK chain with four links. No, mhx does not do that. In mhx two long bones are created which make up an ik chain with two links. The long bones then drive the corresponding bend and twist bones, which thus do not participate in the ik chain directly.

    The leg rig consists of the following hierarchy:

    FK bones: thigh.fk, shin.fk

    IK bones: thigh.ik, shin.ik

    Long bones: thigh, shin, with copy transform constraints to the fk and ik bones.

    Deform thigh bones: thigh.bend, thigh.twist, constrained by the long thigh.

    thigh.bend has an IK constraint to the thigh tail (should probably be damped track instead)

    thigh.twist has a full copy rotation constraint to the long thigh.

    Rigify does something similar, although I now notice that it constrains the bend and twist bones in a different way.

  14. engetudouiti

    Actually I understand what Alessandro hoped, and it is good improvement if it worked. actually if I only use IK or FK posing it not matter. but I clear see, when I twist hand then change FK to IK or IK to FK, (snap IK to FK / snap FK to IK) deform bone hard twist.

    The most important thing what I expect for compatibe rig is, the less deform with switch FK to IK and IK to FK, the less deform is better rig + flexibility without break bosing.

    current status hard deform when switch IK to FK for twist arms. So I hope you re-consider. I test with recent version only, then do not know other commit worked correctly, but I did not see this clear twist deform with switching before I suppose. it happend with G8 and I use set IK rest pose. so I suppose it should happen for all MHX converted rig.

  15. engetudouiti

    you may clear see with this image, about this I just hand pose IK then snap FK to IK. it always happen

    So I may suggest without solve this problem , not try to get perfect same defomation as daz twist way. (restrict twist for twist bone only for MHX IK bone)

    about other things, current MHX is really stable. (must need to solve IK foot issue please ) so do not hope to get new annoying problem if it caused by these try..

  16. Alessandro Padovani reporter

    Thomas, that’s fine too the issue is the same. That is, if you want to get the same deformations as the daz figure, then thigh.bend must not twist, so the constraint you use must lock y. Now the ik lock doesn’t work on the root bone, and damped track doesn’t get any lock at all. The only way you may try is to use copy rotation on thigh.bend as in my examples. Same for shoulder.bend.

    I stress “you may try”. Because in my examples it works fine, but it may require some work for mhx depending on the rig structure. The reason is that copy rotation may meet gimbal locks so it is vital to choose euler with the proper rotation order that’s yzx for the daz rig.

    Below copy rotation vs damped track (the red arrow). Copy rotation gives the same deformation as daz, while damped track gives a different deformation because it twists the bend bone. Then damped track is much more stable because it doesn’t get gimbal lock issues, and the deformation is not bad anyway, though it’s not the same as daz. So if copy rotation fails for mhx you may also use damped track. Just be aware that the deformations will be different.

    Please let me know if you may like to try copy rotation for mhx. Then we may also use the information in this discussion for the “add simple ik” rig that was requested in #178, as soon as #486 is fixed.

  17. Thomas Larsson repo owner

    I don’t think there is any transform space that would work for copy rotation.

    Local does not work, because the parent bones have no rotation at all. Grandparents like the fk bones are rotated, but the immediate parents are not.

    Local with parent does not work, because it also depends on distant ancestors, like the master bone.

    Pose space doesn’t work, I think (cannot test now). Again tranformations of distant ancestors affect the outcome.

    World space obviously does not work.

  18. Thomas Larsson repo owner

    engetedouiti, if there is a problem with fk/ik switching (and I don’t doubt it, it is difficult, at least to go from fk to ik), it is a separate problem. The bend and twist bones only depend on the long forearm bone. This has copy rotation constraints to the fk and ik forearm bones, so the y rotations of these bones must be different. That is a problem but has nothing to do with bend and twist.

  19. engetudouiti

    Thomas about my switch problem I could solve issue,

    you actulally should not set copy rotation for forearm.twist.L. (target) forearmTwk.L actually it cause issue when you snap FK IK or IK FK. then hide it.

    then when I twist forarm, I use real forearm twist.L directly.

    so you only need to set copy rotation for hand.L with forearm.twist.L and use local local, but Mix as before original.

    I test with so then I can still twist as same as daz way and can twist forarm and hand with twist.L bone without strange twist added when I snap FK <> IK

    1 . remove constrain from forearm.twist.L / R

    2. add constrain for hand.twk.L target bone = forearm.twist.L

    3. to twist forarm, set shape for forearm twist.L

    then FK IK switch deform not happen. but can still rotate for each purpose (only twist forarm etc With FK IK mode)

  20. Alessandro Padovani reporter

    Engetudouiti, mhx seems quite complex with constraints among bones, but from what I can understand the ik rig doesn’t seem to drive the forearm twist at all. That’s why you get the geometry “jump” with fk snapping. For Thomas, the constraint below seems to work fine enough within usual limits, if you don’t twist the hand too much, to get what Engetudouiti asks for. And I also agree that the ik rig should drive the forearm twist.

    But honestly I can understand very little of mhx and you may find a better solution.

    edit. Oops I see now the latest comments. If I understand it correctly what Engetudouiti is proposing is to make the forearm twist fk only, to be posed by hand. Personally I believe that ik should twist the forearm too, if we can get it to work. But I agree with Thomas this is a separate issue, though always related to mhx.

    edit. Better image with standard yzx.

  21. engetudouiti

    At first I may apologize I talk mix different issue (but for me after all it is same how make twist work)

    Then I do not test for all commits, but with recent commits I found new bad deform with switching issue more clear,. so may thomas hope to think with this problem (now he seems try to enhance MHX hard, )

    then about my issue, Thomas should solve it , if he follow what I suggested, at least it work better I confirm.

    At same time I understand actually what yours trying ,, . And not think it is wrong direction. (after all Thomas add new rig hieralchy more rig-fy like, to clear devide IK rig, FK rig, and swithcer rig (which add constrain) and deform rig (which mostly simply copy transform)

    So I approve Alessandro plan. because then JCM work correctly. (but do not know you can actually achive it or not)

    . and I may report this typical swithcing (only hard visible with forarm twist ) issue separately (it is actually bad enough for me, as separate topic) . so yours can concentrate OP problem (improvement).

  22. engetudouiti

    Thomas I seems solve this issue.

    1. what you hoped is not rotate bend bone as twist but hope to rotate twist bone only.
    2. then you use dump truck for bend bone as Y axis

    The problem is here.. you set dump target of upper_arm bend bone as covered upper_arm.L tail.

    so actually upper_arm bend bone, simply follow Upper_arm.L = after all you still twist the bned bone.

    What you needed is

    , set upper_arm bend dump target as forearm.L but use head like this.

    then upper_arm bend never Twist, but keep along with upper_arm.L (covered bone of bend and twist) with fit to IK FK chain. so it work with IK and FK mode. (only twist bone twist)

    about upper_arm twist simply keep the copy rotation (target = upper_arm.L/ R as same as before)

    Next about forearm.bend.L/ R , set dump target as hand.L/R then use head, forearm.twist.L/R use copy rotation, target as forearm.L/R

    after that you should see, IK ,FK mode,, actually hand twist bone only twist when you twist the covered upper_arm, and forearm.L/R

    if you make so, with FK when you rotate upper_arm,, upper_arm bend not twist, but upper_arm twist actually twist..

    actually check it please.

    I suppose you can do same thing for legs.. you seemply need to re-think how set dump target to achive your plan.

    you need to set target as not cover bone. but set next chain bone head so bend bone only locate along with cover bone, but not twist. = Daz way. then for twist bone copy rotation of cover bone, it should work. though you may tweak free twist for hand or foot , it is just option. as basic idea it dump usage and target setting (head/tail)

  23. engetudouiti

    At same time I may recommend change way about forearm.twist L/R

    you may only need copy rotation <> replace target as Forearm L/R like this.

    so with FK mode when you twist forearm FK L / R, it only twist forearm.twist L/R as same as daz way. (actually it is better way)

    I think you have intention to copy rotation target as forearmTwk.R then try to rotate by it. but I think actually you need not such twk bone only for rotate the twist bone.

    anyway set like this, and actually try it please

    if you set so, now when you twist forearm.fk.L / R it only twist the twist bone. (bend bone keep there along with cover bone), so you need not lock Y axis for ForeArm anymore, but simply use it as FK rotate Forearm for all axis. (with set limit if you need)

  24. engetudouiti

    After I change MHX so, I do not see any bad deform with Snap FK <> IK, and IK <> FK, and I think it is most look like daz way to use twist bone for IK , FK mode correctly.

  25. engetudouiti

    To check easy, I customize only Left arms 4 bones constrain and setting. (I now concentrate G3 only, but it should be same almost)

    so actually test with blend file, and compare R arm pose with L pose, with check bones how move IK and FK please

  26. engetudouiti

    I could confirm same way should work for leg chain too.

    so key is,

    thigh.bend.L constrain >> Damped Track target bone = shin.L use Head (head/tail = 0.00)

    thigh.twist.L constrain >> Copy Rotation target bone = thigh.L (you already made so) (world world, replace)

    about shin, g3 do not have double bone, then I do not know ^^;

    if G8 have double shin, like rig-fy,, I may simply do same thing. use dumpled truck for bend bone, then set target for the foot , head

    syould work. (not set target as current cover bone, but set next bone head to track. so it not rotate.. I think it is what Alessandro hoped. and I do not see , bad deform when I snape FK <> IK frequently.

    Actually use new chain bone was correct idea to manage IK chain FK chain more clear. (then can customize easy). only dump setting was somehow wrong I feel..

  27. engetudouiti

    And yes,, the idea rotate (twist) IK forarm (twist bone) with hand bone rotation was good idea. but it make things complex as Thomas said. but use the daz way to controll twist is not bad. (for all rig if it can) . so I may prefer this way. (actually I did not need to use new hand twist bone.. but if more enhancement, I think,, if IK chain forearm twist correctly with hand bone is good challenge.. (I may try later if I can,,) at current,, the above way is best what I think. (and now it work better than before..as all aspect I feel)

  28. Log in to comment