Skip to content

cm: higher-quality tonemapping#12204

Merged
vaxerski merged 1 commit into
hyprwm:mainfrom
njdom24:screenshare-cm-brightness
Dec 7, 2025
Merged

cm: higher-quality tonemapping#12204
vaxerski merged 1 commit into
hyprwm:mainfrom
njdom24:screenshare-cm-brightness

Conversation

@njdom24

@njdom24 njdom24 commented Nov 2, 2025

Copy link
Copy Markdown
Contributor

Describe your PR, what does it fix/add?

Inspired by KWin. Updates the tonemapper to use the src imageDescription's luminance info instead of throwing it away. Also scales the reference luminance to match that of the destination, preventing over-bright screenshots / recordings.

Also tossed in a quick fix missed from #12094, which prevents overly-dark screenshares in SDR when render:cm_sdr_eotf > 0.

HDR screenshot tonemapped to SDR:
hdr_to_sdr

SDR screenshot:
reg_sdr

Without these changes:
image

I considered a simple luminance multiplier as a proof-of-concept when getting started. This is what that would look like by keeping the current tonemap and simply multiplying the end result by 80.0 / 203.0:
image

Versus this PR:

image

The changes to blurprepare.frag fix the inverted color issue with blur from SDR->HDR.
Screenshot of my desktop in SDR:
desktop_sdr

And in HDR tonemapped back to SDR with these changes:
desktop_hdr

The blur is still too strong, but the colors are a lot better.

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

I'm not super confident in the "correctness" of tonemapper changes (really just looked at prior art), but it does improve HDR screenshares immensely.

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

Ready for merging

@njdom24 njdom24 force-pushed the screenshare-cm-brightness branch from 3df2f92 to 5e53f84 Compare November 4, 2025 06:52
@njdom24 njdom24 changed the title cm: scale reference luminance when tonemapping cm: higher-quality tonemapping Nov 4, 2025
@njdom24 njdom24 force-pushed the screenshare-cm-brightness branch 2 times, most recently from 3f2aefa to 62a2099 Compare November 5, 2025 04:35
@njdom24 njdom24 force-pushed the screenshare-cm-brightness branch from 62a2099 to b72da6d Compare November 8, 2025 20:52
@njdom24 njdom24 marked this pull request as ready for review November 8, 2025 21:49
@vaxerski

Copy link
Copy Markdown
Member

@UjinT34

@UjinT34

UjinT34 commented Nov 11, 2025

Copy link
Copy Markdown
Contributor

Current tonemapping is also inspired by kwin. If they changed theirs then we should probably do the same. Might be harder to track every necessary change because they combine cpu calcs, shaders and drm properties.
Tonemapping happens when source max luminance is higher than the target one. Most games set their luminance to 10000 or some other high value which almost always results in HDR -> HDR tonemapping. So this PR will affect desktop HDR and fullscreen HDR with cm_fs_passthrough = 0. Might make it better or worse but most likely it'll be too subtle to notice.

@njdom24

njdom24 commented Nov 11, 2025

Copy link
Copy Markdown
Contributor Author

@UjinT34 Thanks, I didn't consider that.
Do you think it warrants a check for HDR-on-HDR to bail, and maybe a new config var for that?

My HDR displays are all Mini-LED, so I can't be sure how it'll look on e.g. OLEDs with HDR400.

@UjinT34

UjinT34 commented Nov 11, 2025

Copy link
Copy Markdown
Contributor

tonemap works with linear values and shouldn't care about SDR/HDR. I don't think we need a separate codepath for that unless someone has issues with HDR and new tonemapping.

@njdom24

njdom24 commented Nov 18, 2025

Copy link
Copy Markdown
Contributor Author

Rebased and moved to a more general HDR-to-SDR check to use transfer function luminances for tonemapping across the board.

This change makes the improved tonemapping apply to HDR content on SDR displays too, instead of just in screenshare.

If Auto-HDR might cause apps to always output HDR, this should make things look okay when you're un-fullscreened and back to SDR.

@njdom24 njdom24 force-pushed the screenshare-cm-brightness branch from 8c958ae to db6a676 Compare November 28, 2025 19:19
@njdom24

njdom24 commented Nov 28, 2025

Copy link
Copy Markdown
Contributor Author

Updated to fix a slight blue-green hue I noticed for HDR->SDR.

@njdom24

njdom24 commented Dec 4, 2025

Copy link
Copy Markdown
Contributor Author

@UjinT34 I've been using this with #12127 on my system for a while, and everything seems to work as intended.

Any changes you'd like to see to get them merged?

@UjinT34

UjinT34 commented Dec 4, 2025

Copy link
Copy Markdown
Contributor

lgtm

@njdom24

njdom24 commented Dec 4, 2025

Copy link
Copy Markdown
Contributor Author

@vaxerski ?

@vaxerski vaxerski merged commit 532ca05 into hyprwm:main Dec 7, 2025
10 checks passed
@UjinT34 UjinT34 mentioned this pull request Dec 21, 2025
68 tasks
@UjinT34 UjinT34 mentioned this pull request Apr 11, 2026
3 tasks
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