glTF icon indicating copy to clipboard operation
glTF copied to clipboard

Clarify multi-node transform behavior with skew and shear

Open aaronfranke opened this issue 2 years ago • 2 comments

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:

  • What is the desired outcome of disallowing skewed/sheared matrices in glTF?
    • Is it to prevent skew/shear from happening? If so, what about the multi-node case?
    • Is it purely just to allow converting a node's local transform matrix to TRS? If so, why?
  • Is it allowed to create a skew/shear with multiple nodes like this?
    • If so, should it be discouraged to compose transforms like this in a way that creates skew/shear?
    • Should conformal transformations, where the only scale is uniform, be recommended for non-leaf nodes?
      • Things where non-uniform scale makes sense, like meshes, could be specified as leaf nodes.
        • However, skew/shear also makes sense with meshes, so that doesn't explain why skew/shear is disallowed.
  • If a glTF extension defines objects that cannot be skewed/sheared (as in the case with physics objects in most physics engines), or can't be non-uniformly scaled:
    • Is it acceptable for a glTF extension to impose additional restrictions on the glTF node transform, such that any files that create skew/shear are considered invalid?
    • Is it acceptable for a glTF extension to impose a conformal restriction so that the only allowed scale is uniform?

aaronfranke avatar Sep 16 '23 02:09 aaronfranke

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.

lexaknyazev avatar Sep 16 '23 08:09 lexaknyazev

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?

rotu avatar Oct 13 '24 02:10 rotu