From ef671580c3c2e917caf281fe9f0a7efae05fe90d Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sun, 30 Oct 2022 16:31:43 +0100 Subject: [PATCH] Fixed an issue where grayscale conversion was not done correctly for BGRA textures. --- resources/shaders/glsl/core.glsl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/resources/shaders/glsl/core.glsl b/resources/shaders/glsl/core.glsl index bcccf8eef..22fb53cfc 100644 --- a/resources/shaders/glsl/core.glsl +++ b/resources/shaders/glsl/core.glsl @@ -99,7 +99,12 @@ void main() // Saturation. if (saturation != 1.0) { - vec3 grayscale = vec3(dot(sampledColor.rgb, vec3(0.34, 0.55, 0.11))); + vec3 grayscale; + // Premultiplied textures are all in BGRA format. + if (0x0u != (shaderFlags & 0x01u)) + grayscale = vec3(dot(sampledColor.bgr, vec3(0.34, 0.55, 0.11))); + else + grayscale = vec3(dot(sampledColor.rgb, vec3(0.34, 0.55, 0.11))); vec3 blendedColor = mix(grayscale, sampledColor.rgb, saturation); sampledColor = vec4(blendedColor, sampledColor.a); }