Skip to content

Render: Propagate the active state of viewlayer node to align with the one from file output node#273

Open
moonyuet wants to merge 20 commits intodevelopfrom
enhancement/YN-0433--Render-only-relevant-view-layers-for-enabled-compositor-output-file-nodes
Open

Render: Propagate the active state of viewlayer node to align with the one from file output node#273
moonyuet wants to merge 20 commits intodevelopfrom
enhancement/YN-0433--Render-only-relevant-view-layers-for-enabled-compositor-output-file-nodes

Conversation

@moonyuet
Copy link
Member

@moonyuet moonyuet commented Mar 12, 2026

Changelog Description

This PR is to propagate the active state of viewlayer node to align with the one from file output node. User can enable/disable file output node, it would also disable the relevant viewlayer nodes which are part of the input connections to it.

Resolve #243

Additional review information

n/a

Testing notes:

  1. Create Render with view layer
  2. mute the file output node
  3. View layer node should be muted also.
  4. Publish the render would not include the muted node.

@moonyuet moonyuet requested a review from LiborBatek March 12, 2026 13:14
@moonyuet moonyuet self-assigned this Mar 12, 2026
@moonyuet moonyuet added type: enhancement Improvement of existing functionality or minor addition sponsored This is directly sponsored by a client or community member labels Mar 12, 2026
Copy link
Member

@LiborBatek LiborBatek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It correctly propagates the selected ViewLayer from the publish instance (in metadata.json) and ignores the unselected one which is correct behaviour.

However for some reason the rendered files end up in different staging folders than expected (marked green vs red incorrect folders on the screenshot) once moved the publish job finnishes as it has all the expected files in correct location.

Image

Im also enclosing the publish report and metadata.json for your evaluation:

b3d-publish-report-260312-16-45.json.txt

renderLightingMain_metadata.json.txt

comp_node = instance.transient_data["instance_node"]
viewlayer_nodes = lib.get_viewlayer_nodes(comp_node)
if not viewlayer_nodes:
cls.log.warning("No view layer nodes found - returning empty items")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't really think this should be a warning. It's not that problematic, right?

Comment on lines +386 to +392
for input_node in node.inputs:
for link in input_node.links:
if link.from_node.type == "R_LAYERS":
if link.from_node.layer in viewlayers:
if input_node.name == name:
return name
return ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should assume the compositor output file node is directly connected to a renderlayers node - it may be absolutely fine to have nodes in between them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But isn't the compositor node only rendering those viewlayers which are connected to that?

Comment on lines +365 to +366
for input_node in node.inputs:
for link in input_node.links:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not just assume the renderlayers node is directly connected to the compositor node - I think we should traverse upstream completely and get all R_LAYERS nodes that are upstream to be evaluated for this comp node to render, etc.

Copy link
Member Author

@moonyuet moonyuet Mar 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can improve the logic to check if the top parent of the trees is the viewlayers node.

# from ayon_blender.api import plugin


# class ValidateRenderlayerActive(plugin.BlenderInstancePlugin):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should likely be a ContextPlugin and consider all active render instances at once. The renderlayers that should be active for rendering should be the combined ones that are used somewhere as input to all enabled Compositor Output Nodes, etc.

Comment on lines +495 to +503
return [
EnumDef(
"viewlayers",
label="View Layers to be Rendered",
multiselection=True,
items=items,
tooltip="Selected view layers to include in the render",
)
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually something the user would 'select' per instance? Isn't the view layers that are relevant to a compositor file output node just the renderlayer nodes that are inputs to it in some way? I'm a bit confused here.

The way I understand:

  • Blender has view layers, the equivalent to renderlayers.
  • In Compositor, these are exposed through Renderlayer nodes which provide the outputs per View Layer.
  • We track Compositor Output File nodes on render submissions, just the files that this outputs.
  • To know which view layers need to be active, is just to find all view layers upstream from the Compositor File Output node to see which affect this output in any way. That's the instance.data["viewlayers"].

I'm a bit confused why it's an attribute def if the node graph itself defines it?

@moonyuet moonyuet requested review from BigRoy and LiborBatek March 13, 2026 08:40
@moonyuet
Copy link
Member Author

@BigRoy I have made some traverse functions to check on composite output node.

@moonyuet moonyuet requested a review from BigRoy March 13, 2026 09:42
@moonyuet moonyuet marked this pull request as ready for review March 13, 2026 14:56
…3--Render-only-relevant-view-layers-for-enabled-compositor-output-file-nodes
@moonyuet moonyuet changed the title Render: Viewlayer filtering support Render: Propagate the active state of viewlayer node to align with the one from file output node Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sponsored This is directly sponsored by a client or community member type: enhancement Improvement of existing functionality or minor addition

Projects

None yet

Development

Successfully merging this pull request may close these issues.

YN-0433: Render only relevant view layers for enabled compositor output file nodes

3 participants