Skip to content
Snippets Groups Projects

Gamma correct blending with sRGB

Merged Pekka Paalanen requested to merge pq/weston:mr/color-arch into main

This MR depends on !582 (merged) and !592 (merged).

This MR introduces the color transformation type 3x1D, per-channel one-dimensional look-up tables. It is implemented in GL-renderer. As a prerequisite, undoing pre-multiplied alpha is also added, adding the "straight alpha" path in the fragment shader. Straight alpha is the path that will be used by all color managed pipelines.

As GL-renderer starts supporting color transformations, the places in GL-renderer that used to assert that no color transformation is present are changed to load the respective color transformations. This takes the weston_output members from_sRGB_to_blend, from_sRGB_to_output and from_blend_to_output into use.

Color-lcms module is changed to install the sRGB EOTF curves in such way that it will lead to "gamma correct" blending. That is, blending will happen in optical (light linear) domain, not in electrical (non-linear) domain. This is the user visible effect of this MR if color-lcms module is active.

Finally, the alpha-blending test is augmented. A manual reference blending implementation is added, which ensures that Weston's blending result does not just match the reference image but also matches the reference mathematics. It can be hard to see from an image if the pixel values are actually correct or just "looking fairly reasonable". A new fixture case is added which enables color-lcms module and checks that the blending happens correctly in optical domain. This new test case is an integration test of the whole color managed pipeline up to this point, and pretty powerful in detecting problems.

This MR contains code from @vitalyp for the LittleCMS parts, and very likely contains inspiration from @swick's Weston work on color management.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Daniel Stone changed target branch from master to main

    changed target branch from master to main

  • Rest is weakly acked by me; I don't know about colour (I'm trying!) but it reads convincingly, and I think makes sense from a Weston PoV.

  • Pekka Paalanen added 75 commits

    added 75 commits

    • 6d28cc3b...6551c09d - 50 commits from branch wayland:main
    • fe9f1058 - libweston: introduce CMS component architecture
    • 4ed49f17 - color: add output color transform API
    • 7e1b0cc0 - color: add from sRGB to output color transformation
    • 4df1d25e - color: add from sRGB to blending color transformation
    • 4ead0406 - libweston: begin color-lcms plugin
    • 432d1cea - compositor: add weston.ini option to enable color management
    • e5b6a27b - tests: ensure color-lcms plugin loads
    • 709e9102 - gl-renderer: do not unbind the context on output destroy
    • 552cb230 - Revert "gl-renderer: Make dummy surface current after all outputs are gone"
    • b50eac07 - gl-renderer: require GL ES 3.0 for color management
    • e9fa5717 - gl-renderer: define fragment shader compile_const
    • 61201eaa - gl-renderer: use shadow framebuffer automatically
    • 951a4b96 - Revert "compositor: add weston.ini option use-renderer-shadow"
    • c3346fb6 - libweston: remove weston_output_set_renderer_shadow_buffer()
    • 5f19a3f4 - gl-renderer: add shader bit input_is_premult
    • c74422ea - gl-renderer: fragment shader precision to high
    • 4345be90 - gl-renderer: implement SHADER_SOURCE_LUT_3x1D
    • c174e798 - gl-renderer: implement 3 x 1D LUT color transformation
    • 16a16ce0 - gl-renderer: color transform censor fill and triangle fan
    • a8d2a81d - gl-renderer: color transform output borders
    • b97cb72c - gl-renderer: color transform in blit_shadow_to_output()
    • 294bf16c - color-lcms: use sRGB EOTF
    • 97dd5e0b - tests/alpha-blending: refactor into get_middle_row()
    • 4f19551a - tests/alpha-blending: reference blending
    • eadf45e2 - tests/alpha-blending: add sRGB linear light case

    Compare with previous version

  • Pekka Paalanen added 16 commits

    added 16 commits

    • 0a3f061f - gl-renderer: require GL ES 3.0 for color management
    • a00f2f77 - gl-renderer: define fragment shader compile_const
    • f9bc02c2 - gl-renderer: use shadow framebuffer automatically
    • 244fe867 - Revert "compositor: add weston.ini option use-renderer-shadow"
    • c036a116 - libweston: remove weston_output_set_renderer_shadow_buffer()
    • 092283a5 - gl-renderer: add shader bit input_is_premult
    • d0dbe952 - gl-renderer: fragment shader precision to high
    • a0f849f8 - gl-renderer: implement SHADER_SOURCE_LUT_3x1D
    • 536cde16 - gl-renderer: implement 3 x 1D LUT color transformation
    • 83e2dde0 - gl-renderer: color transform censor fill and triangle fan
    • 04887a25 - gl-renderer: color transform output borders
    • 0ef654e2 - gl-renderer: color transform in blit_shadow_to_output()
    • c3490bbf - color-lcms: use sRGB EOTF
    • 736f8115 - tests/alpha-blending: refactor into get_middle_row()
    • 9c8d42ed - tests/alpha-blending: reference blending
    • 25f76d19 - tests/alpha-blending: add sRGB linear light case

    Compare with previous version

  • Author Owner

    Rebased due to major rebase in !582 (merged).

  • Pekka Paalanen resolved all threads

    resolved all threads

  • Pekka Paalanen added 27 commits

    added 27 commits

    • a07cd112 - pixman-renderer: draw_view -> draw_paint_node
    • f766b510 - gl-renderer: draw_view -> draw_paint_node
    • a8f61a20 - libweston: introduce CMS component architecture
    • 37997ffa - color: add output color transform API
    • bcc5c503 - color: add from sRGB to output color transformation
    • a044fb3c - color: add from sRGB to blending color transformation
    • 2aab1c7e - libweston: begin color-lcms plugin
    • 7eb33106 - compositor: add weston.ini option to enable color management
    • b92c6eb0 - tests: ensure color-lcms plugin loads
    • b5a5405e - gl-renderer: do not unbind the context on output destroy
    • 5596d091 - Revert "gl-renderer: Make dummy surface current after all outputs are gone"
    • 7f42d387 - gl-renderer: require GL ES 3.0 for color management
    • afc6fa5c - gl-renderer: define fragment shader compile_const
    • 73ca4e62 - gl-renderer: use shadow framebuffer automatically
    • e8abc225 - Revert "compositor: add weston.ini option use-renderer-shadow"
    • 99472da0 - libweston: remove weston_output_set_renderer_shadow_buffer()
    • 7186954c - gl-renderer: add shader bit input_is_premult
    • 5af2080c - gl-renderer: fragment shader precision to high
    • ecb9f60d - gl-renderer: implement SHADER_SOURCE_LUT_3x1D
    • 27aa7998 - gl-renderer: implement 3 x 1D LUT color transformation
    • 456517a5 - gl-renderer: color transform censor fill and triangle fan
    • 58e23351 - gl-renderer: color transform output borders
    • 0a1f069a - gl-renderer: color transform in blit_shadow_to_output()
    • 038a4098 - color-lcms: use sRGB EOTF
    • 048076e4 - tests/alpha-blending: refactor into get_middle_row()
    • 4fed585b - tests/alpha-blending: reference blending
    • 3087097b - tests/alpha-blending: add sRGB linear light case

    Compare with previous version

  • Author Owner

    Rebase and minor mechanical changes due to !582 (comment 927609).

  • Pekka Paalanen added 25 commits

    added 25 commits

    • bdc2ec3b - libweston: introduce CMS component architecture
    • 15c66dc9 - color: add output color transform API
    • d1d7c564 - color: add from sRGB to output color transformation
    • 25db7c48 - color: add from sRGB to blending color transformation
    • 95d6730b - libweston: begin color-lcms plugin
    • 399b2011 - compositor: add weston.ini option to enable color management
    • b5c2602c - tests: ensure color-lcms plugin loads
    • 8e2102e8 - gl-renderer: do not unbind the context on output destroy
    • 4e413d6e - Revert "gl-renderer: Make dummy surface current after all outputs are gone"
    • e8be703a - gl-renderer: require GL ES 3.0 for color management
    • 66007e14 - gl-renderer: define fragment shader compile_const
    • 49385e10 - gl-renderer: use shadow framebuffer automatically
    • 1e2d7e8f - Revert "compositor: add weston.ini option use-renderer-shadow"
    • 24ad7a95 - libweston: remove weston_output_set_renderer_shadow_buffer()
    • c44bde85 - gl-renderer: add shader bit input_is_premult
    • 48bf5741 - gl-renderer: fragment shader precision to high
    • a8ed1e46 - gl-renderer: implement SHADER_TRANSFER_FUNCTION_LUT_3x1D
    • bc89f025 - gl-renderer: implement 3 x 1D LUT transfer function
    • 1f168b6f - gl-renderer: color transform censor fill and triangle fan
    • 5317290f - gl-renderer: color transform output borders
    • 1fb3470a - gl-renderer: color transform in blit_shadow_to_output()
    • 6c5cac6c - color-lcms: use sRGB EOTF
    • 27e83b09 - tests/alpha-blending: refactor into get_middle_row()
    • ced155a6 - tests/alpha-blending: reference blending
    • ce6ab3fe - tests/alpha-blending: add sRGB linear light case

    Compare with previous version

  • Author Owner

    Rebased due to !582 (comment 942116) and renamed everything "source lut" to "transfer function".

    Transfer function describes the operation or step better than source LUT. In the future it might not necessarily even be a LUT, it could be a parameterized function. This change allows the transfer function to be one of anything we want to have.

    Transformation type is changed into transfer function type. weston_color_transform no longer has a type per se, but it is a sequence of operations, each of which may have a type of its own, like transfer function has.

  • Pekka Paalanen added 61 commits

    added 61 commits

    • ce6ab3fe...bfcb1adc - 34 commits from branch wayland:main
    • c73176b4 - pixman-renderer: draw_view -> draw_paint_node
    • eec7fb1b - gl-renderer: draw_view -> draw_paint_node
    • cffbf7c6 - libweston: introduce CMS component architecture
    • 31394a3f - color: add output color transform API
    • 17453673 - color: add from sRGB to output color transformation
    • 809b2eed - color: add from sRGB to blending color transformation
    • 88cc6d95 - libweston: begin color-lcms plugin
    • f576dc45 - compositor: add weston.ini option to enable color management
    • eac289e9 - tests: ensure color-lcms plugin loads
    • 40a8c89b - gl-renderer: do not unbind the context on output destroy
    • 5203a5a4 - Revert "gl-renderer: Make dummy surface current after all outputs are gone"
    • 98623c3a - gl-renderer: require GL ES 3.0 for color management
    • a60b39d0 - gl-renderer: define fragment shader compile_const
    • 569a3663 - gl-renderer: use shadow framebuffer automatically
    • 2af9dfe5 - Revert "compositor: add weston.ini option use-renderer-shadow"
    • 2e03d936 - libweston: remove weston_output_set_renderer_shadow_buffer()
    • 9bdb56c8 - gl-renderer: add shader bit input_is_premult
    • 9be579da - gl-renderer: fragment shader precision to high
    • deac669d - gl-renderer: implement SHADER_TRANSFER_FUNCTION_LUT_3x1D
    • f6c994cd - gl-renderer: implement 3 x 1D LUT transfer function
    • 0e1a92db - gl-renderer: color transform censor fill and triangle fan
    • 7f00e148 - gl-renderer: color transform output borders
    • 74cff4ed - gl-renderer: color transform in blit_shadow_to_output()
    • f6bb1d66 - color-lcms: use sRGB EOTF
    • e69abdd1 - tests/alpha-blending: refactor into get_middle_row()
    • 941806c8 - tests/alpha-blending: reference blending
    • 7fc7ca92 - tests/alpha-blending: add sRGB linear light case

    Compare with previous version

  • Author Owner

    Trivial rebase to main. alpha-blending-test is still ASan-clean, even for leaks.

  • Still looks fine to me. I'm comfortable with everything in there, but not fluent enough in CM to give any useful suggestions.

  • Pekka Paalanen mentioned in merge request !637 (merged)

    mentioned in merge request !637 (merged)

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading