-
Notifications
You must be signed in to change notification settings - Fork 563
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Metal alpha blending fixes + color handling improvements (#4913)
This PR addresses #2125 for the Metal renderer. Both options are available: "Apple-style" blending where colors are blended in a wide gamut color space, which reduces but does not eliminate artifacts; and linear blending where colors are blended in linear RGB. Because this doesn't add support for linear blending on Linux, I don't know whether the issue should be closed or not. ### List of changes in no particular order - We now set the layer's color space in the renderer not in the apprt - We always set the layer to Display P3 color spaces - If the user hasn't configured their `window-colorspace` to `display-p3` then terminal colors are automatically converted from sRGB to the corresponding Display P3 color in the shader - Background color is not set with the clear color anymore, instead we explicitly set all bg cell colors since this is needed for minimum contrast to not break with dark text on the default bg color (try it out, it forces it fully white right now), and we just draw the background as a part of the bg cells shader. Note: We may want to move the main background color to be the `backgroundColor` property on the `CAMetalLayer`, because this should fix the flash of transparency during startup (#4516) and the weirdness at the edge of the window when resizing. I didn't make that a part of this PR because it requires further changes and my changes are already pretty significant, but I can make it a follow-up. - Added a config option for changing alpha blending between "native" blending, where colors are just blended directly in sRGB (or Display P3) and linear blending, where colors are blended in linear space. - Added a config option for an experimental technique that I think works pretty well which compensates for the perceptual thinning and thickening of dark and light text respectively when using linear blending. - Custom shaders can now be hot reloaded with config reloads. - Fixed a bug that was revealed when I changed how we handle backgrounds, page widths weren't being set while cloning the screen. ### Main takeaways Color blending now matches nearly identically to Apple apps like Terminal.app and TextEdit, not *quite* identical in worst case scenarios, off by the tiniest bit, because the default color space is *slightly* different than Display P3. Linear alpha blending is now available for mac users who prefer more accurate color reproduction, and personally I think it looks very nice with the alpha correction turned on, I will be daily driving that configuration. ### Future work - Handle primary background color with `CALayer.backgroundColor` instead of in shader, to avoid issues around edges when resizing. - Parse color space info directly from ICC profiles and compute the color conversion matrix dynamically, and pass it as a uniform to the shaders. - Port linear blending option to OpenGL. - Maybe support wide gamut images (right now all images are assumed to be sRGB).
- Loading branch information
Showing
11 changed files
with
630 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.