mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-23 20:26:09 +03:00
opengl: use premult alpha on fg color to avoid dark edges
This avoids an issue I only see in some renderers where the edges of textures show up with a blurry border. Reading here: https://www.realtimerendering.com/blog/gpus-prefer-premultiplication/
This commit is contained in:
@ -369,9 +369,12 @@ pub fn windowInit(win: apprt.runtime.Window) !void {
|
|||||||
const self: OpenGL = undefined;
|
const self: OpenGL = undefined;
|
||||||
try self.threadEnter(win);
|
try self.threadEnter(win);
|
||||||
|
|
||||||
// Blending for text
|
// Blending for text. We use GL_ONE here because we should be using
|
||||||
|
// premultiplied alpha for all our colors in our fragment shaders.
|
||||||
|
// This avoids having a blurry border where transparency is expected on
|
||||||
|
// pixels.
|
||||||
try gl.enable(gl.c.GL_BLEND);
|
try gl.enable(gl.c.GL_BLEND);
|
||||||
try gl.blendFunc(gl.c.GL_SRC_ALPHA, gl.c.GL_ONE_MINUS_SRC_ALPHA);
|
try gl.blendFunc(gl.c.GL_ONE, gl.c.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
// These are very noisy so this is commented, but easy to uncomment
|
// These are very noisy so this is commented, but easy to uncomment
|
||||||
// whenever we need to check the OpenGL extension list
|
// whenever we need to check the OpenGL extension list
|
||||||
|
@ -42,7 +42,7 @@ void main() {
|
|||||||
|
|
||||||
case MODE_FG:
|
case MODE_FG:
|
||||||
a = texture(text, glyph_tex_coords).r;
|
a = texture(text, glyph_tex_coords).r;
|
||||||
out_FragColor = vec4(color.rgb, color.a*a);
|
out_FragColor = vec4(color.rgb*a, color.a*a);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_FG_COLOR:
|
case MODE_FG_COLOR:
|
||||||
|
Reference in New Issue
Block a user