Page MenuHome

Geometry Nodes: Add a toggle to use attributes as input values
ClosedPublic

Authored by Hans Goudey (HooglyBoogly) on Sep 15 2021, 7:48 PM.

Details

Summary

This adds a toggle to node group inputs exposed in the modifier to use
an attribute instead of a single value. When the toggle is pressed, the
button switches to a text button to choose an attribute name. Attribute
search isn't implemented here yet.

One confusing thing is that some values can't be driven by attributes
at all, like the size of a primitive node. In that case, we should have
a node warning, but that will be separate since it's more general.
We can also have an option to turn off this toggle in node group
input settings.

The two new properties for each input are stored with the same name
as the value, but with "_use_attribute" and "_attribute_name"`
suffixes. The properties are not added for socket types that don't
support attribute input, like object sockets.

Diff Detail

Repository
rB Blender
Branch
geometry-nodes-input-attribute-toggle (branched from master)
Build Status
Buildable 17034
Build 17034: arc lint + arc unit

Event Timeline

Hans Goudey (HooglyBoogly) requested review of this revision.Sep 15 2021, 7:48 PM
Hans Goudey (HooglyBoogly) created this revision.

Looks fine. I don't really have a better idea that does not involve reinventing id properties just for this modifier. One thing I wonder is whether there is a risk of name collisions with the socket identifiers.

source/blender/editors/object/object_modifier.c
3297

no newline

source/blender/modifiers/intern/MOD_nodes.cc
304

Should include SOCK_INT?

This revision is now accepted and ready to land.Sep 16 2021, 1:19 PM

One thing I wonder is whether there is a risk of name collisions with the socket identifiers.

I'm not sure I understand this one, since the socket identifiers will always be unique, and they're always defined automatically like "input_7" IIRC.

Hans Goudey (HooglyBoogly) marked 2 inline comments as done.Sep 17 2021, 2:07 AM