mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
fix(Metal): fix incorrect premultiplication of colors
Also make sure to divide alpha out before applying gamma encoding back to text color when not using linear blending.
This commit is contained in:
@ -139,7 +139,7 @@ float4 load_color(
|
|||||||
// already have the correct color here and
|
// already have the correct color here and
|
||||||
// can premultiply and return it.
|
// can premultiply and return it.
|
||||||
if (display_p3 && !linear) {
|
if (display_p3 && !linear) {
|
||||||
color *= color.a;
|
color.rgb *= color.a;
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ float4 load_color(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Premultiply our color by its alpha.
|
// Premultiply our color by its alpha.
|
||||||
color *= color.a;
|
color.rgb *= color.a;
|
||||||
|
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
@ -503,12 +503,12 @@ fragment float4 cell_text_fragment(
|
|||||||
// If we're not doing linear blending, then we need to
|
// If we're not doing linear blending, then we need to
|
||||||
// re-apply the gamma encoding to our color manually.
|
// re-apply the gamma encoding to our color manually.
|
||||||
//
|
//
|
||||||
// We do it BEFORE premultiplying the alpha because
|
// Since the alpha is premultiplied, we need to divide
|
||||||
// we want to produce the effect of not linearizing
|
// it out before unlinearizing and re-multiply it after.
|
||||||
// it in the first place in order to match the look
|
|
||||||
// of software that never does this.
|
|
||||||
if (!uniforms.use_linear_blending) {
|
if (!uniforms.use_linear_blending) {
|
||||||
|
color.rgb /= color.a;
|
||||||
color = unlinearize(color);
|
color = unlinearize(color);
|
||||||
|
color.rgb *= color.a;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch our alpha mask for this pixel.
|
// Fetch our alpha mask for this pixel.
|
||||||
|
Reference in New Issue
Block a user