mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-02-16 20:15:38 +00:00
Fixed an issue where lowered saturation could not be combined with color shifts.
This commit is contained in:
parent
19111a9c24
commit
0ad339d4c4
|
@ -4,7 +4,7 @@
|
||||||
// core.glsl
|
// core.glsl
|
||||||
//
|
//
|
||||||
// Core shader functionality:
|
// Core shader functionality:
|
||||||
// Clipping, opacity, saturation, dimming and reflections falloff.
|
// Clipping, saturation, opacity, dimming and reflections falloff.
|
||||||
//
|
//
|
||||||
|
|
||||||
// Vertex section of code:
|
// Vertex section of code:
|
||||||
|
@ -39,8 +39,8 @@ in vec2 texCoord;
|
||||||
in vec4 color;
|
in vec4 color;
|
||||||
|
|
||||||
uniform vec4 clipRegion;
|
uniform vec4 clipRegion;
|
||||||
uniform float opacity;
|
|
||||||
uniform float saturation;
|
uniform float saturation;
|
||||||
|
uniform float opacity;
|
||||||
uniform float dimming;
|
uniform float dimming;
|
||||||
uniform float reflectionsFalloff;
|
uniform float reflectionsFalloff;
|
||||||
uniform uint shaderFlags;
|
uniform uint shaderFlags;
|
||||||
|
@ -70,6 +70,18 @@ void main()
|
||||||
|
|
||||||
vec4 sampledColor = texture(textureSampler, texCoord);
|
vec4 sampledColor = texture(textureSampler, texCoord);
|
||||||
|
|
||||||
|
// Saturation.
|
||||||
|
if (saturation != 1.0) {
|
||||||
|
vec3 grayscale;
|
||||||
|
// Premultiplied textures are all in BGRA format.
|
||||||
|
if (0x0u != (shaderFlags & 0x01u))
|
||||||
|
grayscale = vec3(dot(sampledColor.bgr, vec3(0.0721, 0.7154, 0.2125)));
|
||||||
|
else
|
||||||
|
grayscale = vec3(dot(sampledColor.rgb, vec3(0.2125, 0.7154, 0.0721)));
|
||||||
|
vec3 blendedColor = mix(grayscale, sampledColor.rgb, saturation);
|
||||||
|
sampledColor = vec4(blendedColor, sampledColor.a);
|
||||||
|
}
|
||||||
|
|
||||||
// For fonts the alpha information is stored in the red channel.
|
// For fonts the alpha information is stored in the red channel.
|
||||||
if (0x0u != (shaderFlags & 0x2u))
|
if (0x0u != (shaderFlags & 0x2u))
|
||||||
sampledColor = vec4(1.0, 1.0, 1.0, sampledColor.r);
|
sampledColor = vec4(1.0, 1.0, 1.0, sampledColor.r);
|
||||||
|
@ -97,18 +109,6 @@ void main()
|
||||||
sampledColor *= opacity;
|
sampledColor *= opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Saturation.
|
|
||||||
if (saturation != 1.0) {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dimming.
|
// Dimming.
|
||||||
if (dimming != 1.0) {
|
if (dimming != 1.0) {
|
||||||
vec4 dimColor = vec4(dimming, dimming, dimming, 1.0);
|
vec4 dimColor = vec4(dimming, dimming, dimming, 1.0);
|
||||||
|
|
Loading…
Reference in a new issue