Skip to content

Desaturate extreme temperatures to improve colors - #45

Draft
aeraglyx wants to merge 1 commit into
psi4j:mainfrom
aeraglyx:saturation-correction
Draft

aeraglyx wants to merge 1 commit into
psi4j:mainfrom
aeraglyx:saturation-correction

Conversation

@aeraglyx

Copy link
Copy Markdown
Contributor

An experiment to test desaturating screen before applying the temperature multiplier to improve readability of saturated colors.

Problem

Imagine blue text on black background. When using very low temperatures, blue and green channels get multiplied to almost 0, making it hard to read (compared to greyscale or red text). Same thing for white text on red background - blue/green components get dimmed, and what remains is red on red... So potentially an accessibility thing.

Solution

We can first partially desaturate the image and then apply the temperature correction. To do that, instead of using only the diagonal components of the CTM, we can split the contributions within each row. The result is the same overall temperature (no change for greyscale), but saturated text is more readable and images look (subjectively) more pleasant.

In this PR, I'm exponentially reducing saturation the further we get from 6500K (in the inverse space). There is one variable to control the desaturation strength, through experimentation I found 0.4 to work pretty well.

6500K 1500K - Main 1500K - PR
6500k 1500k_main 1500k_pr

Attribution - calibration image found here.

Technically, it might be better to use some proper Chromatic Adaptation Transform, but I believe those can go negative, which hyprland_ctm_control_v1 does not support anyway.

Works in Hyprland, currently no clue about other backends...

@psi4j

psi4j commented Sep 15, 2026

Copy link
Copy Markdown
Owner

I'm sorry I haven't come back to this one yet. I plan on integrating this into v0.13.0. If you'd like to make a PR for the color space work you showed me before, that would also fit well into v0.13.0. If not, I would like to borrow from your work and implement it myself (giving you due credit, of course). Someone recently requested this in #63, and wlsunset already has a working patch for this using wlr-gamma-control. Hope you are well and look forward to hearing from you.

@aeraglyx

Copy link
Copy Markdown
Contributor Author

Hi! Sorry for no updates, I'll look at it over the weekend and let you know.

@aeraglyx

Copy link
Copy Markdown
Contributor Author

Tried comparing the Bradford chromatic adaptation (the "correct" solution that can go negative) with the proposed solution in Blender and it's in the same direction, but I guess why not do it properly and use Bradford? Just with clamped elements and "normalized" rows at the end, that barely changes the output and makes it compatible with hyprland_ctm_control_v1.

It's just very unfortunate that the CTM is not being applied in linear light :( this changes some saturated colors quite a bit (still better than before though). Hyprland discussion #15747 for reference.

Here's a little comparison, current is just the diagonal matrix, bradford probably the ground truth we want and the 2 non-lin options what we could do with the current limitations.

current bradford bradford non-lin desat desat non-lin
current bradford bradford nonlinear desat desat nonlinear

Here's an overview of the Bradford math (just for reference):

blender bradford nodes

I wonder if it could be further simplified. I'll probably experiment with the Bradford method a bit more and maybe try to implement it later, does that sound good?

@psi4j

psi4j commented Sep 22, 2026

Copy link
Copy Markdown
Owner

Thank you for sharing this. The Bradford chromatic adaptation appears to deliver roughly an ideal result for reducing blue and green while maintaining correct relative color expression. The desat non-lin honestly looks pretty good too. If you have time, we could test both non-lin versions live and see how we both feel about it. Increasing readability of blue text is still a win, regardless of which lands. Thank you for the update!

@aeraglyx

Copy link
Copy Markdown
Contributor Author

FWIW here's a WIP branch with some of my earlier experiments + the Bradford adaptation:
main...aeraglyx:sunsetr:color-science

It seems to work pretty well I think (Hyprland only). It's a bit more code (and some of it sucks I'm sure), but if Hyprland decides to do something about the CTM handling in the future, we could just skip a few lines and instantly have something quite good.

Should I maybe make a new PR? (or if you would like to work on it, that's fine with me too)

@psi4j

psi4j commented Sep 23, 2026

Copy link
Copy Markdown
Owner

FWIW here's a WIP branch with some of my earlier experiments + the Bradford adaptation:

Thank you for sharing these. I'll take a more thorough look at what you've implemented thus far soon after my midterms are up next week.

Should I maybe make a new PR? (or if you would like to work on it, that's fine with me too)

If you have time right now, I would greatly appreciate it. I actually made the switch back to Hyprland from Niri recently, and think giving us the option to desaturate or use an approximation of the Bradford adaptation would be a welcomed improvement for many people. Let me know if I can help with anything and I'll get to it asap, hopefully next week. Thank you for your help with this.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

2 participants