# Animation IK

## Recommended Posts

Hello,

I'm very much interested by this conference and the concepts displayed within.

More precisely, I'd like to understand their process for animation sharing.

Could anyone help me understand how they do it ?

Thanks !

##### Share on other sites

Imagine you have only animation data for the hands, feet, hip and head.

It would be easy to adapt just the feet to curved terrain, lower the head under an upper obstacle, tilt the character when carrying heavy weight, etc...

The problem is, you now need to calculate all other bones at runtime:

Example legs: From the distance hip - foot you can calculate the knee angle, from foot orientation you can calculate the direction the knee should point to. From that you already get upper and lower leg.

For arms it's similar, but you might additionally move the shoulder either towards or away from the hand, depending if shoulder - hand distance is large or small.

Example spine: From hip you take the direction upwards, from head the direction downwards. So with both their positions as well, you get 4 points and could create a bezier spline. Along this, for belly, torso, neck... you slerp orientation from hip to head, but also constrain their up vectors to the spline tangent.

Additionally you can use physics to make it more realistic, e.g. use a balanced inverted pendulum to set whole body tilt, or some spring damper stuff etc. Also you probably take joint limits into account (this makes that whole IK stuff a lot more complex than said above).

##### Share on other sites

Hmm, I more or less get the idea. I started a small script to start experimenting. Here it is. What do you think?

The leg streches a bit too much. What could be the next step ?

Capture vidéo 2018-03-12 22:05:46.mp4

##### Share on other sites

Is there a reason you are learning this? Most engines have IK build in these days.

2 hours ago, MehdiUBP said:

The leg streches a bit too much. What could be the next step ?

You are just scaling your rotation with a scalar. The idea behind IK is that we have a rotation, We know our target point, now how do we get there? Once you know how to go from point A to B, you can just add B to A and get the new rotation.

You should start with the most simple IK first. How to make a rope. https://www.youtube.com/watch?v=hbgDqyy8bIw&t=3s This video was shared by someone else @lawnjelly I think, correct me if I am wrong.

On 3/11/2018 at 9:50 PM, MehdiUBP said:

I'm very much interested by this conference and the concepts displayed within.

Thanks for sharing the video it was interesting to watch.

##### Share on other sites
4 hours ago, MehdiUBP said:

The leg streches a bit too much. What could be the next step ?

Yep, too much

I have this line to calculate knee angle:

angU = acos (min(1.0, max(-1.0, (lenUT*lenUT + lUpper*lUpper - lLower*lLower) / (2.0 * lenUT * lUpper))));

I assume lenUT = distance from hip to target ankle position, lUpper/Lower = length of bones

Looks cryptic, but it's the same as asking: I know all lengths of a triangle - how can i calculate the angles? (You should find some better explantation from that with google.)

2 hours ago, Scouting Ninja said:

You should start with the most simple IK first. How to make a rope.

Simple? That's pretty complex - infinite solutions, no clear intention how it should behave. This is usefull only if you want to find a pose for the whole skeleton, but even then a underdeterminated solution from those methods won't look human without a lot extra work.

I really recommend the leg, it's most simple and also most important. And we know how it should behave. If you lack solid experience with 3D roations start in 2D, later do the same in 3D.

2 hours ago, Scouting Ninja said:

Is there a reason you are learning this? Most engines have IK build in these days.

Then, why does OP video look 1000 times better than what we see in actual games? There is a reason to learn this. It's totally necessary to progress in this field. But i agree using available stuff could save some time, although understanding is still necessary and doing yourself guarantees this.

Personally i've spent a lot of free time on this. I skipped animation completely and went directly to physics simulation, which is a whole lot harder because the character might fall on it's nose. (But i could make a real robot walk  )

Does not look very human, upper body is just kept stiff - my focus was entirely an balancing. I really hope i can continue on this some time soon...

However, recently i saw a lot work that does something similar but with procedural animation, and this looks really good and should not be that hard. Motion capture altered by virtual inverted pendulum dynamics seems to work really well. We'll see this stuff a lot very soon i think, it's really the time - performance wise this is pretty cheap  and we could have it for a decade already, if we would focus on important stuff instead SSAO bullshit

##### Share on other sites
1 hour ago, JoeJ said:

Simple? That's pretty complex

It is in fact very simple and has many uses in games. Besides being used for snakes, tentacles, dragons the IK formula is used for many rope effects you see in games.

Spoiler

self.vector = Target.vector -( (Self.vector - Target.vector).normalized *Length)  Works in 2D and 3D.

As you can see this is very easy. It uses offset (Self.vecor - Target.vector) that you need for looking at the target anyway, then inverse it and constraint it to the length of the piece.

It's easy for developers who use vector math. It is often used for teaching because it builds on what developers already know. Mostly it teaches developers how to translate what they want into math.

1 hour ago, JoeJ said:

Then, why does OP video look 1000 times better than what we see in actual games?

