PDA

View Full Version : New FK/IK switch



JiriH
21-Jul-08, 05:07
Hello,

recently I have seen very nice examples of new seamless FK/IK switch without any "hopping". This is really advanced feature and definitely blenderheads should have a look.

Nice introduction and example has presented Malefico:
- http://www.youtube.com/watch?v=QzbaR_jJ0Pw
- http://www.malefico3d.org/blog-en/?p=22

There is also nice application by Matt:
- http://www.promotionstudios.com/files/lighthouse_breakdown_sm.mov

Unfortunately I have huge problems to solve how to apply this in Blender. So if anyone could help, provide "simple three bones arm" set up for research or even refer to some step-by-step tutorial that would be highly appreciated.
(It is quite shame nowadays that sometimes great new advanced features are introduced to Blender but there is nearly no end user documentation.)

hunter551
21-Jul-08, 06:56
I have never had a problem with the IK/FK switch 'snapping'. What is the problem?

JiriH
21-Jul-08, 08:31
During animation it is possible to seamlessly switch between FK and IK mode as the controls in matter do follow each others. As this is possible in Blender I would like to learn how to make such a rig as seen in these videos :-)

mikahl
21-Jul-08, 11:16
I have never had a problem with the IK/FK switch 'snapping'. What is the problem?

I find its more an issue of undesirable rotations, rather than 'snapping' when keying the influence of IK.

While I saw the rig video, Matt also pointed out the animators had issues with the space handler script from Maloyo. But I can't seem to get any problems with Maloyo, even when its linked. What are the problems?

I'd like to know the issues before implementing them in my own rigs.

Cessen
21-Jul-08, 12:40
While I saw the rig video, Matt also pointed out the animators had issues with the space handler script from Maloyo. But I can't seem to get any problems with Maloyo, even when its linked. What are the problems?

When I was first developing the rigs for BBB I took a look at the Maloyo scripts as a possible way to do IK/FK switching. But honestly, it didn't take me long to reject them. It's a cool idea, but in practice it's painful and unintuitive to tweak after you've already set keys with both IK and FK. I think that was the problem Matt was referring to (though please correct me if I got that wrong, Matt).

Mind you, there are also problems with the way I did it for BBB. I haven't seen a good solution in Blender yet.

Michael W
21-Jul-08, 13:07
don't know of any built in method, but essentially the rigger will have three versions of the chain...

For illustration purposes:

Bones are Upper arm, forearm and hand.

the first version of the chain is for animating FK, the second version of the chain is invisible and controlled by an Ik goal (and maybe a pole vector too)

The third version of the chain is the one that actually deforms the mesh.

It is constrained between the other two. There will usually be some control in the rig that weights the positioning ... eg 0 100, (ik) 50 50 (ik fk blended half from each, 100, 0 (fk).

In blender you may be able to do this with the constraint system, though it's a while since I looked there, or you may need to use pyconstraints.)

You would either animate the blend from fk to ik over a series of frames or use stepped interpolation to hand off over a single frame

In this sort of system you may also write a "hand off" script that aligns the fk bones to the IK bone chain and turns on IK in one smooth move.... (single click moves and keyframes everything for you)

JiriH
21-Jul-08, 15:32
... you may also write a "hand off" script that aligns the fk bones to the IK bone chain and turns on IK in one smooth move.... (single click moves and keyframes everything for you)

This is just what the point in question is :-)

But I am really thankful for all hereabove mentioned experiences.

malefico
21-Jul-08, 16:16
hey guys

Maloyo script was more the presentation of a concept than a real production solution. My plans for it are to combine this kind of access to rig features, with driven constraints now that you can drive constraints with bones in same armature (thanks to Cessen annoying Ton for it).

Also there are lots of tiny details my script doesn't take account of like what to do with the poles of an IK chain... so, you better use it to study it and improve it, instead of just producing with it.


Regards !

mikahl
21-Jul-08, 17:44
In blender you may be able to do this with the constraint system, though it's a while since I looked there, or you may need to use pyconstraints.)I read that bassam used this Maya-style IK/FK switching. ( you can see it linked from his blog ). Apparently it worked well.You don't even need pyconstraints. Just a driven bone.

www dot watchmike.ca/wp-content/uploads/2008/mayastyle_switch9 dot blend ( replace the dots with . )

But I'm unsure what you mean by a "hand-off" script...

Michael W
21-Jul-08, 18:42
....But I'm unsure what you mean by a "hand-off" script...

say frame 10 is posed with ik and I want to change to fk at frame 15... I could either manually allign the fk controls at frame 10 and 15 and set keyframes to closely match where the ik bones are, then key the control that blends between ik and fk to blend the ik in to 100% influence over those frames....

or right a "hand-off" script that automates that....
this could all be over a single frame , but the trickis to get the fk controls following the IK ones whilst IK is the "boss" so that it doesn't interpolate wrongly when you switch,

which is the point of this thread, which I misread as I hadn't seen the examples...

JiriH
22-Jul-08, 05:21
I read that bassam used this Maya-style IK/FK switching. ( you can see it linked from his blog ). ...

Thank you, I have just discovered his blogging in matter - http://www.sparkde.com/blog/?p=32#comment-37

Mike has also explained the concept in blog discussion "having 3 separate chains, 1 IK controlled, 1 FK, and one doing the deforming, the deforming one gets weighted to both the IK and FK and the strength of the constraint determines ik/fk."

I hope Bassam will join this thread to share his experience with this in real production.

JiriH
24-Jul-08, 12:39
Interesting news in matter.

This was just committed http://cia.vc/stats/project/Blender :

Commit by theeth r15735 /branches/harmonic-skeleton/source/blender/src/autoarmature.c: (link (http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15735))
Propagate control bones repositioning (can deal with chains of control bones)

Retargetting IK/FK switcher setups should work ok now (worked on a setup I did, need to test with more)Does anyone have any detail information?

mikahl
24-Jul-08, 12:57
Wow interesting developments for that. But if better switching doesn't get
hard-coded, maya-style still works.

Like I said, you can find a quick test I did at:

www dot watchmike.ca/wp-content/uploads/2008/mayastyle_switch9 dot blend ( replace the dots with . )

JiriH
24-Jul-08, 13:30
Like I said, you can find a quick test I did at:

www dot watchmike.ca/wp-content/uploads/2008/mayastyle_switch9 dot blend ( replace the dots with . )

Thank you for your blend file, I have also used this Maya solution lately for testing. But the question of this topic how to make it that in IK mode FK controllers follows and vice versa. And this is not what this blend can do.

The solution seems very easy but maybe difficult to code. There could be just implemented the feature (possibility) for constraint influence that when you zero it the influence will be inherited anyway. Some thing like For Transform feature that some constraints have

May be very useful for all constraints. E.g. you have Child of constraint, so the child follows its parent. You would press this "Save Transform" button and if you would zero constraint influence the child would not move to its original state but keep the one transformed due to previously used Child of constraint.

Definitely this would be very useful and seems not hard to code. But I am not a coder.I guess this would also enable the IK/FK switched with the discussed possibility shown in videos hereabove.

thelowlander
25-Jul-08, 05:17
don't know of any built in method, but essentially the rigger will have three versions of the chain...

For illustration purposes:

Bones are Upper arm, forearm and hand.

the first version of the chain is for animating FK, the second version of the chain is invisible and controlled by an Ik goal (and maybe a pole vector too)

The third version of the chain is the one that actually deforms the mesh.

