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

Commit

Permalink
Merge pull request #748 from pypeclub/hotfix/vray-aov-names
Browse files Browse the repository at this point in the history
Maya: Vray handling of default aov
  • Loading branch information
mkolar authored Nov 27, 2020
2 parents 044d085 + c5ca4d1 commit 2528406
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 30 deletions.
84 changes: 55 additions & 29 deletions pype/hosts/maya/expected_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,12 @@ def get_layer_overrides(self, attr, layer):
if connections:
for connection in connections:
if connection:
node_name = connection.split(".")[0]
if cmds.nodeType(node_name) == "renderLayer":
attr_name = "%s.value" % ".".join(
connection.split(".")[:-1]
)
if node_name == layer:
yield cmds.getAttr(attr_name)
# node_name = connection.split(".")[0]

attr_name = "%s.value" % ".".join(
connection.split(".")[:-1]
)
yield cmds.getAttr(attr_name)

def get_render_attribute(self, attr):
"""Get attribute from render options.
Expand Down Expand Up @@ -572,11 +571,17 @@ def get_files(self):
expected_files = super(ExpectedFilesVray, self).get_files()

layer_data = self._get_layer_data()
# remove 'beauty' from filenames as vray doesn't output it
update = {}
if layer_data.get("enabledAOVs"):
expected_files[0][u"beauty"] = self._generate_single_file_sequence(
layer_data
) # noqa: E501

for aov, seq in expected_files[0].items():
if aov.startswith("beauty"):
new_list = []
for f in seq:
new_list.append(f.replace("_beauty", ""))
update[aov] = new_list

expected_files[0].update(update)
return expected_files

def get_aovs(self):
Expand Down Expand Up @@ -630,28 +635,49 @@ def get_aovs(self):
# todo: find how vray set format for AOVs
enabled_aovs.append(
(self._get_vray_aov_name(aov), default_ext))
enabled_aovs.append(
(u"beauty", default_ext)
)
return enabled_aovs

def _get_vray_aov_name(self, node):
"""Get AOVs name from Vray.
# Get render element pass type
vray_node_attr = next(
attr
for attr in cmds.listAttr(node)
if attr.startswith("vray_name")
)
pass_type = vray_node_attr.rsplit("_", 1)[-1]

# Support V-Ray extratex explicit name (if set by user)
if pass_type == "extratex":
explicit_attr = "{}.vray_explicit_name_extratex".format(node)
explicit_name = cmds.getAttr(explicit_attr)
if explicit_name:
return explicit_name

# Node type is in the attribute name but we need to check if value
# of the attribute as it can be changed
return cmds.getAttr("{}.{}".format(node, vray_node_attr))
Args:
node (str): aov node name.
Returns:
str: aov name.
"""
vray_name = None
vray_explicit_name = None
vray_file_name = None
for attr in cmds.listAttr(node):
if attr.startswith("vray_filename"):
vray_file_name = cmds.getAttr("{}.{}".format(node, attr))
elif attr.startswith("vray_name"):
vray_name = cmds.getAttr("{}.{}".format(node, attr))
elif attr.startswith("vray_explicit_name"):
vray_explicit_name = cmds.getAttr("{}.{}".format(node, attr))

if vray_file_name is not None and vray_file_name != "":
final_name = vray_file_name
elif vray_explicit_name is not None and vray_explicit_name != "":
final_name = vray_explicit_name
elif vray_name is not None and vray_name != "":
final_name = vray_name
else:
continue
# special case for Material Select elements - these are named
# based on the materia they are connected to.
if "vray_mtl_mtlselect" in cmds.listAttr(node):
connections = cmds.listConnections(
"{}.vray_mtl_mtlselect".format(node))
if connections:
final_name += '_{}'.format(str(connections[0]))

return final_name


class ExpectedFilesRedshift(AExpectedFiles):
Expand Down
2 changes: 1 addition & 1 deletion pype/plugins/maya/publish/extract_look.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def _process_texture(self, filepath, do_maketx, staging, linearise, force):
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)
if filepath:
if source:
return source, HARDLINK, texture_hash
else:
self.log.warning(
Expand Down

0 comments on commit 2528406

Please sign in to comment.