From e0b432f8c1a0954a0c42620cf868c4c5d01c85fd Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Fri, 8 Nov 2024 17:07:07 +0200 Subject: [PATCH 01/10] refactor `set_review_color_space` to work with `flipbook` node as well --- client/ayon_houdini/api/lib.py | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/client/ayon_houdini/api/lib.py b/client/ayon_houdini/api/lib.py index 26c1b78438..247d26232a 100644 --- a/client/ayon_houdini/api/lib.py +++ b/client/ayon_houdini/api/lib.py @@ -896,16 +896,19 @@ def get_current_context_template_data_with_entity_attrs(): return template_data -def set_review_color_space(opengl_node, review_color_space="", log=None): +def set_review_color_space(node, review_color_space="", log=None): """Set ociocolorspace parameter for the given OpenGL node. - Set `ociocolorspace` parameter of the given OpenGl node + Set `ociocolorspace` parameter of the given node to to the given review_color_space value. If review_color_space is empty, a default colorspace corresponding to the display & view of the current Houdini session will be used. + Note: + This function expects nodes of type `opengl` or `flipbook`. + Args: - opengl_node (hou.Node): ROP node to set its ociocolorspace parm. + node (hou.Node): ROP node to set its ociocolorspace parm. review_color_space (str): Colorspace value for ociocolorspace parm. log (logging.Logger): Logger to log to. """ @@ -913,23 +916,31 @@ def set_review_color_space(opengl_node, review_color_space="", log=None): if log is None: log = self.log + if node.type().name() not in {"opengl", "flipbook"}: + log.warning( + "Type of given node {} not allowed." + " only types `opengl` and `flipbook` are allowed." + .format(node.type().name()) + ) + # Set Color Correction parameter to OpenColorIO - colorcorrect_parm = opengl_node.parm("colorcorrect") - if colorcorrect_parm.eval() != 2: - colorcorrect_parm.set(2) + colorcorrect_parm = node.parm("colorcorrect") + if colorcorrect_parm.evalAsString() != "ocio": + idx = colorcorrect_parm.menuItems().index("ocio") + colorcorrect_parm.set(idx) log.debug( - "'Color Correction' parm on '{}' has been set to" - " 'OpenColorIO'".format(opengl_node.path()) + "'Color Correction' parm on '{}' has been set to '{}'" + .format(node.path(), colorcorrect_parm.menuLabels()[idx]) ) - opengl_node.setParms( + node.setParms( {"ociocolorspace": review_color_space} ) log.debug( "'OCIO Colorspace' parm on '{}' has been set to " "the view color space '{}'" - .format(opengl_node, review_color_space) + .format(node.path(), review_color_space) ) From 087ccb1e8f724f1692bce4fa48fdc89bbd636aed Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Fri, 8 Nov 2024 17:14:22 +0200 Subject: [PATCH 02/10] add a creator for review using flipbook nodes --- client/ayon_houdini/plugins/create/create_review.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/client/ayon_houdini/plugins/create/create_review.py b/client/ayon_houdini/plugins/create/create_review.py index 71620caa65..990fe58913 100644 --- a/client/ayon_houdini/plugins/create/create_review.py +++ b/client/ayon_houdini/plugins/create/create_review.py @@ -11,10 +11,11 @@ class CreateReview(plugin.HoudiniCreator): """Review with OpenGL ROP""" identifier = "io.openpype.creators.houdini.review" - label = "Review" + label = "Review (OpenGL)" product_type = "review" icon = "video-camera" review_color_space = "" + node_type = "opengl" def apply_settings(self, project_settings): super(CreateReview, self).apply_settings(project_settings) @@ -27,7 +28,7 @@ def apply_settings(self, project_settings): def create(self, product_name, instance_data, pre_create_data): - instance_data.update({"node_type": "opengl"}) + instance_data.update({"node_type": self.node_type}) instance_data["imageFormat"] = pre_create_data.get("imageFormat") instance_data["keepImages"] = pre_create_data.get("keepImages") @@ -150,3 +151,10 @@ def get_pre_create_attr_defs(self): minimum=0.0001, decimals=3) ] + + +class CreateFlipbookReview(CreateReview): + + identifier = "io.ayon.creators.houdini.review.flipbook" + label = "Review (Flipbook)" + node_type = "flipbook" From 42c944002d7507a82d276ed5838a67cbc1455426 Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Fri, 8 Nov 2024 17:14:48 +0200 Subject: [PATCH 03/10] support flipbook node in publishing --- client/ayon_houdini/api/lib.py | 2 +- .../plugins/publish/collect_review_data.py | 2 +- .../plugins/publish/extract_rop.py | 10 ++-- .../publish/validate_review_colorspace.py | 59 +++++++++++-------- 4 files changed, 41 insertions(+), 32 deletions(-) diff --git a/client/ayon_houdini/api/lib.py b/client/ayon_houdini/api/lib.py index 247d26232a..762aa1395b 100644 --- a/client/ayon_houdini/api/lib.py +++ b/client/ayon_houdini/api/lib.py @@ -89,7 +89,7 @@ def get_output_parameter(node): return node.parm("sopoutput") elif node_type == "comp": return node.parm("copoutput") - elif node_type in {"karma", "opengl"}: + elif node_type in {"karma", "opengl", "flipbook"}: return node.parm("picture") elif node_type == "ifd": # Mantra if node.evalParm("soho_outputmode"): diff --git a/client/ayon_houdini/plugins/publish/collect_review_data.py b/client/ayon_houdini/plugins/publish/collect_review_data.py index e9a403f070..c35e069a14 100644 --- a/client/ayon_houdini/plugins/publish/collect_review_data.py +++ b/client/ayon_houdini/plugins/publish/collect_review_data.py @@ -69,7 +69,7 @@ def _get_camera_path(self, ropnode): """ if ropnode.type().name() in { - "opengl", "karma", "ifd", "arnold" + "opengl", "karma", "ifd", "arnold", "flipbook" }: return ropnode.parm("camera").eval() diff --git a/client/ayon_houdini/plugins/publish/extract_rop.py b/client/ayon_houdini/plugins/publish/extract_rop.py index 4944060678..d975e0ba2b 100644 --- a/client/ayon_houdini/plugins/publish/extract_rop.py +++ b/client/ayon_houdini/plugins/publish/extract_rop.py @@ -79,11 +79,11 @@ def update_representation_data(self, pass -class ExtractOpenGL(ExtractROP, - publish.ColormanagedPyblishPluginMixin): +class ExtractOpenGLAndFlipbook(ExtractROP, + publish.ColormanagedPyblishPluginMixin): order = pyblish.api.ExtractorOrder - 0.01 - label = "Extract OpenGL" + label = "Extract Review (OpenGL & Flipbook)" families = ["review"] def process(self, instance): @@ -98,12 +98,12 @@ def process(self, instance): return rop_node = hou.node(instance_node) - if rop_node.type().name() != "opengl": + if rop_node.type().name() not in {"opengl", "flipbook"}: self.log.debug("Skipping OpenGl extraction. Rop node {} " "is not an OpenGl node.".format(rop_node.path())) return - super(ExtractOpenGL, self).process(instance) + super(ExtractOpenGLAndFlipbook, self).process(instance) def update_representation_data(self, instance: pyblish.api.Instance, diff --git a/client/ayon_houdini/plugins/publish/validate_review_colorspace.py b/client/ayon_houdini/plugins/publish/validate_review_colorspace.py index e96b222446..0483e1553a 100644 --- a/client/ayon_houdini/plugins/publish/validate_review_colorspace.py +++ b/client/ayon_houdini/plugins/publish/validate_review_colorspace.py @@ -64,9 +64,9 @@ def process(self, instance): # TODO: Don't run this plugin on wrong instances. # This plugin should run only on review product type # with instance node of opengl type. - if rop_node.type().name() != "opengl": + if rop_node.type().name() not in {"opengl", "flipbook"}: self.log.debug("Skipping Validation. Rop node {} " - "is not an OpenGl node.".format(rop_node.path())) + "is not an `opengl` or `flipbook` node.".format(rop_node.path())) return if not self.is_active(instance.data): @@ -79,35 +79,44 @@ def process(self, instance): ) return - if rop_node.evalParm("colorcorrect") != 2: + colorcorrect = rop_node.parm("colorcorrect").evalAsString() + if not colorcorrect.startswith("ocio"): # any colorspace settings other than default requires # 'Color Correct' parm to be set to 'OpenColorIO' raise PublishValidationError( "'Color Correction' parm on '{}' ROP must be set to" - " 'OpenColorIO'".format(rop_node.path()) + " use 'OpenColorIO'".format(rop_node.path()) ) - current_color_space = rop_node.evalParm("ociocolorspace") - if current_color_space not in hou.Color.ocio_spaces(): - raise PublishValidationError( - "Invalid value: Colorspace name doesn't exist.\n" - "Check 'OCIO Colorspace' parameter on '{}' ROP" - .format(rop_node.path()) - ) - - # if houdini/imageio/workfile is enabled and - # Review colorspace setting is empty then this check should - # actually check if the current_color_space setting equals - # the default colorspace value. - # However, it will make the black cmd screen show up more often - # which is very annoying. - if self.review_color_space and \ - self.review_color_space != current_color_space: - - raise PublishValidationError( - "Invalid value: Colorspace name doesn't match" - "the Colorspace specified in settings." - ) + if colorcorrect == "ocio": + # For both opengl and flipbook nodes. + + current_color_space = rop_node.evalParm("ociocolorspace") + if current_color_space not in hou.Color.ocio_spaces(): + raise PublishValidationError( + "Invalid value: Colorspace name doesn't exist.\n" + "Check 'OCIO Colorspace' parameter on '{}' ROP" + .format(rop_node.path()) + ) + + # If `ayon+settings://houdini/imageio/workfile` is enabled + # and the Review colorspace setting is empty, then this check + # should verify if the `current_color_space` setting equals + # the default colorspace value. + if self.review_color_space and \ + self.review_color_space != current_color_space: + + raise PublishValidationError( + "Invalid value: Colorspace name doesn't match" + "the Colorspace specified in settings." + ) + + # TODO: Check if `ociodisplay` and `ocioview` are the same as the default display and view. + # Should be the default value specified in settings? + # OR Should be the current/default value specified in the hip file? + elif colorcorrect == "ocioview": + # For flipbook nodes only. + pass @classmethod def repair(cls, instance): From 5f8d3254c8b611c627e81f2865608637aa605fbb Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Sat, 16 Nov 2024 01:08:29 +0200 Subject: [PATCH 04/10] use one creator for reviews and add node type enum --- .../plugins/create/create_review.py | 23 ++++++++++++------- server/settings/create.py | 23 ++++++++++++++++--- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/client/ayon_houdini/plugins/create/create_review.py b/client/ayon_houdini/plugins/create/create_review.py index b9f2874ed4..6ad46800ad 100644 --- a/client/ayon_houdini/plugins/create/create_review.py +++ b/client/ayon_houdini/plugins/create/create_review.py @@ -11,7 +11,7 @@ class CreateReview(plugin.HoudiniCreator): """Review with OpenGL ROP""" identifier = "io.openpype.creators.houdini.review" - label = "Review (OpenGL)" + label = "Review" product_type = "review" icon = "video-camera" review_color_space = "" @@ -30,6 +30,13 @@ def apply_settings(self, project_settings): self.review_color_space = color_settings.get("review_color_space") def create(self, product_name, instance_data, pre_create_data): + + self.node_type = pre_create_data.get("node_type") + hou_version = hou.applicationVersionString() + if self.node_type == "flipbook" and not hou_version.startswith("20.5"): + self.log.debug("The Flipbook node type isn't supported in Houdini versions below 20.5." + " Switching to the OpenGL node type instead.") + self.node_type = "opengl" instance_data.update({"node_type": self.node_type}) instance_data["imageFormat"] = pre_create_data.get("imageFormat") @@ -124,8 +131,15 @@ def get_pre_create_attr_defs(self): "bmp", "cin", "exr", "jpg", "pic", "pic.gz", "png", "rad", "rat", "rta", "sgi", "tga", "tif", ] + node_type_enum = [ + "opengl", "flipbook" + ] return attrs + [ + EnumDef("node_type", + node_type_enum, + default=self.node_type, + label="Image Format Options"), BoolDef("keepImages", label="Keep Image Sequences", default=False), @@ -154,10 +168,3 @@ def get_pre_create_attr_defs(self): minimum=0.0001, decimals=3) ] - - -class CreateFlipbookReview(CreateReview): - - identifier = "io.ayon.creators.houdini.review.flipbook" - label = "Review (Flipbook)" - node_type = "flipbook" diff --git a/server/settings/create.py b/server/settings/create.py index 595006c665..0e234248ff 100644 --- a/server/settings/create.py +++ b/server/settings/create.py @@ -9,6 +9,22 @@ class CreatorModel(BaseSettingsModel): default_factory=list, ) +def review_node_types_enum(): + return [ + {"label": "OpenGL", "value": "opengl"}, + {"label": "Flipbook", "value": "flipbook"} + ] + +class CreateReviewModel(BaseSettingsModel): + enabled: bool = SettingsField(title="Enabled") + default_variants: list[str] = SettingsField( + title="Default Products", + default_factory=list, + ) + node_type: str = SettingsField( + Title="Default Node Type", + enum_resolver=review_node_types_enum, + ) class CreateArnoldAssModel(BaseSettingsModel): enabled: bool = SettingsField(title="Enabled") @@ -82,8 +98,8 @@ class CreatePluginsModel(BaseSettingsModel): CreateRedshiftROP: CreatorModel = SettingsField( default_factory=CreatorModel, title="Create Redshift ROP") - CreateReview: CreatorModel = SettingsField( - default_factory=CreatorModel, + CreateReview: CreateReviewModel = SettingsField( + default_factory=CreateReviewModel, title="Create Review") # "-" is not compatible in the new model CreateStaticMesh: CreateStaticMeshModel = SettingsField( @@ -159,7 +175,8 @@ class CreatePluginsModel(BaseSettingsModel): }, "CreateReview": { "enabled": True, - "default_variants": ["Main"] + "default_variants": ["Main"], + "node_type": "opengl" }, "CreateStaticMesh": { "enabled": True, From 72611f4623ea6e6196c16ed8cfbc26523be7ee00 Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Sat, 16 Nov 2024 01:09:59 +0200 Subject: [PATCH 05/10] fix option label --- client/ayon_houdini/plugins/create/create_review.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_houdini/plugins/create/create_review.py b/client/ayon_houdini/plugins/create/create_review.py index 6ad46800ad..c3ab3176da 100644 --- a/client/ayon_houdini/plugins/create/create_review.py +++ b/client/ayon_houdini/plugins/create/create_review.py @@ -139,7 +139,7 @@ def get_pre_create_attr_defs(self): EnumDef("node_type", node_type_enum, default=self.node_type, - label="Image Format Options"), + label="Node Type"), BoolDef("keepImages", label="Keep Image Sequences", default=False), From 9bb792ead39c988edc78f19342dcfeba8c62fa94 Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Tue, 19 Nov 2024 07:36:37 +0200 Subject: [PATCH 06/10] keep the `flipbook` entry out of the Enum if houdini < `20.5` --- client/ayon_houdini/plugins/create/create_review.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/client/ayon_houdini/plugins/create/create_review.py b/client/ayon_houdini/plugins/create/create_review.py index c3ab3176da..3d6a4e8a48 100644 --- a/client/ayon_houdini/plugins/create/create_review.py +++ b/client/ayon_houdini/plugins/create/create_review.py @@ -32,11 +32,6 @@ def apply_settings(self, project_settings): def create(self, product_name, instance_data, pre_create_data): self.node_type = pre_create_data.get("node_type") - hou_version = hou.applicationVersionString() - if self.node_type == "flipbook" and not hou_version.startswith("20.5"): - self.log.debug("The Flipbook node type isn't supported in Houdini versions below 20.5." - " Switching to the OpenGL node type instead.") - self.node_type = "opengl" instance_data.update({"node_type": self.node_type}) instance_data["imageFormat"] = pre_create_data.get("imageFormat") @@ -131,9 +126,9 @@ def get_pre_create_attr_defs(self): "bmp", "cin", "exr", "jpg", "pic", "pic.gz", "png", "rad", "rat", "rta", "sgi", "tga", "tif", ] - node_type_enum = [ - "opengl", "flipbook" - ] + node_type_enum = ["opengl"] + if hou.applicationVersion() >= (20, 5, 0): + node_type_enum.append("flipbook") return attrs + [ EnumDef("node_type", From 51a20d4630097dfac664a569771bc550f5f3dafa Mon Sep 17 00:00:00 2001 From: Mustafa Jafar Date: Tue, 19 Nov 2024 07:38:20 +0200 Subject: [PATCH 07/10] fix argument Co-authored-by: Roy Nieterau --- server/settings/create.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/settings/create.py b/server/settings/create.py index 0e234248ff..a11b63291c 100644 --- a/server/settings/create.py +++ b/server/settings/create.py @@ -22,7 +22,7 @@ class CreateReviewModel(BaseSettingsModel): default_factory=list, ) node_type: str = SettingsField( - Title="Default Node Type", + title="Default Node Type", enum_resolver=review_node_types_enum, ) From 39637766f65e6723d2a1179b4906ab0ce908f424 Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Tue, 19 Nov 2024 07:59:49 +0200 Subject: [PATCH 08/10] remove checking against node type --- .../plugins/publish/extract_rop.py | 19 ------------------- .../publish/validate_review_colorspace.py | 13 +------------ 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/client/ayon_houdini/plugins/publish/extract_rop.py b/client/ayon_houdini/plugins/publish/extract_rop.py index 30c24338b2..e955c6a18c 100644 --- a/client/ayon_houdini/plugins/publish/extract_rop.py +++ b/client/ayon_houdini/plugins/publish/extract_rop.py @@ -85,25 +85,6 @@ class ExtractOpenGLAndFlipbook(ExtractROP, label = "Extract Review (OpenGL & Flipbook)" families = ["rop.opengl"] - def process(self, instance): - # This plugin is triggered when marking render as reviewable. - # Therefore, this plugin will run over wrong instances. - # TODO: Don't run this plugin on wrong instances. - # This plugin should run only on review product type - # with instance node of opengl type. - instance_node = instance.data.get("instance_node") - if not instance_node: - self.log.debug("Skipping instance without instance node.") - return - - rop_node = hou.node(instance_node) - if rop_node.type().name() not in {"opengl", "flipbook"}: - self.log.debug("Skipping OpenGl extraction. Rop node {} " - "is not an OpenGl node.".format(rop_node.path())) - return - - super(ExtractOpenGLAndFlipbook, self).process(instance) - def update_representation_data(self, instance: pyblish.api.Instance, representation: dict): diff --git a/client/ayon_houdini/plugins/publish/validate_review_colorspace.py b/client/ayon_houdini/plugins/publish/validate_review_colorspace.py index 6543a77509..ec99d027e4 100644 --- a/client/ayon_houdini/plugins/publish/validate_review_colorspace.py +++ b/client/ayon_houdini/plugins/publish/validate_review_colorspace.py @@ -57,18 +57,6 @@ def apply_settings(cls, project_settings): def process(self, instance): - rop_node = hou.node(instance.data["instance_node"]) - - # This plugin is triggered when marking render as reviewable. - # Therefore, this plugin will run on over wrong instances. - # TODO: Don't run this plugin on wrong instances. - # This plugin should run only on review product type - # with instance node of opengl type. - if rop_node.type().name() not in {"opengl", "flipbook"}: - self.log.debug("Skipping Validation. Rop node {} " - "is not an `opengl` or `flipbook` node.".format(rop_node.path())) - return - if not self.is_active(instance.data): return @@ -79,6 +67,7 @@ def process(self, instance): ) return + rop_node = hou.node(instance.data["instance_node"]) colorcorrect = rop_node.parm("colorcorrect").evalAsString() if not colorcorrect.startswith("ocio"): # any colorspace settings other than default requires From 979452c4dee0a1769be2ed418b1897467ed10524 Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Tue, 19 Nov 2024 08:55:49 +0200 Subject: [PATCH 09/10] add a todo for publish families --- client/ayon_houdini/plugins/create/create_review.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/ayon_houdini/plugins/create/create_review.py b/client/ayon_houdini/plugins/create/create_review.py index 3d6a4e8a48..601349e3ad 100644 --- a/client/ayon_houdini/plugins/create/create_review.py +++ b/client/ayon_houdini/plugins/create/create_review.py @@ -17,6 +17,9 @@ class CreateReview(plugin.HoudiniCreator): review_color_space = "" node_type = "opengl" + # TODO: Publish families should reflect the node type, + # such as `rop.flipbook` for flipbook nodes + # and `rop.opengl` for OpenGL nodes. def get_publish_families(self): return ["review", "rop.opengl"] From 9347901aa8f24172e0b2ff1f7a2513e01d7261cc Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Wed, 20 Nov 2024 12:49:13 +0200 Subject: [PATCH 10/10] remove unused import --- client/ayon_houdini/plugins/publish/extract_rop.py | 1 - 1 file changed, 1 deletion(-) diff --git a/client/ayon_houdini/plugins/publish/extract_rop.py b/client/ayon_houdini/plugins/publish/extract_rop.py index e955c6a18c..74a5f52154 100644 --- a/client/ayon_houdini/plugins/publish/extract_rop.py +++ b/client/ayon_houdini/plugins/publish/extract_rop.py @@ -1,5 +1,4 @@ import os -import hou import pyblish.api from ayon_core.pipeline import publish