📜 ⬆️ ⬇️

Skeletal animation in games. Technician and Resource Overview

Anima is the soul that distinguishes the living from the dead. The Aristotelian soul is the principle of movement, manifested in four forms: movement, transformation, decrease and increase. After almost two and a half thousand years, we use the same categories in computer graphics. Skeletal animation defines movement, morphing is used for transformations, and descending and increasing is the usual scaling. Animated graphics enlivens the image, breathes the soul into the picture, and this, in my opinion, is even more important than a reliable play of light and shadow.

image


Creating high-quality skeletal 3D animations today is perhaps the most difficult task for indie developers. This is probably why there are so few indie games in 3D, and so many projects in pixel art or primitivism styles, as well as roamers without characters in the frame. But now this ratio may change ...

Try counting the number of different animations in Uncharted 4. I estimate there are about an hour of unique movements, not counting the front animation ( 850 expressions according to the authors). Such games set a fantastic level of quality.
')


Uncharted 4 animation examples (> 40mb GIF)




If physical rendering and creation of well-lit static scenes are available to enthusiasts thanks to powerful free game engines and 3D modeling tools, creating good animation requires equipment for capturing movements and long-term painstaking work on their implementation. One of the most affordable systems is the neuronmocap suit, which costs about $ 1.5k excluding delivery.

I was not able to find examples of creating at least a similar level of animation using a manual personnel approach or some procedural animation. The maximum that can be done manually, in my opinion, is simple strikes, fast movements and stylized cartoon animation. But how to make a realistic walk up the stairs, where there are so many details related to the portable center of gravity and the balance of the body? It is impossible to play them all manually. Maybe I'm wrong, and someone will show the work of specialists of this level? ..

I remember all this in order to appreciate the generous gift from Mixamo . It literally opens the door to a new level for independent developers: Adobe bought Mixamo, and now they give 2.5 thousand skeletal animations for the characters completely free of charge " for unlimited commercial or non commercial use ":
www.mixamo.com

Half a year ago it was possible to get them only by laying out about $ 36,000 (well, or spiral in the network). In addition to animations, the company also offers a free version of the tool for ripping and skinning characters, a tool for creating multiple levels of detail with minimal quality loss (LOD), a character generator and a plugin for capturing facial animation.

Mixamo animation example


There are at least well- developed sets of animations , available for purchase by enthusiasts. But such a huge and high-quality set for the first time was available for free. Another good source of clips remains the animation base of Carnegie’s University - Mellon and its Unity-adapted version , but the quality and content of this base is not so good.

In addition to manual frame animation and motion capture of an actor, there are interesting procedural methods of motion simulation: evolutionary modeling , neural networks , task based locomotion . Interestingly, at the SIGGRAPH 2016 conference, these challenging technicians pay a lot of attention. But these things are not yet available to a wide range of independent developers, and I myself would like to know more about the possibility of their real use. However, today there are also available tools that simulate muscular dynamics ( Euphoria Engine and Puppet Master for Unity3d), which allow you to bring in different reactions of characters to circumstances.







Get high-quality and diverse animation clips is only the first part of the task.
The second part is to correctly use the received animations while controlling the character. To do this, you first need to decide how to generally move the character in the scene: based on the data of the animation itself (1), or on the basis of some other considerations (for example, solid state physics) (2). That is, either the animation will be calculated based on an arbitrary (physical) movement of the object in space (2), or the displacement in space itself will come from the recorded animation, ignoring other interventions (1).

Both approaches have advantages and disadvantages. In the old days, before the mass use of motion capture, there was almost no question about it - the characters moved procedurally, on the basis of some simple principles, and the animation clips were simply played to some extent corresponding to this movement. But the better the animation and the graphics as a whole became, the more noticeable the discrepancy between the movement of the legs and the displacement of the character, as well as the lack of movement dynamics.

One of the clearest examples is the game Guild Wars 2 where the animation of movements and graphics are already quite good, but here a large range of possible speeds and directions of movement of the character is not provided with an equally large set of animations, and the characters either stall in place or slip forward like on ice . The same problem has been pursuing for a long time and games on the Gamebryo engine (TES series: Morrowind, Skyrim), and many others.



The real movement of a person is nonlinear - first we lean forward, then we throw out the leg, and only then we start the movement, quickly accelerating after the foot makes contact with the ground, and we move by inertia until the next step. It is difficult to choose a function that accurately describes such a movement, and rarely anyone thinks about it at all. What to say about more complex movements - strafe, transitions between directions, braking and turning.

Therefore, in order to achieve realism, in any case, we will need a gigantic set of various clips with movements in different directions, at different speeds, and so on ... In addition, animated clips can rarely be used in isolation, reproducing one after another. Most often, the game has a lot of animations, between which there are no special animated transitions. Therefore, for their simulation, smooth mixing through linear interpolation of bone turns is used. For convenient setting of such transitions, so-called. state machine or state machine (State machine). In UE and Unity there are special tools for this: Persona and Mecanim . Each node there is a certain state of the skeleton model (the prepared animation clip or the result of their mixing is the Blend Tree). When certain preconditions are fulfilled, a smooth transition from one state to another takes place, during which both have a time-proportional effect on bone rotations and object displacement. Thus, the illusion of continuity of movement is achieved.

The state may not be a single clip, but a mixed set of clips (Blend Tree / Blend Space) on the same principle. For example, you can select several clips of movements of the character to the sides, mixing them in proportion to the vector of the desired movement, and get movement at any arbitrary angle. However, there are such animations for which mixing turns into incorrect postures. For example, when one animation moves a character's legs forward and the other sideways, linear mixing can cause the legs to intersect with each other. To avoid this, you need to carefully select animated clips, synchronize their phase, length and speed, or add a separate clip specifically for this type of movement. All this is a difficult and painstaking work. And the more possible states and transitions between them, the more difficult it is to bring them into agreement with each other, and make sure that all the necessary transitions work when it is required.

2-D mixing motion tweens


1) The most obvious solution is to capture the movements of a real actor with the help of Motion Capture and link the character's shift in the game to the displacement of the “root bone” in the animation itself - the Root Motion principle. Then the character will move exactly as the actor moved during the recording.

It looks very realistic. Moreover, this is the only way to reliably reproduce complex maneuvers such as attacks, dodging, and parry attacks with melee weapons.

But this approach also has obvious problems.

Suppose a character wants to move to the edge of a cliff: the actor on the record leans, lifts his foot and takes a bold broad step across the stage. And the character walks straight into the abyss ... To avoid this, you need to interrupt the step somewhere in the middle, but it not only looks unnatural, but also makes it difficult for the player to choose the right moment due to the nonlinearity of movement, which can be a long preparation (slope), and then a sharp confident movement (step). You can record several variations of movements. Suppose: cautious small steps, normal, and running. And then mix them in the required speed, which can be increased linearly and predictably. But what if we need movements to the side? So for each variant of the step width, we need three or four more variants (minus the mirror ones). And the character must be able to turn while moving. So for each option, we need movement with a turn. And if the turn can be fast and slow? So once again multiply the number of clips needed by two. And now we need to move on an inclined surface! And then we want the character to be able to do the same thing on a squat. Total - just hundreds and thousands of animation options that need to be mixed and ensure that this happens correctly and leads to movements with the desired speed. And still, in many cases, the management will be felt as “wadded”, since the inertia of the actor and our inability to foresee all possible human maneuvers will deprive the player of control over the character. By the way, the players in The Witcher 3 felt this problem, so in one of the major updates, the developers introduced an alternative management option, where the animation responds faster to management to the detriment of realism. In shooters, the problem of non-linearity of movement becomes particularly pronounced: the player often has to look around the corner and quickly go back, and the moment of an abrupt change in direction can be very different - the player needs to return back to cover as soon as possible, but we cannot predict in advance what width the pitch he planned and play the corresponding animation. The player, in turn, will find it difficult to get used to the width of the step his character makes and to the speed of this step in order to interrupt him in time.

Secondly, Root Motion is bad for network games. Motion nonlinearity not only makes it difficult for the player to predict speed, but also makes it impossible for us to interpolate and extrapolate motion to compensate for network latency, which is a very important and complex aspect in fast network games. If the character's offset is set only by animation, then it is difficult to analytically select the necessary parameters of the state machine (mixing different animations), which will lead to movement of the character in the exact direction we need and at the exact speed we need (selected to compensate for the discrepancy). If we do the opposite, so that the animation will focus on the actual movement, then when correcting the discrepancy between the server and the client, it will be easy to choose the most suitable animation, and even if it slightly mismatches the actual displacement, almost no one will notice.

Therefore, the Root Motion technique is often used in third-person single-player games, where control is contextual, depending on the availability of shelter, obstacles, driving patterns, or other circumstances, and is rarely used in network mode and MMOG.

Of the last notable projects that use Root Motion, we can distinguish The Witcher 3 . It is difficult to overestimate the efforts invested in the production of all its movements.

An example of the animation The Witcher 3 and its shooting
The actor performs the movements of the witcher


Images from the game The Witcher 3


2) Another solution is back to the principle of Root Motion - you need to bring the animation in the most exact correspondence with the happened or planned movement. Then many of the problems described above are solved - the movement of the character can be made uniformly accelerated and predictable with the possibility of an arbitrarily fast change of direction. But how to bring the nonlinear and inertial animation in accordance with such a movement? An interesting integrated approach was described by the developers of the game Paragon. Its essence is to find and play only the desired series of animation frames to achieve the desired offset / rotation, skipping unnecessary. And use inverse kinematics to modify the step width.



The first obvious difficulty in adjusting the animation to the movement is that the movement has already occurred, and the animation has not yet been played. Therefore, a motion prediction system that calculates the position of the character for the next frame is very useful. Then, knowing the offset that the character must make for the next frame, you need to skip as many frames of the motion animation clip as you need to achieve the desired offset, and play the frame in which the desired offset has been reached. In this case, the animation will be played at a changed speed, so as to exactly match the actual displacement, and this speed may be faster or slower than the original one, since it is impossible to make the real actor maintain a constant acceleration or speed. This approach will allow smoothing the animation and aligning it with any complex procedural model of movement that changes during the game (the character can drink some accelerating potion or be slowed down by the opponent). The disadvantage, of course, is that the animation may become less realistic due to strong changes in speed. However, in practice, this gives a very good window of available variations in which the speed violations are not noticeable. And together with the amendments of the step width using inverse kinematics, it covers an even greater range.

But, unfortunately, this method quite violates the usual approach to animation, and therefore I could not find an easy way to implement it, for example, using the standard Unity animation component. The Unreal Engine also does not yet have the necessary functionality, but the developers promise someday to transfer the low-level developments made for Paragon to the public version of the engine. The main difficulty is the search and playback of the desired frame based on data on the actual displacement and rotation. To do this, the authors propose to pre-process animation clips and generate an additional data block for each of them: Distance Curve, in which the offset and rotation of the root bone relative to the beginning or end of the animation will be stored frame by frame. Then, during the sampling, you can perform a quick binary search of the desired frame, where the corresponding offset and rotation parameters are achieved, and play it back.

In the meantime, you can limit yourself to the previous approach, and make a less accurate fit to the speed of the animation to the speed of the planned movement, focusing only on the speed of the character in the last frame. The most important thing - a good set of souls for experiments is now available!

Source: https://habr.com/ru/post/304042/


All Articles