mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
Correct colorspace when using "View Transform"
This commit is contained in:
parent
16f6cc133b
commit
d39dd9ce1d
3 changed files with 70 additions and 56 deletions
|
|
@ -46,6 +46,7 @@ import attr
|
||||||
|
|
||||||
from . import lib
|
from . import lib
|
||||||
from . import lib_rendersetup
|
from . import lib_rendersetup
|
||||||
|
from openpype.pipeline.colorspace import get_ocio_config_views
|
||||||
|
|
||||||
from maya import cmds, mel
|
from maya import cmds, mel
|
||||||
|
|
||||||
|
|
@ -646,7 +647,11 @@ class RenderProductsArnold(ARenderProducts):
|
||||||
|
|
||||||
def _view_transform():
|
def _view_transform():
|
||||||
preferences = lib.get_color_management_preferences()
|
preferences = lib.get_color_management_preferences()
|
||||||
return preferences["view_transform"]
|
views_data = get_ocio_config_views(preferences["config"])
|
||||||
|
view_data = views_data[
|
||||||
|
"{}/{}".format(preferences["display"], preferences["view"])
|
||||||
|
]
|
||||||
|
return view_data["colorspace"]
|
||||||
|
|
||||||
def _raw():
|
def _raw():
|
||||||
preferences = lib.get_color_management_preferences()
|
preferences = lib.get_color_management_preferences()
|
||||||
|
|
|
||||||
|
|
@ -198,41 +198,19 @@ def validate_imageio_colorspace_in_config(config_path, colorspace_name):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def get_ocio_config_colorspaces(config_path):
|
def get_data_subprocess(config_path, data_type):
|
||||||
"""Get all colorspace data
|
"""Get data via subprocess
|
||||||
|
|
||||||
Wrapper function for aggregating all names and its families.
|
|
||||||
Families can be used for building menu and submenus in gui.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
config_path (str): path leading to config.ocio file
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
dict: colorspace and family in couple
|
|
||||||
"""
|
|
||||||
if sys.version_info[0] == 2:
|
|
||||||
return get_colorspace_data_subprocess(config_path)
|
|
||||||
|
|
||||||
from ..scripts.ocio_wrapper import _get_colorspace_data
|
|
||||||
return _get_colorspace_data(config_path)
|
|
||||||
|
|
||||||
|
|
||||||
def get_colorspace_data_subprocess(config_path):
|
|
||||||
"""Get colorspace data via subprocess
|
|
||||||
|
|
||||||
Wrapper for Python 2 hosts.
|
Wrapper for Python 2 hosts.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
config_path (str): path leading to config.ocio file
|
config_path (str): path leading to config.ocio file
|
||||||
|
|
||||||
Returns:
|
|
||||||
dict: colorspace and family in couple
|
|
||||||
"""
|
"""
|
||||||
with _make_temp_json_file() as tmp_json_path:
|
with _make_temp_json_file() as tmp_json_path:
|
||||||
# Prepare subprocess arguments
|
# Prepare subprocess arguments
|
||||||
args = [
|
args = [
|
||||||
"run", get_ocio_config_script_path(),
|
"run", get_ocio_config_script_path(),
|
||||||
"config", "get_colorspace",
|
"config", data_type,
|
||||||
"--in_path", config_path,
|
"--in_path", config_path,
|
||||||
"--out_path", tmp_json_path
|
"--out_path", tmp_json_path
|
||||||
|
|
||||||
|
|
@ -251,6 +229,47 @@ def get_colorspace_data_subprocess(config_path):
|
||||||
return json.loads(return_json_data)
|
return json.loads(return_json_data)
|
||||||
|
|
||||||
|
|
||||||
|
def compatible_python():
|
||||||
|
"""Only 3.9 or higher can directly use PyOpenColorIO in ocio_wrapper"""
|
||||||
|
compatible = False
|
||||||
|
if sys.version[0] == 3 and sys.version[1] >= 9:
|
||||||
|
compatible = True
|
||||||
|
return compatible
|
||||||
|
|
||||||
|
|
||||||
|
def get_ocio_config_colorspaces(config_path):
|
||||||
|
"""Get all colorspace data
|
||||||
|
|
||||||
|
Wrapper function for aggregating all names and its families.
|
||||||
|
Families can be used for building menu and submenus in gui.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
config_path (str): path leading to config.ocio file
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: colorspace and family in couple
|
||||||
|
"""
|
||||||
|
if compatible_python():
|
||||||
|
from ..scripts.ocio_wrapper import _get_colorspace_data
|
||||||
|
return _get_colorspace_data(config_path)
|
||||||
|
else:
|
||||||
|
return get_colorspace_data_subprocess(config_path)
|
||||||
|
|
||||||
|
|
||||||
|
def get_colorspace_data_subprocess(config_path):
|
||||||
|
"""Get colorspace data via subprocess
|
||||||
|
|
||||||
|
Wrapper for Python 2 hosts.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
config_path (str): path leading to config.ocio file
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: colorspace and family in couple
|
||||||
|
"""
|
||||||
|
return get_data_subprocess(config_path, "get_colorspace")
|
||||||
|
|
||||||
|
|
||||||
def get_ocio_config_views(config_path):
|
def get_ocio_config_views(config_path):
|
||||||
"""Get all viewer data
|
"""Get all viewer data
|
||||||
|
|
||||||
|
|
@ -263,12 +282,12 @@ def get_ocio_config_views(config_path):
|
||||||
Returns:
|
Returns:
|
||||||
dict: `display/viewer` and viewer data
|
dict: `display/viewer` and viewer data
|
||||||
"""
|
"""
|
||||||
if sys.version_info[0] == 2:
|
if compatible_python():
|
||||||
|
from ..scripts.ocio_wrapper import _get_views_data
|
||||||
|
return _get_views_data(config_path)
|
||||||
|
else:
|
||||||
return get_views_data_subprocess(config_path)
|
return get_views_data_subprocess(config_path)
|
||||||
|
|
||||||
from ..scripts.ocio_wrapper import _get_views_data
|
|
||||||
return _get_views_data(config_path)
|
|
||||||
|
|
||||||
|
|
||||||
def get_views_data_subprocess(config_path):
|
def get_views_data_subprocess(config_path):
|
||||||
"""Get viewers data via subprocess
|
"""Get viewers data via subprocess
|
||||||
|
|
@ -281,27 +300,7 @@ def get_views_data_subprocess(config_path):
|
||||||
Returns:
|
Returns:
|
||||||
dict: `display/viewer` and viewer data
|
dict: `display/viewer` and viewer data
|
||||||
"""
|
"""
|
||||||
with _make_temp_json_file() as tmp_json_path:
|
return get_data_subprocess(config_path, "get_views")
|
||||||
# Prepare subprocess arguments
|
|
||||||
args = [
|
|
||||||
"run", get_ocio_config_script_path(),
|
|
||||||
"config", "get_views",
|
|
||||||
"--in_path", config_path,
|
|
||||||
"--out_path", tmp_json_path
|
|
||||||
|
|
||||||
]
|
|
||||||
log.info("Executing: {}".format(" ".join(args)))
|
|
||||||
|
|
||||||
process_kwargs = {
|
|
||||||
"logger": log,
|
|
||||||
"env": {}
|
|
||||||
}
|
|
||||||
|
|
||||||
run_openpype_process(*args, **process_kwargs)
|
|
||||||
|
|
||||||
# return all colorspaces
|
|
||||||
return_json_data = open(tmp_json_path).read()
|
|
||||||
return json.loads(return_json_data)
|
|
||||||
|
|
||||||
|
|
||||||
def get_imageio_config(
|
def get_imageio_config(
|
||||||
|
|
|
||||||
|
|
@ -157,11 +157,21 @@ def _get_views_data(config_path):
|
||||||
|
|
||||||
config = ocio.Config().CreateFromFile(str(config_path))
|
config = ocio.Config().CreateFromFile(str(config_path))
|
||||||
|
|
||||||
return {
|
data = {}
|
||||||
f"{d}/{v}": {"display": d, "view": v}
|
for display in config.getDisplays():
|
||||||
for d in config.getDisplays()
|
for view in config.getViews(display):
|
||||||
for v in config.getViews(d)
|
colorspace = config.getDisplayViewColorSpaceName(display, view)
|
||||||
}
|
# Special token. See https://opencolorio.readthedocs.io/en/latest/guides/authoring/authoring.html#shared-views
|
||||||
|
if colorspace == "<USE_DISPLAY_NAME>":
|
||||||
|
colorspace = display
|
||||||
|
|
||||||
|
data[f"{display}/{view}"] = {
|
||||||
|
"display": display,
|
||||||
|
"view": view,
|
||||||
|
"colorspace": colorspace
|
||||||
|
}
|
||||||
|
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue