BabylonJS / Exporters

Exporters for Babylon.js and gltf file formats
Other
611 stars 313 forks source link

3ds Max 2017: How to handle multiple Skin modifiers, single bone tree #554

Closed dpalacio closed 5 years ago

dpalacio commented 5 years ago

When two objects have been rigged to the very same bones and then the document is exported to glTF2, should a common skin be made for every skin modifier? My usecase is a set of meshes rigged to a human skeleton but I can't show that here so here are some teapots: 3dsmax_bYvZwMMV94 glftTest2.zip And a testcase.

In the testcase both teapots get different skins with the same nodes in the exported glTF2 document.

I'm not sure this situation is clearly defined in the specification.

dpalacio commented 5 years ago

Similar issue KhronosGroup/glTF-Blender-IO#566 where in Blender, skins are more clearly defined but still multiple copies of the skin are made in the exported document.

sebavan commented 5 years ago

Ping @bghgary and @PatrickRyanMS

Drigax commented 5 years ago

Hey @dpalacio, can you help by explaining some real world usecases for this? I'd like to support something like this if it's reasonable, but teapots aren't helping this make sense for me.

We have multiple meshes with similar skinning, and we want to have them share the skinning matrix at export? It sounds feasible, but I'll take a look into whether or not we can support this behavior in the .babylon and GLTF2 formats right now

Drigax commented 5 years ago

Currently we can't do that in .babylon, but that's alright as the format is somewhat intended to be human readable and verbose. There's no concept of accessors or indexing here so we'd have to make some changes to the format to support that type of behavior.

But with some wrangling of gltf2 files, we can totally support multiple meshes that share the same skeleton and skinning information. The format allows assigning multiple nodes to have different meshes with the same skeleton, and have the mesh primitives share skinning joint and weighting information.

I'll make the changes to our GLTF exporter to support this. Ideally this should only work for meshes that share the same skeleton and have identical vert/face count, skinning weights, and vertex and face ordering. I only really expect this optimization to work when the meshes are clones of each other with no modification other than object transforms.

dpalacio commented 5 years ago

My use case is for using user provided glTF2 models to manipulate and pose from rigid and articulated objects to human avatars in Godot. As it is right now, when the posed entity is broken in different meshes I get multiple copies of the same subsets of the skeletons. It can get unwieldy in some cases to manage.

As you make it sound it looks like this doesn't help me in any case. And I'm not sure it helps anyone else either.

Sorry about this, but I feel as I may have jumped the gun on reporting this issue. I'm new to 3D engine programming and working alone in this project.

sebavan commented 5 years ago

Fixed by #559

Drigax commented 5 years ago

Just to follow up, sounds like rather than shared skinning you want animation retargeting between exported skeletons.

There's a bit of a vagueness between how the spec defines skinning matrixes in GLTF meshes, GLTF skins, GLTF skeletons, and how engines like Godot and Babylon implement and expose them to the user. currently we already share skeleton data (joint hierarchy) between multiple GLTF skins, but i believe engines implement multiple GLTF skins that share the same skeleton as unique skeletons.

But in order to support your usecase (say we have a character with multiple switchable clothing items all rigged to the same skeleton, and want to share animation) we should be able to realize that they share the same skeleton, and calculate their pose deform using their unique skinning matrixes, and bind pose. But currently I don't really have plans to support this yet.

I do like that people are running into this usecase though, and hopefully we can amend the spec to support this. It'll make GLTF so much more friendly for game developers.