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

Maya: OP-2630 acescg maya #4340

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
5880810
OP-4642 - refactor weird assignment
kalisp Jan 16, 2023
b35ee73
OP-4643 - added Settings for ExtractColorTranscode
kalisp Jan 6, 2023
687d6db
OP-4643 - added ExtractColorTranscode
kalisp Jan 6, 2023
e36cf80
OP-4643 - extractor must run just before ExtractReview
kalisp Jan 6, 2023
cb27e5a
OP-4643 - fix for full file paths
kalisp Jan 6, 2023
7201c57
OP-4643 - pass path for ocio config
kalisp Jan 6, 2023
dc796b7
OP-4643 - add custom_tags
kalisp Jan 6, 2023
50ff228
OP-4643 - added docstring
kalisp Jan 6, 2023
7a162f9
OP-4643 - updated Settings schema
kalisp Jan 6, 2023
171af69
OP-4643 - skip video files
kalisp Jan 6, 2023
c7b4435
OP-4643 - refactored profile, delete of original
kalisp Jan 6, 2023
69c04bb
OP-4643 - switched logging levels
kalisp Jan 6, 2023
44e12b0
OP-4643 - propagate new extension to representation
kalisp Jan 6, 2023
85fc41b
OP-4643 - added label to Settings
kalisp Jan 6, 2023
f564ca9
Merge branch 'feature/OP-4643_color-v3-global-oiio-transcoder-exctrac…
tokejepsen Jan 16, 2023
d583093
Merge branch 'feature/OP-4643_color-v3-global-oiio-transcoder-exctrac…
tokejepsen Jan 17, 2023
5649e79
Merge branch 'feature/OP-2479_color-v3-Colorspace-management-and-dist…
tokejepsen Jan 18, 2023
53470bb
Initial draft
tokejepsen Jan 18, 2023
ab9b2d5
Missing initial commit
tokejepsen Jan 18, 2023
fbd6e08
Merge branch 'release/3.15.x' into enchancement/OP-2630_acescg_maya
tokejepsen Jan 18, 2023
3279634
Fix
tokejepsen Jan 18, 2023
7a7f87e
Improvement
tokejepsen Jan 19, 2023
c2d0bc8
HOund
tokejepsen Jan 19, 2023
bdd6877
Merge branch 'feature/OP-2479_color-v3-Colorspace-management-and-dist…
tokejepsen Jan 19, 2023
98b8e20
Merge branch 'feature/OP-4643_color-v3-global-oiio-transcoder-exctrac…
tokejepsen Jan 31, 2023
28c793b
Merge branch 'develop' into enchancement/OP-2630_acescg_maya
tokejepsen Jan 31, 2023
3fa7610
Working version for Arnold.
tokejepsen Jan 31, 2023
5c4856d
BigRoy feedback
tokejepsen Feb 1, 2023
89d7edd
Support for Maya Hardware
tokejepsen Feb 1, 2023
0a33103
Merge branch 'feature/OP-4643_color-v3-global-oiio-transcoder-exctrac…
tokejepsen Feb 1, 2023
21d275d
Support for Vray
tokejepsen Feb 1, 2023
a1e026e
Merge branch 'feature/OP-4643_color-v3-global-oiio-transcoder-exctrac…
tokejepsen Feb 10, 2023
16f6cc1
Merge branch 'develop' into enchancement/OP-2630_acescg_maya
tokejepsen Feb 13, 2023
d39dd9c
Correct colorspace when using "View Transform"
tokejepsen Feb 13, 2023
e21323c
Hound
tokejepsen Feb 13, 2023
58c7a97
Merge branch 'feature/OP-4643_color-v3-global-oiio-transcoder-exctrac…
tokejepsen Feb 14, 2023
2621016
Template for config.
tokejepsen Feb 14, 2023
ebc8826
Merge branch 'develop' into enchancement/OP-2630_acescg_maya
tokejepsen Feb 17, 2023
7b6fb46
Fix colorspaceTemplate
tokejepsen Feb 20, 2023
3039bdb
Merge branch 'feature/OP-4643_color-v3-global-oiio-transcoder-exctrac…
tokejepsen Feb 22, 2023
125b10d
Merge branch 'develop' into enchancement/OP-2630_acescg_maya
tokejepsen Feb 22, 2023
8f7b6c6
Hound.
tokejepsen Feb 22, 2023
f22ece7
Merge branch 'develop' into enchancement/OP-2630_acescg_maya
tokejepsen Feb 23, 2023
0ce2d86
Merge branch 'develop' into enchancement/OP-2630_acescg_maya
jakubjezek001 Feb 23, 2023
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
55 changes: 54 additions & 1 deletion openpype/hosts/maya/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from six import string_types

