mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
metal: premult alpha for fg color
This commit is contained in:
@ -1299,8 +1299,8 @@ fn initPipelineState(device: objc.Object, library: objc.Object) !objc.Object {
|
||||
attachment.setProperty("blendingEnabled", true);
|
||||
attachment.setProperty("rgbBlendOperation", @enumToInt(MTLBlendOperation.add));
|
||||
attachment.setProperty("alphaBlendOperation", @enumToInt(MTLBlendOperation.add));
|
||||
attachment.setProperty("sourceRGBBlendFactor", @enumToInt(MTLBlendFactor.source_alpha));
|
||||
attachment.setProperty("sourceAlphaBlendFactor", @enumToInt(MTLBlendFactor.source_alpha));
|
||||
attachment.setProperty("sourceRGBBlendFactor", @enumToInt(MTLBlendFactor.one));
|
||||
attachment.setProperty("sourceAlphaBlendFactor", @enumToInt(MTLBlendFactor.one));
|
||||
attachment.setProperty("destinationRGBBlendFactor", @enumToInt(MTLBlendFactor.one_minus_source_alpha));
|
||||
attachment.setProperty("destinationAlphaBlendFactor", @enumToInt(MTLBlendFactor.one_minus_source_alpha));
|
||||
}
|
||||
|
@ -188,8 +188,10 @@ fragment float4 uber_fragment(
|
||||
float2 size = float2(textureGreyscale.get_width(), textureGreyscale.get_height());
|
||||
float2 coord = in.tex_coord / size;
|
||||
|
||||
// We premult the alpha to our whole color since our blend function
|
||||
// uses One/OneMinusSourceAlpha to avoid blurry edges.
|
||||
float a = textureGreyscale.sample(textureSampler, coord).r;
|
||||
return float4(in.color.rgb, in.color.a * a);
|
||||
return in.color * a;
|
||||
}
|
||||
|
||||
case MODE_FG_COLOR: {
|
||||
|
Reference in New Issue
Block a user