Add full support for non-uniform scaling and/or shear

Non-uniform scaling is mildly supported by Babylon, but falls apart in the common case of reparenting a mesh. I think adding full support for non-uniform scaling includes adding shear to the fundamental transformations supported by Babylon, which currently only supports scale, rotation, and translation (with some support of an additional pivot and optional ordering of that pivot).

To be clear, non-uniform scaling is not strictly prohibited, but using non-uniform scaling leads to complications (usually “failures”) in reparenting a mesh, and when matrices with non-uniform scaling are decomposed.

Searching the forums for “non-uniform” reveals difficulty in modifying constructed meshes, gizmos, bones, and imported models. Although I can’t wrap my head around non-uniform scaling in the case of bones (does the distant bone itself change scale/shear during rotation?), I suspect gltf and blender both support non-uniform scaling. Modifying meshes from those tools can (reportedly) be difficult without using bakeCurrentTransformIntoVertices().

This feature may be a (very?) heavy lift, so this request is intended to assess community interest.

Much more information on this issue is available primarily in this post, but also in the entire thread, as well as a general search for “non-uniform”.

There is already a Feature Request for shear, but my request is a superset of that one, with additional detail regarding the issues that adding shear would hopefully resolve.

May I ask for clarification: will this enable us to get rid of the infamous gltf root node? For instance, will Havok Ragdoll work without setting the scene to right-handed, then?

I’m not sure. Left/right handed issue is related to negative scale, but I don’t know if that “issue” is just a result of non-uniform scale. I kind of doubt it.

1 Like

Following up on this after additional research, this seems to be a very common problem with 3d systems. Random links related to Unity and Autodesk:

https://www.autodesk.com/support/technical/article/caas/sfdcarticles/sfdcarticles/Non-uniform-scale-causes-rotation-issues-with-linked-geometry-in-3ds-Max.html

The problems in the links is specifically that child meshes distort when rotated when the parent has a non-uniform scale. The solution appears to be equivalent to “bake vertices.” This may workable in most cases.

If parent instances can be defined as uniformly scaled from an initial non-uniformly scaled “reference,” then the solution is to bake the initial non-uniform scale into the reference parent.

If the vertices of the parent need to remain unmodified, the solution may be to insert a transform node between parent and child with the inverse non-uniform scaling of the parent. This makes it more difficult to place the child relative to a specific point on the parent because the position of the child is no longer in the local space of the original parent. I think the workaround in that case is to assign position of the child with the desired position inverse transformed by the transformNode local matrix.

Does this indicate there is a use case for utility functions making this workaround easier to impement?

Maybe. But the best solution remains to bake the transform in that case. It is universally a problem (even in blender)

1 Like