OpenColorIO icon indicating copy to clipboard operation
OpenColorIO copied to clipboard

Why are processors entirely unaffected by any set look?

Open pyalot opened this issue 8 years ago • 4 comments

pyalot avatar Mar 17 '17 16:03 pyalot

setting a look on a view in the configuration seemed to have no effect, even when this was the only colorspace defined.

pyalot avatar Mar 17 '17 19:03 pyalot

I'd take a look at the Displaying an image, using the CPU (simple ColorSpace conversion) section, and the one after it in this first: http://opencolorio.org/developers/usage_examples.html

But the simple gist of it is that processors only get passed a to and from colorspace, whereas Displays are just logical ordering of Views (they aren't really anything unto themselves), and Views are just a logical coupling of a "fromColorspace" and a "look", where looks essentially just tack on additional transform operations to the from-to-colorspace-transform stack.

scoopxyz avatar Mar 17 '17 19:03 scoopxyz

After being unsuccessful to set any look because of the object/string confusion, I resorted to editing the ocio file. I've found this one from blender filmic: https://github.com/sobotka/filmic-blender/blob/master/config.ocio

It defines a "Base Contrast" look, which I presume, works if you set it programmatically. But it contains a line for software that doesn't support looks (vray):

  • !<View> {name: Filmic Base Contrast, colorspace: Filmic Log Encoding, look: +Base Contrast}

Commenting that line out, and setting the default and active view to " Filmic Base Contrast" did nothing. Using the alternate "looks" attribute did nothing either. Commenting everything out and having nothing but that colorspace still did nothing. It's only when I took the transform defined in the look, and appended it to the Filmic Log Encoding colorspace that finally something happened.

pyalot avatar Mar 17 '17 19:03 pyalot

The config you are referring to looks like it was not generated in an OCIO-legal manner, as in hand-crafted instead of generated through the API, so I cannot comment directly on the behavior of this config.

But since I can't seem to find a good reference implementation in our docs here's a quick snippet that should answer your question.

import PyOpenColorIO as OCIO
from array import array

config = OCIO.Config.CreateFromFile('/path/to/config.ocio')

transform = OCIO.DisplayTransform()
transform.setInputColorSpaceName(OCIO.Constants.ROLE_SCENE_LINEAR)

display = config.getDefaultDisplay()
view = config.getDefaultView(display)

transform.setDisplay(display)
transform.setView(view)

processor = config.getProcessor(transform)

out = processor.applyRGB(array('f', [0.1, 0.2, 0.3]))

Which should work in the case of the config you've referred to. If you want to apply the look outside of a view chain than you can treat the Look as a Look Transform within a larger chain of transforms.

scoopxyz avatar Mar 18 '17 00:03 scoopxyz