Geometry Nodes: How to handle instances with shear? #85049

Closed
opened 2021-01-25 17:26:32 +01:00 by Jacques Lucke · 10 comments
Member

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 8b777ee6d6. 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".

skew.blend

2021-01-25 17-27-11.mp4


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.

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 8b777ee6d6. [P1909](https://archive.blender.org/developer/P1909.txt) 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](https://archive.blender.org/developer/P1909.txt) applied, you get the following result with shear is not supported. Note, in master this works fine currently, because the shear is "applied". [skew.blend](https://archive.blender.org/developer/F9597161/skew.blend) [2021-01-25 17-27-11.mp4](https://archive.blender.org/developer/F9597164/2021-01-25_17-27-11.mp4) -------- 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.
Author
Member

Added subscriber: @JacquesLucke

Added subscriber: @JacquesLucke
Author
Member

Added subscribers: @ZedDB, @brecht

Added subscribers: @ZedDB, @brecht
Jacques Lucke changed title from Geometry Nodes: How to handle instances with skew? to Geometry Nodes: How to handle instances with shear? 2021-01-25 17:37:14 +01:00

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.

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.

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.

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.
Author
Member

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.

@ZedDB Can you change how transforms of instances are stored in a separate patch, or should I do it?

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. @ZedDB Can you change how transforms of instances are stored in a separate patch, or should I do it?

I'll take care of it :)

I'll take care of it :)

This issue was referenced by abd6b1d7b2

This issue was referenced by abd6b1d7b281c85fce748e0535f1f769916cd9b3

Changed status from 'Needs Triage' to: 'Resolved'

Changed status from 'Needs Triage' to: 'Resolved'
Sebastian Parborg self-assigned this 2021-01-26 18:23:10 +01:00

This issue was referenced by 6157c45445

This issue was referenced by 6157c45445dceb0bceabb5b9ea80cd6eb60e04fc
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#85049
No description provided.