Attribute Sockets for simplified attribute workflow #89067

Closed
opened 2021-06-11 19:51:08 +02:00 by Lukas Tönne · 3 comments
Member

DISCLAIMER: This is an unofficial proposal and not planned work. As such it has been moved to devtalk.blender.org to reflect its status.

A new socket type (or multiple types, see (Socket types) is added, which represents an attribute reference. This works much like the current string references, but has some additional features that greatly simplify workflow.

attribute_sockets.jpg

An attribute can be a node output, rather than an input that has to be named. Output attributes are named automatically. To the user the attribute is presented as unnamed, its internal generated name is largely irrelevant and only needs to be chosen such that it is unique and does not collide with user-defined attribute names.

unnamed_outputs.jpg

An unnamed attribute is automatically removed from the geometry when all nodes accessing it have been executed. The user does not need to remove such attributes explicitly. If an attribute is supposed to be persistent outside the node tree it must be stored with an "Attribute Store" node, giving it an explicit user-defined name (see Storing an attribute).

implicit_removal.jpg

Attributes can be loaded from existing geometry layers with an "Attribute Load" node. This simply looks for an existing attribute name on the input geometry and initializes the attribute reference.

load_attribute.jpg

Attribute references associate a data type as well as an optional domain type with the attribute name. This should be handled with some flexibility, doing conversions between attribute types as much as possible, just like current string references do. Domain can be set to "automatic" to chose whichever domain type matches best in a given context.

Why is this needed?

Geometry nodes in their current state are powerful, but also very difficult to use beyond simple setups. The way attributes are referenced with explicit names adds a lot of visual noise and mental overhead:

  1. Temporary attributes still require explicit naming. The user has to keep track of which names are used for which attributes, and where name collisions might occur. temp_attribute_names.jpg
  2. Temporary attributes have to be deleted explicitly. This can also cause side effects if an attribute is supposed to be internal and transient, but an attribute with the same name is used inside a group. delete_temp_attributes.jpg
  3. Attribute changes are not reflected by node sockets.
 For any other data type a socket represents a particular state of the value. That could be a simple number output from a math node, or a geometry set that is passed between modifiers. Attributes on the other hand are always referred to by the same name and the user has to keep track of what the state is at each point in the node tree. {F10167254}
  1. All attributes become input sockets: The natural flow in nodes from inputs to outputs does not work, because there are no "unnamed" attributes.
 The suggested implementation would generate unique disposable names for such output attributes which only become "real" persistent attributes once stored by the user deliberately (see [[#storing-an-attribute-to-geometry|Storing an attribute]]). {F10167260}
  1. Operations that work element-wise (math nodes in particular) have to be specialized for accepting singular values.
 This wouldn't be necessary if the attribute inputs would just accept singular values and automatically treat them as "filled" attributes.{F10167262}

With the proposed changes, attributes would behave much more like conventional values in a node tree. This will reduce the mental overhead when constructing large and complex node trees. Attribute output sockets will keep connections shorter and localized. Broadcasting will remove the need to specify for each input whether it accepts singular values or attributes.

How does this fit in with the Attribute Processor?

The attribute processor node (D11547]) will make a lot of math operations simpler and remove the complexity of string attribute references from most low-level computations.

However, modifier-like operations still have to be performed outside of the attribute node trees, e.g.

  • Boolean operations
  • Joining Geometry
  • Subdivision
  • Instancing

Passing attribute references between such higher-level nodes still relies on string references, input-heavy nodes, and explicit singular vs. attribute input switching. The changes proposed in this document could still have significant impact even when most of the low-level math is moved into attribute processor nodes.

Attribute socket types and broadcasting

Multiple typed attribute sockets for float/int/vector/color/etc. values exist on the UI level. Internally these are largely handled the same way. Different UI socket types are a convenience feature to allow default input values and give some indication of what attribute a node expects. A generic attribute socket could be used for nodes such as "Reroute".

attribute_types.jpg

Attributes support broadcasting to simplify nodes that support both singular values and attributes (e.g. Attribute Math). A singular value can be connected to an attribute input, which is equivalent to an "Attribute Fill" node (see examples). Connecting an attribute to a singular value input is NOT allowed. In the future specialized nodes might be available for this purpose, but that is out of scope of this proposal (e.g. Attribute Sum/Average/MinMax).

broadcasting.jpg

The advantage of broadcasting is that specifying if an input is a singular value or an attribute is no longer necessary. A singular value can be connected directly to an attribute and will be implicitly broadcasted. If an attribute input is unconnected it will broadcast the default input value.

Future optimization: propagating input modes

The way geometry nodes evaluate does not leave much room for constant-folding right now. With broadcasting it would be possible, in principle, to reduce many nodes (like math nodes or the new attribute processor) to a singular value computation automatically if all inputs are singular values.

Determining if a node can be "constant-folded" depends on whether all inputs are singular values, which in turn depends on their source nodes, etc. (Some nodes may generate full attribute layers regardless of input modes).

Such optimization is outside the scope of this design document, but should be part of future work.

Equivalent Node Setups

The proposed system should not require fundamental changes to the execution of nodes as they are now. Below are listed a number of node setups in the proposed attribute style together with their equivalents in the current string-based system.

Description Old String Sockets New Attribute Sockets
Loading an attribute with explicit lookup old_load_attribute.jpg new_load_attribute.jpg
Store an attribute to geometry and make it persistent old_store_attribute.jpg new_store_attribute.jpg
Broadcasting to an attribute input old_broadcast.jpg new_broadcast.jpg
Use an unnamed output old_unnamed_output.jpg new_unnamed_output.jpg
> **DISCLAIMER**: This is an unofficial proposal and not planned work. As such it has been moved to [devtalk.blender.org](https://devtalk.blender.org/t/proposal-for-attribute-socket-types/19177) to reflect its status. A new socket type (or multiple types, see ([Socket types](#attribute-socket-types-and-broadcasting)) is added, which represents an attribute reference. This works much like the current string references, but has some additional features that greatly simplify workflow. ![attribute_sockets.jpg](https://archive.blender.org/developer/F10167234/attribute_sockets.jpg) An attribute can be a node output, rather than an input that has to be named. Output attributes are named *automatically*. To the user the attribute is presented as *unnamed*, its internal generated name is largely irrelevant and only needs to be chosen such that it is unique and does not collide with user-defined attribute names. ![unnamed_outputs.jpg](https://archive.blender.org/developer/F10167236/unnamed_outputs.jpg) An unnamed attribute is automatically removed from the geometry when all nodes accessing it have been executed. The user does not need to remove such attributes explicitly. If an attribute is supposed to be persistent outside the node tree it must be *stored* with an "Attribute Store" node, giving it an explicit user-defined name (see [Storing an attribute](#storing-an-attribute-to-geometry)). ![implicit_removal.jpg](https://archive.blender.org/developer/F10167238/implicit_removal.jpg) Attributes can be *loaded* from existing geometry layers with an "Attribute Load" node. This simply looks for an existing attribute name on the input geometry and initializes the attribute reference. ![load_attribute.jpg](https://archive.blender.org/developer/F10167240/load_attribute.jpg) Attribute references associate a data type as well as an optional domain type with the attribute name. This should be handled with some flexibility, doing conversions between attribute types as much as possible, just like current string references do. Domain can be set to "automatic" to chose whichever domain type matches best in a given context. ## Why is this needed? Geometry nodes in their current state are powerful, but also very difficult to use beyond simple setups. The way attributes are referenced with explicit names adds a lot of visual noise and mental overhead: 1. Temporary attributes still require explicit naming. The user has to keep track of which names are used for which attributes, and where name collisions might occur. ![temp_attribute_names.jpg](https://archive.blender.org/developer/F10167247/temp_attribute_names.jpg) 1. Temporary attributes have to be deleted explicitly. This can also cause side effects if an attribute is supposed to be internal and transient, but an attribute with the same name is used inside a group. ![delete_temp_attributes.jpg](https://archive.blender.org/developer/F10167250/delete_temp_attributes.jpg) 1. Attribute changes are not reflected by node sockets. ``` For any other data type a socket represents a particular state of the value. That could be a simple number output from a math node, or a geometry set that is passed between modifiers. Attributes on the other hand are always referred to by the same name and the user has to keep track of what the state is at each point in the node tree. {F10167254} ``` 1. All attributes become input sockets: The natural flow in nodes from inputs to outputs does not work, because there are no "unnamed" attributes. ``` The suggested implementation would generate unique disposable names for such output attributes which only become "real" persistent attributes once stored by the user deliberately (see [[#storing-an-attribute-to-geometry|Storing an attribute]]). {F10167260} ``` 1. Operations that work element-wise (math nodes in particular) have to be specialized for accepting singular values. ``` This wouldn't be necessary if the attribute inputs would just accept singular values and automatically treat them as "filled" attributes.{F10167262} ``` With the proposed changes, attributes would behave much more like conventional values in a node tree. This will reduce the mental overhead when constructing large and complex node trees. Attribute output sockets will keep connections shorter and localized. [Broadcasting](#attribute-socket-types-and-broadcasting) will remove the need to specify for each input whether it accepts singular values or attributes. ## How does this fit in with the Attribute Processor? The attribute processor node ([D11547](https://archive.blender.org/developer/D11547)]) will make a lot of math operations simpler and remove the complexity of string attribute references from most low-level computations. However, modifier-like operations still have to be performed outside of the attribute node trees, e.g. * Boolean operations * Joining Geometry * Subdivision * Instancing Passing attribute references between such higher-level nodes still relies on string references, input-heavy nodes, and explicit singular vs. attribute input switching. The changes proposed in this document could still have significant impact even when most of the low-level math is moved into attribute processor nodes. ## Attribute socket types and broadcasting Multiple *typed* attribute sockets for float/int/vector/color/etc. values exist on the UI level. Internally these are largely handled the same way. Different UI socket types are a convenience feature to allow default input values and give some indication of what attribute a node expects. A generic attribute socket could be used for nodes such as "Reroute". ![attribute_types.jpg](https://archive.blender.org/developer/F10167264/attribute_types.jpg) Attributes support broadcasting to simplify nodes that support both singular values and attributes (e.g. Attribute Math). A singular value can be connected to an attribute input, which is equivalent to an "Attribute Fill" node (see [examples](#equivalent-node-setups)). Connecting an attribute to a singular value input is **NOT** allowed. In the future specialized nodes might be available for this purpose, but that is out of scope of this proposal (e.g. Attribute Sum/Average/MinMax). ![broadcasting.jpg](https://archive.blender.org/developer/F10167269/broadcasting.jpg) The advantage of broadcasting is that specifying if an input is a singular value or an attribute is no longer necessary. A singular value can be connected directly to an attribute and will be implicitly broadcasted. If an attribute input is unconnected it will broadcast the default input value. ### Future optimization: propagating input modes The way geometry nodes evaluate does not leave much room for constant-folding right now. With broadcasting it would be possible, in principle, to reduce many nodes (like math nodes or the new [attribute processor](#how-does-this-play-with-the-attribute-processor)) to a singular value computation automatically if all inputs are singular values. Determining if a node can be "constant-folded" depends on whether all inputs are singular values, which in turn depends on their source nodes, etc. (Some nodes may generate full attribute layers regardless of input modes). Such optimization is outside the scope of this design document, but should be part of future work. ## Equivalent Node Setups The proposed system should **not** require fundamental changes to the execution of nodes as they are now. Below are listed a number of node setups in the proposed attribute style together with their equivalents in the current string-based system. |Description|Old String Sockets|New Attribute Sockets| |---|---|---| |Loading an attribute with explicit lookup|![old_load_attribute.jpg](https://archive.blender.org/developer/F10167271/old_load_attribute.jpg)|![new_load_attribute.jpg](https://archive.blender.org/developer/F10167273/new_load_attribute.jpg)| |Store an attribute to geometry and make it persistent|![old_store_attribute.jpg](https://archive.blender.org/developer/F10167275/old_store_attribute.jpg)|![new_store_attribute.jpg](https://archive.blender.org/developer/F10167277/new_store_attribute.jpg)| |Broadcasting to an attribute input|![old_broadcast.jpg](https://archive.blender.org/developer/F10167279/old_broadcast.jpg)|![new_broadcast.jpg](https://archive.blender.org/developer/F10167281/new_broadcast.jpg)| |Use an unnamed output|![old_unnamed_output.jpg](https://archive.blender.org/developer/F10167283/old_unnamed_output.jpg)|![new_unnamed_output.jpg](https://archive.blender.org/developer/F10167285/new_unnamed_output.jpg)|
Author
Member

Added subscriber: @LukasTonne

Added subscriber: @LukasTonne
Author
Member

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

Changed status from 'Needs Triage' to: 'Archived'
Author
Member

I'm moving this proposal to the devtalk.blender.org to avoid the impression that this is an official design or planned work.

I'm moving this proposal to the devtalk.blender.org to avoid the impression that this is an official design or planned work.
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
1 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#89067
No description provided.