Skip to content

Commit

Permalink
Merge pull request #67 from ynput/enhancement/collect-render-layer-na…
Browse files Browse the repository at this point in the history
…me-from-rop

Render layer name collector
  • Loading branch information
antirotor authored Sep 20, 2024
2 parents b32f446 + 22fda79 commit 68c8892
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import os
import warnings
import pyblish.api
from ayon_core.pipeline.create import get_product_name
from ayon_core.pipeline.farm.patterning import match_aov_pattern
from ayon_core.pipeline.farm.pyblish_functions import (
get_product_name_and_group_from_template,
_get_legacy_product_name_and_group
)
from ayon_core.pipeline.publish import (
get_plugin_settings,
apply_plugin_settings_automatically,
Expand Down Expand Up @@ -75,14 +79,6 @@ def process(self, instance):
expected_files = next(iter(instance.data["expectedFiles"]), {})

product_type = "render" # is always render
product_group = get_product_name(
context.data["projectName"],
context.data["taskEntity"]["name"],
context.data["taskEntity"]["taskType"],
context.data["hostName"],
product_type,
instance.data["productName"]
)

# NOTE: The assumption that the output image's colorspace is the
# scene linear role may be incorrect. Certain renderers, like
Expand All @@ -92,11 +88,20 @@ def process(self, instance):
# majority of production scenarios these would not be overridden.
# TODO: Support renderer-specific explicit colorspace overrides
colorspace = get_scene_linear_colorspace()
for aov_name, aov_filepaths in expected_files.items():
product_name = product_group

for aov_name, aov_filepaths in expected_files.items():
dynamic_data = {}
if aov_name:
product_name = "{}_{}".format(product_name, aov_name)
dynamic_data["aov"] = aov_name

if instance.data.get("renderlayer"):
dynamic_data["renderlayer"] = instance.data["renderlayer"]

product_name, product_group = self._get_product_name_and_group(
instance,
product_type,
dynamic_data
)

# Create instance for each AOV
aov_instance = context.create_instance(product_name)
Expand Down Expand Up @@ -164,3 +169,51 @@ def process(self, instance):
# Skip integrating original render instance.
# We are not removing it because it's used to trigger the render.
instance.data["integrate"] = False

def _get_product_name_and_group(self, instance, product_type, dynamic_data):
"""Get product name and group
This method matches the logic in farm that gets
`product_name` and `group_name` respecting
`use_legacy_product_names_for_renders` logic in core settings.
Args:
instance (pyblish.api.Instance): The instance to publish.
product_type (str): Product type.
dynamic_data (dict): Dynamic data (camera, aov, ...)
Returns:
tuple (str, str): product name and group name
"""

project_settings = instance.context.data.get("project_settings")

use_legacy_product_name = True
try:
use_legacy_product_name = project_settings["core"]["tools"]["creator"]["use_legacy_product_names_for_renders"] # noqa: E501
except KeyError:
warnings.warn(
("use_legacy_for_renders not found in project settings. "
"Using legacy product name for renders. Please update "
"your ayon-core version."), DeprecationWarning)
use_legacy_product_name = True

if use_legacy_product_name:
product_name, group_name = _get_legacy_product_name_and_group(
product_type=product_type,
source_product_name=instance.data["productName"],
task_name=instance.data["task"],
dynamic_data=dynamic_data)

else:
product_name, group_name = get_product_name_and_group_from_template(
project_name=instance.context.data["projectName"],
task_entity=instance.context.data["taskEntity"],
host_name=instance.context.data["hostName"],
product_type=product_type,
variant=instance.data["productName"],
dynamic_data=dynamic_data
)

return product_name, group_name
27 changes: 27 additions & 0 deletions client/ayon_houdini/plugins/publish/collect_renderlayer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Collect Render layer name from ROP.
This simple collector will take name of the ROP node and set it as the render
layer name for the instance.
This aligns with the behavior of Maya and possibly others, even though there
is nothing like render layer explicitly in Houdini.
"""
import hou
import pyblish.api
from ayon_houdini.api import plugin


class CollectRendelayerFromROP(plugin.HoudiniInstancePlugin):
label = "Collect Render layer name from ROP"
order = pyblish.api.CollectorOrder - 0.499
families = ["mantra_rop",
"karma_rop",
"redshift_rop",
"arnold_rop",
"vray_rop",
"usdrender"]

def process(self, instance):
rop = hou.node(instance.data.get("instance_node"))
instance.data["renderlayer"] = rop.name()
2 changes: 1 addition & 1 deletion package.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
client_dir = "ayon_houdini"

ayon_required_addons = {
"core": ">0.4.1",
"core": ">=0.4.4",
}
ayon_compatible_addons = {}

0 comments on commit 68c8892

Please sign in to comment.