Nodes: support node output visibility inferencing

Currently, only the visibility of input sockets can be changed dynamically based
on other menu inputs. However, under some circumstances, it can also be useful
to hide certain outputs. For example, the built-in Curve Arc primitive node does
that.

This patch adds support for automatic detection of unused outputs. How to detect
unused outputs is less straight forward compared to inputs. This patch uses the
rule that an output is unused if it always outputs a "fallback value" (typically
0) irrespective of the currently used inputs. If the output is independent of
all inputs, it stays visible though.

There is a new small utility node called "Enable Output". It replaces a value
with it's fallback value unless it is disabled. This simplifies setting up
unused outputs. In theory, a normal switch node can also be used, but that is
less usable and the user will have to hardcode the fallback value for each type
which is not something that is explicitly exposed yet.

Supporting dynamic output visibility is also a prerequisite for exposing some
menu node options as sockets (e.g. in the Arc node).

Pull Request: https://projects.blender.org/blender/blender/pulls/140856
This commit is contained in:
Jacques Lucke
2025-09-27 10:09:48 +02:00
parent db88381e75
commit b186e60759
16 changed files with 456 additions and 69 deletions

View File

@@ -62,6 +62,7 @@ class NODE_MT_compositor_node_output_base(node_add_menu.NodeMenu):
def draw(self, context):
layout = self.layout
self.node_operator(layout, "NodeEnableOutput")
self.node_operator(layout, "NodeGroupOutput")
self.node_operator(layout, "CompositorNodeViewer")
if context.space_data.node_tree_sub_type == 'SCENE':

View File

@@ -595,6 +595,7 @@ class NODE_MT_gn_output_base(node_add_menu.NodeMenu):
def draw(self, context):
layout = self.layout
self.node_operator(layout, "NodeEnableOutput")
self.node_operator(layout, "NodeGroupOutput")
self.node_operator(layout, "GeometryNodeViewer")
self.node_operator_with_searchable_enum(context, layout, "GeometryNodeWarning", "warning_type")