Skip to content

effects/invert: Add a color-preserving brightness inversion shader.

Bartosz Taudul requested to merge wolfpld/kwin:master into master

The currently existing screen inversion effect simply inverts each of the RGB channels by doing:

out = 1 - in

This MR adds an option to additionally rotate the color hue by 180°, which has the effect of keeping the original color value, while the brightness is still reversed.

The math for this has been worked out by Vasili Novikov in the following repository: https://github.com/vn971/linux-color-inversion/blob/master/shift.glsl


Normal window: Screenshot_20230214_223001

Inverted window, without these changes: Screenshot_20230214_223015

Inverted window, with these changes: Screenshot_20230214_223027


Note that while colors can be now preserved, the contrast is changed due to how particular colors are perceived. For example, look at the terminal screenshot, where the green and yellow text becomes hardly readable against a white background. This is one of reasons this should be a toggle.

I am not happy with binding the toggle action to Ctrl+Meta+O key shortcut. I would rather it be a checkbox in the effect settings window, but making this work is beyond what I am able to do.

Merge request reports

Loading