From 3770eb69b653f31292faee388ed416f7bf8a171f Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Tue, 29 Mar 2022 18:34:34 +0300 Subject: [PATCH 01/47] add rstex function --- .../maya/plugins/publish/extract_look.py | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index a8893072d08..15164952789 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -6,6 +6,7 @@ import tempfile import contextlib import subprocess +from openpype.lib.vendor_bin_utils import find_executable from collections import OrderedDict from maya import cmds # noqa @@ -42,6 +43,58 @@ def find_paths_by_hash(texture_hash): return io.distinct(key, {"type": "version"}) +def rstex(source, *args): + """Make `.rstexbin` using `redshiftTextureProcessor` + with some default settings. + + This function requires the `REDSHIFT_COREDATAPATH` + to be in `PATH`. + + Args: + source (str): Path to source file. + *args: Additional arguments for `redshiftTextureProcessor`. + + Returns: + str: Output of `redshiftTextureProcessor` command. + + """ + if "REDSHIFT_COREDATAPATH" not in os.environ: + raise RuntimeError("Must have Redshift available.") + + redshift_bin_path = os.path.join( + os.environ["REDSHIFT_COREDATAPATH"], + "bin", + "redshiftTextureProcessor" + ) + + texture_processor_path = find_executable(redshift_bin_path) + + cmd = [ + texture_processor_path, + escape_space(source), + + ] + + cmd.extend(args) + + cmd = " ".join(cmd) + + CREATE_NO_WINDOW = 0x08000000 + kwargs = dict(args=cmd, stderr=subprocess.STDOUT) + + if sys.platform == "win32": + kwargs["creationflags"] = CREATE_NO_WINDOW + try: + out = subprocess.check_output(**kwargs) + except subprocess.CalledProcessError as exc: + print(exc) + import traceback + + traceback.print_exc() + raise + return out + + def maketx(source, destination, *args): """Make `.tx` using `maketx` with some default settings. From 72b45229e943c419083e243ae27a540373edd6e2 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Tue, 29 Mar 2022 19:23:25 +0300 Subject: [PATCH 02/47] fix style warnings --- openpype/hosts/maya/plugins/publish/extract_look.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 15164952789..6102b311a3c 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -65,10 +65,10 @@ def rstex(source, *args): os.environ["REDSHIFT_COREDATAPATH"], "bin", "redshiftTextureProcessor" - ) + ) texture_processor_path = find_executable(redshift_bin_path) - + cmd = [ texture_processor_path, escape_space(source), @@ -83,7 +83,7 @@ def rstex(source, *args): kwargs = dict(args=cmd, stderr=subprocess.STDOUT) if sys.platform == "win32": - kwargs["creationflags"] = CREATE_NO_WINDOW + kwargs["creationflags"] = CREATE_NO_WINDOW try: out = subprocess.check_output(**kwargs) except subprocess.CalledProcessError as exc: From e65a1ea7d144abdcd0681641b45c50d11e903405 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Tue, 29 Mar 2022 19:45:00 +0300 Subject: [PATCH 03/47] remove extra line --- openpype/hosts/maya/plugins/publish/extract_look.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 6102b311a3c..cd647a67331 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -71,8 +71,7 @@ def rstex(source, *args): cmd = [ texture_processor_path, - escape_space(source), - + escape_space(source), ] cmd.extend(args) From 2406f78f4717451c2408a21b0f36bd66bd4ec95b Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Tue, 29 Mar 2022 19:45:49 +0300 Subject: [PATCH 04/47] fix trailing 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 cd647a67331..fb90d7538ba 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -71,7 +71,7 @@ def rstex(source, *args): cmd = [ texture_processor_path, - escape_space(source), + escape_space(source), ] cmd.extend(args) From be840d3a8b8b786c3fdfb56ab8ef7577c04747f3 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Mon, 4 Apr 2022 15:50:33 +0300 Subject: [PATCH 05/47] add exectuable path finder function --- openpype/lib/vendor_bin_utils.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/openpype/lib/vendor_bin_utils.py b/openpype/lib/vendor_bin_utils.py index 23e28ea3042..c30a1ee7092 100644 --- a/openpype/lib/vendor_bin_utils.py +++ b/openpype/lib/vendor_bin_utils.py @@ -120,6 +120,26 @@ def get_oiio_tools_path(tool="oiiotool"): return find_executable(os.path.join(oiio_dir, tool)) +def get_redshift_tool(tool_name): + """Path to redshift texture processor. + + On Windows it adds .exe extension if missing from tool argument. + + Args: + tool (string): Tool name. + + Returns: + str: Full path to redshift texture processor executable. + """ + redshift_tool_path = os.path.join( + os.environ["REDSHIFT_COREDATAPATH"], + "bin", + tool_name + ) + + return find_executable(redshift_tool_path) + + def get_ffmpeg_tool_path(tool="ffmpeg"): """Path to vendorized FFmpeg executable. From d4b8d47b18ed1605cdffa9a635586b40e29a6adf Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Mon, 4 Apr 2022 15:51:31 +0300 Subject: [PATCH 06/47] use redshift tool finder in extractor --- openpype/hosts/maya/plugins/publish/extract_look.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index fb90d7538ba..6ce3a981f47 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -6,7 +6,7 @@ import tempfile import contextlib import subprocess -from openpype.lib.vendor_bin_utils import find_executable +from openpype.lib.vendor_bin_utils import get_redshift_tool from collections import OrderedDict from maya import cmds # noqa @@ -61,13 +61,7 @@ def rstex(source, *args): if "REDSHIFT_COREDATAPATH" not in os.environ: raise RuntimeError("Must have Redshift available.") - redshift_bin_path = os.path.join( - os.environ["REDSHIFT_COREDATAPATH"], - "bin", - "redshiftTextureProcessor" - ) - - texture_processor_path = find_executable(redshift_bin_path) + texture_processor_path = get_redshift_tool("TextureProcessor") cmd = [ texture_processor_path, From abc299e86eea14ec425c07e46c5af51551cf1a3e Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Tue, 5 Apr 2022 20:00:54 +0300 Subject: [PATCH 07/47] Add redshift texture processing option to schema --- .../schemas/projects_schema/schemas/schema_maya_create.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/openpype/settings/entities/schemas/projects_schema/schemas/schema_maya_create.json b/openpype/settings/entities/schemas/projects_schema/schemas/schema_maya_create.json index 0544b4bab70..b0bd46d20fb 100644 --- a/openpype/settings/entities/schemas/projects_schema/schemas/schema_maya_create.json +++ b/openpype/settings/entities/schemas/projects_schema/schemas/schema_maya_create.json @@ -21,6 +21,11 @@ "key": "make_tx", "label": "Make tx files" }, + { + "type": "boolean", + "key": "rstex", + "label": "Make Redshift texture files" + }, { "type": "list", "key": "defaults", From 640415a0959bbc67f0e516b2363c4998b5d74508 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Tue, 5 Apr 2022 20:18:42 +0300 Subject: [PATCH 08/47] adjust key name --- .../schemas/projects_schema/schemas/schema_maya_create.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/settings/entities/schemas/projects_schema/schemas/schema_maya_create.json b/openpype/settings/entities/schemas/projects_schema/schemas/schema_maya_create.json index b0bd46d20fb..bf3c9b3fe84 100644 --- a/openpype/settings/entities/schemas/projects_schema/schemas/schema_maya_create.json +++ b/openpype/settings/entities/schemas/projects_schema/schemas/schema_maya_create.json @@ -23,7 +23,7 @@ }, { "type": "boolean", - "key": "rstex", + "key": "rs_tex", "label": "Make Redshift texture files" }, { From 0bcf353c82df569dc4bab517f3f2713f05f29b71 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Tue, 5 Apr 2022 20:26:47 +0300 Subject: [PATCH 09/47] add redshift texture create option to look creator --- openpype/hosts/maya/plugins/create/create_look.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/maya/plugins/create/create_look.py b/openpype/hosts/maya/plugins/create/create_look.py index 56e2640919f..c190a73ade0 100644 --- a/openpype/hosts/maya/plugins/create/create_look.py +++ b/openpype/hosts/maya/plugins/create/create_look.py @@ -12,6 +12,7 @@ class CreateLook(plugin.Creator): family = "look" icon = "paint-brush" make_tx = True + rs_tex = False def __init__(self, *args, **kwargs): super(CreateLook, self).__init__(*args, **kwargs) @@ -20,6 +21,7 @@ def __init__(self, *args, **kwargs): # Whether to automatically convert the textures to .tx upon publish. self.data["maketx"] = self.make_tx - + # Whether to automatically convert the textures to .rstex upon publish. + self.data["rstex"] = self.rs_tex # Enable users to force a copy. self.data["forceCopy"] = False From 7bbf381c6e8fbd6a12a9ecf58d891f15d0e5ad83 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Tue, 5 Apr 2022 20:29:54 +0300 Subject: [PATCH 10/47] add rs_tex option to schema defaults --- openpype/settings/defaults/project_settings/maya.json | 1 + 1 file changed, 1 insertion(+) diff --git a/openpype/settings/defaults/project_settings/maya.json b/openpype/settings/defaults/project_settings/maya.json index 19d9a955954..7c09fa78912 100644 --- a/openpype/settings/defaults/project_settings/maya.json +++ b/openpype/settings/defaults/project_settings/maya.json @@ -34,6 +34,7 @@ "CreateLook": { "enabled": true, "make_tx": true, + "rs_tex": false, "defaults": [ "Main" ] From 078775e9b6bb5e814d1f284202419760853e631a Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Tue, 5 Apr 2022 21:16:02 +0300 Subject: [PATCH 11/47] add rstex variable to process_resources --- openpype/hosts/maya/plugins/publish/extract_look.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 6ce3a981f47..11f62ab80b6 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -363,7 +363,8 @@ def process_resources(self, instance, staging_dir): # be the input file to multiple nodes. resources = instance.data["resources"] do_maketx = instance.data.get("maketx", False) - + # Option to convert textures to native redshift textures + do_rstex = instance.data.get("rstex", False) # Collect all unique files used in the resources files_metadata = {} for resource in resources: From 6ac5cd4a4a5efad533512b9deea45fe0bba4532a Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Fri, 8 Apr 2022 07:22:49 +0300 Subject: [PATCH 12/47] Add redshift texture processing flag --- openpype/hosts/maya/plugins/publish/extract_look.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 11f62ab80b6..87e66256530 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -396,6 +396,7 @@ def process_resources(self, instance, staging_dir): source, mode, texture_hash = self._process_texture( filepath, + do_rstex, do_maketx, staging=staging_dir, linearize=linearize, @@ -487,7 +488,7 @@ def resource_destination(self, instance, filepath, do_maketx): resources_dir, basename + ext ) - def _process_texture(self, filepath, do_maketx, staging, linearize, force): + def _process_texture(self, filepath, do_rstex, do_maketx, staging, linearize, force): """Process a single texture file on disk for publishing. This will: 1. Check whether it's already published, if so it will do hardlink From c43ec04003c7763d82d62944cc36c62512f11fb4 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Fri, 8 Apr 2022 07:50:49 +0300 Subject: [PATCH 13/47] add redshift processor call to generate .rstexbin --- openpype/hosts/maya/plugins/publish/extract_look.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 87e66256530..6ce8ff60528 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -548,6 +548,10 @@ def _process_texture(self, filepath, do_rstex, do_maketx, staging, linearize, fo return converted, COPY, texture_hash + self.log.info("Generating .rstexbin file for %s .." % filepath) + # Generates Redshift optimized textures using Redshift processor + if do_rstex: + rstex(filepath) return filepath, COPY, texture_hash From 92c1ac7342d94889abb79a71a9be8b8750d7fba7 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Tue, 19 Apr 2022 21:33:11 +0300 Subject: [PATCH 14/47] refactor convertor function to abstract class and inherited class --- .../maya/plugins/publish/extract_look.py | 75 +++++++++++-------- 1 file changed, 43 insertions(+), 32 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index e0a5bff56cc..7f236637214 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- """Maya look extractor.""" +from abc import ABC, abstractmethod import os import sys import json @@ -43,50 +44,60 @@ def find_paths_by_hash(texture_hash): key = "data.sourceHashes.{0}".format(texture_hash) return io.distinct(key, {"type": "version"}) +class TextureProcessor(metaclass=ABC.ABCMeta): + def __init__(self): + #TODO: Figure out design for predetermined objects to be initialized. + + @abstractmethod + def process(self, filepath): -def rstex(source, *args): - """Make `.rstexbin` using `redshiftTextureProcessor` - with some default settings. + - This function requires the `REDSHIFT_COREDATAPATH` - to be in `PATH`. +class MakeRSTexBin(TextureProcessor): + + def process(source, *args): + """Make `.rstexbin` using `redshiftTextureProcessor` + with some default settings. - Args: - source (str): Path to source file. - *args: Additional arguments for `redshiftTextureProcessor`. + This function requires the `REDSHIFT_COREDATAPATH` + to be in `PATH`. - Returns: - str: Output of `redshiftTextureProcessor` command. + Args: + source (str): Path to source file. + *args: Additional arguments for `redshiftTextureProcessor`. - """ - if "REDSHIFT_COREDATAPATH" not in os.environ: - raise RuntimeError("Must have Redshift available.") + Returns: + str: Output of `redshiftTextureProcessor` command. - texture_processor_path = get_redshift_tool("TextureProcessor") + """ + if "REDSHIFT_COREDATAPATH" not in os.environ: + raise RuntimeError("Must have Redshift available.") - cmd = [ - texture_processor_path, - escape_space(source), - ] + texture_processor_path = get_redshift_tool("TextureProcessor") - cmd.extend(args) + cmd = [ + texture_processor_path, + escape_space(source), + ] - cmd = " ".join(cmd) + cmd.extend(args) - CREATE_NO_WINDOW = 0x08000000 - kwargs = dict(args=cmd, stderr=subprocess.STDOUT) + cmd = " ".join(cmd) - if sys.platform == "win32": - kwargs["creationflags"] = CREATE_NO_WINDOW - try: - out = subprocess.check_output(**kwargs) - except subprocess.CalledProcessError as exc: - print(exc) - import traceback + CREATE_NO_WINDOW = 0x08000000 + kwargs = dict(args=cmd, stderr=subprocess.STDOUT) - traceback.print_exc() - raise - return out + if sys.platform == "win32": + kwargs["creationflags"] = CREATE_NO_WINDOW + try: + processed_filepath = subprocess.check_output(**kwargs) + except subprocess.CalledProcessError as exc: + print(exc) + import traceback + + traceback.print_exc() + raise + return processed_filepath def maketx(source, destination, *args): From 74f2c78415b091cdbc9bd447549d20dc0b796235 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Tue, 19 Apr 2022 21:34:26 +0300 Subject: [PATCH 15/47] refactor tx conversion into class --- .../maya/plugins/publish/extract_look.py | 92 +++++++++---------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 7f236637214..54ab7b7877b 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -99,65 +99,65 @@ def process(source, *args): raise return processed_filepath +class MakeTX(TextureProcessor): + def process(source, destination, *args): + """Make `.tx` using `maketx` with some default settings. -def maketx(source, destination, *args): - """Make `.tx` using `maketx` with some default settings. + The settings are based on default as used in Arnold's + txManager in the scene. + This function requires the `maketx` executable to be + on the `PATH`. - The settings are based on default as used in Arnold's - txManager in the scene. - This function requires the `maketx` executable to be - on the `PATH`. - - Args: - source (str): Path to source file. - destination (str): Writing destination path. - *args: Additional arguments for `maketx`. + Args: + source (str): Path to source file. + destination (str): Writing destination path. + *args: Additional arguments for `maketx`. - Returns: - str: Output of `maketx` command. + Returns: + str: Output of `maketx` command. - """ - from openpype.lib import get_oiio_tools_path + """ + from openpype.lib import get_oiio_tools_path - maketx_path = get_oiio_tools_path("maketx") + maketx_path = get_oiio_tools_path("maketx") - if not os.path.exists(maketx_path): - print( - "OIIO tool not found in {}".format(maketx_path)) - raise AssertionError("OIIO tool not found") + if not os.path.exists(maketx_path): + print( + "OIIO tool not found in {}".format(maketx_path)) + raise AssertionError("OIIO tool not found") - cmd = [ - maketx_path, - "-v", # verbose - "-u", # update mode - # unpremultiply before conversion (recommended when alpha present) - "--unpremult", - "--checknan", - # use oiio-optimized settings for tile-size, planarconfig, metadata - "--oiio", - "--filter lanczos3", - ] + cmd = [ + maketx_path, + "-v", # verbose + "-u", # update mode + # unpremultiply before conversion (recommended when alpha present) + "--unpremult", + "--checknan", + # use oiio-optimized settings for tile-size, planarconfig, metadata + "--oiio", + "--filter lanczos3", + ] - cmd.extend(args) - cmd.extend(["-o", escape_space(destination), escape_space(source)]) + cmd.extend(args) + cmd.extend(["-o", escape_space(destination), escape_space(source)]) - cmd = " ".join(cmd) + cmd = " ".join(cmd) - CREATE_NO_WINDOW = 0x08000000 # noqa - kwargs = dict(args=cmd, stderr=subprocess.STDOUT) + CREATE_NO_WINDOW = 0x08000000 # noqa + kwargs = dict(args=cmd, stderr=subprocess.STDOUT) - if sys.platform == "win32": - kwargs["creationflags"] = CREATE_NO_WINDOW - try: - out = subprocess.check_output(**kwargs) - except subprocess.CalledProcessError as exc: - print(exc) - import traceback + if sys.platform == "win32": + kwargs["creationflags"] = CREATE_NO_WINDOW + try: + processed_filepath = subprocess.check_output(**kwargs) + except subprocess.CalledProcessError as exc: + print(exc) + import traceback - traceback.print_exc() - raise + traceback.print_exc() + raise - return out + return processed_filepath @contextlib.contextmanager From 7b1346e300c047654d6378c300916a4ac76acf56 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Tue, 19 Apr 2022 21:41:48 +0300 Subject: [PATCH 16/47] add processor list and adjust logic for more options later --- openpype/hosts/maya/plugins/publish/extract_look.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 54ab7b7877b..4b77a47729a 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -374,9 +374,15 @@ def process_resources(self, instance, staging_dir): # might be included more than once amongst the resources as they could # be the input file to multiple nodes. resources = instance.data["resources"] + # Specify texture processing executables to activate + processors = [] do_maketx = instance.data.get("maketx", False) + if do_maketx: + processors.append(MakeTX) # Option to convert textures to native redshift textures do_rstex = instance.data.get("rstex", False) + if do_rstex: + processors.append(MakeRSTexBin) # Collect all unique files used in the resources files_metadata = {} for resource in resources: From 0100ea5bf8496915875ad0f7ca90ec1bd93e88de Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Tue, 7 Jun 2022 15:46:30 +0300 Subject: [PATCH 17/47] Move redshift tool finder function to extractor. --- .../maya/plugins/publish/extract_look.py | 29 +++++++++++++++---- openpype/lib/vendor_bin_utils.py | 20 ------------- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 92d8f5ab17f..357f7a44305 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -8,7 +8,7 @@ import platform import contextlib import subprocess -from openpype.lib.vendor_bin_utils import get_redshift_tool +from openpype.lib.vendor_bin_utils import find_executable from collections import OrderedDict from maya import cmds # noqa @@ -46,15 +46,13 @@ def find_paths_by_hash(texture_hash): class TextureProcessor(metaclass=ABC.ABCMeta): def __init__(self): - #TODO: Figure out design for predetermined objects to be initialized. - + #TODO: Figure out design for predetermined objects to be initialized. + @abstractmethod def process(self, filepath): - class MakeRSTexBin(TextureProcessor): - def process(source, *args): """Make `.rstexbin` using `redshiftTextureProcessor` with some default settings. @@ -99,6 +97,7 @@ def process(source, *args): raise return processed_filepath + class MakeTX(TextureProcessor): def process(source, destination, *args): """Make `.tx` using `maketx` with some default settings. @@ -603,3 +602,23 @@ def get_maya_scene_type(self, instance): self.scene_type = self.scene_type_prefix + self.scene_type return typ + + +def get_redshift_tool(tool_name): + """Path to redshift texture processor. + + On Windows it adds .exe extension if missing from tool argument. + + Args: + tool (string): Tool name. + + Returns: + str: Full path to redshift texture processor executable. + """ + redshift_tool_path = os.path.join( + os.environ["REDSHIFT_COREDATAPATH"], + "bin", + tool_name + ) + + return find_executable(redshift_tool_path) diff --git a/openpype/lib/vendor_bin_utils.py b/openpype/lib/vendor_bin_utils.py index cdc12904007..e5ab2872a0e 100644 --- a/openpype/lib/vendor_bin_utils.py +++ b/openpype/lib/vendor_bin_utils.py @@ -123,26 +123,6 @@ def get_oiio_tools_path(tool="oiiotool"): return find_executable(os.path.join(oiio_dir, tool)) -def get_redshift_tool(tool_name): - """Path to redshift texture processor. - - On Windows it adds .exe extension if missing from tool argument. - - Args: - tool (string): Tool name. - - Returns: - str: Full path to redshift texture processor executable. - """ - redshift_tool_path = os.path.join( - os.environ["REDSHIFT_COREDATAPATH"], - "bin", - tool_name - ) - - return find_executable(redshift_tool_path) - - def get_ffmpeg_tool_path(tool="ffmpeg"): """Path to vendorized FFmpeg executable. From 2102e4f4fa86778542d96e9758dbb12967b6b762 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Tue, 7 Jun 2022 15:46:50 +0300 Subject: [PATCH 18/47] Add variable for redshift os path. --- openpype/hosts/maya/plugins/publish/extract_look.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 357f7a44305..69d7eb78af8 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -615,8 +615,10 @@ def get_redshift_tool(tool_name): Returns: str: Full path to redshift texture processor executable. """ + redshift_os_path = os.environ["REDSHIFT_COREDATAPATH"] + redshift_tool_path = os.path.join( - os.environ["REDSHIFT_COREDATAPATH"], + redshift_os_path, "bin", tool_name ) From 406ac826e018ffcac07aa9145f5c532b86ddfd27 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Tue, 7 Jun 2022 16:09:53 +0300 Subject: [PATCH 19/47] Style fix --- 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 69d7eb78af8..2e83af1437c 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -46,7 +46,7 @@ def find_paths_by_hash(texture_hash): class TextureProcessor(metaclass=ABC.ABCMeta): def __init__(self): - #TODO: Figure out design for predetermined objects to be initialized. + # TODO: Figure out design for predetermined objects to be initialized. @abstractmethod def process(self, filepath): From 710ed3a889ee3d7043501d514d0cc3be3e8d571e Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Wed, 8 Jun 2022 10:37:46 +0300 Subject: [PATCH 20/47] Start moving processors logic. --- .../maya/plugins/publish/extract_look.py | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 2e83af1437c..cce2643dba1 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -44,6 +44,7 @@ def find_paths_by_hash(texture_hash): key = "data.sourceHashes.{0}".format(texture_hash) return legacy_io.distinct(key, {"type": "version"}) + class TextureProcessor(metaclass=ABC.ABCMeta): def __init__(self): # TODO: Figure out design for predetermined objects to be initialized. @@ -51,6 +52,8 @@ def __init__(self): @abstractmethod def process(self, filepath): + return processed_texture_path + class MakeRSTexBin(TextureProcessor): def process(source, *args): @@ -373,15 +376,6 @@ def process_resources(self, instance, staging_dir): # might be included more than once amongst the resources as they could # be the input file to multiple nodes. resources = instance.data["resources"] - # Specify texture processing executables to activate - processors = [] - do_maketx = instance.data.get("maketx", False) - if do_maketx: - processors.append(MakeTX) - # Option to convert textures to native redshift textures - do_rstex = instance.data.get("rstex", False) - if do_rstex: - processors.append(MakeRSTexBin) # Collect all unique files used in the resources files_metadata = {} for resource in resources: @@ -420,8 +414,7 @@ def process_resources(self, instance, staging_dir): source, mode, texture_hash = self._process_texture( filepath, - do_rstex, - do_maketx, + processors, staging=staging_dir, linearize=linearize, force=force_copy @@ -514,7 +507,7 @@ def resource_destination(self, instance, filepath, do_maketx): resources_dir, basename + ext ) - def _process_texture(self, filepath, do_rstex, do_maketx, staging, linearize, force): + def _process_texture(self, filepath, processors, staging, linearize, force): """Process a single texture file on disk for publishing. This will: 1. Check whether it's already published, if so it will do hardlink @@ -546,7 +539,17 @@ def _process_texture(self, filepath, do_rstex, do_maketx, staging, linearize, fo ("Paths not found on disk, " "skipping hardlink: %s") % (existing,) ) - + texture_files = self.collect_text + # Specify texture processing executables to activate + processors = [] + do_maketx = instance.data.get("maketx", False) + if do_maketx: + processors.append(MakeTX) + # Option to convert textures to native redshift textures + do_rstex = instance.data.get("rstex", False) + if do_rstex: + processors.append(MakeRSTexBin) + if do_maketx and ext != ".tx": # Produce .tx file in staging if source file is not .tx converted = os.path.join(staging, "resources", fname + ".tx") From 68caaa7528882654077a208b835a712f3e319850 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Thu, 9 Jun 2022 10:56:26 +0300 Subject: [PATCH 21/47] move function --- .../maya/plugins/publish/extract_look.py | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index cce2643dba1..d6c35882804 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -24,6 +24,28 @@ HARDLINK = 2 +def get_redshift_tool(tool_name): + """Path to redshift texture processor. + + On Windows it adds .exe extension if missing from tool argument. + + Args: + tool (string): Tool name. + + Returns: + str: Full path to redshift texture processor executable. + """ + redshift_os_path = os.environ["REDSHIFT_COREDATAPATH"] + + redshift_tool_path = os.path.join( + redshift_os_path, + "bin", + tool_name + ) + + return find_executable(redshift_tool_path) + + def escape_space(path): """Ensure path is enclosed by quotes to allow paths with spaces""" return '"{}"'.format(path) if " " in path else path @@ -605,25 +627,3 @@ def get_maya_scene_type(self, instance): self.scene_type = self.scene_type_prefix + self.scene_type return typ - - -def get_redshift_tool(tool_name): - """Path to redshift texture processor. - - On Windows it adds .exe extension if missing from tool argument. - - Args: - tool (string): Tool name. - - Returns: - str: Full path to redshift texture processor executable. - """ - redshift_os_path = os.environ["REDSHIFT_COREDATAPATH"] - - redshift_tool_path = os.path.join( - redshift_os_path, - "bin", - tool_name - ) - - return find_executable(redshift_tool_path) From 29b69bcbb805702080fe54e52505fe09a3741f99 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Thu, 9 Jun 2022 20:47:26 +0300 Subject: [PATCH 22/47] Class cleanup --- openpype/hosts/maya/plugins/publish/extract_look.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index d7b179daf2c..be31deeb6eb 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -69,12 +69,12 @@ def find_paths_by_hash(texture_hash): class TextureProcessor(metaclass=ABC.ABCMeta): def __init__(self): - # TODO: Figure out design for predetermined objects to be initialized. + pass @abstractmethod def process(self, filepath): - return processed_texture_path + pass class MakeRSTexBin(TextureProcessor): @@ -544,8 +544,7 @@ def _process_texture(self, filepath, processors, staging, linearize, force): fname, ext = os.path.splitext(os.path.basename(filepath)) args = [] - if do_maketx: - args.append("maketx") + texture_hash = openpype.api.source_hash(filepath, *args) # If source has been published before with the same settings, @@ -571,7 +570,7 @@ def _process_texture(self, filepath, processors, staging, linearize, force): do_rstex = instance.data.get("rstex", False) if do_rstex: processors.append(MakeRSTexBin) - + if do_maketx and ext != ".tx": # Produce .tx file in staging if source file is not .tx converted = os.path.join(staging, "resources", fname + ".tx") From e78314ca92283b38fd05d8995aeb9c06b460277e Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Thu, 9 Jun 2022 20:49:07 +0300 Subject: [PATCH 23/47] Remove unused maketx code. --- .../maya/plugins/publish/extract_look.py | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index be31deeb6eb..3e1f91f5b7d 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -544,7 +544,6 @@ def _process_texture(self, filepath, processors, staging, linearize, force): fname, ext = os.path.splitext(os.path.basename(filepath)) args = [] - texture_hash = openpype.api.source_hash(filepath, *args) # If source has been published before with the same settings, @@ -571,32 +570,6 @@ def _process_texture(self, filepath, processors, staging, linearize, force): if do_rstex: processors.append(MakeRSTexBin) - if do_maketx and ext != ".tx": - # Produce .tx file in staging if source file is not .tx - converted = os.path.join(staging, "resources", fname + ".tx") - - if linearize: - self.log.info("tx: converting sRGB -> linear") - colorconvert = "--colorconvert sRGB linear" - else: - colorconvert = "" - - # Ensure folder exists - if not os.path.exists(os.path.dirname(converted)): - os.makedirs(os.path.dirname(converted)) - - self.log.info("Generating .tx file for %s .." % filepath) - maketx( - filepath, - converted, - # Include `source-hash` as string metadata - "-sattrib", - "sourceHash", - escape_space(texture_hash), - colorconvert, - ) - - return converted, COPY, texture_hash self.log.info("Generating .rstexbin file for %s .." % filepath) # Generates Redshift optimized textures using Redshift processor From 00d877e2dfca6b1e89a4b4d289b2621a6e8b2037 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Thu, 9 Jun 2022 20:50:51 +0300 Subject: [PATCH 24/47] Move processors list --- .../maya/plugins/publish/extract_look.py | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 3e1f91f5b7d..88c93a8e3ba 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -433,7 +433,15 @@ def process_resources(self, instance, staging_dir): # if do_maketx: # color_space = "Raw" - + # Specify texture processing executables to activate + processors = [] + do_maketx = instance.data.get("maketx", False) + if do_maketx: + processors.append(MakeTX) + # Option to convert textures to native redshift textures + do_rstex = instance.data.get("rstex", False) + if do_rstex: + processors.append(MakeRSTexBin) source, mode, texture_hash = self._process_texture( filepath, processors, @@ -559,16 +567,6 @@ def _process_texture(self, filepath, processors, staging, linearize, force): ("Paths not found on disk, " "skipping hardlink: %s") % (existing,) ) - texture_files = self.collect_text - # Specify texture processing executables to activate - processors = [] - do_maketx = instance.data.get("maketx", False) - if do_maketx: - processors.append(MakeTX) - # Option to convert textures to native redshift textures - do_rstex = instance.data.get("rstex", False) - if do_rstex: - processors.append(MakeRSTexBin) self.log.info("Generating .rstexbin file for %s .." % filepath) From 2933e409c769f13afd0e1df778fdacd06cf7b848 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Thu, 9 Jun 2022 20:59:19 +0300 Subject: [PATCH 25/47] Handle texture processing through processors separately --- openpype/hosts/maya/plugins/publish/extract_look.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 88c93a8e3ba..73d661168a3 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -442,6 +442,7 @@ def process_resources(self, instance, staging_dir): do_rstex = instance.data.get("rstex", False) if do_rstex: processors.append(MakeRSTexBin) + source, mode, texture_hash = self._process_texture( filepath, processors, @@ -567,12 +568,9 @@ def _process_texture(self, filepath, processors, staging, linearize, force): ("Paths not found on disk, " "skipping hardlink: %s") % (existing,) ) - - - self.log.info("Generating .rstexbin file for %s .." % filepath) - # Generates Redshift optimized textures using Redshift processor - if do_rstex: - rstex(filepath) + for processor in processors: + processor().process(filepath) + self.log.info("Generating .rstexbin file for %s .." % filepath) return filepath, COPY, texture_hash From b054175d6e834dabd7b3d8719eed901ab139062f Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Thu, 9 Jun 2022 21:06:02 +0300 Subject: [PATCH 26/47] Reorganize functionality for do_maketx to linearize properly. --- openpype/hosts/maya/plugins/publish/extract_look.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 73d661168a3..e90f9759f9e 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -426,23 +426,20 @@ def process_resources(self, instance, staging_dir): for filepath in files_metadata: linearize = False - 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" # Specify texture processing executables to activate processors = [] do_maketx = instance.data.get("maketx", False) + do_rstex = instance.data.get("rstex", False) if do_maketx: processors.append(MakeTX) # Option to convert textures to native redshift textures - do_rstex = instance.data.get("rstex", False) if do_rstex: processors.append(MakeRSTexBin) - + 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" source, mode, texture_hash = self._process_texture( filepath, processors, From fd3125deda242f2676f1262fffb4e93212ffa300 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Thu, 9 Jun 2022 21:07:26 +0300 Subject: [PATCH 27/47] Style fixes --- openpype/hosts/maya/plugins/publish/extract_look.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index e90f9759f9e..018e45a01f1 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -436,6 +436,7 @@ def process_resources(self, instance, staging_dir): # Option to convert textures to native redshift textures if do_rstex: processors.append(MakeRSTexBin) + 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 From 41e7ac78aa340d4af45c48b036fb3ccf39c56f79 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Thu, 9 Jun 2022 22:11:12 +0300 Subject: [PATCH 28/47] adjust comment --- 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 018e45a01f1..922e3475612 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -568,7 +568,7 @@ def _process_texture(self, filepath, processors, staging, linearize, force): ) for processor in processors: processor().process(filepath) - self.log.info("Generating .rstexbin file for %s .." % filepath) + self.log.info("Generating texture file for %s .." % filepath) return filepath, COPY, texture_hash From 35be81615ee986b0b71482a8f13097fa469ab477 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Fri, 10 Jun 2022 10:51:19 +0300 Subject: [PATCH 29/47] Fix returned filepath --- openpype/hosts/maya/plugins/publish/extract_look.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 922e3475612..7693e917659 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -567,9 +567,9 @@ def _process_texture(self, filepath, processors, staging, linearize, force): "skipping hardlink: %s") % (existing,) ) for processor in processors: - processor().process(filepath) + processed_path = processor().process(filepath) self.log.info("Generating texture file for %s .." % filepath) - return filepath, COPY, texture_hash + return processed_path, COPY, texture_hash class ExtractModelRenderSets(ExtractLook): From cfb90934289a742572d93323d48df6ae061acdb7 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Fri, 10 Jun 2022 20:32:58 +0300 Subject: [PATCH 30/47] Append processors check, append path return. --- openpype/hosts/maya/plugins/publish/extract_look.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 7693e917659..c72aede0d4c 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -566,9 +566,13 @@ def _process_texture(self, filepath, processors, staging, linearize, force): ("Paths not found on disk, " "skipping hardlink: %s") % (existing,) ) - for processor in processors: - processed_path = processor().process(filepath) - self.log.info("Generating texture file for %s .." % filepath) + + if bool(processors): + for processor in processors: + processed_path = processor().process(filepath) + self.log.info("Generating texture file for %s .." % filepath) + return processed_path + return processed_path, COPY, texture_hash From eb9994484e94f9e595d95fac302da49cef986cc4 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Fri, 10 Jun 2022 20:35:53 +0300 Subject: [PATCH 31/47] Style fix --- 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 c72aede0d4c..6d8b6f1d8e4 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -536,7 +536,7 @@ def resource_destination(self, instance, filepath, do_maketx): resources_dir, basename + ext ) - def _process_texture(self, filepath, processors, staging, linearize, force): + def _process_texture(self, filepath, processors, staging, linearize, force): # noqa """Process a single texture file on disk for publishing. This will: 1. Check whether it's already published, if so it will do hardlink From e5fdd9e9302fe82620b5fb0c94c4ce1188c4a731 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Tue, 26 Jul 2022 20:45:54 +0300 Subject: [PATCH 32/47] Syntax fix. --- openpype/hosts/maya/plugins/publish/extract_look.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 6d8b6f1d8e4..3fe8139dd65 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """Maya look extractor.""" -from abc import ABC, abstractmethod +import abc import os import sys import json @@ -67,11 +67,11 @@ def find_paths_by_hash(texture_hash): return legacy_io.distinct(key, {"type": "version"}) -class TextureProcessor(metaclass=ABC.ABCMeta): +class TextureProcessor(abc.ABCMeta): def __init__(self): pass - @abstractmethod + @abc.abstractmethod def process(self, filepath): pass From ab14895753c72177ebdfc7ff4f6e8b0bb1eb68ec Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Tue, 26 Jul 2022 23:27:11 +0300 Subject: [PATCH 33/47] Change metaclass inheritance formatting to 2.7 --- openpype/hosts/maya/plugins/publish/extract_look.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 3fe8139dd65..be6d8638783 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """Maya look extractor.""" -import abc +from abc import ABCMeta, abstractmethod import os import sys import json @@ -67,11 +67,13 @@ def find_paths_by_hash(texture_hash): return legacy_io.distinct(key, {"type": "version"}) -class TextureProcessor(abc.ABCMeta): +class TextureProcessor(object): + __metaclass__ = ABCMeta + def __init__(self): pass - @abc.abstractmethod + @abstractmethod def process(self, filepath): pass From c471bbe71e20f09df30c1ea734a958f3a308e3f6 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Wed, 27 Jul 2022 02:26:18 +0300 Subject: [PATCH 34/47] Fix inheritance with `six`, adjust processing code --- .../maya/plugins/publish/extract_look.py | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index be6d8638783..19e0bd9568f 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- """Maya look extractor.""" from abc import ABCMeta, abstractmethod +import six import os import sys import json @@ -67,9 +68,9 @@ def find_paths_by_hash(texture_hash): return legacy_io.distinct(key, {"type": "version"}) -class TextureProcessor(object): - __metaclass__ = ABCMeta - +@six.add_metaclass(ABCMeta) +class TextureProcessor: + @abstractmethod def __init__(self): pass @@ -80,7 +81,10 @@ def process(self, filepath): class MakeRSTexBin(TextureProcessor): - def process(source, *args): + def __init__(self): + super(TextureProcessor, self).__init__() + + def process(self, source, *args): """Make `.rstexbin` using `redshiftTextureProcessor` with some default settings. @@ -126,7 +130,10 @@ def process(source, *args): class MakeTX(TextureProcessor): - def process(source, destination, *args): + def __init__(self): + super(TextureProcessor, self).__init__() + + def process(self, source, destination, *args): """Make `.tx` using `maketx` with some default settings. The settings are based on default as used in Arnold's @@ -558,6 +565,10 @@ def _process_texture(self, filepath, processors, staging, linearize, force): # n # If source has been published before with the same settings, # then don't reprocess but hardlink from the original existing = find_paths_by_hash(texture_hash) + # if processors["do_maketx"]: + # Produce .tx file in staging if source file is not .tx + + if existing and not force: self.log.info("Found hash in database, preparing hardlink..") source = next((p for p in existing if os.path.exists(p)), None) @@ -571,9 +582,15 @@ def _process_texture(self, filepath, processors, staging, linearize, force): # n if bool(processors): for processor in processors: - processed_path = processor().process(filepath) - self.log.info("Generating texture file for %s .." % filepath) - return processed_path + if processor == MakeTX: + converted = os.path.join(staging, "resources", fname + ".tx") + processed_path = processor().process(converted, filepath) + self.log.info("Generating texture file for %s .." % filepath) # noqa + return processed_path + elif processor == MakeRSTexBin: + processed_path = processor().process(filepath) + self.log.info("Generating texture file for %s .." % filepath) # noqa + return processed_path return processed_path, COPY, texture_hash From 5f4d06baecce44fd735e1a26770f0a617c0284fb Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Wed, 27 Jul 2022 02:48:43 +0300 Subject: [PATCH 35/47] Remove unnecessary comment, style fixes. --- openpype/hosts/maya/plugins/publish/extract_look.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 19e0bd9568f..bb4335a3d52 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -172,7 +172,7 @@ def process(self, source, destination, *args): ] cmd.extend(args) - cmd.extend(["-o", escape_space(destination), escape_space(source)]) + cmd.extend([escape_space(source), "-o", escape_space(destination)]) cmd = " ".join(cmd) @@ -188,6 +188,8 @@ def process(self, source, destination, *args): import traceback traceback.print_exc() + print(exc.returncode) + print(exc.output) raise return processed_filepath @@ -565,9 +567,6 @@ def _process_texture(self, filepath, processors, staging, linearize, force): # n # If source has been published before with the same settings, # then don't reprocess but hardlink from the original existing = find_paths_by_hash(texture_hash) - # if processors["do_maketx"]: - # Produce .tx file in staging if source file is not .tx - if existing and not force: self.log.info("Found hash in database, preparing hardlink..") @@ -583,8 +582,8 @@ def _process_texture(self, filepath, processors, staging, linearize, force): # n if bool(processors): for processor in processors: if processor == MakeTX: - converted = os.path.join(staging, "resources", fname + ".tx") - processed_path = processor().process(converted, filepath) + converted = os.path.join(staging, "resources", fname + ".tx") # noqa + processed_path = processor().process(filepath, converted) self.log.info("Generating texture file for %s .." % filepath) # noqa return processed_path elif processor == MakeRSTexBin: From 9b0cc4dfac23100fa3979b53418734c39399c5ca Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Mon, 1 Aug 2022 03:28:26 +0300 Subject: [PATCH 36/47] Continue refactor --- .../maya/plugins/publish/extract_look.py | 52 +++++++++++-------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 136b64a5474..8d302686191 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -615,12 +615,29 @@ def _process_texture(self, filepath, processors, staging, linearize, force): # n ("Paths not found on disk, " "skipping hardlink: %s") % (existing,) ) + config_path = get_ocio_config_path("nuke-default") + color_config = "--colorconfig {0}".format(config_path) + # Ensure folder exists + if linearize: + self.log.info("tx: converting sRGB -> linear") + colorconvert = "--colorconvert sRGB linear" + else: + colorconvert = "" + + converted = os.path.join(staging, "resources", fname + ".tx") + if not os.path.exists(os.path.dirname(converted)): + os.makedirs(os.path.dirname(converted)) if bool(processors): for processor in processors: if processor == MakeTX: - converted = os.path.join(staging, "resources", fname + ".tx") # noqa - processed_path = processor().process(filepath, converted) + processed_path = processor().process(filepath, + converted, + "--sattrib", + "sourceHash %", + escape_space(texture_hash), # noqa + colorconvert, + color_config) self.log.info("Generating texture file for %s .." % filepath) # noqa return processed_path elif processor == MakeRSTexBin: @@ -628,27 +645,18 @@ def _process_texture(self, filepath, processors, staging, linearize, force): # n self.log.info("Generating texture file for %s .." % filepath) # noqa return processed_path - return processed_path, COPY, texture_hash - - config_path = get_ocio_config_path("nuke-default") - color_config = "--colorconfig {0}".format(config_path) - # Ensure folder exists - if not os.path.exists(os.path.dirname(converted)): - os.makedirs(os.path.dirname(converted)) - - self.log.info("Generating .tx file for %s .." % filepath) - maketx( - filepath, - converted, - # Include `source-hash` as string metadata - "--sattrib", - "sourceHash", - escape_space(texture_hash), - colorconvert, - color_config - ) - return converted, COPY, texture_hash + # self.log.info("Generating .tx file for %s .." % filepath) + # maketx( + # filepath, + # converted, + # # Include `source-hash` as string metadata + # "--sattrib", + # "sourceHash", + # escape_space(texture_hash), + # colorconvert, + # color_config + # ) return filepath, COPY, texture_hash From c35f1cfe3c295d7915e4a2b856f48ecae85cab38 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Mon, 1 Aug 2022 04:09:09 +0300 Subject: [PATCH 37/47] Remove leftover code --- .../maya/plugins/publish/extract_look.py | 32 +------------------ 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 8d302686191..ecbb0709161 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -114,27 +114,10 @@ def process(self, source, *args): This function requires the `REDSHIFT_COREDATAPATH` to be in `PATH`. - cmd = [ - maketx_path, - "-v", # verbose - "-u", # update mode - # unpremultiply before conversion (recommended when alpha present) - "--unpremult", - "--checknan", - # use oiio-optimized settings for tile-size, planarconfig, metadata - "--oiio", - "--filter lanczos3", - escape_space(source) - ] Args: source (str): Path to source file. *args: Additional arguments for `redshiftTextureProcessor`. - cmd.extend(args) - cmd.extend(["-o", escape_space(destination)]) - Returns: - str: Output of `redshiftTextureProcessor` command. - """ if "REDSHIFT_COREDATAPATH" not in os.environ: raise RuntimeError("Must have Redshift available.") @@ -634,7 +617,7 @@ def _process_texture(self, filepath, processors, staging, linearize, force): # n processed_path = processor().process(filepath, converted, "--sattrib", - "sourceHash %", + "sourceHash", escape_space(texture_hash), # noqa colorconvert, color_config) @@ -645,19 +628,6 @@ def _process_texture(self, filepath, processors, staging, linearize, force): # n self.log.info("Generating texture file for %s .." % filepath) # noqa return processed_path - - # self.log.info("Generating .tx file for %s .." % filepath) - # maketx( - # filepath, - # converted, - # # Include `source-hash` as string metadata - # "--sattrib", - # "sourceHash", - # escape_space(texture_hash), - # colorconvert, - # color_config - # ) - return filepath, COPY, texture_hash From 099dfba8fa19dca4bc1cc9a30632f659854c9300 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Mon, 1 Aug 2022 05:06:58 +0300 Subject: [PATCH 38/47] Fix return bug --- openpype/hosts/maya/plugins/publish/extract_look.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index ecbb0709161..53b6dcbf358 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -622,11 +622,11 @@ def _process_texture(self, filepath, processors, staging, linearize, force): # n colorconvert, color_config) self.log.info("Generating texture file for %s .." % filepath) # noqa - return processed_path + return processed_path, COPY, texture_hash elif processor == MakeRSTexBin: processed_path = processor().process(filepath) self.log.info("Generating texture file for %s .." % filepath) # noqa - return processed_path + return processed_path, COPY, texture_hash return filepath, COPY, texture_hash From 8995dcdff4a9a6c5c951958fb71b99ee93b44029 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Mon, 1 Aug 2022 12:26:44 +0300 Subject: [PATCH 39/47] Check for return value, adjust argument --- .../hosts/maya/plugins/publish/extract_look.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 53b6dcbf358..48af6443264 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- """Maya look extractor.""" from abc import ABCMeta, abstractmethod + import six import os import sys @@ -189,10 +190,11 @@ def process(self, source, destination, *args): # use oiio-optimized settings for tile-size, planarconfig, metadata "--oiio", "--filter lanczos3", + escape_space(source) ] cmd.extend(args) - cmd.extend([escape_space(source), "-o", escape_space(destination)]) + cmd.extend(["-o", escape_space(destination)]) cmd = " ".join(cmd) @@ -620,13 +622,21 @@ def _process_texture(self, filepath, processors, staging, linearize, force): # n "sourceHash", escape_space(texture_hash), # noqa colorconvert, - color_config) + color_config, + ) self.log.info("Generating texture file for %s .." % filepath) # noqa - return processed_path, COPY, texture_hash + self.log.info(converted) + if processed_path: + return processed_path + else: + self.log.info("maketx has returned nothing") elif processor == MakeRSTexBin: processed_path = processor().process(filepath) self.log.info("Generating texture file for %s .." % filepath) # noqa - return processed_path, COPY, texture_hash + if processed_path: + return processed_path + else: + self.log.info("redshift texture converter has returned nothing") # noqa return filepath, COPY, texture_hash From 3cd7fd503c0cb94ef3f4da86a3c465ff6bc26cb1 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Mon, 15 Aug 2022 04:23:24 +0300 Subject: [PATCH 40/47] Fix assignment bug, remove unnecessary class sugar --- openpype/hosts/maya/plugins/publish/extract_look.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 48af6443264..c092e2ac251 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -94,7 +94,7 @@ def find_paths_by_hash(texture_hash): @six.add_metaclass(ABCMeta) class TextureProcessor: - @abstractmethod + def __init__(self): pass @@ -106,7 +106,7 @@ def process(self, filepath): class MakeRSTexBin(TextureProcessor): def __init__(self): - super(TextureProcessor, self).__init__() + super(MakeRSTexBin, self).__init__() def process(self, source, *args): """Make `.rstexbin` using `redshiftTextureProcessor` @@ -152,7 +152,7 @@ def process(self, source, *args): class MakeTX(TextureProcessor): def __init__(self): - super(TextureProcessor, self).__init__() + super(MakeTX, self).__init__() def process(self, source, destination, *args): """Make `.tx` using `maketx` with some default settings. @@ -627,18 +627,18 @@ def _process_texture(self, filepath, processors, staging, linearize, force): # n self.log.info("Generating texture file for %s .." % filepath) # noqa self.log.info(converted) if processed_path: - return processed_path + return processed_path, COPY, texture_hash else: self.log.info("maketx has returned nothing") elif processor == MakeRSTexBin: processed_path = processor().process(filepath) self.log.info("Generating texture file for %s .." % filepath) # noqa if processed_path: - return processed_path + return processed_path, COPY, texture_hash else: self.log.info("redshift texture converter has returned nothing") # noqa - return filepath, COPY, texture_hash + return processed_path, COPY, texture_hash class ExtractModelRenderSets(ExtractLook): From 9ec42cb4376e0e14eb990cfd22c6a9f1c38e0575 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Tue, 23 Aug 2022 13:05:37 +0300 Subject: [PATCH 41/47] Fix bugs --- .../hosts/maya/plugins/publish/extract_look.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 52751eea813..19765d43966 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -125,7 +125,7 @@ def process(self, source, *args): if "REDSHIFT_COREDATAPATH" not in os.environ: raise RuntimeError("Must have Redshift available.") - texture_processor_path = get_redshift_tool("TextureProcessor") + texture_processor_path = get_redshift_tool("redshiftTextureProcessor") cmd = [ texture_processor_path, @@ -142,14 +142,14 @@ def process(self, source, *args): if sys.platform == "win32": kwargs["creationflags"] = CREATE_NO_WINDOW try: - processed_filepath = subprocess.check_output(**kwargs) + subprocess.check_output(**kwargs) except subprocess.CalledProcessError as exc: print(exc) import traceback traceback.print_exc() raise - return processed_filepath + return source class MakeTX(TextureProcessor): @@ -206,7 +206,7 @@ def process(self, source, destination, *args): if sys.platform == "win32": kwargs["creationflags"] = CREATE_NO_WINDOW try: - processed_filepath = subprocess.check_output(**kwargs) + subprocess.check_output(**kwargs) except subprocess.CalledProcessError as exc: print(exc) import traceback @@ -216,7 +216,7 @@ def process(self, source, destination, *args): print(exc.output) raise - return processed_filepath + return destination @contextlib.contextmanager @@ -629,7 +629,7 @@ def _process_texture(self, filepath, processors, staging, linearize, force): # n if bool(processors): for processor in processors: - if processor == MakeTX: + if processor is MakeTX: processed_path = processor().process(filepath, converted, "--sattrib", @@ -644,7 +644,7 @@ def _process_texture(self, filepath, processors, staging, linearize, force): # n return processed_path, COPY, texture_hash else: self.log.info("maketx has returned nothing") - elif processor == MakeRSTexBin: + elif processor is MakeRSTexBin: processed_path = processor().process(filepath) self.log.info("Generating texture file for %s .." % filepath) # noqa if processed_path: From cc62035e1be2e02d38c3e1972bd37f458f70eb83 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Tue, 23 Aug 2022 13:22:59 +0300 Subject: [PATCH 42/47] Fix destination finding for copying resrouce. --- .../maya/plugins/publish/extract_look.py | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 19765d43966..7f79867cea5 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -483,9 +483,15 @@ def process_resources(self, instance, staging_dir): linearize=linearize, force=force_copy ) - destination = self.resource_destination(instance, - source, - do_maketx) + for processor in processors: + if processor is MakeTX: + destination = self.resource_destination( + instance, source, MakeTX + ) + elif processor is MakeRSTexBin: + destination = self.resource_destination( + instance, source, MakeRSTexBin + ) # Force copy is specified. if force_copy: @@ -512,9 +518,15 @@ def process_resources(self, instance, staging_dir): if source not in destinations: # Cache destination as source resource might be included # multiple times - destinations[source] = self.resource_destination( - instance, source, do_maketx - ) + for processor in processors: + if processor is MakeTX: + destinations[source] = self.resource_destination( + instance, source, MakeTX + ) + elif processor is MakeRSTexBin: + destinations[source] = self.resource_destination( + instance, source, MakeRSTexBin + ) # Preserve color space values (force value after filepath change) # This will also trigger in the same order at end of context to @@ -555,7 +567,7 @@ def process_resources(self, instance, staging_dir): "attrRemap": remap, } - def resource_destination(self, instance, filepath, do_maketx): + def resource_destination(self, instance, filepath, processor): """Get resource destination path. This is utility function to change path if resource file name is @@ -564,7 +576,7 @@ def resource_destination(self, instance, filepath, do_maketx): Args: instance: Current Instance. filepath (str): Resource path - do_maketx (bool): Flag if resource is processed by `maketx`. + processor: Texture processor converting resource. Returns: str: Path to resource file @@ -576,8 +588,10 @@ def resource_destination(self, instance, filepath, do_maketx): basename, ext = os.path.splitext(os.path.basename(filepath)) # If `maketx` then the texture will always end with .tx - if do_maketx: + if processor == MakeTX: ext = ".tx" + elif processor == MakeRSTexBin: + ext = ".rstexbin" return os.path.join( resources_dir, basename + ext From ad8177cee3c7ee6241b995b781b9dc93fead19b1 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Tue, 23 Aug 2022 16:10:44 +0300 Subject: [PATCH 43/47] Removed submodule vendor/configs/OpenColorIO-Configs --- vendor/configs/OpenColorIO-Configs | 1 - 1 file changed, 1 deletion(-) delete mode 160000 vendor/configs/OpenColorIO-Configs diff --git a/vendor/configs/OpenColorIO-Configs b/vendor/configs/OpenColorIO-Configs deleted file mode 160000 index 0bb079c08be..00000000000 --- a/vendor/configs/OpenColorIO-Configs +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0bb079c08be410030669cbf5f19ff869b88af953 From 590538eb128dc8e7e8e6eee0b8d16ab593530e5e Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Tue, 4 Oct 2022 11:07:09 +0300 Subject: [PATCH 44/47] Fix import bug --- openpype/hosts/maya/plugins/publish/extract_look.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 7e640c375d0..f3128306eeb 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -11,13 +11,14 @@ import contextlib import subprocess from openpype.lib.vendor_bin_utils import find_executable +from openpype.lib import source_hash from collections import OrderedDict from maya import cmds # noqa import pyblish.api -from openpype.lib import source_hash, run_subprocess + from openpype.pipeline import legacy_io, publish from openpype.hosts.maya.api import lib @@ -93,7 +94,6 @@ def find_paths_by_hash(texture_hash): key = "data.sourceHashes.{0}".format(texture_hash) return legacy_io.distinct(key, {"type": "version"}) - @six.add_metaclass(ABCMeta) class TextureProcessor: @@ -612,7 +612,7 @@ def _process_texture(self, filepath, processors, staging, linearize, force): # n fname, ext = os.path.splitext(os.path.basename(filepath)) args = [] - texture_hash = openpype.api.source_hash(filepath, *args) + texture_hash = source_hash(filepath, *args) # If source has been published before with the same settings, # then don't reprocess but hardlink from the original From 035281fa4c939e6e56d356a97535cf837cc933a2 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Tue, 4 Oct 2022 11:08:27 +0300 Subject: [PATCH 45/47] Style fix --- openpype/hosts/maya/plugins/publish/extract_look.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index f3128306eeb..6b0fe36d8f5 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -94,6 +94,7 @@ def find_paths_by_hash(texture_hash): key = "data.sourceHashes.{0}".format(texture_hash) return legacy_io.distinct(key, {"type": "version"}) + @six.add_metaclass(ABCMeta) class TextureProcessor: From 18435fa7065065d8446c3b0448f664f9ef4a8123 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Tue, 4 Oct 2022 14:11:30 +0300 Subject: [PATCH 46/47] Add validation to check for texture --- .../plugins/publish/validate_look_contents.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/openpype/hosts/maya/plugins/publish/validate_look_contents.py b/openpype/hosts/maya/plugins/publish/validate_look_contents.py index 53501d11e52..837e8ea3a29 100644 --- a/openpype/hosts/maya/plugins/publish/validate_look_contents.py +++ b/openpype/hosts/maya/plugins/publish/validate_look_contents.py @@ -1,6 +1,7 @@ import pyblish.api import openpype.hosts.maya.api.action from openpype.pipeline.publish import ValidateContentsOrder +from maya import cmds # noqa class ValidateLookContents(pyblish.api.InstancePlugin): @@ -85,6 +86,7 @@ def validate_lookdata_attributes(cls, instance): invalid.add(instance.name) return list(invalid) + @classmethod def validate_looks(cls, instance): @@ -112,3 +114,23 @@ def validate_files(cls, instance): invalid.append(node) return invalid + + @classmethod + def validate_renderer(cls, instance): + + renderer = cmds.getAttr( + 'defaultRenderGlobals.currentRenderer').lower() + do_maketx = instance.data.get("maketx", False) + do_rstex = instance.data.get("rstex", False) + processors = [] + + if do_maketx: + processors.append('arnold') + if do_rstex: + processors.append('redshift') + + for processor in processors: + if processor == renderer: + continue + else: + cls.log.error("Converted texture does not match current renderer.") # noqa From 3728ce0a586820bd0e7619dd7acc5cff82e0f918 Mon Sep 17 00:00:00 2001 From: Allan Ihsan Date: Tue, 4 Oct 2022 14:16:54 +0300 Subject: [PATCH 47/47] Style fix --- openpype/hosts/maya/plugins/publish/validate_look_contents.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/maya/plugins/publish/validate_look_contents.py b/openpype/hosts/maya/plugins/publish/validate_look_contents.py index 837e8ea3a29..5e242ed3d2f 100644 --- a/openpype/hosts/maya/plugins/publish/validate_look_contents.py +++ b/openpype/hosts/maya/plugins/publish/validate_look_contents.py @@ -119,7 +119,7 @@ def validate_files(cls, instance): def validate_renderer(cls, instance): renderer = cmds.getAttr( - 'defaultRenderGlobals.currentRenderer').lower() + 'defaultRenderGlobals.currentRenderer').lower() do_maketx = instance.data.get("maketx", False) do_rstex = instance.data.get("rstex", False) processors = []