Page MenuHome

OpenColorIO: update GPU display shader for version 2.0
ClosedPublic

Authored by Brecht Van Lommel (brecht) on Feb 1 2021, 3:57 PM.

Details

Summary

To avoid baking exposure and gamma into the GLSL shader and requiring slow
recompiles when tweaking, we manually apply them in the shader. This leads
to some logic duplicaton between the CPU and GPU display processor, but it
seems unavoidable.

Caching was also changed. Previously this was done both on the imbuf and
opencolorio module levels. Now it's all done in the opencolorio module by
simply matching color space names. We no longer use cacheIDs from OpenColorIO
since computing them is expensive, and they are unlikely to match now that
more is baked into the shader code.

Shaders can now use multiple 2D textures, 3D textures and uniforms, rather
than a single 3D texture. So allocating and binding those adds some code.

Color space conversions for blending with overlays is now hardcoded in the
shader. This was using harcoded numbers anyway, if this every becomes a
general OpenColorIO transform it can be changed, but for now there is no
point to add code complexity.

Depends on D10272

Event Timeline

Brecht Van Lommel (brecht) requested review of this revision.Feb 1 2021, 3:57 PM
Brecht Van Lommel (brecht) created this revision.

Rebase on dependent diffs.

Pretty solid! Nothing much to add. Only small codestyle comments.

intern/opencolorio/gpu_shader_display_transform.glsl
3

Nitpick: No need for these defines for uniforms. They are optimized away by compilers. If that's for code clarity just move the uniform down to before OCIO_GPUCurveMappingParameters.

intern/opencolorio/ocio_impl_glsl.cc
130

We should use nullptr in new C++ code IIRC.

source/blender/imbuf/intern/colormanagement.c
4078

Just curious, why check for theses bypass cases? Precision?

4079

Use max_ff instead of MAX2.

This revision is now accepted and ready to land.Feb 4 2021, 3:46 PM
Brecht Van Lommel (brecht) marked 4 inline comments as done.

Address comments.

source/blender/imbuf/intern/colormanagement.c
4078

In OCIO_gpuDisplayShaderBind we check if (scale != 1.0f), so we need it to be exactly 1.

In practice the precision is probably enough, but no need to take the risk.