KhronosGroup / glTF

glTF – Runtime 3D Asset Delivery
Other
7.14k stars 1.14k forks source link

Skinning use cases and examples #1403

Open donmccurdy opened 6 years ago

donmccurdy commented 6 years ago

We currently do not have example assets for many of the less-common situations involving skinning, which has prompted questions about whether they are valid and how to implement them.

Have examples:

TBD:

In each case, if we find that an example cannot be consistently implemented we may tighten the spec accordingly.

donmccurdy commented 6 years ago

@bghgary would some of these be reasonably within scope for glTF-Asset-Generator to output? I can start making some one-off models in Blender if not.

bghgary commented 6 years ago

@donmccurdy Some of these are planned already. See https://github.com/bghgary/glTF-Asset-Generator/issues/437. I think the only ones that are not covered are the first one and last one.

donmccurdy commented 6 years ago

~Added another edge case above, "Node references a skin but not a mesh.". See https://github.com/KhronosGroup/glTF/issues/1448.~

lexaknyazev commented 6 years ago

@donmccurdy This isn't allowed by schema: https://github.com/KhronosGroup/glTF/blob/6612de29c8d182ba8d374491ce43d38a6be0e07f/specification/2.0/schema/node.schema.json#L85-L88

donmccurdy commented 6 years ago

Ah good to know. Removed the addition above.

donmccurdy commented 5 years ago

Added A subset of joints in one skin are reused in another skin. above, per https://github.com/KhronosGroup/glTF/issues/1454.

donmccurdy commented 5 years ago

Thanks to @kcoley, @stevk, and @bghgary, for adding new test cases in glTF-Asset-Generator, with more on the way. 🎉

From those that are available now, I've filled in three of the "example" links above:

Joint hierarchy is intermixed with non-joint nodes. (donmccurdy/three-gltf-viewer#101)

This works fine for all of the three implementations tested (BabylonJS, ThreeJS, PlayCanvas). We may want to test a native engine like Unreal or Unity as well, but it seems like this case can probably be allowed, and should possibly be mentioned as an implementation note. It is a known use case that engines may attach objects to bones after loading, and I see no reason to disallow it in the model itself.

Animation transforming parents of joints (works) or parents of skinned mesh (no effect). (#1195)

Works in all three, and the spec is already clear on this case.

Some or all joints are detached from the scene hierarchy (#1383)

Works only in BabylonJS. I'm not sure whether this should be allowed.

zellski commented 5 years ago

Pragmatic question -- for an exporter like FBX2glTF, do you think it's reasonable to cater to the loaders that have issues with your example #1 (joints form a strict subset of the relevant sub-scene-graph) by simply adding the inactive but tree-connecting nodes as joints in the skin? It definitely solves the issue I'm working on, but I'm not clever enough to figure out if it's likely to cause other issues on some esoteric models.

bghgary commented 5 years ago

I've update the first comment with the latest examples from asset generator v0.6. The only one that is missing is the >4 joints one because no engines support it right now.

bghgary commented 5 years ago

adding the inactive but tree-connecting nodes as joints in the skin?

Would you also add weights and inverse bind matrices for them? I think the down side is that it costs more space?

zellski commented 5 years ago

adding the inactive but tree-connecting nodes as joints in the skin?

Would you also add weights and inverse bind matrices for them? I think the down side is that it costs more space?

I would, and it does, which is irritating. Still, it's per-node waste rather than per-vertex waste, and on the models I just tested on, the size increase is a small fraction of a percent. I can live with that (and if others hate it it's easy to add command line flags). I'm more worried about unintended side effects I hadn't though of –– to say I'm weak on skinning is an understatement.

bghgary commented 5 years ago

I don't call myself an expert on skinning either, but I don't think there will be any side effects. BTW, which viewers don't work correctly without this?

zellski commented 5 years ago

BTW, which viewers don't work correctly without this?

The bug report I received mentioned Blender glTF import & Windows 3D Viewer.

I didn't test Blender, but the latter stumbles like this: image

If we peek at the bones we see unnaturally many of them are rooted in the same spot on the lumbar spine. The misplaced limbs (head, left arm, right arm) all sit on nodes that don't don't have FbxSkin deformers in the original FBX, so they don't become joints. Maybe the loader assumes a tree, interprets this skeleton as four disjoint trees, and roots them all in the common shared ancestor node?

image

After the "fix" all is well (and animations run correctly too, so WEIGHTS_0 and JOINTS_0 appear to be undisturbed). image

Yikes, that was a lot of large images. Sorry to spam.

bghgary commented 5 years ago

Yes, confirmed with 3D viewer. This will get fixed as we require that the app pass all asset generator tests.

zen85 commented 5 years ago

I also have the problem that constraints on a mesh to another mesh or parenting does not really work. i get it to the point where the mesh gets positioned correctly once in the beginning but does not move along when iE the hand of the model moves.

i am relativly new to this: do i understand you correctly that this is a known issue of the exporter (in my case Blender) but you need testdata to solve that issue? because i would happily provide you with that if you tell me what you need and i can safe some of your precious time since it seems you are busy on so many forums answering our questions. can i contribute/support you at this somehow?

i just want to attach supersimple eyebrows on my robotface with morph-targets to get some kind of expression in that face. or is there another route to get that working? i want to achive something similar to that: https://threejs.org/examples/?q=morph#webgl_animation_skinning_morph

donmccurdy commented 5 years ago

@zen85 it sounds like you're describing a bug in a Blender exporter? If you haven't already, could you file a bug on the exporter you're using? If it's the one that ships with Blender, glTF-Blender-IO, we're tracking a related issue here: https://github.com/KhronosGroup/glTF-Blender-IO/issues/75.

If you're able to share an example model and attach it to the issue above, that would be helpful. Thanks!