Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exporter freezes when exporting with animation #327

Closed
vtange opened this issue Jun 7, 2018 · 11 comments
Closed

Exporter freezes when exporting with animation #327

vtange opened this issue Jun 7, 2018 · 11 comments
Labels
Animation exporter This involves or affects the export process

Comments

@vtange
Copy link

vtange commented Jun 7, 2018

I have a model I downloaded and re-rigged myself and have been testing with Babylon.js. It is a mostly vertex-painted model with the solidify modifier to add the cartoon outline effect.

It exports and loads fine, armature and all, in Babylon.js. without animations.

static

So I added a simple Head Turn animation for starters. Nothing too fancy.

I tried the latest version of Kupoman's gltf exporter as of today and it exports without error but the animations are incorrect - the head distorts instead of turns, and the character doesn't turn her head a full 90 degrees each direction.

In the older version of this exporter (latest from October 2 2017), it exports without error and seems to animate properly, but many other bones seem to be displaced and there are black artifacts everywhere.

glitched

In the latest version of this exporter, however, it exports fine without animations but the moment I check [export skinning] it will never finish exporting. Blender stops responding and I'm forced to close it.

Oddly enough, the older version of the exporter manages a smaller gltf (5MB) than the newest one (10MB). Is this supposed to happen?

Here is the file for reference:

GwenSimp - w_head_turn.zip

@donmccurdy
Copy link
Contributor

Try shortening the animation range, or disabling "Export within playback range", otherwise it is baking out 50,000 keyframes and that will take a long time.

Unfortunately even so there are some issues. I don't know the cause of those, but maybe they are solveable by applying modifiers and joining meshes?

dc693a05-d37c-4ade-af4a-69adf2018826-11477-00000f1a4a5008c7

@donmccurdy
Copy link
Contributor

Oh one note, I'm working of this branch will be merged soon: KhronosGroup/glTF-Blender-Exporter#166. But I'd expect the results on the master branch to be the same here.

@vtange
Copy link
Author

vtange commented Jul 8, 2018

Thanks for the reply. I tried lowering the animation range to 65 frames and it did the trick. It's still a giant .bin file (32.5MB, attached)

Even after applying all my modifiers and merging all objects into one mesh, I do get still get black artifacts and odd bugs given the only thing that moves is her head (right foot is twisted).

I don't really know, but could the black artifacts be specific to Babylon.js? I don't know what viewer you used for the .gif above, yours also seem to be missing the toon-effect black outlines on the character. Maybe the black artifacts stems from the outlining?

animationblack

I've attached the cleaned up .blend, and resulting .gltf and .bin here.

GwenSimp - w_head_turn_mergeApplied.zip

@donmccurdy
Copy link
Contributor

donmccurdy commented Jul 9, 2018

Getting closer! 😅 I'm viewing the model in https://gltf-viewer.donmccurdy.com/ (based on three.js), and the toon-black outlines are intact but subtle.

The main issue here is that there are many (~20) joint influences per vertex. Most realtime engines support only 4. You can reduce this in Blender with the Limit Total option. The result looks much better:

before (three.js) after (three.js)
9a8e39ee-d98e-4251-bea6-f7653d6cef2f-15256-0000278f6a910d97 1620c865-4383-4264-938b-48ca25baf0e6-15256-0000280a723da8b3

Even with that fix, there is a remaining issue in one foot (for both engines) and an additional problem in BabylonJS, which I think is related to the outline? I would file an issue with BabylonJS about that.

BabylonJS:

screen shot 2018-07-08 at 8 55 45 pm

@vtange
Copy link
Author

vtange commented Jul 11, 2018

Lookin' great @donmccurdy!

That explains the glitchiness! I've read about the max 4 joint-influences thing somewhere in the Babylon.js forums before, but never knew what going past it would look like. Now I do :)

How did you find out there was too many joint influences? Was it somewhere in the blender file? I'm relatively new in Blender (this is not my model, it is a user named "Ctool"'s at Sketchfab. https://sketchfab.com/models/fbfbac4c809741838fb6882fda3da175 ), all I did was simplify the model to use it to learn rigging and test out toon-effects in WebGL.

Did the babylon.js version animate? I don't know if the issue in the last pic is due to the outlining effect (it's made with extra geometry) since Babylon.js renders everything fine in my very first screenshot at the top of this thread, without animations exported, but I can open an issue if I can get a copy of the .gltf/.glb you used for the last screen.

@donmccurdy
Copy link
Contributor

I don't know how to find the number of joint influences in Blender (surely there's a way!) but in the .gltf file (if you open it in a text editor and search for "meshes") you'll see something like:

screen shot 2018-07-10 at 11 27 59 pm

Each of those JOINTS_N attributes can hold 4 influences per vertex, so with 5 attributes allocated there must have been 17-20 influences.

The BabylonJS model does animate yes, although it has that same foot deformation issue as in three.js. Here's the file —

GwenSimp - w_limited_weights.zip

@donmccurdy
Copy link
Contributor

Just guessing here, but BabylonJS might have a bug handling uint32 indices. That toon outline uses one, while most other parts of the model do not.

@bghgary
Copy link

bghgary commented Jul 18, 2018

I investigated this a bit with BabylonJS. I'm not sure where the culprit is, but there are lots of vertices where all the weights are zero. This isn't valid. I'm not sure why three renders this correctly.

From the GwenSimp - w_limited_weights.gltf:

                {
                    "attributes" : {
                        "COLOR_0" : 29,
                        "JOINTS_0" : 30,
                        "NORMAL" : 26,
                        "POSITION" : 25,
                        "TANGENT" : 27,
                        "TEXCOORD_0" : 28,
                        "WEIGHTS_0" : 31
                    },
                    "indices" : 24,
                    "material" : 1
                },

The weights for this mesh has a whole bunch of all zeros.
image

@bghgary
Copy link

bghgary commented Jul 18, 2018

The weights are also not normalized.
KhronosGroup/glTF#1352

@donmccurdy
Copy link
Contributor

Confirmed the model looks undistorted in both engines with skinning removed, so I guess the issue was not uint32 indices. I don't know why the weights are zero, it's possible that's a result of using Limit Total in Blender although I would hope it chooses the highest weights to keep...

three babylon
screen shot 2018-07-21 at 3 48 40 pm screen shot 2018-07-21 at 3 48 36 pm

@donmccurdy donmccurdy transferred this issue from KhronosGroup/glTF-Blender-Exporter Feb 25, 2019
@julienduroure julienduroure added the exporter This involves or affects the export process label Feb 26, 2019
@scurest
Copy link
Contributor

scurest commented Jul 27, 2020

Can this be closed? This model now exports and displays with no obvious visual problem in Three/Babylon. The validator reports that there are still zero weights, but that is tracked by #308.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Animation exporter This involves or affects the export process
Projects
None yet
Development

No branches or pull requests

5 participants