diff --git a/src/renderer/shaders/cell.metal b/src/renderer/shaders/cell.metal index 1ce7e74a4..5609305b2 100644 --- a/src/renderer/shaders/cell.metal +++ b/src/renderer/shaders/cell.metal @@ -328,7 +328,12 @@ fragment float4 image_fragment( // BGRA8Unorm. So we need to convert it. We should really be converting // our texture to BGRA8Unorm. 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; } //------------------------------------------------------------------- diff --git a/src/renderer/shaders/image.f.glsl b/src/renderer/shaders/image.f.glsl index c9623b6f9..e8c00b271 100644 --- a/src/renderer/shaders/image.f.glsl +++ b/src/renderer/shaders/image.f.glsl @@ -7,5 +7,6 @@ layout(location = 0) out vec4 out_FragColor; uniform sampler2D image; void main() { - out_FragColor = texture(image, tex_coord); + vec4 color = texture(image, tex_coord); + out_FragColor = vec4(color.rgb * color.a, color.a); }