Skip to content

renderer: implement wp-color-management-v1 transfer functions#11084

Merged
vaxerski merged 8 commits into
hyprwm:mainfrom
Tom94:tf-funcs
Jul 20, 2025
Merged

renderer: implement wp-color-management-v1 transfer functions#11084
vaxerski merged 8 commits into
hyprwm:mainfrom
Tom94:tf-funcs

Conversation

@Tom94

@Tom94 Tom94 commented Jul 18, 2025

Copy link
Copy Markdown
Contributor

Describe your PR, what does it fix/add?

Implements all remaining transfer functions from wp-color-management-v1 and their inverses.

(Also cleans up trailing whitespaces, mixed tabs and spaces, and a redundant alpha mult+div in CM.glsl.)

Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)

The implementation is based on the primary source (the ITU H.273 standard) as well as my own mathematical derivations of some of the constants and inverses which the standard does not provide.

I'm the author of an image viewer that encounters most of these transfer functions in the wild on a daily basis, so I'm reasonably confident in the correctness.

I also wrote a debug shader (not included in this PR) that verified that the GLSL implementation has correct rountrip behavior (i.e. fromLinear(toLinear(c)) == c) for all transfer functions.

Is it ready for merging, or does it need work?

Ready for merging.

@Tom94 Tom94 changed the title Implement wp-color-management-v1 transfer functions renderer: implement wp-color-management-v1 transfer functions Jul 18, 2025
@vaxerski

Copy link
Copy Markdown
Member

@UjinT34 for hdr, if you could take a look

@UjinT34

UjinT34 commented Jul 19, 2025

Copy link
Copy Markdown
Contributor

setSetTfNamed needs an update with a list of new tfs. Keep all of them listed explicitly because proto enum can be extended as a backward compatible change without creating a new major version.

Tom94 added 2 commits July 19, 2025 15:01
They all map to their equivalent now-supported color-management-v1
transfer functions.
@Tom94

Tom94 commented Jul 19, 2025

Copy link
Copy Markdown
Contributor Author

Done! I also flagged all xx-color-manager-v4 tfs as supported while I was at it. Looks like they are all already mapped to the respectively equivalent color-management-v1 tfs.

Should I also have a look at frog tfs? Their mapping to color-management-v1 seems a bit less trivial than the xx- protocol, so I held off on that for now.

@UjinT34

UjinT34 commented Jul 19, 2025

Copy link
Copy Markdown
Contributor

xx and frog are for removal, shouldn't be used by any recent client.

lgtm

vaxerski
vaxerski previously approved these changes Jul 20, 2025
@Tom94

Tom94 commented Jul 20, 2025

Copy link
Copy Markdown
Contributor Author

Please wait with merging. I just noticed that Hyprland's existing implementation of the HLG transfer function is incorrect -- inverse and forward appear to be mistakenly swapped. Going to push a fix in a moment.

Previous implementation had forward and inverse swapped + used
unnecessarily expensive math (pow(x, 2) instead of x*x, pow(M_E, x)
instead of exp(x), and pow(x, 0.5) instead of sqrt(x)).
@Tom94

Tom94 commented Jul 20, 2025

Copy link
Copy Markdown
Contributor Author

Should be all good now. Sorry for not catching this earlier.

sqrt(3) * pow(1/12, 0.5) is just a complicated way to express 0.5
@vaxerski vaxerski merged commit bf1602d into hyprwm:main Jul 20, 2025
13 checks passed
@UjinT34 UjinT34 mentioned this pull request Jul 22, 2025
68 tasks
Boom-Hacker pushed a commit to Boom-Hacker/Hyprland that referenced this pull request Sep 27, 2025
Boom-Hacker pushed a commit to Boom-Hacker/Hyprland that referenced this pull request Sep 27, 2025
Boom-Hacker pushed a commit to Boom-Hacker/Hyprland that referenced this pull request Sep 27, 2025
crthpl pushed a commit to crthpl/Hyprland that referenced this pull request Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants