From ce301f8d0a2907eec5c2f5ad5916cb9a8f1cb7fc Mon Sep 17 00:00:00 2001 From: Ondrej Samohel Date: Tue, 27 Jul 2021 14:18:20 +0200 Subject: [PATCH 1/2] add support for RedshiftNormalMap node, fix tx linear space --- .../maya/plugins/publish/collect_look.py | 15 ++++++++++-- .../maya/plugins/publish/extract_look.py | 24 ++++++++++++------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/collect_look.py b/openpype/hosts/maya/plugins/publish/collect_look.py index bf24b463ac..0dde52447d 100644 --- a/openpype/hosts/maya/plugins/publish/collect_look.py +++ b/openpype/hosts/maya/plugins/publish/collect_look.py @@ -167,6 +167,8 @@ def get_file_node_path(node): if cmds.nodeType(node) == 'aiImage': return cmds.getAttr('{0}.filename'.format(node)) + if cmds.nodeType(node) == 'RedshiftNormalMap': + return cmds.getAttr('{}.tex0'.format(node)) # otherwise use fileTextureName return cmds.getAttr('{0}.fileTextureName'.format(node)) @@ -357,6 +359,7 @@ class CollectLook(pyblish.api.InstancePlugin): files = cmds.ls(history, type="file", long=True) files.extend(cmds.ls(history, type="aiImage", long=True)) + files.extend(cmds.ls(history, type="RedshiftNormalMap", long=True)) self.log.info("Collected file nodes:\n{}".format(files)) # Collect textures if any file nodes are found @@ -487,7 +490,7 @@ class CollectLook(pyblish.api.InstancePlugin): """ self.log.debug("processing: {}".format(node)) - if cmds.nodeType(node) not in ["file", "aiImage"]: + if cmds.nodeType(node) not in ["file", "aiImage", "RedshiftNormalMap"]: self.log.error( "Unsupported file node: {}".format(cmds.nodeType(node))) raise AssertionError("Unsupported file node") @@ -500,11 +503,19 @@ class CollectLook(pyblish.api.InstancePlugin): self.log.debug("aiImage node") attribute = "{}.filename".format(node) computed_attribute = attribute + elif cmds.nodeType(node) == 'RedshiftNormalMap': + self.log.debug("RedshiftNormalMap node") + attribute = "{}.tex0".format(node) + computed_attribute = attribute source = cmds.getAttr(attribute) self.log.info(" - file source: {}".format(source)) color_space_attr = "{}.colorSpace".format(node) - color_space = cmds.getAttr(color_space_attr) + try: + color_space = cmds.getAttr(color_space_attr) + except ValueError: + # node doesn't have colorspace attribute + color_space = "raw" # Compare with the computed file path, e.g. the one with the # pattern in it, to generate some logging information about this # difference diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index bdd061578e..c823602dc4 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -233,11 +233,14 @@ class ExtractLook(openpype.api.Extractor): for filepath in files_metadata: linearize = False - if do_maketx and files_metadata[filepath]["color_space"] == "sRGB": # noqa: E501 + if do_maketx and files_metadata[filepath]["color_space"].lower() == "srgb": # noqa: E501 linearize = True # set its file node to 'raw' as tx will be linearized files_metadata[filepath]["color_space"] = "raw" + if do_maketx: + color_space = "raw" + source, mode, texture_hash = self._process_texture( filepath, do_maketx, @@ -280,15 +283,20 @@ class ExtractLook(openpype.api.Extractor): # This will also trigger in the same order at end of context to # ensure after context it's still the original value. color_space_attr = resource["node"] + ".colorSpace" - color_space = cmds.getAttr(color_space_attr) - if files_metadata[source]["color_space"] == "raw": - # set color space to raw if we linearized it - color_space = "Raw" - # Remap file node filename to destination + try: + color_space = cmds.getAttr(color_space_attr) + except ValueError: + # node doesn't have color space attribute + color_space = "raw" + else: + if files_metadata[source]["color_space"] == "raw": + # set color space to raw if we linearized it + color_space = "raw" + # Remap file node filename to destination + remap[color_space_attr] = color_space attr = resource["attribute"] remap[attr] = destinations[source] - remap[color_space_attr] = color_space - + self.log.info("Finished remapping destinations ...") # Extract in correct render layer From af45f466d5f81e4d7daca097ff06b9df0008b92a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= <33513211+antirotor@users.noreply.github.com> Date: Tue, 3 Aug 2021 17:13:35 +0200 Subject: [PATCH 2/2] remove whitespace --- openpype/hosts/maya/plugins/publish/extract_look.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index c823602dc4..f09d50d714 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -296,7 +296,7 @@ class ExtractLook(openpype.api.Extractor): remap[color_space_attr] = color_space attr = resource["attribute"] remap[attr] = destinations[source] - + self.log.info("Finished remapping destinations ...") # Extract in correct render layer