Page MenuHome

Geometry Nodes: How to handle instances with shear?
Closed, ResolvedPublic

Description

It would be good if the Object Info and Collection Info nodes could output instances of the referenced objects/collections, because it could significantly improve performance and reduce memory usage.
The nodes have an "Original" and "Relative" mode that has been introduced in rB8b777ee6d69d: Geometry Nodes - Object Info: option to apply obj transform to the geometry. P1909 is a small patch that changes the Object Info node so that it outputs instances.

The problem is that the "Relative" mode can result in sheared instances if the objects have non-uniform scaling and are rotated differently.
Having shear is not a problem by itself. However, afaik Blender usually expects that object matrices can be decomposed into location, rotation and scale.

We have two options:

  1. If we allow sheared instances in geometry nodes, we might have to update many other places to support sheared objects or we would have to "apply" the shear, resulting in higher memory usage and performance loss.
  2. If we do not allow sheared instances, the "Relative" mode in the Object/Collection Info node does not work correctly, when the object with the modifier has non-uniform scaling and is rotated differently than the instanced object.

With P1909 applied, you get the following result with shear is not supported. Note, in master this works fine currently, because the shear is "applied".


My current personal opinion is that the second option is more practical. Non uniform scaling is discouraged in some other contexts as well afaik.

I'd appreciate some feedback on the topic.

Event Timeline

Jacques Lucke (JacquesLucke) renamed this task from Geometry Nodes: How to handle instances with skew? to Geometry Nodes: How to handle instances with shear?.Jan 25 2021, 5:37 PM
Jacques Lucke (JacquesLucke) updated the task description. (Show Details)

Shear/skew in Blender object matrices is allowed, and should generally work. Parenting and constraints can already generate it. Though it's not the most well tested code path, did you find significant issues with it?

Personally I think using shear/skew (and non-uniform scale for that matter) on object level is bad practice for artists, and comes with subtle problems even when it's handled correctly by the software. So ideally the workflow makes it hard to end up with such things. But if the parent has non-uniform scale, then so be it.

The following is relavant for the Collection Info node. Not 100% sure if this also applies for the object info node:

The issue is that the the geometry nodes InstancesComponent data type/class saves the transform matrix of each instance in a positions, rotations, and scales array.
When we instance objects we transform them in to the modifier object space.

In "relative mode" we don't want this transformation, so we calculate the inverse matrix of the modifier object and store it in the pos, rot, scale data array.
If the inverse matrix contains shear, then this will be lost when storing it this way.

My suggestion is to not use pos,rot, and scale and instead just have one 4x4 matrix array. This way we do not have any issues with storing shear.
I don't think this will be much slower, but I could be wrong of course.

I was kind of expecting instance transforms to be stored as a matrix already. It should also make generating duplis a little faster, which is done repeatedly for non-animated outputs whereas generating the instance is only done once. The only downside I think is memory usage, 16 floats instead of 9. It could be reduced to 12 since the last row can be assumed to be 0,0,0,1.

Thanks for the feedback.

I'm fine with storing instance transforms as matrices then. For simplicity, I think we should store 4x4 matrices for now. For rendering we separately allocate more memory for every instance anyway. The savings here wouldn't be very significant compares to that.
We can think about storing 3x4 matrices when we can render many instances more efficiently.

@Sebastian Parborg (zeddb) Can you change how transforms of instances are stored in a separate patch, or should I do it?