Page MenuHome

Single-socket input/output nodes in node groups.
DraftPublic

Authored by Lukas Tönne (lukastoenne) on Jul 8 2021, 4:53 PM.
This is a draft revision that has not yet been submitted for review.

Details

Reviewers
None
Summary

Changes the default group input/output nodes in groups to show only
a single socket. This is more convenient for keeping connections short
and put parameters closer to where they are used inside a group.

For input nodes this is purely a UI feature: they can already be
duplicated and unused sockets can be hidden (ctrl+h). The patch only
makes this the default setup of input nodes by providing all inputs
separately in the "Add Node" menu.

For output nodes the situation requires some functional changes,
because outputs have to be unique.

The "virtual" extension socket on group input/output nodes is now
disabled by default, since it adds a lot of visual noise without saving
much work (see discussion in T68733). The feature can be enabled with
a per-node flag.

Todo:

  • Implement unique output handling across different node systems.

Diff Detail

Repository
rB Blender
Branch
node-group-single-socket-nodes
Build Status
Buildable 15696
Build 15696: arc lint + arc unit

Event Timeline

Notes on unique outputs:
The "active" output node is currently defined by the NODE_DO_OUTPUT flag. This is used in a lot of places:

  • Node systems (Compositor, Geometry nodes, Renderers)
  • Many operators use the node_connected_to_output function to trigger updates, previews, etc.
  • "Ungroup" operator uses it to decide which connections to keep

What changes the the NODE_DO_OUTPUT flag is mostly the ED_node_set_active method, which switches output to the active node. I.e. simple selection will change the active output. In addition the ntreeSetOutput also selects the active output, but to an arbitrary node (first in the list), which could be regarded as a fallback to ensure uniqueness.

It would be nice to replace this old system with a more reliable mapping using a direct pointers to the active outputs, similar to how the active object is set in a view layer. It's quite an extensive change, but i think node systems would benefit in the long run by increased reliability and simplified code. The assignment of "active output" would be not just a single node but list of sockets, one for each tree output. Doing this with flags would become quite complicated, even if each output node has only one socket.

Decided to restrict single-socket nodes to group inputs for the time being. The way outputs are disambiguated in node trees currently makes it difficult to split out the group output over multiple nodes. It would require some changes to the NODE_DO_OUTPUT flag as mentioned above.