Moguri / panda3d-gltf

glTF utilities for Panda3D
BSD 3-Clause "New" or "Revised" License
81 stars 19 forks source link

Vertex skinning is not performed on all vertices #99

Closed el-dee closed 3 years ago

el-dee commented 3 years ago

The glTF sample 'Simple Skin' (https://github.com/KhronosGroup/glTF-Sample-Models/blob/master/2.0/SimpleSkin) is not animated correctly. Some vertices are not modified at all, contrary to what is expected.

Here is a snapshot from gltf-viewer :

Simple Skin

Instead we should have something like this :

rdb commented 3 years ago

I'm looking into it, I suspect an issue reading out the joint indices, since some of them looking pretty funky, like referencing the same joint twice.

rdb commented 3 years ago

It looks like panda3d-gltf currently doesn't support a byteStride that isn't equal to the size of the component. In the gltf file, the (uint32) index column is only 2 wide (meaning 8 bytes) but it is padded to 16 bytes.

It also looks like the transform indices are being imported as C_other instead of C_index, this is an oversight, but likely harmless.

rdb commented 3 years ago

Padded columns are now handled correctly, and the model animates properly now, though it would be great if you could test this on a few models to make sure I haven't broken anything.

I didn't touch the is_interleaved case—it looks like that case makes a lot of potentially faulty assumptions about the vertex data layout, but that's out of scope for this issue.

el-dee commented 3 years ago

Padded columns are now handled correctly, and the model animates properly now, though it would be great if you could test this on a few models to make sure I haven't broken anything.

I tested with several models with animation and skinning, they all behave correctly.

I didn't touch the is_interleaved case—it looks like that case makes a lot of potentially faulty assumptions about the vertex data layout, but that's out of scope for this issue.

Out of curiosity, I tested the BoxInterleaved sample from Khronos, the vertex color and normals of some faces look weird. I will test a bit more and, if confirmed, open an issue.