Page MenuHome

Geometry Nodes: Add Invert option to the Transform node
AbandonedPublic

Authored by Leon Schittek (lone_noel) on Feb 8 2021, 12:26 AM.

Details

Summary

This patch adds an Invert option to the Geometry Nodes’ Transform node.

Problem
When transforming the geometry with the Transform node the transformations (scaling, rotating and translating) are applied in a set order. This means, doing another transform with inverted inputs will not necessarily reverse the transformation.
To invert the transform one has to undo all the steps of the original transformation in reverse order. This is not obvious and can be a little tedious. An invert option simplifies this process a lot.

Use Case
When building node groups it’s easy to make implicit assumptions about positions and orientations.
Here’s an example of a primitive snow effect. I marked all the places where it's relying on the snow falling straight down with a red node frame.

With the Invert option you can circumvent this limitation of the node group by doing the transformation from outside the node group (e.g. to make it look like there is some wind and the snow sticks to the front of the sign) without actually having to modify the snow effect itself.

Diff Detail

Repository
rB Blender
Branch
geometry-nodes-transform-node-add-inverse (branched from master)
Build Status
Buildable 12955
Build 12955: arc lint + arc unit

Event Timeline

Leon Schittek (lone_noel) requested review of this revision.Feb 8 2021, 12:26 AM
Leon Schittek (lone_noel) edited the summary of this revision. (Show Details)

Thanks for your first patch!

I don't have a strong opinion on whether we want this option yet. Still I added some comments inline.

Can you make an example file that shows where this option would be useful in practice?

source/blender/nodes/geometry/nodes/node_geo_transform.cc
80

Please use clang-format to format the code according to our code style rules.

https://wiki.blender.org/wiki/Tools/ClangFormat

98

Seems like you could just store -translation in a new variable here and use that in the loop.

Jacques Lucke (JacquesLucke) requested changes to this revision.Feb 8 2021, 1:16 PM
This revision now requires changes to proceed.Feb 8 2021, 1:16 PM
Leon Schittek (lone_noel) updated this revision to Diff 33746.EditedFeb 9 2021, 10:05 AM
  • address requested changes
  • update location of layout and draw code according to D10352
Leon Schittek (lone_noel) marked 2 inline comments as done.Feb 9 2021, 11:15 AM

Thanks for having a look at it!

I started looking into this, because I wanted to control attribute falloffs with an empty. This isn't easily doable currently, if you also want to account for orientation. To be honest though, porting the Rotate Vector node and the Mapping node from the shader, would be the better way to approach that issue, but this turned out to be an easier fix for me.

In general, though, the use case for this is, that it easily allows working around any issues that might arise from functions depending on some kind of hard defined position or orientation (e.g. simulations that depend on gravity pointing in the z-direction).

This will surely be a necessary workaround for people using pre-made node groups at some point, but I can see this not being a pressing issue at this moment.

I made a file showcasing the use case, where you can manipulate a attribute falloff in z-direction with an empty:

Leon Schittek (lone_noel) retitled this revision from Geometry Nodes: Add Invert option to the Transform node. to Geometry Nodes: Add Invert option to the Transform node.Feb 9 2021, 1:52 PM
Leon Schittek (lone_noel) edited the summary of this revision. (Show Details)

Given the examples and how it can drastically simplify node trees for users, I think this is a good option to add.

Thanks for the examples @Leon Schittek (lone_noel)!

I think this could be a boolean socket, at the bottom of the node.

Personally, I'm still not convinced that this option should exist in the Transform node. We don't really want users to do what you did in your example with the falloff. We need a more artist friendly solution for that.
I do understand that sometimes inverting can be useful, so I'm not dismissing the patch in general. I wonder if it makes sense to have Invert Transforms as a separate node or so, not sure.

Leon Schittek (lone_noel) edited the summary of this revision. (Show Details)
  • Change Invert option to boolean socket.
  • Revert previous changes that aren't necessary now that the invert option is a socket.

@Hans Goudey (HooglyBoogly) Having the Invert option as a socket is much better and actually simplifies the implementation a lot.

Old:


New:

@Jacques Lucke (JacquesLucke) I agree that the falloff example shows a really bad workflow. Porting the Mapping node and the Vector Rotate node to Geometry Nodes will solve those cases much more elegantly (a first shot at implementing the Vector Rotate node in D10410 for reference).

After further thought about the invert option, I dislike that it’s mostly facilitating a workaround, rather than bringing an actual solution. While I know from experience that these kind of workarounds certainly will be necessary at some point, I guess it's preferable to first think about the tools necessary to avoid them in the first place.

For example: What's been missing to make the orientation of the snow example in the summary easily customizable is the ability to do rotations on arbitrary vector attributes - basically nodes that mirror the functionality of the Transform Node and the Vector Rotate node for attributes.

So it's probably better to wait with further considerations of this patch until the tools to modify attributes are a more complete.

I agree with what Leon said above, and actually those solutions are already implemented, so I think the need for this is mostly gone.

In the future, this could also be solved by adding transform matrices as a data type, where there could be an "Invert" node.

So I'm going to close this patch. Regardless, thanks for the contribution Leon.