from maya import cmds, mel
import maya.api.OpenMaya as om
from maya.api import OpenMaya

from openpype.client import (
get_project,
Expand Down Expand Up @@ -3509,3 +3509,56 @@ def write_xgen_file(data, filepath):

with open(filepath, "w") as f:
f.writelines(lines)


def get_color_management_preferences():
"""Get and resolve OCIO preferences."""
data = {
# Is color management enabled.
"enabled": cmds.colorManagementPrefs(
query=True, cmEnabled=True
),
"rendering_space": cmds.colorManagementPrefs(
query=True, renderingSpaceName=True
),
"output_transform": cmds.colorManagementPrefs(
query=True, outputTransformName=True
),
"output_transform_enabled": cmds.colorManagementPrefs(
query=True, outputTransformEnabled=True
),
"view_transform": cmds.colorManagementPrefs(
query=True, viewTransformName=True
)
}

# Split view and display from view_transform. view_transform comes in
# format of "{view} ({display})".
regex = re.compile(r"^(?P<view>.+) \((?P<display>.+)\)$")
match = regex.match(data["view_transform"])
data.update({
"display": match.group("display"),
"view": match.group("view")
})

# Get config absolute path.
path = cmds.colorManagementPrefs(
query=True, configFilePath=True
)

# The OCIO config supports a custom <MAYA_RESOURCES> token.
maya_resources_token = "<MAYA_RESOURCES>"
maya_resources_path = OpenMaya.MGlobal.getAbsolutePathToResources()
path = path.replace(maya_resources_token, maya_resources_path)

data["config"] = path

return data


def get_color_management_output_transform():
preferences = get_color_management_preferences()
colorspace = preferences["rendering_space"]
if preferences["output_transform_enabled"]:
colorspace = preferences["output_transform"]
return colorspace
100 changes: 76 additions & 24 deletions openpype/hosts/maya/api/lib_renderproducts.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

from . import lib
from . import lib_rendersetup
from openpype.pipeline.colorspace import get_ocio_config_views

from maya import cmds, mel

Expand Down Expand Up @@ -127,6 +128,7 @@ class RenderProduct(object):
"""
productName = attr.ib()
ext = attr.ib() # extension
colorspace = attr.ib() # colorspace
aov = attr.ib(default=None) # source aov
driver = attr.ib(default=None) # source driver
multipart = attr.ib(default=False) # multichannel file
Expand Down Expand Up @@ -562,6 +564,9 @@ def _get_aov_render_products(self, aov, cameras=None):
]

for ai_driver in ai_drivers:
colorspace = self._get_colorspace(
ai_driver + ".colorManagement"
)
# todo: check aiAOVDriver.prefix as it could have
# a custom path prefix set for this driver

Expand Down Expand Up @@ -599,26 +604,32 @@ def _get_aov_render_products(self, aov, cameras=None):
global_aov = self._get_attr(aov, "globalAov")
if global_aov:
for camera in cameras:
product = RenderProduct(productName=name,
ext=ext,
aov=aov_name,
driver=ai_driver,
multipart=self.multipart,
camera=camera)
product = RenderProduct(
productName=name,
ext=ext,
aov=aov_name,
driver=ai_driver,
multipart=self.multipart,
camera=camera,
colorspace=colorspace
)
products.append(product)

all_light_groups = self._get_attr(aov, "lightGroups")
if all_light_groups:
# All light groups is enabled. A single multipart
# Render Product
for camera in cameras:
product = RenderProduct(productName=name + "_lgroups",
ext=ext,
aov=aov_name,
driver=ai_driver,
# Always multichannel output
multipart=True,
camera=camera)
product = RenderProduct(
productName=name + "_lgroups",
ext=ext,
aov=aov_name,
driver=ai_driver,
# Always multichannel output
multipart=True,
camera=camera,
colorspace=colorspace
)
products.append(product)
else:
value = self._get_attr(aov, "lightGroupsList")
Expand All @@ -634,12 +645,36 @@ def _get_aov_render_products(self, aov, cameras=None):
aov=aov_name,
driver=ai_driver,
ext=ext,
camera=camera
camera=camera,
colorspace=colorspace
)
products.append(product)

return products

def _get_colorspace(self, attribute):
"""Resolve colorspace from Arnold settings."""

def _view_transform():
preferences = lib.get_color_management_preferences()
views_data = get_ocio_config_views(preferences["config"])
view_data = views_data[
"{}/{}".format(preferences["display"], preferences["view"])
]
return view_data["colorspace"]

def _raw():
preferences = lib.get_color_management_preferences()
return preferences["rendering_space"]

resolved_values = {
"Raw": _raw,
"Use View Transform": _view_transform,
# Default. Same as Maya Preferences.
"Use Output Transform": lib.get_color_management_output_transform
}
return resolved_values[self._get_attr(attribute)]()

def get_render_products(self):
"""Get all AOVs.

Expand Down Expand Up @@ -668,11 +703,19 @@ def get_render_products(self):
]

