diff --git a/res/border.fs.glsl b/res/border.fs.glsl index 272e7370e8..db6b371e70 100644 --- a/res/border.fs.glsl +++ b/res/border.fs.glsl @@ -32,6 +32,6 @@ void main(void) ceil(position.x), ceil(position.y)); float value = (Value(pixelBounds.xy) + Value(pixelBounds.zy) + Value(pixelBounds.xw) + Value(pixelBounds.zw)) / 4.0; - SetFragColor(mix(vec4(1.0) - vColor, vColor, value)); + SetFragColor(vec4(vColor.rgb, mix(1.0 - vColor.a, vColor.a, value))); } diff --git a/src/device.rs b/src/device.rs index 7dd6ee4271..ab9f8fbb80 100644 --- a/src/device.rs +++ b/src/device.rs @@ -593,6 +593,14 @@ impl Device { } } + pub fn texture_has_alpha(&self, texture_id: TextureId) -> bool { + if let Some(texture) = self.textures.get(&texture_id) { + texture.format == ImageFormat::RGBA8 + } else { + true + } + } + pub fn update_raw_texture(&mut self, texture_id: TextureId, x0: u32, diff --git a/src/renderer.rs b/src/renderer.rs index 29f25070cc..f08268dc5c 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -827,11 +827,16 @@ impl Renderer { color_texture_id: TextureId, program_id: ProgramId, blur_direction: Option) { - gl::disable(gl::BLEND); gl::disable(gl::DEPTH_TEST); gl::disable(gl::SCISSOR_TEST); let (texture_width, texture_height) = self.device.get_texture_dimensions(update_id); + if !self.device.texture_has_alpha(update_id) { + gl::enable(gl::BLEND); + gl::blend_func(gl::SRC_ALPHA, gl::ZERO); + } else { + gl::disable(gl::BLEND); + } let projection = Matrix4::ortho(0.0, texture_width as f32,