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

Renderman support for sample and display filters #4003

Merged
merged 26 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
62a6f4c
Renderman setup for sample and display filters
Oct 19, 2022
28dfc7b
Renderman setup for sample and display filters
Oct 19, 2022
bf5213a
Renderman setup for sample and display filters
Oct 19, 2022
769763c
Renderman setup for sample and display filters
Oct 26, 2022
fed2a21
Renderman setup for sample and display filters
Oct 26, 2022
8a9399f
Renderman setup for sample and display filters
Oct 28, 2022
7cf4578
renderman-support-for-sample-and-display
Nov 8, 2022
6466857
renderman
Nov 8, 2022
8dc7a17
Renderman support for sample and deisplay filter
Nov 8, 2022
d3f0ab4
Renderman support for sample and deisplay filter
Nov 8, 2022
7885a7b
Renderman support for sample and deisplay filter
Nov 8, 2022
59cab53
Renderman support for sample and deisplay filter
Nov 8, 2022
81e3157
Renderman support for sample and deisplay filter
Nov 8, 2022
c3c7288
Renderman support for sample and deisplay filter
Nov 8, 2022
17f2c8c
Merge remote-tracking branch 'origin/develop' into OP-3572/Renderman-…
antirotor Nov 23, 2022
ddcb213
Removed submodule vendor/configs/OpenColorIO-Configs
antirotor Nov 23, 2022
9c02477
Merge branch 'develop' into OP-3572/Renderman-support-for-Sample-and-…
Nov 24, 2022
642bd65
Merge branch 'OP-3572/Renderman-support-for-Sample-and-Display' of ht…
Nov 28, 2022
474958f
set the correct path for filters, image ouptut and image directory
Nov 29, 2022
6e3c75f
set the correct path for filters, image ouptut and image directory
Nov 29, 2022
8b5a7c4
set the correct path for filters, image ouptut and image directory
Nov 29, 2022
f63c28f
set the correct path for filters, image ouptut and image directory
Nov 29, 2022
7e65eb2
set the correct path for filters, image ouptut and image directory
Nov 29, 2022
7dc9734
add the correct image prefix format for Renderman
Nov 29, 2022
8ad8aa9
add the correct image prefix format for Renderman
Nov 29, 2022
92e3d10
add cryptomatte into collect render layers
moonyuet Jan 17, 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
24 changes: 24 additions & 0 deletions openpype/hosts/maya/api/lib_renderproducts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,7 @@ class RenderProductsRenderman(ARenderProducts):
"""

renderer = "renderman"
unmerged_aovs = {"PxrCryptomatte"}

def get_render_products(self):
"""Get all AOVs.
Expand Down Expand Up @@ -1181,6 +1182,17 @@ def get_render_products(self):
if not display_types.get(display["driverNode"]["type"]):
continue

has_cryptomatte = cmds.ls(type=self.unmerged_aovs)
matte_enabled = False
if has_cryptomatte:
for cryptomatte in has_cryptomatte:
cryptomatte_aov = cryptomatte
matte_name = "cryptomatte"
rman_globals = cmds.listConnections(cryptomatte +
".message")
if rman_globals:
matte_enabled = True

aov_name = name
if aov_name == "rmanDefaultDisplay":
aov_name = "beauty"
Expand All @@ -1199,6 +1211,15 @@ def get_render_products(self):
camera=camera,
multipart=True
)

if has_cryptomatte and matte_enabled:
cryptomatte = RenderProduct(
productName=matte_name,
aov=cryptomatte_aov,
ext=extensions,
camera=camera,
multipart=True
)
else:
# this code should handle the case where no multipart
# capable format is selected. But since it involves
Expand All @@ -1218,6 +1239,9 @@ def get_render_products(self):

products.append(product)

if has_cryptomatte and matte_enabled:
products.append(cryptomatte)

return products

def get_files(self, product):
Expand Down
80 changes: 77 additions & 3 deletions openpype/hosts/maya/api/lib_rendersettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,25 @@ class RenderSettings(object):
_image_prefix_nodes = {
'vray': 'vraySettings.fileNamePrefix',
'arnold': 'defaultRenderGlobals.imageFilePrefix',
'renderman': 'defaultRenderGlobals.imageFilePrefix',
'renderman': 'rmanGlobals.imageFileFormat',
'redshift': 'defaultRenderGlobals.imageFilePrefix'
}

