Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GradingPrimaryTransform shader fails Windows / macOS #1603

Closed
sobotka opened this issue Feb 17, 2022 · 6 comments
Closed

GradingPrimaryTransform shader fails Windows / macOS #1603

sobotka opened this issue Feb 17, 2022 · 6 comments

Comments

@sobotka
Copy link
Contributor

sobotka commented Feb 17, 2022

GradingPrimaryTransform appears to fail in the shader on macOS (Intel). v 2.0.0 and 2.1.1.

ERROR (gpu.shader): OCIOShader FragShader: 
      | 
    1 | #version 330
      |                                                                                    ^
      | Error: Use of undeclared identifier 'inf'
      | 
      | #version 330
      |                                                                                     ^
      | Error: Use of undeclared identifier 'inf'
      | 
      | #version 330
      |                                                                                                  ^
      | Error: Use of undeclared identifier 'clampBlack'
      | Error: Use of undeclared identifier 'clampWhite'
@hodoulp
Copy link
Member

hodoulp commented Feb 18, 2022

In OCIO we already have many GPU unit tests around GradingPrimaryTransform, could you provide us some code snippet or a simplified config file to reproduce the problem?

@jessey-git
Copy link

@hodoulp
I'm attempting to triage this issue from the originating software so here's some additional information:

vec4 OCIO_to_display(in vec4 inPixel)
{
  vec4 outColor = inPixel;

  // Add GradingPrimary 'log' forward processing

  {
    vec3 brightness = vec3(0., 0., 0.);
    vec3 contrast = vec3(1.29999995, 1.29999995, 1.29999995);
    vec3 gamma = vec3(1., 1., 1.);
    float pivot = 0.400000006;
    float pivotBlack = 0.;
    float pivotWhite = 1.;
    float clampBlack = -inf;
    float clampWhite = inf;
    float saturation = 3.29999995;
    outColor.rgb += brightness;
    outColor.rgb = ( outColor.rgb - pivot ) * contrast + pivot;
    if ( gamma != vec3(1., 1., 1.) )
    {
      vec3 normalizedOut = abs(outColor.rgb - pivotBlack) / (pivotWhite - pivotBlack);
      vec3 scale = sign(outColor.rgb - pivotBlack) * (pivotWhite - pivotBlack);
      outColor.rgb = pow( normalizedOut, gamma ) * scale + pivotBlack;
    }
    vec3 lumaWgts = vec3(0.212599993, 0.715200007, 0.0722000003);
    float luma = dot( outColor.rgb, lumaWgts );
    outColor.rgb = luma + saturation * (outColor.rgb - luma);
    outColor.rgb = clamp( outColor.rgb, clampBlack, clampWhite );
  }

  return outColor;
}

It appears as though the 'clampWhite' and 'clampBlack' defaults of +,- max double is being written out to glsl as 'inf'

@jessey-git
Copy link

BTW, forgot to add that my repro was done on Windows+nVidia so it's not specific to Mac. The only workaround is to specify your own values for clamp inside the config. For example: clamp: {black: -100000, white: 100000}

sobotka pushed a commit to sobotka/blender that referenced this issue Mar 23, 2022
When using GradingPrimaryTransform the generated GLSL code fails to compile. The actual issue is
inside OCIO (AcademySoftwareFoundation/OpenColorIO#1603).

The reason is that unset clamping values are rendered out as `inf`, which isn't recognizable
by GLSL.

The issue is worked around by defining a default for `inf`.

Reviewed By: brecht

Maniphest Tasks: T96502

Differential Revision: https://developer.blender.org/D14425
@sobotka
Copy link
Contributor Author

sobotka commented Mar 23, 2022

Plausibly related to #1601 ?

@sobotka sobotka changed the title GradingPrimaryTransform shader fails on macOS GradingPrimaryTransform shader fails Windows / macOS Mar 23, 2022
@hodoulp
Copy link
Member

hodoulp commented Mar 24, 2022

Hi @sobotka & @jessey-git
The problem is fixed by PR #1462 (I'm able to reproduce the problem by removing a change from this PR) which is merged in main and RB-2.1. So, I suggest an update to OpenColorIO 2.1.

@doug-walker
Copy link
Collaborator

Despite what is written in the issue description above, based on Patrick's investigation, it should not be possible for the stated problem to occur in the 2.1 release, or later. Therefore, I am closing this issue as Fixed.

sobotka pushed a commit to sobotka/blender that referenced this issue Apr 21, 2022
When using GradingPrimaryTransform the generated GLSL code fails to compile. The actual issue is
inside OCIO (AcademySoftwareFoundation/OpenColorIO#1603).

The reason is that unset clamping values are rendered out as `inf`, which isn't recognizable
by GLSL.

The issue is worked around by defining a default for `inf`.

Reviewed By: brecht

Maniphest Tasks: T96502

Differential Revision: https://developer.blender.org/D14425
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants