This document proposes a way to generalize what values a node group input can have by default. Note that this proposal still has some weak points. However, I was referencing this node in discussions every now and then, so it’s better to have the proposal in public.
Current Limitations
There are various limitations for what default inputs for a node group can be:
- For geometry, matrix (and later bundle and closure) sockets, there is no way to specify a default value.
- For some primitive socket types (e.g. float and boolean) one can only specify a single value, but the default can’t be e.g. a field.
- For some primitive types (e.g. integer and vector) one can have a single value as default, or choose from a hard-coded set of fields, including e.g. the position, normal and index field.
It isn’t possible to use arbitrary values as defaults for any socket type.
Proposal
The proposed solution is to introduce a new Group Defaults node which is conceptually on the same level as the Group Input and Group Output node. It does not do any operations on it’s own, but only helps building the interface of the node group.
There can only be a single (active) Group Defaults node. The node has an input socket for every input of the node group. The node shows the default values for all inputs.
The new part is that one can connect arbitrary other nodes to the Group Defaults node to specify more complex defaults. For example, to use the position attribute as default for the Vector input, one can do this:
Another common example would be to use a noise texture as default. For example a simple Displace node group could be build as shown in the next image. It’s more convenient than before because it uses the noise texture by default, but can still be customized by passing in a different noise.
In theory, the Group Defaults node could also depend on the Group Input node (as long as the default does not depend on itself). Supporting this, might be interesting at some point, but for now it’s probably not worth the implementation complexity.
Problems
While specifying the default values like this works well, things are a bit more complex on the caller site when we start to rely on more complex defaults more heavily. Currently there are three different callers: group nodes, the Geometry Nodes modifier, and the Node Tools operator.
Currently, when creating a Group node or modifier, the initial value will generally be taken from the underlying group, but then the connection to the group is lost. So when the default value changes later on, the value in the group node or modifier does not update.
The situations is different when using the Group Defaults node. In this case, the group node or modifier will automatically get the new default if it changes. While this might be nice in some cases, it’s a bit bad to be inconsistent.
Another tricky situation is when a socket that had a single value default before, suddenly gets a field as default. The question is, how should that change existing usages of the group if they have or have not yet changed the single value default?
Propagating default values to the inputs of the parent node group is also more tricky. Currently, when you hit ctrl+G on a group node, the default values of that new group will be the same as those of the inner group. It’s not obvious how that would work when the Group Defaults node is used in the inner group.