julienduroure / gltf2-blender-importer

Blender importer addon for glTF 2.0 files
68 stars 13 forks source link

Bone weights / vertex groups problem #18

Closed gildor2 closed 6 years ago

gildor2 commented 6 years ago

Hi,

I'm adding glTF 2.0 export to my tool, and using several tools for debugging, including your Blender addon. In general addon works well, however I've got into strange bugs with vertex group assignment with one of meshes (one of community members sent a mesh to me). I've tried with "release" version of addon and with version pulled from "master" branch, both have issue.

This is how mesh looks like after import: image

If I'm trying to move bones, mesh becomes cracked. Looking at vertex group assignment in "weight paint" mode displays red/blue colors randomly spread over the mesh. For example, how "b_C_Spine1" bone assignment appears: image

For testing, I've added code which "hacks" this bone, to verify if I'm shuffling vertices in some way. I'm assigning null normals to vertices which are bound to mentioned bone. Blender doesn't do anything with normals, however when loaded into Babylon.js Sandbow, mesh parts with null normals appears black:

image

To be sure that weighing is ok in model, I've added 0.1 offset to the bone's X, editing gltf file in text editor. Babylon.js displayed this:

image

So I can assume that weights are correct. Please take a look if you'll have time. I'm attaching the gltf file - there are 2 .gltf files inside which are sharing the same .bin file - one model is original, another with bone offset. corrupt_weights.zip

Thanks, Konstantin

julienduroure commented 6 years ago

Thanks for your bug report. I can confirm the issue. Still have to check if this is a bug from my addon, or if there are some bad data in gltf. Will check it in following weeks (summer break here)

julienduroure commented 6 years ago

First check : I opened your file in https://gltf-viewer.donmccurdy.com/ that give me a list of 16 errors on your file ...

gildor2 commented 6 years ago

Thank you for checking. Three.js can't display skeletal meshes made with my tool anyway, it has some strange problems with scale - mesh appears as point. Babylon.js and Cesium doesn't have this issue.

I'm aware of "problems" reported by glTF validator: http://github.khronos.org/glTF-Validator/ Half of "errors" are "mesh has texture coordinates but no textured materials", another half - "computed min/max values doesn't match values in json, they differs in 1e-8" etc. Both kinds of errors are stupid: 1) mesh is not required to have textures, but texture coordinates are must for many renderers 2) printing binary float value to a text file loses precision somewhere, it is expectable - even using float/double values or different FPU rounding mode will cause differences.

julienduroure commented 6 years ago

Hello, VertexGroups issues are now fixed in master :)

gildor2 commented 6 years ago

Cool, thanks!