mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
renderer/metal,opengl: premult alpha for fragment shaders for images
Fixes #1346
This commit is contained in:
@ -328,7 +328,12 @@ fragment float4 image_fragment(
|
|||||||
// BGRA8Unorm. So we need to convert it. We should really be converting
|
// BGRA8Unorm. So we need to convert it. We should really be converting
|
||||||
// our texture to BGRA8Unorm.
|
// our texture to BGRA8Unorm.
|
||||||
uint4 rgba = image.sample(textureSampler, in.tex_coord);
|
uint4 rgba = image.sample(textureSampler, in.tex_coord);
|
||||||
return float4(rgba) / 255.0f;
|
|
||||||
|
// Convert to float4 and premultiply the alpha. We should also probably
|
||||||
|
// premultiply the alpha in the texture.
|
||||||
|
float4 result = float4(rgba) / 255.0f;
|
||||||
|
result.rgb *= result.a;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
|
@ -7,5 +7,6 @@ layout(location = 0) out vec4 out_FragColor;
|
|||||||
uniform sampler2D image;
|
uniform sampler2D image;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
out_FragColor = texture(image, tex_coord);
|
vec4 color = texture(image, tex_coord);
|
||||||
|
out_FragColor = vec4(color.rgb * color.a, color.a);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user