Because this is an advertisement and not practical use. Huge amounts of solving steps to produce smooth results, very few objects and other math needed.

The main problem with IK and FK is the math involved. Any IK focused game has a very limited set of objects because it takes a huge toll on the engine. Unreal's IK is amazing, when there is only one character using it in a scene.

Also IK in games are very good. A lot of animations that exist in games today is just one animation re-targeted to every character. Take the Witcher as an example, the towns are filled with people that look very different, clearly the developers didn't force there animators to make animations for everyone.

1 hour ago, JoeJ said:

It's totally necessary to progress in this field.

There seems to be a misunderstanding. I asked OP why he wants it to know what to provide.

If a developer wants IK for retargeting hands to press a button, open a chest, hit a target with a weapon or just to share animations; then providing the developer with formulas or a engine is the best way to proceed.

If instead the developer wants to learn IK then allowing them to discover the formulas themself is more important. After all IK and FK is the process of turning a action into math. I don't want to hinder someones learning process by giving them the answers.

1 hour ago, JoeJ said:

Does not look very human, upper body is just kept stiff - my focus was entirely an balancing.

Looks good.

If you ever want to use it in a game you can cheat a lot, use a single ray to find the center of gravity then align the legs; instead of using the legs to find the center of gravity.

A lot of these Auto animation tools, like Endorphin use cheats to help make realistic AI. Because in a engine we actually know things about the objects that we don't in the real world.

##### Share on other sites
2 hours ago, Scouting Ninja said:

If you ever want to use it in a game you can cheat a lot, use a single ray to find the center of gravity then align the legs; instead of using the legs to find the center of gravity.

This is the kind of thinking that made my reply a bit argumentative. There's nothing wrong with what you say, but that's not how progress is made. This way we never get realistic animation, or get closer to 'real' art like movies or stop motion animation. We need to have a larger vision, we should aim for more than just retargeting feet so they much slopped terrain etc. The video, similar to natural motions videos, does a good job in inspiring people. Maybe their tech is not yet practical (did not watch), or advertisement or whatever. But this IS doable in realtime for enough characters to be used in games right now. The simulation i show runs at 120 Hz while most research projects run with 1000 Hz or much more. If i can do this with real physics at game settings (thanks to Newton - other physics engines are too inaccurate), then the industry would be able to do the same with animation only a lot faster.

That said :), naively projecting the com down to the ground and putting the feet there is not good enough. Because that's not how physics work, that's not how humans do it and so it looks artificial. The correct way would be to simulate a simple inverted pendulum that tells you exactly the position the com must have to be in stable or unstable balance, and then retarget animation according to this. The math is very involved, but performance cost is negligible.

Even if we look at very advanced work like this:

If you look close the body still appears to be kept upright by magic. The way it leans forth and back is clearly not dynamic. Although very impressive, it's still visibly fake. Inverted pendulum would fix this with little extra work, and the method works for simple or advanced animation, and also for physics or real robots. But it took me years to arrive at that knowledge, it's nothing you learn from a IK toolset, wikipedia or by visiting a quick course. More research required, more people should work on this...

.

##### Share on other sites
12 hours ago, MehdiUBP said:

Hmm, I more or less get the idea. I started a small script to start experimenting. Here it is. What do you think?

The leg streches a bit too much. What could be the next step ?

I am definitely no expert but I recently added some IK / procedural animation, here are two blog posts you might be interested in:

The first explains the math for the 2 bone analytical leg solution. Although it is good for learning playing with a 2d version, one you have this working, and you want to move to 3d you need to have a working skeletal animation system you can tweak the bones of. I don't know if you have one of your own or you could tweak the bone positions in unity or unreal etc.

Once you move outside 2d into 3d you can handle the rotations as quaternions, you need a bit of understanding of how they work for animation and slerping.

I haven't done animation retargetting, but as I understand it as he explains it sounds like something like this:

1. Deconstruct the original animation data into relative positions / orientations of IK chain roots and effectors
2. Scale this IK data to the new rig
3. Apply IK to recalculate the bones on the new rig

Essentially you can store the most important aspects of the animation data as an IK system rather than a forward kinematic set of rotations. Indeed animators will often create the animation data using IK in their 3d package. This data is easier to retarget than the bone rotations (which can be thought of as an intermediate format).

As an example of this scaling, he scales the footsteps (end effectors for the legs) to change the speed of movement.

I had seen this video before but I was interested to see his legs suffering some of the same problems I had lol.

##### Share on other sites

Thanks y'all for answering.

I've started to write an IK solver for experience. I'll let you know as soon as it is done.

The whole point of me wanting to learn this is that I want to be able to easily transfer animations from one character to another. I'm making games with Unity and Blender and, well, I'd like to be able to get some procedural animation in the loop.

##### Share on other sites

This one is pretty interesting too.

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

1. 1
2. 2
3. 3
Rutin
19
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633657
• Total Posts
3013197
×