Animation takes up too much memory

Started by
27 comments, last by comfy chair 8 years, 10 months ago
Spell-check forced my hand.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Advertisement

"Redundant frames" needn't mean only frames that are the same. A redundant frame is any frame that is sufficiently close to the value you would calculate by interpolating/SLERPing the previous and following frame. I.e., if you're interpolating frames anyway, and the frame data for time t is what you get from interpolating frame t-1 and frame t+2, frame t is redundant.

I eliminated these frames also and I am now down to 44 MB. Perhaps I can compress it a bit further by increasing the comparison threshold without hurting the playback quality.

increasing the comparison threshold without hurting the playback quality.

The playback quality is what you have to decide on with regard to the results. With regard to that quality, be careful with your algorithm, the threshold, and how you're implementing it. If you're using only 3 consecutive frames ( a, b, c ) to determine if b is "redundant," you may be "flattening" curves unnecessarily.

I.e., in the pix below (just an illustration of the principle,) if you approach the curve from the left, if your threshold is a bit too large, you may decide to eliminate point b, where point c may, in fact, be a better choice.

[attachment=27810:redundant_point.png]

Just some random suggestions - I understand your rendering algorithm is tied to the format of the keyframe data, but (as you likely know) it's driving up the size of the data structure. I know it's a decision among refactoring, code speed and data size. For your consideration (perhaps for future implementation):

- A matrix is 16 values. A rotation matrix (9 values), a translation vector (3 values) and a scale vector (3 values) are 15 values. A quaternion instead of a rotation matrix makes the structure only 10 values. Scaling is rarely needed, and eliminating that saves you 3 values ( perhaps 12 bytes/frame ).

- you're using long for your tick count. Do you ever have an animation that long?? In addition, it's a signed integer and you shouldn't be using negative tick counts. I.e., uint8_t or uint16_t may cover the max tickcount needed, doubles the value range and can save several bytes per keyframe. uint32_t, at a minimum, is no larger and doubles the range.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

So I need to choose if I want to support scaling, or not. Actually, I don't think I will ever need it.


scaling, ... I don't think I will ever need it.

It's rare, but not unknown. It can be used for morphing, i.e., causing the mesh around a bone to "swell" or "shrink." Probably a good decision for now.

Another random thought - my brain works in the background sometimes, and it occurs to me that, because you're using a matrix at run-time for your animation calcs, (unless you decompose it) you may be linearly interpolating your rotations. If so, you should use the same algorithm in your preprocessing to determine redundant frames. I.e., if you SLERP to determine unneeded rotations in your exporter, you won't get the expected results if you do a linear interpolation at runtime.

N.B., SLERPing and LERPing over small angles won't provide greatly different results, but they are not identical. Just recommending you make decisions during preprocessing that reflect the results you'll end up with at run-time.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Yes, I already made sure that I use the same interpolation method in preprocessing and at runtime. SLERP was necessary to use because LERP sometimes gave crazy errors.

I asked the animator if we ever used scaling, the answer was "don't know". But now I think it will probably be needed at some point, if it isn't being used already.


SLERP was necessary to use

Just a suggestion - if you're decomposing the matrix at runtime to slerp the rotations (and, I assume, interpolate the translation and scale), why not export the data as separate rotation, translation and scaling to begin with? wink.png

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Yes, I should of course do that when possible. The build time is long enough already.

With the changes to the struct (uint instead of long, vectors instead of Matrix) I got down to 28 MB. That's good enough for now I think.

Thanks for the help.

This topic is closed to new replies.

Advertisement