From a given node tree, what is the most reliable way to get the end node being used for output, if any?
My current approach is to check for the correct output type for the tree (OUTPUT_MATERIAL
, OUTPUT_WORLD
...) and for is_active_output
:
nodes = node_tree.nodes
for n in nodes:
if n.type == 'OUTPUT_WORLD' and n.is_active_output:
return n
return None
However, I see no guarantee that there is only one node with is_active_output
(I can set this to True in multiple nodes).
The ShaderNodeTree has an active_input
field, but the value is -1.