KhronosGroup / glTF

glTF – Runtime 3D Asset Delivery
Other
7.18k stars 1.14k forks source link

Clarify multi-node transform behavior with skew and shear #2328

Open aaronfranke opened 1 year ago

aaronfranke commented 1 year ago

https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#transformations

The glTF specification section for node transformations contains this implementation note:

Implementation Note

Transformation matrices cannot skew or shear.

However, there is something left unclear. This seems to indicate that the glTF spec does not desire for skewed and sheared transformation matrices to exist in the file. However, it is possible to create a skew/shear by having a parent node with a non-uniform scale, and a child node with a rotation. There is a way to ensure skew/shear cannot be created by composition, by ensuring all transformation matrices are conformal, or by disallowing this configuration of a scaled parent with a rotated child.

So, questions:

lexaknyazev commented 1 year ago

What is the desired outcome of disallowing skewed/sheared matrices in glTF?

To allow converting a node's local transform matrix to TRS because some engines at the time of writing were accepting only TRS properties for node transforms. Initially, the node.matrix property was intended for storing precomputed TRS transforms for static nodes, hence the restriction on targeting such nodes by animations.

Is it allowed to create a skew/shear with multiple nodes like this?

Technically yes. This case has never been addressed explicitly.

Is it acceptable for a glTF extension ...

This may be tricky to enforce considering nested transforms and animations, e.g., if skewing or shearing appear only between keyframes.

rotu commented 2 weeks ago

The TRS restriction has the unfortunate consequence that you can’t just “unparent” an arbitrary node and keep the same transform because that might be an illegal matrix.

Should conformal transformations, where the only scale is uniform, be recommended for non-leaf nodes?

I like the idea of restricting non-leaf nodes to conformal transforms. But even better, I like the idea of lifting the TRS constraint.

This may be tricky to enforce considering nested transforms and animations, e.g., if skewing or shearing appear only between keyframes.

Fortunately (and unlike TRS), the composition of conformal transforms is conformal. So I think it’s enough to check that no keyframe has non-uniform scaling. Am I missing something?