mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Update set_viewers_colorspace method to
handle imageio_nuke dictionary, refactor ExporterReviewMov class to support different colorspaces for baking, and adjust settings in PublishPluginsModel.
This commit is contained in:
parent
4a80413232
commit
2d13f9787f
3 changed files with 83 additions and 59 deletions
|
|
@ -1509,36 +1509,30 @@ class WorkfileSettings(object):
|
|||
for filter in nodes_filter:
|
||||
return [n for n in self._nodes if filter in n.Class()]
|
||||
|
||||
def set_viewers_colorspace(self, viewer_dict):
|
||||
def set_viewers_colorspace(self, imageio_nuke):
|
||||
''' Adds correct colorspace to viewer
|
||||
|
||||
Arguments:
|
||||
viewer_dict (dict): adjustments from presets
|
||||
imageio_nuke (dict): nuke colorspace configurations
|
||||
|
||||
'''
|
||||
if not isinstance(viewer_dict, dict):
|
||||
msg = "set_viewers_colorspace(): argument should be dictionary"
|
||||
log.error(msg)
|
||||
nuke.message(msg)
|
||||
return
|
||||
viewer_config = imageio_nuke["viewer"]
|
||||
monitor_config = imageio_nuke["monitor"]
|
||||
|
||||
filter_knobs = [
|
||||
"viewerProcess",
|
||||
"wipe_position",
|
||||
"monitorOutOutputTransform"
|
||||
]
|
||||
|
||||
display, viewer = get_viewer_config_from_string(
|
||||
viewer_dict["viewerProcess"]
|
||||
)
|
||||
viewer_process = create_viewer_profile_string(
|
||||
viewer, display, path_like=False
|
||||
)
|
||||
display, viewer = get_viewer_config_from_string(
|
||||
viewer_dict["output_transform"]
|
||||
viewer_config["view"],
|
||||
viewer_config["display"],
|
||||
path_like=False,
|
||||
)
|
||||
output_transform = create_viewer_profile_string(
|
||||
viewer, display, path_like=False
|
||||
monitor_config["view"],
|
||||
monitor_config["display"],
|
||||
path_like=False,
|
||||
)
|
||||
erased_viewers = []
|
||||
for v in nuke.allNodes(filter="Viewer"):
|
||||
|
|
@ -1547,8 +1541,10 @@ class WorkfileSettings(object):
|
|||
|
||||
if viewer_process not in v["viewerProcess"].value():
|
||||
copy_inputs = v.dependencies()
|
||||
copy_knobs = {k: v[k].value() for k in v.knobs()
|
||||
if k not in filter_knobs}
|
||||
copy_knobs = {
|
||||
k: v[k].value() for k in v.knobs()
|
||||
if k not in filter_knobs
|
||||
}
|
||||
|
||||
# delete viewer with wrong settings
|
||||
erased_viewers.append(v["name"].value())
|
||||
|
|
@ -1590,12 +1586,12 @@ class WorkfileSettings(object):
|
|||
if not config_data:
|
||||
# no ocio config found and no custom path used
|
||||
if self._root_node["colorManagement"].value() \
|
||||
not in color_management:
|
||||
not in color_management:
|
||||
self._root_node["colorManagement"].setValue(color_management)
|
||||
|
||||
# second set ocio version
|
||||
if self._root_node["OCIO_config"].value() \
|
||||
not in native_ocio_config:
|
||||
not in native_ocio_config:
|
||||
self._root_node["OCIO_config"].setValue(native_ocio_config)
|
||||
|
||||
else:
|
||||
|
|
@ -1623,21 +1619,25 @@ class WorkfileSettings(object):
|
|||
if correct_settings:
|
||||
self._set_ocio_config_path_to_workfile(config_data)
|
||||
|
||||
workfile_settings_output = {}
|
||||
# get monitor lut from settings respecting Nuke version differences
|
||||
monitor_lut_data = self._get_monitor_settings(
|
||||
workfile_settings["monitor_out_lut"],
|
||||
workfile_settings["monitor_lut"]
|
||||
)
|
||||
monitor_lut_data.update({
|
||||
"workingSpaceLUT": workfile_settings["working_space"],
|
||||
"int8Lut": workfile_settings["int_8_lut"],
|
||||
"int16Lut": workfile_settings["int_16_lut"],
|
||||
"logLut": workfile_settings["log_lut"],
|
||||
"floatLut": workfile_settings["float_lut"]
|
||||
})
|
||||
workfile_settings_output |= monitor_lut_data
|
||||
workfile_settings_output.update(
|
||||
{
|
||||
"workingSpaceLUT": workfile_settings["working_space"],
|
||||
"int8Lut": workfile_settings["int_8_lut"],
|
||||
"int16Lut": workfile_settings["int_16_lut"],
|
||||
"logLut": workfile_settings["log_lut"],
|
||||
"floatLut": workfile_settings["float_lut"],
|
||||
}
|
||||
)
|
||||
|
||||
# then set the rest
|
||||
for knob, value_ in monitor_lut_data.items():
|
||||
for knob, value_ in workfile_settings_output.items():
|
||||
# skip unfilled ocio config path
|
||||
# it will be dict in value
|
||||
if isinstance(value_, dict):
|
||||
|
|
@ -1972,7 +1972,7 @@ Reopening Nuke should synchronize these paths and resolve any discrepancies.
|
|||
|
||||
log.info("Setting colorspace to viewers...")
|
||||
try:
|
||||
self.set_viewers_colorspace(nuke_colorspace["viewer"])
|
||||
self.set_viewers_colorspace(nuke_colorspace)
|
||||
except AttributeError as _error:
|
||||
msg = "Set Colorspace to viewer error: {}".format(_error)
|
||||
nuke.message(msg)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import dis
|
||||
import nuke
|
||||
import re
|
||||
import os
|
||||
|
|
@ -638,12 +639,18 @@ class ExporterReview(object):
|
|||
from . import lib as opnlib
|
||||
nuke_imageio = opnlib.get_nuke_imageio_settings()
|
||||
|
||||
# TODO: this is only securing backward compatibility lets remove
|
||||
# this once all projects's anatomy are updated to newer config
|
||||
if "baking" in nuke_imageio.keys():
|
||||
return nuke_imageio["baking"]["viewerProcess"]
|
||||
if (
|
||||
"baking_target" in nuke_imageio.keys()
|
||||
and nuke_imageio["baking_target"]["enabled"]
|
||||
):
|
||||
return nuke_imageio["baking_target"]
|
||||
else:
|
||||
return nuke_imageio["viewer"]["viewerProcess"]
|
||||
# viewer is having display and view keys only and it is
|
||||
# display_view type
|
||||
return {
|
||||
"type": "display_view",
|
||||
"display_view": nuke_imageio["viewer"],
|
||||
}
|
||||
|
||||
|
||||
class ExporterReviewLut(ExporterReview):
|
||||
|
|
@ -861,16 +868,16 @@ class ExporterReviewMov(ExporterReview):
|
|||
bake_viewer_process = kwargs["bake_viewer_process"]
|
||||
bake_viewer_input_process_node = kwargs[
|
||||
"bake_viewer_input_process"]
|
||||
viewer_process_override = kwargs[
|
||||
"viewer_process_override"]
|
||||
|
||||
baking_view_profile = (
|
||||
viewer_process_override or self.get_imageio_baking_profile())
|
||||
colorspace_override = kwargs["colorspace_override"]
|
||||
|
||||
baking_colorspace = self.get_imageio_baking_profile()
|
||||
if colorspace_override["enabled"]:
|
||||
baking_colorspace = colorspace_override["colorspace"]
|
||||
|
||||
fps = self.instance.context.data["fps"]
|
||||
|
||||
self.log.debug(">> baking_view_profile `{}`".format(
|
||||
baking_view_profile))
|
||||
self.log.debug(f">> baking_view_profile `{baking_colorspace}`")
|
||||
|
||||
add_custom_tags = kwargs.get("add_custom_tags", [])
|
||||
|
||||
|
|
@ -932,32 +939,50 @@ class ExporterReviewMov(ExporterReview):
|
|||
|
||||
if not self.viewer_lut_raw:
|
||||
# OCIODisplay
|
||||
dag_node = nuke.createNode("OCIODisplay")
|
||||
if baking_colorspace["type"] == "display_view":
|
||||
display_view = baking_colorspace["display_view"]
|
||||
|
||||
# assign display
|
||||
display, viewer = get_viewer_config_from_string(
|
||||
str(baking_view_profile)
|
||||
)
|
||||
if display:
|
||||
dag_node["display"].setValue(display)
|
||||
message = "OCIODisplay... '{}'"
|
||||
node = nuke.createNode("OCIODisplay")
|
||||
|
||||
# assign viewer
|
||||
dag_node["view"].setValue(viewer)
|
||||
# assign display
|
||||
display = display_view["display"]
|
||||
view = display_view["view"]
|
||||
|
||||
if config_data:
|
||||
# convert display and view to colorspace
|
||||
colorspace = get_display_view_colorspace_name(
|
||||
config_path=config_data["path"],
|
||||
display=display,
|
||||
view=viewer
|
||||
if display:
|
||||
node["display"].setValue(display)
|
||||
|
||||
# assign viewer
|
||||
node["view"].setValue(view)
|
||||
if config_data:
|
||||
# convert display and view to colorspace
|
||||
colorspace = get_display_view_colorspace_name(
|
||||
config_path=config_data["path"],
|
||||
display=display, view=view
|
||||
)
|
||||
# OCIOColorSpace
|
||||
elif baking_colorspace["type"] == "colorspace":
|
||||
baking_colorspace = baking_colorspace["colorspace"]
|
||||
node = nuke.createNode("OCIOColorSpace")
|
||||
message = "OCIOColorSpace... '{}'"
|
||||
node["in_colorspace"].setValue(colorspace)
|
||||
node["out_colorspace"].setValue(baking_colorspace)
|
||||
colorspace = baking_colorspace
|
||||
|
||||
else:
|
||||
raise ValueError(
|
||||
"Invalid baking color space type: "
|
||||
f"{baking_colorspace['type']}"
|
||||
)
|
||||
|
||||
self._connect_to_above_nodes(
|
||||
dag_node, product_name, "OCIODisplay... `{}`"
|
||||
node, product_name, message
|
||||
)
|
||||
|
||||
# Write node
|
||||
write_node = nuke.createNode("Write")
|
||||
self.log.debug("Path: {}".format(self.path))
|
||||
self.log.debug(f"Path: {self.path}")
|
||||
|
||||
write_node["file"].setValue(str(self.path))
|
||||
write_node["file_type"].setValue(str(self.ext))
|
||||
write_node["channels"].setValue(str(self.color_channels))
|
||||
|
|
@ -1020,8 +1045,6 @@ class ExporterReviewMov(ExporterReview):
|
|||
nuke.scriptSave()
|
||||
|
||||
return self.data
|
||||
|
||||
def _shift_to_previous_node_and_temp(self, product_name, node, message):
|
||||
self._temp_nodes[product_name].append(node)
|
||||
self.previous_node = node
|
||||
self.log.debug(message.format(self._temp_nodes[product_name]))
|
||||
|
|
|
|||
|
|
@ -270,6 +270,7 @@ class PublishPluginsModel(BaseSettingsModel):
|
|||
section="Integrators"
|
||||
)
|
||||
|
||||
|
||||
DEFAULT_PUBLISH_PLUGIN_SETTINGS = {
|
||||
"CollectInstanceData": {
|
||||
"sync_workfile_version_on_product_types": [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue