Skip to content
Snippets Groups Projects
Commit d63eeb1e authored by Niklas Haas's avatar Niklas Haas
Browse files

shaders/colorspace: introduce colorimetric gamut clipping

This change adds some smarter logic than the dumb per-channel clip. We
first get rid of negative (e.g. super-red) components by mixing in
enough gray until the result is no longer oversaturated, and then we
linearly scale all components down to get rid of too-bright values.

I experimented briefly with using e.g. BT.2390 tone-mapping instead of a
linear scale for the second step, but the results were not significantly
better enough to justify the performance hit of BT.2390.

I tested this by inspecting the resulting gamut-clipped values on a Yxy
chromaticity diagram and confirmed that the resulting color was indeed
at the same angle (relative to the white point) as the original, but
contained within the gamut (with Y preserved).

Subjective comparisons using a wide gamut monitor between the original
(unclipped) source and the clipped BT.709 versions of various test clips
seem visually pleasing, so I enabled it by default.

Fixes #101
parent 77e9c80d
No related branches found
No related tags found
No related merge requests found
Pipeline #19140 passed with stages
in 7 minutes and 30 seconds
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment