Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 1 addition & 6 deletions src/lib/ip/OCIONodes/OCIOIPNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,11 @@ namespace IPCore
{
m_state->linear = "";
}
else if (getenv("OCIO"))
else
{
OCIO::ConstColorSpaceRcPtr linearColorSpace = m_state->config->getColorSpace(OCIO::ROLE_SCENE_LINEAR);
m_state->linear = linearColorSpace ? linearColorSpace->getName() : "";
}
else
{
m_state->linear = "";
std::cerr << "ERROR: OCIO environment variable not set" << std::endl;
}

m_state->shaderID = "";

Expand Down
30 changes: 27 additions & 3 deletions src/plugins/rv-packages/ocio_source_setup/ocio_source_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

def ocio_config_from_media(media, attributes):
if os.getenv("OCIO") is None:
raise Exception("ERROR: $OCIO environment variable unset!")
raise Exception

return OCIO.GetCurrentConfig()

Expand Down Expand Up @@ -268,8 +268,7 @@ def useSourceOCIO(self, source, nodeType, defaultSetting=""):
self.config = ocio_config_from_media(media, attrDict)
OCIO.SetCurrentConfig(self.config)
commands.defineModeMenu("OCIO Source Setup", self.buildOCIOMenu(), True)
except Exception as inst:
print(("ERROR: Unable to retrieve OCIO context: %s" % inst))
except Exception:
return

#
Expand Down Expand Up @@ -529,7 +528,20 @@ def selectConfig(self, event):
config = commands.openFileDialog(True, False, False, "ocio|OCIO Config", None)[0]
self.config = OCIO.Config.CreateFromFile(config)
OCIO.SetCurrentConfig(self.config)
for source in commands.nodesOfType("RVFileSource") + commands.nodesOfType("RVImageSource"):
for nodeType in OCIO_ROLES.keys():
self.disableSourceOCIO(source, nodeType)
for group in commands.nodesOfType("RVDisplayGroup"):
self.disableDisplayOCIO(group)
DEFAULT_PIPE.clear()
for source in commands.nodesOfType("RVFileSource") + commands.nodesOfType("RVImageSource"):
for nodeType in OCIO_ROLES.keys():
self.useSourceOCIO(source, nodeType)
for group in commands.nodesOfType("RVDisplayGroup"):
self.usingOCIOForDisplay[group] = False
self.useDisplayOCIO(group)
commands.defineModeMenu("OCIO Source Setup", self.buildOCIOMenu(), True)
commands.writeSettings("ocio_source_setup", "ocio_config", config)
except Exception as inst:
print(inst)

Expand Down Expand Up @@ -685,6 +697,8 @@ def addMenu(root, isSingle):
("Displays", None, None, lambda: commands.DisabledMenuState),
]
final += daList
final += [("_", None)]
final += [("Change Config...", self.selectConfig, None, None)]

return [("OCIO", final)]

Expand Down Expand Up @@ -716,6 +730,16 @@ def __init__(self):
except ImportError:
pass

# Restore saved OCIO config from previously loaded config
# An externally set OCIO env var takes precendence
if os.getenv("OCIO") is None:
Comment thread
bernie-laberge marked this conversation as resolved.
config = commands.readSettings("ocio_source_setup", "ocio_config", "")
if config != "" and os.path.isfile(config):
self.config = OCIO.Config.CreateFromFile(config)
OCIO.SetCurrentConfig(self.config)
else:
print("WARNING: $OCIO environment variable unset!")

self.init(
"OCIO Source Setup",
None,
Expand Down