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

Maya: Redshift Skip aov file format check for Cryptomatte #3654

Merged
merged 7 commits into from
Sep 23, 2022
43 changes: 28 additions & 15 deletions openpype/hosts/maya/plugins/publish/validate_rendersettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
from openpype.hosts.maya.api import lib


def get_redshift_image_format_labels():
"""Return nice labels for Redshift image formats."""
var = "$g_redshiftImageFormatLabels"
return mel.eval("{0}={0}".format(var))


class ValidateRenderSettings(pyblish.api.InstancePlugin):
"""Validates the global render settings

Expand Down Expand Up @@ -102,8 +108,9 @@ def get_invalid(cls, instance):

# Get the node attributes for current renderer
attrs = lib.RENDER_ATTRS.get(renderer, lib.RENDER_ATTRS['default'])
# Prefix attribute can return None when a value was never set
prefix = lib.get_attr_in_layer(cls.ImagePrefixes[renderer],
layer=layer)
layer=layer) or ""
padding = lib.get_attr_in_layer("{node}.{padding}".format(**attrs),
layer=layer)

Expand Down Expand Up @@ -180,18 +187,22 @@ def get_invalid(cls, instance):
redshift_AOV_prefix
))
invalid = True
# get aov format
aov_ext = cmds.getAttr(
"{}.fileFormat".format(aov), asString=True)

default_ext = cmds.getAttr(
"redshiftOptions.imageFormat", asString=True)
Comment on lines -187 to -188
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've removed the asString argument since the returned values were returned as integers anyway.


if default_ext != aov_ext:
cls.log.error(("AOV file format is not the same "
"as the one set globally "
"{} != {}").format(default_ext,
aov_ext))

# check aov file format
aov_ext = cmds.getAttr("{}.fileFormat".format(aov))
default_ext = cmds.getAttr("redshiftOptions.imageFormat")
aov_type = cmds.getAttr("{}.aovType".format(aov))
if aov_type == "Cryptomatte":
# redshift Cryptomatte AOV always uses "Cryptomatte (EXR)"
# so we ignore validating file format for it.
pass

elif default_ext != aov_ext:
labels = get_redshift_image_format_labels()
cls.log.error(
"AOV file format {} does not match global file format "
"{}".format(labels[aov_ext], labels[default_ext])
)
invalid = True

if renderer == "renderman":
Expand Down Expand Up @@ -291,6 +302,9 @@ def repair(cls, instance):
default = lib.RENDER_ATTRS['default']
render_attrs = lib.RENDER_ATTRS.get(renderer, default)

# Repair animation must be enabled
cmds.setAttr("defaultRenderGlobals.animation", True)

# Repair prefix
if renderer != "renderman":
node = render_attrs["node"]
Expand Down Expand Up @@ -323,8 +337,7 @@ def repair(cls, instance):
cmds.optionMenuGrp("vrayRenderElementSeparator",
v=instance.data.get("aovSeparator", "_"))
cmds.setAttr(
"{}.fileNameRenderElementSeparator".format(
node),
"{}.fileNameRenderElementSeparator".format(node),
instance.data.get("aovSeparator", "_"),
type="string"
)
Expand Down