Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Maya looks: support for native Redshift texture format #2971

Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
3770eb6
add rstex function
Mar 29, 2022
72b4522
fix style warnings
Mar 29, 2022
e65a1ea
remove extra line
Mar 29, 2022
2406f78
fix trailing whitespace
Mar 29, 2022
be840d3
add exectuable path finder function
Apr 4, 2022
d4b8d47
use redshift tool finder in extractor
Apr 4, 2022
abc299e
Add redshift texture processing option to schema
Apr 5, 2022
640415a
adjust key name
Apr 5, 2022
0bcf353
add redshift texture create option to look creator
Apr 5, 2022
7bbf381
add rs_tex option to schema defaults
Apr 5, 2022
078775e
add rstex variable to process_resources
Apr 5, 2022
6ac5cd4
Add redshift texture processing flag
Apr 8, 2022
c43ec04
add redshift processor call to generate .rstexbin
Apr 8, 2022
c36552e
Merge branch 'develop' into feature/OP-2524_Maya-looks-support-for-na…
Apr 14, 2022
92c1ac7
refactor convertor function to abstract class and inherited class
Apr 19, 2022
74f2c78
refactor tx conversion into class
Apr 19, 2022
7b1346e
add processor list and adjust logic for more options later
Apr 19, 2022
ae8ecfe
Merge branch 'develop' into feature/OP-2524_Maya-looks-support-for-na…
Jun 1, 2022
3c3be40
Merge branch 'develop' into feature/OP-2524_Maya-looks-support-for-na…
Jun 6, 2022
0bebd06
Merge branch 'develop' into feature/OP-2524_Maya-looks-support-for-na…
Jun 7, 2022
0100ea5
Move redshift tool finder function to extractor.
Jun 7, 2022
2102e4f
Add variable for redshift os path.
Jun 7, 2022
406ac82
Style fix
Jun 7, 2022
710ed3a
Start moving processors logic.
Jun 8, 2022
68caaa7
move function
Jun 9, 2022
a74e8c2
Merge branch 'develop' into feature/OP-2524_Maya-looks-support-for-na…
Jun 9, 2022
29b69bc
Class cleanup
Jun 9, 2022
e78314c
Remove unused maketx code.
Jun 9, 2022
00d877e
Move processors list
Jun 9, 2022
2933e40
Handle texture processing through processors separately
Jun 9, 2022
b054175
Reorganize functionality for do_maketx to linearize properly.
Jun 9, 2022
fd3125d
Style fixes
Jun 9, 2022
41e7ac7
adjust comment
Jun 9, 2022
35be816
Fix returned filepath
Jun 10, 2022
cfb9093
Append processors check, append path return.
Jun 10, 2022
eb99944
Style fix
Jun 10, 2022
77c15e0
Merge branch 'develop' into feature/OP-2524_Maya-looks-support-for-na…
Jun 10, 2022
8f8845e
Merge branch 'develop' into feature/OP-2524_Maya-looks-support-for-na…
Jul 26, 2022
e5fdd9e
Syntax fix.
Jul 26, 2022
ab14895
Change metaclass inheritance formatting to 2.7
Jul 26, 2022
c471bbe
Fix inheritance with `six`, adjust processing code
Jul 26, 2022
5f4d06b
Remove unnecessary comment, style fixes.
Jul 26, 2022
9098822
Merge branch 'develop' into feature/OP-2524_Maya-looks-support-for-na…
Jul 31, 2022
9b0cc4d
Continue refactor
Aug 1, 2022
c35f1cf
Remove leftover code
Aug 1, 2022
099dfba
Fix return bug
Aug 1, 2022
8995dcd
Check for return value, adjust argument
Aug 1, 2022
787c797
Merge branch 'develop' into feature/OP-2524_Maya-looks-support-for-na…
Aug 14, 2022
3cd7fd5
Fix assignment bug, remove unnecessary class sugar
Aug 15, 2022
ac0b931
Merge branch 'feature/OP-2524_Maya-looks-support-for-native-Redshift-…
Aug 15, 2022
0179c63
Merge branch 'develop' into feature/OP-2524_Maya-looks-support-for-na…
Aug 15, 2022
d28c7e1
Merge branch 'develop' into feature/OP-2524_Maya-looks-support-for-na…
Aug 22, 2022
9ec42cb
Fix bugs
Aug 23, 2022
cc62035
Fix destination finding for copying resrouce.
Aug 23, 2022
09bbb30
Merge branch 'develop' into feature/OP-2524_Maya-looks-support-for-na…
Aug 23, 2022
ad8177c
Removed submodule vendor/configs/OpenColorIO-Configs
Aug 23, 2022
7413ca6
Merge branch 'develop' into feature/OP-2524_Maya-looks-support-for-na…
Oct 4, 2022
590538e
Fix import bug
Oct 4, 2022
035281f
Style fix
Oct 4, 2022
18435fa
Add validation to check for texture
Oct 4, 2022
3728ce0
Style fix
Oct 4, 2022
c9c2635
Merge remote-tracking branch 'origin/develop' into feature/OP-2524_Ma…
antirotor Oct 27, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion openpype/hosts/maya/plugins/create/create_look.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
49 changes: 48 additions & 1 deletion openpype/hosts/maya/plugins/publish/extract_look.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import tempfile
import contextlib
import subprocess
from openpype.lib.vendor_bin_utils import get_redshift_tool
This conversation was marked as resolved.
Show resolved Hide resolved
from collections import OrderedDict

from maya import cmds # noqa
Expand Down Expand Up @@ -42,6 +43,51 @@ 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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I think we should validate this environment during validation, only when is needed if it's possible to know.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see! Thank you, I'll take a look about moving that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's something I don't know. Maybe it's not needed or impossible to validate before this plugin, can't tell.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thank you!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more complex as this is set only if studio is using and has configured Redshift. So I think the logic should be - add option make redshift texture on the same place as we have with make tx (look instance) and then probably have validator that will run on look family and will validate this env var.

raise RuntimeError("Must have Redshift available.")

texture_processor_path = get_redshift_tool("TextureProcessor")

cmd = [
texture_processor_path,
escape_space(source),
]

cmd.extend(args)

cmd = " ".join(cmd)
Copy link
Member

@iLLiCiTiT iLLiCiTiT Mar 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few notes that are connected to each other:

  • I would recommend to implement function that will return path to redshift tool (single function job, easy to check what it does)
  • also would recommend to use run_subprocess from openpype.lib which would do what you do here with subprocess
  • when those 2 above would be implemented this function would have 2 lines and is not needed at all...
  • if you know what the arguments will be, it is always better to pass launch arguments as list instead of string to subprocess function
    • more safe for multiplatform support
    • escape_space will not be needed in that case
    • but it has few disadvantages
    # This will work (arg is just for example)
    args = [texture_processor_path, source_path, "-arg", "value"]
    # This will not work
    args = [texture_processor_path, source_path, "-arg value"]

At this stage are these notes just recommendation because I don't know how it will be used.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! This is helpful, makes me think whether we should consider refactoring the maketx function as well to simplify a little bit.

Will hop on to something else in the meantime. I appreciate your time!


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.

Expand Down Expand Up @@ -317,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)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes thank you I know :D

# Collect all unique files used in the resources
files_metadata = {}
for resource in resources:
Expand Down
20 changes: 20 additions & 0 deletions openpype/lib/vendor_bin_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a huge issue - but this does feel off here since unlike the rest of the methods here this Redshift binary isn't actually vendorized? I do like that there's unison in the function itself however - nonetheless it's not perfect.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @BigRoy, you bring up a good point. I wonder where it would be good to place the function then @antirotor @iLLiCiTiT would love your take on where I should be placing this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably define separate ENV var for the tool that should be defined in the tool itself to use it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably define separate ENV var for the tool that should be defined in the tool itself to use it.

is it necessary? why can't we use the mandatory {REDSHIFT_COREDATAPATH}/bin/redshiftTextureProcessor.exe (and the appropriate lnx and mac variant)



def get_ffmpeg_tool_path(tool="ffmpeg"):
"""Path to vendorized FFmpeg executable.

Expand Down
1 change: 1 addition & 0 deletions openpype/settings/defaults/project_settings/maya.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"CreateLook": {
"enabled": true,
"make_tx": true,
"rs_tex": false,
"defaults": [
"Main"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
"key": "make_tx",
"label": "Make tx files"
},
{
"type": "boolean",
"key": "rs_tex",
"label": "Make Redshift texture files"
},
{
"type": "list",
"key": "defaults",
Expand Down