It is constrained between the other two. There will usually be some control in the rig that weights the positioning ... eg 0 100, (ik) 50 50 (ik fk blended half from each, 100, 0 (fk).

In blender you may be able to do this with the constraint system, though it's a while since I looked there, or you may need to use pyconstraints.)

Pardon me if I'm wrong, but can't you achieve exactly the same with using just 1 chain?
When you switch the IK constrain on the arm off it reacts as a FK setup. This also eliminates the need for a defromation chain arm setup.
I've seen some people make rigs like that, with those 3 arm sets setups, when just using 1 armset could do the exact same thing. Or does it somehow give glitches during animation? why would you use such a chain when you can just set a slider for the IK effect instead?

Michael W
25-Jul-08, 07:00
I was just explaining the theory.... haven't done it in blender, only did it back in my Lightwave days....

slikdigit
25-Jul-08, 10:52
doing it with more chains is safer. In a production recently I found (the hard way) that the behaviour of <1 influence Ik is bad, specifically with the pole vector. a blended copy rot (or copy rot+copy scale if you do stretchy) is much safer.

the maloyo script is nice, but it doesn't do anything hard to do by hand; you can get "seamless" by simply keying visual rot on your fk chain at the IK on point, using constant IPO for your IK/FK switcher. Of course this is "by hand", but that's it. The hard part is somehow tracking that change as you change the animation poses or timing; this requires either moving the keys along with the blend, or rekeying visual rot; something to be done by hand. in practice it's easier if you did it by hand the first time, to remember to do it again. otherwise, it's something hidden that comes and bites you in the a$$.

I'm not experienced enough with maya to know, but our maya animator said (in his experience) that the same problem (with seamless blending) exists in maya too; that is, once you have made the switch, it is a pain to keep track of it as you edit the animation.

JiriH
25-Jul-08, 14:59
bassam, could you be more specific concerning your "by hand solution"? To be honest I did not quite get it even though I have tried to play this way in Blender :-(
Thank you in advance.

slikdigit
25-Jul-08, 15:15
well, what a seamless blend does is key one set of controls to the same location as the other when you do a blend, and do the switch across one frame.
i.e.: none seamless blend: take 10-15 frames to go from IK to FK, so the viewer sees motion as result of constraint animation (and the animator sees the arm move when he/she switches IK/FK)
seamless blend: take 1 frame to go from IK to FK. at (e.g.) the IK side, the FK bones are keyed to their visual rotations, so that the FK chain is responsible for the animation from one position ot another. If an animator is using an automated setup this is done (surprise) automatically: i.e. the animator switches to IK, resulting in moving the IK target to where the chain already is, and keying the visual rot of the FK chain, so there is no visible jump. the animator could of course, do this themselves (more or less) in practice.

my workflow:

animate in FK in frames 1-30 (e.g.)
at IK switch point: (frame 40 for example)
pose and key the armature in IK
then select the FK chain and key->visual rot
you'll notice after you've done this that (at frame 40) the chain doesn't move if you turn IK on or off- that's a manual seamless blend!, furthermore, the interpolation between frame 30 and frame 40 is due to the FK bone interpolation, not to the IK influence, so it is a tad more predictable.

you can go the opposite way:
at your FK switch frame (say frame 61) turn the IK off
go to the last IK frame (frame 60), key your IK controllers for safety, select your FK chain and key visual rot
go to frame 70 and make your next pose in FK

yes, I realize it's a hassle, but at least this way there is no mystery as to what happened during hte blend. if you want to adjust the poses or timing, you should know exactly what keys you need to move, or which bones you need to re-key, without mysteries. If a script does it, but doesn't somehow automate over tweaks, it becomes slightly nightmarish..

btw, I still think there is a way to do this entirely automated, either in python completely or with some blender enhancement. you basically need a way for the software to keep a record of each constraint switch, store the keys it made to keep the visual appearance consistant, hide the info from the animator and just expose a "blending key" that they can then use to easily change where the blend happens. If you change the pose, the script/blender could automatically change the visual keying of the opposing (IK if you change the FK pose, FK if you change the IK pose) pose without disrupting the blend.

of course, this might result in some new sideffect I haven't thought of.

JiriH
25-Jul-08, 15:44
This fast fast, thank you very much.

Edit: I understand your concept bassam and I definitely agree that the attitude to have the switch under control by animator is preferred way. I have tried it with new cessen`s rig "Simple biped rig", http://blenderartists.org/forum/showthread.php?t=131079, but it is tricky to set it up add still I am not able to produce satisfactory result. I have also noticed that this rig has the feature that FK controllers follows the IK ones but it do not work opposite way.

Edit: I have tried the hereabove mentioned attitude of bassam this morning once again and it works really good!!! I guess this is very clever attitude and provides lot of control. In fact animator fully controls FK till the frame when IK should be applied (so uses VisualRot values of FK "driven" by IK) and vice versa. I also guess this may be automated somehow, just to key VisualRot when the swithc is activated. Some kind of "bone driven keying" :-) Maybe someone fluent in python could come with such python expression drive channel.

Extrudeface
26-Jul-08, 09:06
very cool trick... nice for those of us getting the grips of animation in Blender...In Max's Biped, you have ik/fk at any moment, that is, you can handle in both ways just clicking on the bone and dragging. but doesn't do in 100% of bones, so I guess some sort of trick is under surface... that is, you can just grab a hand and works like Blender's auto-ik , but also handle totally free any obne of that chain. I think there is not so much freedom with max bones (I say 'cause yet havent handled M. 2008, nor 2009, it may have changed.).

That trick seems really good, I'll try to use it...I was doing very complex helpers and constraint rigs to calculate every possible need, but combining with that sounds powerful.


that the behaviour of <1 influence Ik is bad,

another interesting tip.. was using that with a pair of limiting distance constraints...

yet tho, I get the feeling I'll have probs if I just dont rely simply in my ik and helpers rig...

Cessen
28-Jul-08, 06:00
doing it with more chains is safer. In a production recently I found (the hard way) that the behaviour of <1 influence Ik is bad, specifically with the pole vector. a blended copy rot (or copy rot+copy scale if you do stretchy) is much safer.

Just want to second that, as well as add that it's not only safer (in terms of avoiding weird flipping) but also just looks better. Using a copyrot with two chains makes the arm rotate between them like FK (i.e. you get arcs). It's basically just all-around a better way to do things.


The hard part is somehow tracking that change as you change the animation poses or timing; this requires either moving the keys along with the blend, or rekeying visual rot; something to be done by hand. in practice it's easier if you did it by hand the first time, to remember to do it again. otherwise, it's something hidden that comes and bites you in the a$$.Right, to make that work well for the user the FK/IK switch keys would have to be somehow linked to the actual arm keys that they coincide with. And both the IK and FK controls would have to be keyed and kept in sync at those points too.

The difficulty in making FK/IK switching really work well actually has little to do with the initial keying. Rather, it's about making it easy and seamless to tweak the keys afterward.

Ghost_Train
29-Jul-08, 09:49
Wow. I had no idea making an IK/FK switch would be so difficult in Blender.
I've used eFrontier Poser 7 a little bit and all you do is click to check
and un-check IK for each hand and foot. That's it. No side effects. Nothing
moves or changes other than how they act when you move them. Same
with Autodesk Motion Builder (from what I've seen in the demo video) except
that's a bit more advanced.

After being exposed to those, the work around in Blender seem a bit going
out of the way to make it happen, which in the end would probably add up
to hours spent adjusting IK/FK as opposed to a few seconds of turning it on
and off in other software.

I hope there can be a simple feature added in the future like these other
programs have. For now, the best way for me seem IK for the feet and
keep the arms as FK. It's a bummer though.

Ghost_Train
29-Jul-08, 11:29
I read that bassam used this Maya-style IK/FK switching. ( you can see it linked from his blog ). Apparently it worked well.You don't even need pyconstraints. Just a driven bone.

www dot watchmike.ca/wp-content/uploads/2008/mayastyle_switch9 dot blend ( replace the dots with . )

But I'm unsure what you mean by a "hand-off" script...


I've been trying to pick this file apart to see how it was set up and I
cannot figure it out. I don't see any drivers or contraints, or triggers
or whatever they would be called. I can't see anything in the IPO window.
I don't know how moving the switch is causing IK/FK to alternate.
I can see some things in Oops when showing all layers named:
upperarm_ik
ColIpo.003
CoIpo
arm_fk

Please, do tell how it was set up. I want to give this method a
try until a better one gets developed. Is there a tutorial somewhere
I have overlooked?

Edit: Oooh. Maybe I just figured something out. I forgot to check the armature layers.

JiriH
29-Jul-08, 14:47
Ghost_train there are constraints, third chain is constraint to follow either IK or FK chain. You just have to turn other bones layers on.

Vertex Pusher
29-Jul-08, 17:00
Maybe I am missing something here ... but doesn't the improved Auto IK in 2.46 do this already ? Since now you can change the IK chain length "on the fly" as it were with the mouse scroll or the pg up/pg dn keys, if you set the IK to chain length = 1 = FK , chain length > 1 = IK ... with no popping to a target since the rotations are evaluated depending on the length of the chain between poses ...

"But what about the nice target that the IK Solver constraint gives you ?", you might ask ... Well why not just "fake" one by adding a non deforming extra bone which is attached to the end of the chain with all its rotations locked (another improvement - Auto IK now conforms to axis locks in the Transform Properties window) which will act as the target for constraints such as Copy location ? You need to have the chain length to at least 2 for FK and more then that for IK with this setup .

The IK length once specified gets inherited by any other bone you choose so if you want to go all FK you can choose chain length 2 if using the above setup and add additional control bones at the elbow for consistency, so that when you go from the "target" at the wrist to the elbow it will behave as a FK setup if you leave the chain length alone ...

The chain length value shows up in the 3D header along side the Dx/Dy/Dz values when you hit the G key with a bone selected .

The biggest problem with IK/FK switches is the fact that you couldn't adjust the chain length in the constraint (because a IK chain length of 1 behaves like FK except you pose with a target so if you could change you could go from IK to FK or vice versa with no problems) so that it left you with a sudden snapping of the constrained bone when going from FK to IK ... now that the Auto IK allows you to change the chain length while posing/animating you can just go on and pose in FK or IK depending on the situation without worrying about sudden snapping or even dealing with a separate switch to go from IK to FK ... And mind you, you can have IK "on the fly" for any bone in a chain and as long or short as needed ... And no more "lost" targets since the "target" is (unlike the constraint) attached to the chain length :) This is a very very flexible addition and very easy to set up ...

I've attached a simple arm/torso rig ... And yes no Pole Targets either but the elbow "target" can be moved around to do the same thing ... Hit G and the current IK length of 3 will show up in the header . Go from the wrist to the elbow "target" and change the IK length to 2 for FK (use the pg up/pg dn buttons - they are more predictable then the scroll wheel) : http://uploader.polorix.net//files/307/AUTO%20IK-FK.blend

Extrudeface
30-Jul-08, 11:57
very useful thread... Thanks!

JiriH
23-Aug-08, 13:41
..

btw, I still think there is a way to do this entirely automated, either in python completely or with some blender enhancement. you basically need a way for the software to keep a record of each constraint switch, store the keys it made to keep the visual appearance consistant, hide the info from the animator and just expose a "blending key" that they can then use to easily change where the blend happens. If you change the pose, the script/blender could automatically change the visual keying of the opposing (IK if you change the FK pose, FK if you change the IK pose) pose without disrupting the blend.

of course, this might result in some new sideffect I haven't thought of.

Maybe it would help if there would be a feature (an option) for the constant that when you zero it there is recorded visual key i.e. that the object that previously had this constraint active will keep resulting constrained position even the constraint was zeroed.

But I guess Aligorith has already some improvements in his mind for Blender 2.50. According to premise (nearly) all key-able in 2.50 :-)

slikdigit
23-Aug-08, 14:51
perhaps; the more general form of the problem is: at the point of switching you have: IK bone positions, FK bone rotations, and the switch itself. Later on in the animation, if the animator changes one of these (either in time or in value) the others should, or might have to change also. Another possibility is to "grey out" fk keys during IK mode, and IK keys during FK mode (these get handled automatically by blender or the script).
I think it would also be nicer for the animator to get a nice toggle FK/IK instead of a bone slider; if it's scripted, the bone could still exist, but only to give keys/make it trackable/editable.

Recording the key automatically as you suggested is already done by e.g. malefico's script, and even if it's done automatically by blender, the result is the same; you get the convenience during the switch, but now it has to be handled when you edit the action.

I don't think it really matters if the solution comes 100% from blender or from python, the important part is that it works, allows easy adjustment of the animation, and that it is flexible enough for many different rigs.

Ghost_Train
23-Aug-08, 23:39
Every night I go to bed crying.
It's because we don't have that simple easy IK/FK switch that Poser has.
I definitely took it for granted while using that software.

How about someone cram all the best parts of every awesome 3D application
into one big ball of food for Blender to eat.

JiriH
31-Aug-08, 11:04
...

my workflow:

animate in FK in frames 1-30 (e.g.)
at IK switch point: (frame 40 for example)
pose and key the armature in IK
then select the FK chain and key->visual rot
you'll notice after you've done this that (at frame 40) the chain doesn't move if you turn IK on or off- that's a manual seamless blend!, furthermore, the interpolation between frame 30 and frame 40 is due to the FK bone interpolation, not to the IK influence, so it is a tad more predictable.

you can go the opposite way:
at your FK switch frame (say frame 61) turn the IK off
go to the last IK frame (frame 60), key your IK controllers for safety, select your FK chain and key visual rot
go to frame 70 and make your next pose in FK

...

Bassam, referring to your attitude have played lately with cessen`s biped rig.

Best steps for no-jumping FK/IK switch are following:
Before going from FK to IK I always for each IK controller need to one frame before switching:
- Select IK controller
- Shift select respective FK controller (Hand.L - IK_Hand.L, ElbowTarget.L - ForeArm.L, KneeTarget.L - Shin.L, IK_Foot.L - Foot.L)
- Ctrl-C Copy Pose Attributes - Visual Location
- Ctrl-C Copy Pose Attributes - Visual Rotation
- Select just IK controller
- Hit I (Insert Key) VisualLocRot

Before going from IK to FK I always for each FK controller need to
- Select FK controller
- Hit I (Insert Key) VisualRot

I guess there really could be a "python macro" for this repetitive steps. And then just to connect the macro to the one button or even switch itself.

Nice is the over all control of the animator using this keying method also for later tweaking.

futar
15-Aug-09, 13:02
Sorry for bumping this year old thread.

I'm trying to animate a switch from IK to FK using Mancandy whilst following the workflow Bassam outlined in post #19 of this thread. I have set a 'VisualRot' key on all of the bones in mancandy's arm before switching to FK, yet there is still a noticeable pop in the animation. It kind of looks like his arm grows ever so slightly.

Does anyone know how to solve this problem?

Many thanks

JiriH
15-Aug-09, 14:09
Hello, I believe the problem is in the way how IK squash and stretch works in Bassam`s Mancandy rig. Mancandy uses stretch value for IK in Armature Bones panel. Even it is the lowest possible 0.001 the arm in fact is always scaled in IK a little bit (including no extreme positions). This is why FK - IK switching with Mancandy "hopes". FK chain is not stretched but IK is always scaled a little, so their positions cannot match.
(You can try to set 0,000 value for stretch and "hoping" should stop - but you will not have stretchy arm.)

The only solution is to use more accurated stretchy IK setup. For example the one I have used for George rig. FK - IK swithcing is 100% seamless in George rig.
Link here - http://blenderartists.org/forum/showthread.php?t=161257

futar
15-Aug-09, 14:40
Hey JiriH, thanks for the reply.

I tried setting the stretch value for the 'toparm' and 'lowarm' bones to 0.000 as you suggested, but the problem still remained. I can't work out how to make mancandy smoothly switch from IK to FK. Maybe it's not possible. :(

Thanks for the link to your George rig. If there is no solution for Mancandy then I will give George a go.

EDIT: I just got it to work by setting the stretch value for the 'toparmIK' and 'lowarmIK' bones, hidden on the 11th bone layer, to 0.000 as well. Just a shame Mancandy is no longer stretchy after doing this.