SaschaWillems/Vulkan-glTF-PBR

Invalid Joint Indices/Broken Animation

Spirrwell opened this issue · 3 comments

Hello!

So I have no idea whether the problem is here, in tinygltf, or in Blender's exporter, so sorry.

But if you take say CesiumMan from the sample models repo and import him to Blender and re-export, the joint indices stored in Vertex::joint0 go way out of bounds and the animation dies horribly.
image

The console output is the Vertex::joint0 values.

Blender can re-import its own gltf models just fine and throwing them through a gltf validator doesn't give off any issues.

I don't know much about animation in general, tinygltf or the gltf spec, so I'm hoping somebody has some insight. I don't think I can figure this out.

I think I figured it out, sort of. Blender exports joints with componentType 5121 or "unsigned byte", but the code just seems to assume the joints are in uint16_t format: https://github.com/SaschaWillems/Vulkan-glTF-PBR/blob/master/base/VulkanglTFModel.cpp#L484

Changing it to uint8_t* fixes the joint indices being broken and the animation is normal for the Blender exported models.

However, I don't think this is the only problem. Because when I import the Blender exported version, the camera is off-center from the object.
image

I'll investigate some more, but I'd be a lot more comfortable if somebody who actually knows what they're doing fixed this.

Alright, I can't verify for sure, but I think the off-center issue may be Blender's fault. I noticed re-exporting cesium man is changing bone roll on one of the bones. But I've got joint indices/animation working fine now as far as I know.

So I guess I'll do a pull request. Sorry for potentially two messages at once. lol

Fixed with #48