glTF-Blender-IO icon indicating copy to clipboard operation
glTF-Blender-IO copied to clipboard

Skinning examples often require 'Always sample animations' to be enabled

Open donmccurdy opened this issue 5 years ago • 15 comments

This is a tracking bug for examples that export correctly with Always sample animations enabled, but not when it is disabled. I would consider all of these to be lower-priority than other animation issues, because the option is there to work around them.

  • [ ] ac_coa.blend.zip from https://github.com/KhronosGroup/glTF-Blender-IO/issues/347
  • [ ] game_man_sketchbookb1.zip from https://github.com/KhronosGroup/glTF-Blender-IO/issues/373
  • [ ] rotation-example.zip from https://github.com/KhronosGroup/glTF-Blender-IO/issues/351 (incomplete rotation)
  • [ ] Cow.blend.zip from https://github.com/KhronosGroup/glTF-Blender-IO/issues/571

donmccurdy avatar Jun 18 '19 22:06 donmccurdy

I'd like to argue this should be a higher priority. For example that super low poly Cow file.

Without animation: 121k With curve based animation: 187k With sampled animation: 615k.

That's a 320% increase in size and that's a very simple skeleton with only 6 short animations.

if glTF is the transmission format for the web then it's actually extremely important the files be small. A solution with large files that drive users away from websites is not really a viable a solution. In other words I'm arguing the supposed workaround is not really a workaround. Sure you can test something but you can't ship if you want users to have a good experience.

PS: I know I'm not working the exporter and it's easy to say something when I'm not the one implementing. I'm only trying to add a POV that there really isn't a work around. I appreciate all the amazing work you guys are doing. Just wanted to point out something I thought might not have been considered.

samanthajo2 avatar Jul 04 '19 17:07 samanthajo2

@samanthajo2 The cow armature has some IK constraints. That means that the deformation bones are not directly animated (animation on FrontFoot.L location will have some influence on location and rotation on FrontLeg.L and FrontUpLeg.L and FrontLowLeg.L. These 3 later bones are not directly animated, and I can't find any other solution than sampling to take into account these animations in glTF files.

Any good ideas are of course welcome :)

julienduroure avatar Jul 04 '19 19:07 julienduroure

Sampling does help the export to be more robust, and for now that is the highest priority.

One of the solutions I'd like to have (and not necessarily the only one) would be a way to downsample the animation after it's been sampled. Many other exporters will probably have this same need, so something like that could be implemented in glTF-Pipeline or glTF-Toolkit to optimize the model after export.

That isn't terribly complicated (three.js has a simple implementation here), but I'm not aware of anything ready to use yet.

donmccurdy avatar Jul 04 '19 21:07 donmccurdy

Should we consider enabling Always sample animations by default, since that is better supported and performance has improved?

donmccurdy avatar Sep 19 '19 22:09 donmccurdy

Yes, we may have to do it. I received lots of bug report and/or user support request where the solution is only to say "you have some constraints, please use this option". Now, performance is acceptable. Only file size can be an issue.

My next step in this subject is adding an option to export only needed bones (deformation bones + parents of def bones if needed). I planned it for 2.82

julienduroure avatar Sep 20 '19 21:09 julienduroure

Yes, please consider enabling Always sample animations by default. We thought the glTF exporter was broken when rotations & movement in the exported model went in the completely opposite direction.

Enabling Always sample animations fixed it, and the filesize only changed 20%.

By default, please prefer reliably correct animations, over possibly broken animations.

    export_force_sampling = BoolProperty(
        name='Always Sample Animations',
        description='Apply sampling to all animations',
        default=True # <- Please
    )

Peach1 avatar Oct 01 '19 12:10 Peach1

There's also a gltfpack tool (by @zeux) that can resample animations to reduce filesize. For anyone needing to reduce the size of glTF animations exported from Blender with samples on every frame, that may be a good option. Note that the -c option should not be enabled at this time, if you want to have a valid/portable glTF file.

/cc @titansoftime

donmccurdy avatar Oct 14 '19 17:10 donmccurdy

Thank you, I'll check it out.

titansoftime avatar Oct 14 '19 17:10 titansoftime

I had the same issue yesterday...

I think "Always Sampe Animations" should be the default. It's a shame that it increases the file size, but should outputting valid files not be the priority ?...

Looking for a solution, I found that a lot of people are frustrated by the GLTF exporter, and tutorials and resources are scarce.... I even found this video on Youtube of somebody explaning that the Blender GLTF exporter is broken, and advising to use ESCN instead

We can see in the video that he doesn't check "Always Sampe Animations", which is probably the reason of his problems, and the problem of the 400 people who watched the video since it was posted 2 months ago.

felixmariotto avatar Oct 15 '19 02:10 felixmariotto

Thanks @felixmariotto for your comments. Note that "Always Sample Animations" is checked by default in current master, and will be checked in Blender 2.81 (released planned next month)

julienduroure avatar Oct 15 '19 04:10 julienduroure

Hi guys, I had a hell of a week trying to figure out a problem related to this, at the end, enabling sampling solved the mesh deformation of the character but at the same time the armature object animation did not get exported and the workaround was to have the armature linked to an empty and then animate that empty. I can only guess it is not supposed to be like this and both pose animation and object animation should be exported and played at the same time without any problem. I can share some files and deepen into subject if it is not a simple "aha! you didn't do this" kind of thing. I also agree that sampling enabled by default is a good idea, at least for now.

elcienfuegos avatar Oct 26 '19 16:10 elcienfuegos

The sampling is enable by default in 2.81 (currently in beta, will be released in November). Don't hesitate to share a .blend file, so I can have a look!

julienduroure avatar Oct 26 '19 16:10 julienduroure

A year has passed and I just tried going from FBX to GLB again, but none of the issues seem to have been fixed. It's a shame. I'm still forced to use FBX.

Here's my experience, maybe someone will find it useful:

  • If I check "Animation" but not "Skinning" on GLB export, I get this error traceback
  • IK still samples incorrectly (as seen in #373)
  • The exporter still does changes to the blend file on export (attaching animation clips to objects in Blender)
  • my character ends up rotated by +90° or -90° on the X axis, regardless of the "+Y up" option being checked. Maybe this is my fault, but again, FBX doesn't have this issue. (game_man_sketchbookb1.zip from #373)

Blender's GLTF export is fine for static objects, but it's still unusable for skinned animated meshes.

swift502 avatar Jan 01 '20 21:01 swift502

@swift502 I will create some new ticket to not pollute this thread that is not directly linked to your issues. Please continue the discussion on other tickets.

julienduroure avatar Jan 04 '20 20:01 julienduroure

@julienduroure Thanks for the help. I'm using the glb format now, with the few tweaks to my model it works nice. Me saying the exporter is "unusable" wasn't quite accurate. 🙂

It's just really deterring when everything went wrong on my first export attempt.

swift502 avatar Jan 05 '20 14:01 swift502

Closing this ticket, as we are now using sampling by default since few years.

julienduroure avatar Feb 24 '24 17:02 julienduroure