mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
Added support for changing the saturation for font textures.
This commit is contained in:
parent
885a225525
commit
d9f38dab3e
|
@ -115,6 +115,13 @@ void TextComponent::setOpacity(float opacity)
|
||||||
mTextCache->setOpacity(mThemeOpacity);
|
mTextCache->setOpacity(mThemeOpacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextComponent::setSaturation(float saturation)
|
||||||
|
{
|
||||||
|
mSaturation = saturation;
|
||||||
|
if (mTextCache)
|
||||||
|
mTextCache->setSaturation(saturation);
|
||||||
|
}
|
||||||
|
|
||||||
void TextComponent::setDimming(float dimming)
|
void TextComponent::setDimming(float dimming)
|
||||||
{
|
{
|
||||||
mDimming = dimming;
|
mDimming = dimming;
|
||||||
|
|
|
@ -62,6 +62,7 @@ public:
|
||||||
float const getColorOpacity() const override { return mColorOpacity; }
|
float const getColorOpacity() const override { return mColorOpacity; }
|
||||||
|
|
||||||
void setOpacity(float opacity) override;
|
void setOpacity(float opacity) override;
|
||||||
|
void setSaturation(float saturation) override;
|
||||||
void setDimming(float dimming) override;
|
void setDimming(float dimming) override;
|
||||||
|
|
||||||
void setSelectable(bool status) { mSelectable = status; }
|
void setSelectable(bool status) { mSelectable = status; }
|
||||||
|
|
|
@ -826,6 +826,14 @@ void TextCache::setOpacity(float opacity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextCache::setSaturation(float saturation)
|
||||||
|
{
|
||||||
|
for (auto it = vertexLists.begin(); it != vertexLists.end(); ++it) {
|
||||||
|
for (auto it2 = it->verts.begin(); it2 != it->verts.end(); ++it2)
|
||||||
|
it2->saturation = saturation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TextCache::setDimming(float dimming)
|
void TextCache::setDimming(float dimming)
|
||||||
{
|
{
|
||||||
for (auto it = vertexLists.begin(); it != vertexLists.end(); ++it) {
|
for (auto it = vertexLists.begin(); it != vertexLists.end(); ++it) {
|
||||||
|
|
|
@ -238,6 +238,7 @@ public:
|
||||||
|
|
||||||
void setColor(unsigned int color);
|
void setColor(unsigned int color);
|
||||||
void setOpacity(float opacity);
|
void setOpacity(float opacity);
|
||||||
|
void setSaturation(float saturation);
|
||||||
void setDimming(float dimming);
|
void setDimming(float dimming);
|
||||||
|
|
||||||
friend Font;
|
friend Font;
|
||||||
|
|
|
@ -79,8 +79,8 @@ void main()
|
||||||
sampledColor.rgb *= sampledColor.a;
|
sampledColor.rgb *= sampledColor.a;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Saturation.
|
// Saturation, except for font textures.
|
||||||
if (saturation != 1.0) {
|
if (saturation != 1.0 && 0x0u == (shaderFlags & 0x2u)) {
|
||||||
vec3 grayscale;
|
vec3 grayscale;
|
||||||
// Premultiplied textures are all in BGRA format.
|
// Premultiplied textures are all in BGRA format.
|
||||||
if (0x0u != (shaderFlags & 0x01u))
|
if (0x0u != (shaderFlags & 0x01u))
|
||||||
|
@ -105,6 +105,13 @@ void main()
|
||||||
sampledColor *= color;
|
sampledColor *= color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Saturation for font textures.
|
||||||
|
if (saturation != 1.0 && 0x0u != (shaderFlags & 0x2u)) {
|
||||||
|
vec3 grayscale = vec3(dot(sampledColor.rgb, vec3(0.299, 0.587, 0.114)));
|
||||||
|
vec3 blendedColor = mix(grayscale, sampledColor.rgb, saturation);
|
||||||
|
sampledColor = vec4(blendedColor, sampledColor.a);
|
||||||
|
}
|
||||||
|
|
||||||
// When post-processing we drop the alpha channel to avoid strange issues with some
|
// When post-processing we drop the alpha channel to avoid strange issues with some
|
||||||
// graphics drivers.
|
// graphics drivers.
|
||||||
if (0x0u != (shaderFlags & 0x4u))
|
if (0x0u != (shaderFlags & 0x4u))
|
||||||
|
|
Loading…
Reference in a new issue