mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 15:45: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);
|
||||
}
|
||||
|
||||
void TextComponent::setSaturation(float saturation)
|
||||
{
|
||||
mSaturation = saturation;
|
||||
if (mTextCache)
|
||||
mTextCache->setSaturation(saturation);
|
||||
}
|
||||
|
||||
void TextComponent::setDimming(float dimming)
|
||||
{
|
||||
mDimming = dimming;
|
||||
|
|
|
@ -62,6 +62,7 @@ public:
|
|||
float const getColorOpacity() const override { return mColorOpacity; }
|
||||
|
||||
void setOpacity(float opacity) override;
|
||||
void setSaturation(float saturation) override;
|
||||
void setDimming(float dimming) override;
|
||||
|
||||
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)
|
||||
{
|
||||
for (auto it = vertexLists.begin(); it != vertexLists.end(); ++it) {
|
||||
|
|
|
@ -238,6 +238,7 @@ public:
|
|||
|
||||
void setColor(unsigned int color);
|
||||
void setOpacity(float opacity);
|
||||
void setSaturation(float saturation);
|
||||
void setDimming(float dimming);
|
||||
|
||||
friend Font;
|
||||
|
|
|
@ -79,8 +79,8 @@ void main()
|
|||
sampledColor.rgb *= sampledColor.a;
|
||||
}
|
||||
|
||||
// Saturation.
|
||||
if (saturation != 1.0) {
|
||||
// Saturation, except for font textures.
|
||||
if (saturation != 1.0 && 0x0u == (shaderFlags & 0x2u)) {
|
||||
vec3 grayscale;
|
||||
// Premultiplied textures are all in BGRA format.
|
||||
if (0x0u != (shaderFlags & 0x01u))
|
||||
|
@ -105,6 +105,13 @@ void main()
|
|||
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
|
||||
// graphics drivers.
|
||||
if (0x0u != (shaderFlags & 0x4u))
|
||||
|
|
Loading…
Reference in a new issue