Search code examples
matrix3dgltf

Gltf: inversebindmatrice calculation?


Currently creating a gltf importer/exporter.

How are the inversebindmatrices calculated exactly? I need that info to modulate them in order to change some bone positions in my model.

Thanks


Solution

  • An inverseBindMatrix for a joint in glTF is the inverse of a 4x4 matrix describing the transform from glTF root model space to that particular joint's rest location. The rest location is where the joint naturally lies when in the "bind pose" when the joint is first bound to the unaltered raw mesh.

    At runtime, a client application will need to quickly calculate the delta between a joint's current transformation and the same joint's original "bind pose" transformation. That difference is what will be applied to the vertex position in the skinning shader. Doing so involves multiplying both the current joint transform and the inverse of the bind transform by the vertex position. This causes the vertex position to move from its original raw location to a new location, based on the difference between the two transforms.

    If a joint's rest / bind position is updated, store the inverse of that new transform as the inverseBindMatrix for that joint.

    For more details, see the glTF Skinning Tutorial.