_image_prefixes = {
'vray': get_current_project_settings()["maya"]["RenderSettings"]["vray_renderer"]["image_prefix"], # noqa
'arnold': get_current_project_settings()["maya"]["RenderSettings"]["arnold_renderer"]["image_prefix"], # noqa
'renderman': '<Scene>/<layer>/<layer>{aov_separator}<aov>',
'renderman': get_current_project_settings()["maya"]["RenderSettings"]["renderman_renderer"]["image_prefix"], # noqa
'redshift': get_current_project_settings()["maya"]["RenderSettings"]["redshift_renderer"]["image_prefix"] # noqa
}

# Renderman only
_image_dir = {
'renderman': get_current_project_settings()["maya"]["RenderSettings"]["renderman_renderer"]["image_dir"], # noqa
'cryptomatte': get_current_project_settings()["maya"]["RenderSettings"]["renderman_renderer"]["cryptomatte_dir"], # noqa
'imageDisplay': get_current_project_settings()["maya"]["RenderSettings"]["renderman_renderer"]["imageDisplay_dir"], # noqa
"watermark": get_current_project_settings()["maya"]["RenderSettings"]["renderman_renderer"]["watermark_dir"] # noqa
}

_aov_chars = {
"dot": ".",
"dash": "-",
Expand Down Expand Up @@ -81,7 +89,6 @@ def set_default_renderer_settings(self, renderer=None):
prefix, type="string") # noqa
else:
print("{0} isn't a supported renderer to autoset settings.".format(renderer)) # noqa

# TODO: handle not having res values in the doc
width = asset_doc["data"].get("resolutionWidth")
height = asset_doc["data"].get("resolutionHeight")
Expand All @@ -96,6 +103,13 @@ def set_default_renderer_settings(self, renderer=None):
if renderer == "redshift":
self._set_redshift_settings(width, height)

if renderer == "renderman":
image_dir = self._image_dir["renderman"]
cmds.setAttr("rmanGlobals.imageOutputDir",
image_dir, type="string")
self._set_renderman_settings(width, height,
aov_separator)

def _set_arnold_settings(self, width, height):
"""Sets settings for Arnold."""
from mtoa.core import createOptions # noqa
Expand Down Expand Up @@ -158,6 +172,66 @@ def _set_redshift_settings(self, width, height):
cmds.setAttr("defaultResolution.height", height)
self._additional_attribs_setter(additional_options)

def _set_renderman_settings(self, width, height, aov_separator):
"""Sets settings for Renderman"""
rman_render_presets = (
self._project_settings
["maya"]
["RenderSettings"]
["renderman_renderer"]
)
display_filters = rman_render_presets["display_filters"]
d_filters_number = len(display_filters)
for i in range(d_filters_number):
d_node = cmds.ls(typ=display_filters[i])
if len(d_node) > 0:
filter_nodes = d_node[0]
else:
filter_nodes = cmds.createNode(display_filters[i])

cmds.connectAttr(filter_nodes + ".message",
"rmanGlobals.displayFilters[%i]" % i,
force=True)
if filter_nodes.startswith("PxrImageDisplayFilter"):
imageDisplay_dir = self._image_dir["imageDisplay"]
imageDisplay_dir = imageDisplay_dir.replace("{aov_separator}",
aov_separator)
cmds.setAttr(filter_nodes + ".filename",
imageDisplay_dir, type="string")

sample_filters = rman_render_presets["sample_filters"]
s_filters_number = len(sample_filters)
for n in range(s_filters_number):
s_node = cmds.ls(typ=sample_filters[n])
if len(s_node) > 0:
filter_nodes = s_node[0]
else:
filter_nodes = cmds.createNode(sample_filters[n])

cmds.connectAttr(filter_nodes + ".message",
"rmanGlobals.sampleFilters[%i]" % n,
force=True)

if filter_nodes.startswith("PxrCryptomatte"):
matte_dir = self._image_dir["cryptomatte"]
matte_dir = matte_dir.replace("{aov_separator}",
aov_separator)
cmds.setAttr(filter_nodes + ".filename",
matte_dir, type="string")
elif filter_nodes.startswith("PxrWatermarkFilter"):
watermark_dir = self._image_dir["watermark"]
watermark_dir = watermark_dir.replace("{aov_separator}",
aov_separator)
cmds.setAttr(filter_nodes + ".filename",
watermark_dir, type="string")

additional_options = rman_render_presets["additional_options"]

self._set_global_output_settings()
cmds.setAttr("defaultResolution.width", width)
cmds.setAttr("defaultResolution.height", height)
self._additional_attribs_setter(additional_options)

def _set_vray_settings(self, aov_separator, width, height):
# type: (str, int, int) -> None
"""Sets important settings for Vray."""
Expand Down
10 changes: 10 additions & 0 deletions openpype/settings/defaults/project_settings/maya.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@
"force_combine": true,
"aov_list": [],
"additional_options": []
},
"renderman_renderer": {
"image_prefix": "<layer>{aov_separator}<aov>.<f4>.<ext>",
"image_dir": "<scene>/<layer>",
"display_filters": [],
"imageDisplay_dir": "<imagedir>/<layer>{aov_separator}imageDisplayFilter.<f4>.<ext>",
"sample_filters": [],
"cryptomatte_dir": "<imagedir>/<layer>{aov_separator}cryptomatte.<f4>.<ext>",
"watermark_dir": "<imagedir>/<layer>{aov_separator}watermarkFilter.<f4>.<ext>",
"additional_options": []
}
},
"create": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,93 @@
}
}
]
}
},
{
"type": "dict",
"collapsible": true,
"key": "renderman_renderer",
"label": "Renderman Renderer",
"is_group": true,
"children": [
{
"key": "image_prefix",
"label": "Image prefix template",
"type": "text"
},
{
"key": "image_dir",
"label": "Image Output Directory",
"type": "text"
},
{
"key": "display_filters",
"label": "Display Filters",
"type": "enum",
"multiselection": true,
"defaults": "empty",
"enum_items": [
{"PxrBackgroundDisplayFilter": "PxrBackgroundDisplayFilter"},
{"PxrCopyAOVDisplayFilter": "PxrCopyAOVDisplayFilter"},
{"PxrEdgeDetect":"PxrEdgeDetect"},
{"PxrFilmicTonemapperDisplayFilter": "PxrFilmicTonemapperDisplayFilter"},
{"PxrGradeDisplayFilter": "PxrGradeDisplayFilter"},
{"PxrHalfBufferErrorFilter": "PxrHalfBufferErrorFilter"},
{"PxrImageDisplayFilter": "PxrImageDisplayFilter"},
{"PxrLightSaturation": "PxrLightSaturation"},
{"PxrShadowDisplayFilter": "PxrShadowDisplayFilter"},
{"PxrStylizedHatching": "PxrStylizedHatching"},
{"PxrStylizedLines": "PxrStylizedLines"},
{"PxrStylizedToon": "PxrStylizedToon"},
{"PxrWhitePointDisplayFilter": "PxrWhitePointDisplayFilter"}
]
},
{
"key": "imageDisplay_dir",
"label": "Image Display Filter Directory",
"type": "text"
},
{
"key": "sample_filters",
"label": "Sample Filters",
"type": "enum",
"multiselection": true,
"defaults": "empty",
"enum_items": [
{"PxrBackgroundSampleFilter": "PxrBackgroundSampleFilter"},
{"PxrCopyAOVSampleFilter": "PxrCopyAOVSampleFilter"},
{"PxrCryptomatte": "PxrCryptomatte"},
{"PxrFilmicTonemapperSampleFilter": "PxrFilmicTonemapperSampleFilter"},
{"PxrGradeSampleFilter": "PxrGradeSampleFilter"},
{"PxrShadowFilter": "PxrShadowFilter"},
{"PxrWatermarkFilter": "PxrWatermarkFilter"},
{"PxrWhitePointSampleFilter": "PxrWhitePointSampleFilter"}
]
},
{
"key": "cryptomatte_dir",
"label": "Cryptomatte Output Directory",
"type": "text"
},
{
"key": "watermark_dir",
"label": "Watermark Filter Directory",
"type": "text"
},
{
"type": "label",
"label": "Add additional options - put attribute and value, like <code>Ci</code>"
},
{
"type": "dict-modifiable",
"store_as_list": true,
"key": "additional_options",
"label": "Additional Renderer Options",
"use_label_wrap": true,
"object_type": {
"type": "text"
}
}
]
}
]
}