diff --git a/client/ayon_houdini/plugins/publish/collect_local_render_instances.py b/client/ayon_houdini/plugins/publish/collect_local_render_instances.py index 4a2396c02c..3ba54d2f38 100644 --- a/client/ayon_houdini/plugins/publish/collect_local_render_instances.py +++ b/client/ayon_houdini/plugins/publish/collect_local_render_instances.py @@ -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, @@ -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 @@ -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) @@ -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 diff --git a/client/ayon_houdini/plugins/publish/collect_renderlayer.py b/client/ayon_houdini/plugins/publish/collect_renderlayer.py new file mode 100644 index 0000000000..5e2dddf534 --- /dev/null +++ b/client/ayon_houdini/plugins/publish/collect_renderlayer.py @@ -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() diff --git a/package.py b/package.py index 29459454f7..f64e1bc7cf 100644 --- a/package.py +++ b/package.py @@ -5,6 +5,6 @@ client_dir = "ayon_houdini" ayon_required_addons = { - "core": ">0.4.1", + "core": ">=0.4.4", } ayon_compatible_addons = {}