From de15f1bc3a135738f218fe27db928aef5cdb1af9 Mon Sep 17 00:00:00 2001 From: Jacob Danell Date: Thu, 23 Feb 2023 18:50:21 +0100 Subject: [PATCH 1/9] Updated render_local.py to not only process the first instance Moved the __hasRun to render_once() so the check only happens with the rendering. Currently only the first render node gets the representations added --- .../fusion/plugins/publish/render_local.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/openpype/hosts/fusion/plugins/publish/render_local.py b/openpype/hosts/fusion/plugins/publish/render_local.py index 53d8eb64e1..49aaf63a61 100644 --- a/openpype/hosts/fusion/plugins/publish/render_local.py +++ b/openpype/hosts/fusion/plugins/publish/render_local.py @@ -18,15 +18,9 @@ class Fusionlocal(pyblish.api.InstancePlugin): def process(self, instance): - # This plug-in runs only once and thus assumes all instances - # currently will render the same frame range context = instance.context - key = f"__hasRun{self.__class__.__name__}" - if context.data.get(key, False): - return - - context.data[key] = True - + + # Start render self.render_once(context) frame_start = context.data["frameStartHandle"] @@ -60,6 +54,14 @@ class Fusionlocal(pyblish.api.InstancePlugin): def render_once(self, context): """Render context comp only once, even with more render instances""" + + # This plug-in assumes all render nodes get rendered at the same time + # to speed up the rendering. The check below makes sure that we only + # execute the rendering once and not for each instance. + key = f"__hasRun{self.__class__.__name__}" + if context.data.get(key, False): + return + context.data[key] = True current_comp = context.data["currentComp"] frame_start = context.data["frameStartHandle"] From d8041562d0e08afd7dfc34158591142158d51e0e Mon Sep 17 00:00:00 2001 From: Jacob Danell Date: Thu, 23 Feb 2023 18:52:50 +0100 Subject: [PATCH 2/9] Fixed Hounds notes --- openpype/hosts/fusion/plugins/publish/render_local.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/fusion/plugins/publish/render_local.py b/openpype/hosts/fusion/plugins/publish/render_local.py index 49aaf63a61..c22074d6c6 100644 --- a/openpype/hosts/fusion/plugins/publish/render_local.py +++ b/openpype/hosts/fusion/plugins/publish/render_local.py @@ -19,7 +19,7 @@ class Fusionlocal(pyblish.api.InstancePlugin): def process(self, instance): context = instance.context - + # Start render self.render_once(context) @@ -54,7 +54,7 @@ class Fusionlocal(pyblish.api.InstancePlugin): def render_once(self, context): """Render context comp only once, even with more render instances""" - + # This plug-in assumes all render nodes get rendered at the same time # to speed up the rendering. The check below makes sure that we only # execute the rendering once and not for each instance. From 59cea8c7d070bfe1b757d5f12be96c8f4d1e9a47 Mon Sep 17 00:00:00 2001 From: Jacob Danell Date: Thu, 2 Mar 2023 12:15:37 +0100 Subject: [PATCH 3/9] Catch for each instance whether the render succeeded or not --- .../fusion/plugins/publish/render_local.py | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/openpype/hosts/fusion/plugins/publish/render_local.py b/openpype/hosts/fusion/plugins/publish/render_local.py index c22074d6c6..27bd312048 100644 --- a/openpype/hosts/fusion/plugins/publish/render_local.py +++ b/openpype/hosts/fusion/plugins/publish/render_local.py @@ -59,24 +59,27 @@ class Fusionlocal(pyblish.api.InstancePlugin): # to speed up the rendering. The check below makes sure that we only # execute the rendering once and not for each instance. key = f"__hasRun{self.__class__.__name__}" - if context.data.get(key, False): - return - context.data[key] = True + if key not in context.data: + # We initialize as false to indicate it wasn't successful yet + # so we can keep track of whether Fusion succeeded + context.data[key] = False - current_comp = context.data["currentComp"] - frame_start = context.data["frameStartHandle"] - frame_end = context.data["frameEndHandle"] + current_comp = context.data["currentComp"] + frame_start = context.data["frameStartHandle"] + frame_end = context.data["frameEndHandle"] + + self.log.info("Starting Fusion render") + self.log.info(f"Start frame: {frame_start}") + self.log.info(f"End frame: {frame_end}") + + with comp_lock_and_undo_chunk(current_comp): + result = current_comp.Render({ + "Start": frame_start, + "End": frame_end, + "Wait": True + }) + + context.data[key] = bool(result) - self.log.info("Starting render") - self.log.info(f"Start frame: {frame_start}") - self.log.info(f"End frame: {frame_end}") - - with comp_lock_and_undo_chunk(current_comp): - result = current_comp.Render({ - "Start": frame_start, - "End": frame_end, - "Wait": True - }) - - if not result: + if context.data[key] is False: raise RuntimeError("Comp render failed") From 8fcf6de8c802d78effd5e5e696aa36707f84b473 Mon Sep 17 00:00:00 2001 From: Jacob Danell Date: Fri, 3 Mar 2023 12:58:00 +0100 Subject: [PATCH 4/9] Fixed hound's comments --- .../fusion/plugins/publish/render_local.py | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/openpype/hosts/fusion/plugins/publish/render_local.py b/openpype/hosts/fusion/plugins/publish/render_local.py index 27bd312048..3eb4cbd868 100644 --- a/openpype/hosts/fusion/plugins/publish/render_local.py +++ b/openpype/hosts/fusion/plugins/publish/render_local.py @@ -17,7 +17,6 @@ class Fusionlocal(pyblish.api.InstancePlugin): families = ["render.local"] def process(self, instance): - context = instance.context # Start render @@ -35,10 +34,10 @@ class Fusionlocal(pyblish.api.InstancePlugin): for frame in range(frame_start, frame_end + 1) ] repre = { - 'name': ext[1:], - 'ext': ext[1:], - 'frameStart': f"%0{len(str(frame_end))}d" % frame_start, - 'files': files, + "name": ext[1:], + "ext": ext[1:], + "frameStart": f"%0{len(str(frame_end))}d" % frame_start, + "files": files, "stagingDir": output_dir, } @@ -67,18 +66,20 @@ class Fusionlocal(pyblish.api.InstancePlugin): current_comp = context.data["currentComp"] frame_start = context.data["frameStartHandle"] frame_end = context.data["frameEndHandle"] - + self.log.info("Starting Fusion render") self.log.info(f"Start frame: {frame_start}") self.log.info(f"End frame: {frame_end}") - + with comp_lock_and_undo_chunk(current_comp): - result = current_comp.Render({ - "Start": frame_start, - "End": frame_end, - "Wait": True - }) - + result = current_comp.Render( + { + "Start": frame_start, + "End": frame_end, + "Wait": True, + } + ) + context.data[key] = bool(result) if context.data[key] is False: From efac55ba8961d75e3fa1fb9d2f2860790f1e58e8 Mon Sep 17 00:00:00 2001 From: Jacob Danell Date: Fri, 3 Mar 2023 14:08:00 +0100 Subject: [PATCH 5/9] Added render log per instance --- openpype/hosts/fusion/plugins/publish/render_local.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/openpype/hosts/fusion/plugins/publish/render_local.py b/openpype/hosts/fusion/plugins/publish/render_local.py index 3eb4cbd868..86c283952c 100644 --- a/openpype/hosts/fusion/plugins/publish/render_local.py +++ b/openpype/hosts/fusion/plugins/publish/render_local.py @@ -22,6 +22,15 @@ class Fusionlocal(pyblish.api.InstancePlugin): # Start render self.render_once(context) + # Log render status + self.log.info( + "Rendered '{nm}' for asset '{ast}' under the task '{tsk}'".format( + nm=instance.data.name, + ast=instance.data.asset, + tsk=instance.data.task, + ) + ) + frame_start = context.data["frameStartHandle"] frame_end = context.data["frameEndHandle"] path = instance.data["path"] From a63872b54b4e4aaf42e4875a2b437642b345eb27 Mon Sep 17 00:00:00 2001 From: Jacob Danell Date: Fri, 3 Mar 2023 16:07:29 +0100 Subject: [PATCH 6/9] Fixed dict data access --- openpype/hosts/fusion/plugins/publish/render_local.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openpype/hosts/fusion/plugins/publish/render_local.py b/openpype/hosts/fusion/plugins/publish/render_local.py index 86c283952c..0eca7f6cdd 100644 --- a/openpype/hosts/fusion/plugins/publish/render_local.py +++ b/openpype/hosts/fusion/plugins/publish/render_local.py @@ -25,9 +25,9 @@ class Fusionlocal(pyblish.api.InstancePlugin): # Log render status self.log.info( "Rendered '{nm}' for asset '{ast}' under the task '{tsk}'".format( - nm=instance.data.name, - ast=instance.data.asset, - tsk=instance.data.task, + nm=instance.data["name"], + ast=instance.data["asset"], + tsk=instance.data["task"], ) ) From 73e0ba9cb266507c0f7ea562d6895bcd2dbaaddb Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Tue, 7 Mar 2023 10:53:06 +0100 Subject: [PATCH 7/9] Set colorspace based on file rules in imageio settings --- openpype/hosts/fusion/plugins/publish/render_local.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/fusion/plugins/publish/render_local.py b/openpype/hosts/fusion/plugins/publish/render_local.py index 0eca7f6cdd..212242630b 100644 --- a/openpype/hosts/fusion/plugins/publish/render_local.py +++ b/openpype/hosts/fusion/plugins/publish/render_local.py @@ -1,9 +1,11 @@ import os import pyblish.api +from openpype.pipeline import publish from openpype.hosts.fusion.api import comp_lock_and_undo_chunk -class Fusionlocal(pyblish.api.InstancePlugin): +class Fusionlocal(pyblish.api.InstancePlugin, + publish.ColormanagedPyblishPluginMixin): """Render the current Fusion composition locally. Extract the result of savers by starting a comp render @@ -50,6 +52,11 @@ class Fusionlocal(pyblish.api.InstancePlugin): "stagingDir": output_dir, } + self.set_representation_colorspace( + representation=repre, + context=context, + ) + if "representations" not in instance.data: instance.data["representations"] = [] instance.data["representations"].append(repre) From 1bb7dbc9d9707335d246e9a7a924859c1d09fd84 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Tue, 7 Mar 2023 10:55:40 +0100 Subject: [PATCH 8/9] Make sure repre preview copy is a deepcopy --- openpype/hosts/fusion/plugins/publish/render_local.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/fusion/plugins/publish/render_local.py b/openpype/hosts/fusion/plugins/publish/render_local.py index 212242630b..9ed17f23c6 100644 --- a/openpype/hosts/fusion/plugins/publish/render_local.py +++ b/openpype/hosts/fusion/plugins/publish/render_local.py @@ -1,4 +1,6 @@ import os +import copy + import pyblish.api from openpype.pipeline import publish from openpype.hosts.fusion.api import comp_lock_and_undo_chunk @@ -62,7 +64,7 @@ class Fusionlocal(pyblish.api.InstancePlugin, instance.data["representations"].append(repre) # review representation - repre_preview = repre.copy() + repre_preview = copy.deepcopy(repre) repre_preview["name"] = repre_preview["ext"] = "mp4" repre_preview["tags"] = ["review", "ftrackreview", "delete"] instance.data["representations"].append(repre_preview) From f94fb76a238c5fc24ff26d84061fc7f7f5d5c90f Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Tue, 7 Mar 2023 13:56:53 +0100 Subject: [PATCH 9/9] Update OCIO config hook to use the correct imageio settings --- .../fusion/hooks/pre_fusion_ocio_hook.py | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/openpype/hosts/fusion/hooks/pre_fusion_ocio_hook.py b/openpype/hosts/fusion/hooks/pre_fusion_ocio_hook.py index d1ae5f64fd..6bf0f55081 100644 --- a/openpype/hosts/fusion/hooks/pre_fusion_ocio_hook.py +++ b/openpype/hosts/fusion/hooks/pre_fusion_ocio_hook.py @@ -1,7 +1,7 @@ -import os -import platform +from openpype.lib import PreLaunchHook -from openpype.lib import PreLaunchHook, ApplicationLaunchFailed +from openpype.pipeline.colorspace import get_imageio_config +from openpype.pipeline.template_data import get_template_data_with_names class FusionPreLaunchOCIO(PreLaunchHook): @@ -11,24 +11,22 @@ class FusionPreLaunchOCIO(PreLaunchHook): def execute(self): """Hook entry method.""" - # get image io - project_settings = self.data["project_settings"] + template_data = get_template_data_with_names( + project_name=self.data["project_name"], + asset_name=self.data["asset_name"], + task_name=self.data["task_name"], + host_name=self.host_name, + system_settings=self.data["system_settings"] + ) - # make sure anatomy settings are having flame key - imageio_fusion = project_settings["fusion"]["imageio"] - - ocio = imageio_fusion.get("ocio") - enabled = ocio.get("enabled", False) - if not enabled: - return - - platform_key = platform.system().lower() - ocio_path = ocio["configFilePath"][platform_key] - if not ocio_path: - raise ApplicationLaunchFailed( - "Fusion OCIO is enabled in project settings but no OCIO config" - f"path is set for your current platform: {platform_key}" - ) + config_data = get_imageio_config( + project_name=self.data["project_name"], + host_name=self.host_name, + project_settings=self.data["project_settings"], + anatomy_data=template_data, + anatomy=self.data["anatomy"] + ) + ocio_path = config_data["path"] self.log.info(f"Setting OCIO config path: {ocio_path}") - self.launch_context.env["OCIO"] = os.pathsep.join(ocio_path) + self.launch_context.env["OCIO"] = ocio_path