Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text Rendering / Clarity: Implement correct gamma correction #108

Closed
bryphe opened this issue Dec 14, 2018 · 1 comment
Closed

Text Rendering / Clarity: Implement correct gamma correction #108

bryphe opened this issue Dec 14, 2018 · 1 comment

Comments

@bryphe
Copy link
Member

bryphe commented Dec 14, 2018

Issue: The font rendering is not as clear as it could be on low-dpi displays.

One contributing factor is that we are not appropriately handling gamma color space. When we render a glyph, freetype gives us back an alpha mask - each pixel is an 8bit value describing the coverage. If a pixel is 50% covered, it is made 50% black.

However, that 50% does not actually translate to 50% brightness - we treat '128' as the halfway point (which it is in linear space), however, in actuality, ~'186' is the halfway point for brightness.

This is described in more detail here:

One open question is - does this mean we can't render text with a transparent background? It might be that, for subpixel rendering and for this, we'd need to render text with a solid background (or a known color / map in the background).

Following from the above document, there might be a way to gamma-correct properly w/o knowing the background: https://bel.fi/alankila/lcd/

The goal of this work would be to implement proper gamma-correction - ideally preserving transparent backgrounds for the text, if possible!

@bryphe
Copy link
Member Author

bryphe commented Dec 15, 2018

Another good article on gamma correction: https://learnopengl.com/Advanced-Lighting/Gamma-Correction

bryphe added a commit that referenced this issue Mar 2, 2019
* Start gamma-corrected shader

* Rename assets

* Add gamma slider to example

* Visualize gamma correction

* Tweak example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant