banner



How To Mark Animation As Legacy Unity 5

Blitheness Pinch: Unity 5

Unity 5 Official Trailer

Unity 5 is a very popular video game engine on mobile devices and other platforms. Beingness a state of the fine art game engine, information technology supports everything you might need when information technology comes to character animation including compression.

The relevant FBX Importer and Animation Clip documentation is very sparse. It'south worth mentioning that Unity 5 is a airtight source software and as such, there is some amount of uncertainty and speculation. Withal, I was able to arrive touch with an old colleague working at Unity to analyze what happens under the hood.

Before we dig into what each compression setting does we must first briefly cover the data representations that Unity 5 uses internally.

Runway Data Encoding

The engine uses one of iii encodings to represent an animation runway regardless of the rail data type (quaternion, vector, float, etc.):

  • Legacy Curve
  • Streaming Curve
  • Dense Bend

Rotation tracks are ever encoded as four curves to stand for a full quaternion (1 curve per component). An obvious win here could be to instead encode rotations as quaternion logarithms or by dropping the quaternion W component or the largest component. This would of class immediately reduce the retention footprint for rotation tracks by 25% at the expense of a few instructions to reconstruct the original quaternion.

Legacy Bend

Legacy curves are a strange animate being. The source data is sampled uniformly at a fixed interval such as xxx FPS and is kept unsorted in full precision. Using discreet samples during decompression a Hermite curve is constructed on the wing and interpolated. It is unclear to me how this format emerged but information technology has since been superseded by the other two and it is non frequently used.

Information technology must take been quite tiresome to decompress and should probably be avoided.

Streaming Curve

Streaming curves are proper curves that employ Hermite coefficients. A rail is split into intervals and each interval is encoded as a distinct spline. This allows discontinuities between intervals. For example, a camera cut or teleporting the root in a cinematic. Each interval has a minor header of 8 bytes and each control point is stored in full floating signal precision plus an index. This is likely overkill. Full floating point precision is typically far besides much for encoding rotations and using simple quantization to store them on sixteen $.25 per component or less could provide significant memory savings.

The resulting command points are sorted by time followed by track to render them as cache as efficient equally possible which is a very good thing. At decompression, a cursor or enshroud is used to avoid repeatedly searching for our control points when playback is continuous and predictable. For these two reasons streaming curves are very fast to decompress in the average utilise case.

Dumbo Curve

What Unity five calls a dumbo curve I would call a raw format. The original source data is sampled at a stock-still interval such equally 30 FPS and goose egg more is washed to it equally far every bit I am aware. The data is sorted to brand it cache efficient by time and track. No linear primal reduction is performed or attempted. The sampled values are not quantized and are merely stored with total precision.

Dense curves will typically have a smaller memory footprint than streaming curves simply for very short tracks or for tracks where the data is very noisy such as a motion capture. For this reason, they are unlikely to be used in practice.

Overall their implementation is simple just perhaps a flake naive. Using simple quantization would give significant memory gains hither without degrading decompression performance and might fifty-fifty speed information technology up! On the upside decompression speed is very likely to exist faster than with streaming curves.

Compression Settings

At the time of writing, Unity 5 supports three pinch settings:

  • No Compression
  • Keyframe Reduction
  • Optimal

No Compression

The nearly detailed quote from the documentation about what this setting does is:

Disables animation compression. This means that Unity doesn't reduce keyframe count on import, which leads to the highest precision animations, but slower performance and bigger file and runtime retentiveness size. Information technology is generally not appropriate to use this pick - if yous need higher precision animation, you should enable keyframe reduction and lower allowed Animation Compression Error values instead.

From what I could gather the originally imported clip is sampled uniformly (e.g. 30 FPS) and each rail is converted into a streaming curve. This ensures everything remains shine and authentic simply the overhead tin be very significant since all samples are retained. To make things worse nothing is done for constant tracks with this setting.

Keyframe Reduction

The most detailed quote from the documentation is:

Removes redundant keyframes.

When this setting is used constant tracks will be collapsed to a single value and redundant control points in animated tracks which will be removed within the specified fault threshold. This setting uses streaming curves to stand for track information.

Only three thresholds are exposed for this compression setting. Ane for each track blazon: rotation, translation, and scale. This is very likely to lead to the problems discussed in my post on measuring accurateness. And indeed, a quick search yields this gem. Even though information technology dates from Unity 3(2010), I doubtfulness the animation compression has changed much. Unfortunately, the problems information technology raises are both very telling and mutual with local infinite mistake metric functions. Here are some relevant excerpts:

Now, you may be asking yourself, why would this guy turn off the key reducer in the first place? The answer is simple. The fundamental reducer sucks. Here's why.

Every animation I take completed for this project uses planted keys to anchor the feet (and sometimes easily) to the floor. This allows me to grab any part of the body and animate information technology, knowing that the feet will not move. When I export the FBX, the keys stay intact. I tin can bring the animation back into Max or into Maya using the keyframe reducer for either software, and the anxiety remain anchored. When I bring the aforementioned FBX into Unity the feet slide effectually. Often quite noticably. The only way to terminate the feet from sliding is to turn off the fundamental reducer.

This is a very common problem with local space error functions. Tweaking them is hard! The end event is that very often a weaker compression or no pinch at all is used when issues are plant on a prune by clip footing. I have seen this exact beliefs from animators working on Unreal three back in the day and very recently in a proprietary AAA game engine. Even though from the user's perspective the issue is the animation pinch algorithm, in reality, the consequence is virtually entirely due to the error function.

What I would really like to come across is some options within Unity's blitheness importer. A couple ideas:

i) Max'due south FBX keyframe reduction has several precision threshold settings that dictate how authentic the keyframe reduction should exist. In Unity, it's all or aught. I would dear the power to accommodate the threshold in which a keyframe gets added. I could turn up the sensitivity on some animations to reduce sliding and peradventure turn it down on areas that need fewer keys than are given by the current value.

2) I'm not sure if this is possible, but it would be great to set up keyframe reductions on some bones and non others. That style I can go along the arm chain in the proper location without having to bloat the keyframes of every bone in the whole skeleton.

Exposing a single error threshold per track type is very common and provides a source of frustration for animators. They often know which basic need higher accuracy but are unable to properly tweak per bone thresholds. Sadly, when this characteristic is present the settings oftentimes end up being re-create & pasted with overly conservative values which yield a higher than needed memory footprint. Nobody has fourth dimension to tweak a large number of thresholds repeatedly.

Unity 3 really corrects the trouble by giving us direct command over the keyframe reduction vs allowable error. If you find your animation is sliding to much, dial down the Position Mistake and/or Rotation Fault settings in the animation import settings.

Unfortunately, I didn't notice whatsoever satisfying setup :/

I got some characters that move super fast in their anim, and I demand the histrion to run across the motility correctly for gameplay / residual reasons.

Then it can works for some anims, only not for others (making them feel like they are teleporting).

And under a certain reduction threshold, the memory size do good is too modest to resolve loading times problem :/

In fact, the only reduction setting I found that didn't caused teleportations was :

Position : 0.i
Rotation : 0.ane
Scale : 0 (as there is never any blithe calibration)

But this is notwithstanding causing huge file sizes :(

A single error threshold per rail type also means that the mistake threshold has to be as depression as your about sensitive bone requires. This will, in plough, retain college accurateness that might otherwise be needed yielding again a higher memory footprint that is ofttimes unacceptable.

Optimal

The nigh detailed quote from the documentation is:

Let unity decide how to compress. Either past keyframe reduction or by using dumbo format. Unity volition pick the most optimal of the ii.

This is very vague and judging from the results of a quick search, a lot of people are curious.

Thankfully, I was able to get some answers!

If a track is very short or very noisy (which could happen with motion capture clips or broiled simulations), the key reduction algorithm might non give appreciable gains and it is possible that a dumbo bend might finish upward having a smaller memory footprint than a streaming curve. When this happens for a detail track it will use the curve with the smallest memory footprint. As such, within a single clip, we tin can have a mix of dense and streaming curves.

Conclusion

The Unity 5 documentation is sparse and at times unclear. Information technology leads to rampant speculation as to what might be going on under the hood and a lot of confusing results.

Its error function is poor, exposing a single value per track type. This leads to classic issues such as turning compression off to retain accuracy and using an overly conservative threshold to retain accuracy at the expense of the memory footprint. Information technology perpetuates the stigma that animation compression can exist painful to work with and can hands butcher an animator'south work without manual tweaking. Fixing the error office could be a reasonably elementary task.

The optimal pinch setting seems to exist a very reasonable default value but it is non clear why the other two are exposed at all. Users are very likely to utilise one of the other settings instead of tweaking the error function thresholds which is probably a bad idea.

All bend types encode the data in total precision with 32-chip floating point numbers. This is probable overkill in a very large number of scenarios and implementing some form of simple quantization could provide huge memory gains with fiddling work and piffling try. Due to the reduced memory footprint, decompression timings might even improve.

Furthermore, rotation tracks could be encoded in a improve format than a full quaternion farther reducing the retention footprint for minimal work.

From what I could find nobody seemed to complain nigh animation decompression operation at runtime. This is more often than not likely a straight result of the enshroud friendly data format and the usage of a cursor for streaming curves.

Upwards next: GDC 2017 Presentation

Back to table of contents

Source: https://nfrechette.github.io/2017/01/30/anim_compression_unity5/

Posted by: huttonlecoany.blogspot.com

0 Response to "How To Mark Animation As Legacy Unity 5"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel