OpenColorIO icon indicating copy to clipboard operation
OpenColorIO copied to clipboard

[python][bug] Dynamic Property bug with `DYNAMIC_PROPERTY_GRADING_PRIMARY`

Open MrLixm opened this issue 3 years ago • 1 comments

Hello,

Executing the following snippet :

import PyOpenColorIO as ocio

# ! REPLACE CONFIG_PATH !
config = ocio.Config().CreateFromFile(CONFIG_PATH)

gp = ocio.GradingPrimary(ocio.GRADING_LIN)
gp.clampBlack = 0.5
trsfm = ocio.GradingPrimaryTransform(
    gp,
    ocio.GRADING_LIN,
    dynamic=True,
)
proc = config.getProcessor(trsfm)
print("proc created.")

shader_desc = ocio.GpuShaderDesc.CreateShaderDesc(language=ocio.GPU_LANGUAGE_GLSL_4_0)
ocio_gpu_proc = proc.getDefaultGPUProcessor()
ocio_gpu_proc.extractGpuShaderInfo(shader_desc)

dyn_prop_type = ocio.DYNAMIC_PROPERTY_GRADING_PRIMARY
if shader_desc.hasDynamicProperty(dyn_prop_type):
    dyn_prop: ocio.DynamicProperty = shader_desc.getDynamicProperty(dyn_prop_type)
    dyn_prop.setDouble(2.66)
    print("DynamicProperty updated.")

print("Success")

Raises :

line 25, in <module>
    dyn_prop.setDouble(2.66)
PyOpenColorIO.Exception: Dynamic property value is not a double.

And I think it's not expected ? ~~Perhaps there is a missing float/double conversion is the cpp API ?~~ EDIT: Issue is on my side, check next comment.

CONTEXT:

Windows 10 PyOpenColorIO 2.1.1

Cheers. Liam.

MrLixm avatar May 31 '22 20:05 MrLixm

Hmm or perhaps the error is on my side haha, opened the issue too quick this time my bad !

I think I'm supposed to do :

    ...
    dyn_prop.setGradingPrimary(gp)
    ...

Which seems more logical.

I was just confused by the error which doesn't explicitly tell me that I did something wrong. Maybe getting an error message like you can't use setDouble on property of type GRADING_PRIMARY more explicit, but it's a very minor feature-request.

If you don't think any further discussion is needed, feel free to close this issue.

MrLixm avatar May 31 '22 20:05 MrLixm