default_ext = self._get_attr("defaultRenderGlobals.imfPluginKey")
beauty_products = [RenderProduct(
productName="beauty",
ext=default_ext,
driver="defaultArnoldDriver",
camera=camera) for camera in cameras]
colorspace = self._get_colorspace(
"defaultArnoldDriver.colorManagement"
)
beauty_products = [
RenderProduct(
productName="beauty",
ext=default_ext,
driver="defaultArnoldDriver",
camera=camera,
colorspace=colorspace
) for camera in cameras
]

# AOVs > Legacy > Maya Render View > Mode
aovs_enabled = bool(
self._get_attr("defaultArnoldRenderOptions.aovMode")
Expand Down Expand Up @@ -825,6 +868,7 @@ def get_render_products(self):
productName="",
ext=default_ext,
camera=camera,
colorspace=lib.get_color_management_output_transform(),
multipart=self.multipart
)
)
Expand Down Expand Up @@ -880,10 +924,13 @@ def get_render_products(self):

aov_name = self._get_vray_aov_name(aov)
for camera in cameras:
product = RenderProduct(productName=aov_name,
ext=default_ext,
aov=aov,
camera=camera)
product = RenderProduct(
productName=aov_name,
ext=default_ext,
aov=aov,
camera=camera,
colorspace=lib.get_color_management_output_transform()
)
products.append(product)

return products
Expand Down Expand Up @@ -1367,7 +1414,12 @@ def get_render_products(self):

products = []
for cam in self.get_renderable_cameras():
product = RenderProduct(productName="beauty", ext=ext, camera=cam)
product = RenderProduct(
productName="beauty",
ext=ext,
camera=cam,
colorspace=lib.get_color_management_output_transform()
)
products.append(product)

return products
Expand Down
3 changes: 2 additions & 1 deletion openpype/hosts/maya/api/lib_rendersettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class RenderSettings(object):
'vray': 'vraySettings.fileNamePrefix',
'arnold': 'defaultRenderGlobals.imageFilePrefix',
'renderman': 'rmanGlobals.imageFileFormat',
'redshift': 'defaultRenderGlobals.imageFilePrefix'
'redshift': 'defaultRenderGlobals.imageFilePrefix',
'mayahardware2': 'defaultRenderGlobals.imageFilePrefix'
}

_image_prefixes = {
Expand Down
5 changes: 4 additions & 1 deletion openpype/hosts/maya/plugins/publish/collect_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def process(self, context):
self.log.info(full_exp_files)
self.log.info("collecting layer: {}".format(layer_name))
# Get layer specific settings, might be overrides

colorspace_data = lib.get_color_management_preferences()
data = {
"subset": expected_layer_name,
"attachTo": attach_to,
Expand Down Expand Up @@ -323,6 +323,9 @@ def process(self, context):
"renderSetupIncludeLights": render_instance.data.get(
"renderSetupIncludeLights"
),
"colorspaceConfig": colorspace_data["config"],
"colorspaceDisplay": colorspace_data["display"],
"colorspaceView": colorspace_data["view"],
"strict_error_checking": render_instance.data.get(
"strict_error_checking", True
)
Expand Down
3 changes: 2 additions & 1 deletion openpype/hosts/maya/startup/userSetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@

from maya import cmds


host = MayaHost()
install_host(host)


print("Starting OpenPype usersetup...")


# Open Workfile Post Initialization.
key = "OPENPYPE_OPEN_WORKFILE_POST_INITIALIZATION"
if bool(int(os.environ.get(key, "0"))):
Expand Down
39 changes: 35 additions & 4 deletions openpype/modules/deadline/plugins/publish/submit_publish_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,9 @@ def _copy_extend_frames(self, instance, representation):
self.log.info(
"Finished copying %i files" % len(resource_files))

def _create_instances_for_aov(self, instance_data, exp_files):
def _create_instances_for_aov(
self, instance_data, exp_files, additional_data
):
"""Create instance for each AOV found.

This will create new instance for every aov it can detect in expected
Expand Down Expand Up @@ -536,6 +538,14 @@ def _create_instances_for_aov(self, instance_data, exp_files):
else:
files = os.path.basename(col)

# Copy render product "colorspace" data to representation.
colorspace = ""
products = additional_data["renderProducts"].layer_data.products
for product in products:
if product.productName == aov:
colorspace = product.colorspace
break

rep = {
"name": ext,
"ext": ext,
Expand All @@ -545,7 +555,16 @@ def _create_instances_for_aov(self, instance_data, exp_files):
# If expectedFile are absolute, we need only filenames
"stagingDir": staging,
"fps": new_instance.get("fps"),
"tags": ["review"] if preview else []
"tags": ["review"] if preview else [],
"colorspaceData": {
"colorspace": colorspace,
"config": {
"path": additional_data["colorspaceConfig"],
tokejepsen marked this conversation as resolved.
Show resolved Hide resolved
"template": additional_data["colorspaceTemplate"]
},
"display": additional_data["display"],
"view": additional_data["view"]
}
}

# support conversion from tiled to scanline
Expand All @@ -569,7 +588,7 @@ def _create_instances_for_aov(self, instance_data, exp_files):
self.log.debug("instances:{}".format(instances))
return instances

def _get_representations(self, instance, exp_files):
def _get_representations(self, instance, exp_files, additional_data):
"""Create representations for file sequences.

This will return representations of expected files if they are not
Expand Down Expand Up @@ -914,6 +933,16 @@ def process(self, instance):

self.log.info(data.get("expectedFiles"))

additional_data = {
"renderProducts": instance.data["renderProducts"],
"colorspaceConfig": instance.data["colorspaceConfig"],
"display": instance.data["colorspaceDisplay"],
"view": instance.data["colorspaceView"],
"colorspaceTemplate": instance.data["colorspaceConfig"].replace(
str(context.data["anatomy"].roots["work"]), "{root[work]}"
)
}

if isinstance(data.get("expectedFiles")[0], dict):
# we cannot attach AOVs to other subsets as we consider every
# AOV subset of its own.
Expand All @@ -928,7 +957,9 @@ def process(self, instance):
# there are multiple renderable cameras in scene)
instances = self._create_instances_for_aov(
instance_skeleton_data,
data.get("expectedFiles"))
data.get("expectedFiles"),
additional_data
)
self.log.info("got {} instance{}".format(
len(instances),
"s" if len(instances) > 1 else ""))
Expand Down
Loading