From 1517826b2342a48e79394d74ee7f740362b438c9 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Mon, 12 Dec 2022 20:24:16 +0100 Subject: [PATCH] Fixed an issue where lowered saturation would not work correctly when combined with scanline rendering. --- resources/shaders/glsl/scanlines.glsl | 30 ++++++++------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/resources/shaders/glsl/scanlines.glsl b/resources/shaders/glsl/scanlines.glsl index 960a0065e..9e9bc62f0 100644 --- a/resources/shaders/glsl/scanlines.glsl +++ b/resources/shaders/glsl/scanlines.glsl @@ -101,13 +101,6 @@ void main() float h_weight_00 = dx / SPOT_WIDTH; WEIGHT(h_weight_00); - // Saturation. - if (saturation != 1.0) { - vec3 grayscale = vec3(dot(color.rgb, vec3(0.34, 0.55, 0.11))); - vec3 blendedColor = mix(grayscale, color.rgb, saturation); - color = vec4(blendedColor, color.a); - } - color *= vec4(h_weight_00, h_weight_00, h_weight_00, h_weight_00); // Get closest horizontal neighbour to blend. @@ -122,13 +115,6 @@ void main() } vec4 colorNB = TEX2D(texture_coords + coords01); - // Saturation. - if (saturation != 1.0) { - vec3 grayscale = vec3(dot(colorNB.rgb, vec3(0.34, 0.55, 0.11))); - vec3 blendedColor = mix(grayscale, colorNB.rgb, saturation); - colorNB = vec4(blendedColor, colorNB.a); - } - float h_weight_01 = dx / SPOT_WIDTH; WEIGHT(h_weight_01); @@ -152,13 +138,6 @@ void main() } colorNB = TEX2D(texture_coords + coords10); - // Saturation. - if (saturation != 1.0) { - vec3 grayscale = vec3(dot(colorNB.rgb, vec3(0.34, 0.55, 0.11))); - vec3 blendedColor = mix(grayscale, colorNB.rgb, saturation); - colorNB = vec4(blendedColor, colorNB.a); - } - float v_weight_10 = dy / SPOT_HEIGHT; WEIGHT(v_weight_10); @@ -170,6 +149,15 @@ void main() color *= vec4(COLOR_BOOST); vec4 colorTemp = clamp(GAMMA_OUT(color), 0.0, 1.0); + + // Saturation. + if (saturation != 1.0) { + vec3 grayscale; + grayscale = vec3(dot(colorTemp.bgr, vec3(0.0721, 0.7154, 0.2125))); + vec3 blendedColor = mix(grayscale, colorTemp.rgb, saturation); + colorTemp = vec4(blendedColor, colorTemp.a); + } + FragColor = vec4(colorTemp.rgb, colorTemp.a * opacity); } #endif