Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upText is not gamma corrected #230
Comments
|
How does Core Graphics read from the destination framebuffer while shading? I thought that was unsupported on all desktop GPUs… |
|
GL_NV_texture_barrier lets you read from the destination framebuffer if you play nice. |
|
Very interesting. I do have that extension on my Intel. This yields another alternative approach to that of WR2. cc @glennw |
|
I think the best approach here is probably to do what Skia does and preblend. This approach will across all of the platforms we need to support and the fact that Skia does it suggests it good enough. Basically it builds a lookup table for 1 << MAX_LUM_BITS (8) different luminance values using SkTMaskGamma_build_correcting_lut. these lookup tables are then used to adjust the mask so that when composited using linear blending the result is somewhat similar to a gamma corrected results. The larger impact of this is that we need to include the luminance value of the text color in the glyph cache key. |
|
@jrmuizel That seems like a good approach. |
|
If we don't aim to be precisely matching the native OS text rendering, we might also consider just using sRGB framebuffer for the GPU text anti-aliased rendering:
|
|
Fair warning, that extension has had some confusing specification history - see e.g. https://lists.freedesktop.org/archives/mesa-dev/2016-August/125215.html |
|
I've ported the skia preblend code to rust here: https://github.com/jrmuizel/mac-font-stuff/blob/master/src/lib.rs#L57 |
On Windows and OS X text is blended in a way that tries to be more correct gamma.
For example, OS X blends using a gamma of 2.0. CoreGraphics implements this by reading from the destination framebuffer while shading (this is supported on all platforms that CoreGraphics runs on). Skia has a pre-blend step that tries to mimic this without needing to read from the framebuffer. See SkTMaskGamma_build_correcting_lut near https://skia.googlesource.com/skia.git/+/master/src/core/SkMaskGamma.cpp#78