mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
Added theme support for defining relative brightness for images, videos and animations.
This commit is contained in:
parent
cfdfe3e6e0
commit
f4d4abb33b
|
@ -29,6 +29,7 @@ GuiComponent::GuiComponent()
|
||||||
, mOrigin {0.0f, 0.0f}
|
, mOrigin {0.0f, 0.0f}
|
||||||
, mRotationOrigin {0.5f, 0.5f}
|
, mRotationOrigin {0.5f, 0.5f}
|
||||||
, mSize {0.0f, 0.0f}
|
, mSize {0.0f, 0.0f}
|
||||||
|
, mBrightness {0.0f}
|
||||||
, mOpacity {1.0f}
|
, mOpacity {1.0f}
|
||||||
, mSaturation {1.0f}
|
, mSaturation {1.0f}
|
||||||
, mDimming {1.0f}
|
, mDimming {1.0f}
|
||||||
|
@ -183,6 +184,16 @@ const int GuiComponent::getChildIndex() const
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GuiComponent::setBrightness(float brightness)
|
||||||
|
{
|
||||||
|
if (mBrightness == brightness)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mBrightness = brightness;
|
||||||
|
for (auto it = mChildren.cbegin(); it != mChildren.cend(); ++it)
|
||||||
|
(*it)->setBrightness(brightness);
|
||||||
|
}
|
||||||
|
|
||||||
void GuiComponent::setOpacity(float opacity)
|
void GuiComponent::setOpacity(float opacity)
|
||||||
{
|
{
|
||||||
if (mOpacity == opacity)
|
if (mOpacity == opacity)
|
||||||
|
@ -371,6 +382,9 @@ void GuiComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
else
|
else
|
||||||
setZIndex(getDefaultZIndex());
|
setZIndex(getDefaultZIndex());
|
||||||
|
|
||||||
|
if (properties & ThemeFlags::BRIGHTNESS && elem->has("brightness"))
|
||||||
|
mBrightness = glm::clamp(elem->get<float>("brightness"), -2.0f, 2.0f);
|
||||||
|
|
||||||
if (properties & ThemeFlags::OPACITY && elem->has("opacity"))
|
if (properties & ThemeFlags::OPACITY && elem->has("opacity"))
|
||||||
mThemeOpacity = glm::clamp(elem->get<float>("opacity"), 0.0f, 1.0f);
|
mThemeOpacity = glm::clamp(elem->get<float>("opacity"), 0.0f, 1.0f);
|
||||||
|
|
||||||
|
|
|
@ -222,8 +222,10 @@ public:
|
||||||
virtual void stopGamelistFadeAnimations() {}
|
virtual void stopGamelistFadeAnimations() {}
|
||||||
virtual bool isListScrolling() { return false; }
|
virtual bool isListScrolling() { return false; }
|
||||||
virtual void stopListScrolling() {}
|
virtual void stopListScrolling() {}
|
||||||
|
virtual const float getBrightness() const { return mBrightness; }
|
||||||
virtual const float getOpacity() const { return mOpacity; }
|
virtual const float getOpacity() const { return mOpacity; }
|
||||||
virtual const float getColorOpacity() const { return 1.0f; }
|
virtual const float getColorOpacity() const { return 1.0f; }
|
||||||
|
virtual void setBrightness(float brightness);
|
||||||
virtual void setOpacity(float opacity);
|
virtual void setOpacity(float opacity);
|
||||||
virtual float getSaturation() const { return static_cast<float>(mColor); }
|
virtual float getSaturation() const { return static_cast<float>(mColor); }
|
||||||
virtual void setSaturation(float saturation) { mSaturation = saturation; }
|
virtual void setSaturation(float saturation) { mSaturation = saturation; }
|
||||||
|
@ -336,6 +338,7 @@ protected:
|
||||||
glm::vec2 mRotationOrigin;
|
glm::vec2 mRotationOrigin;
|
||||||
glm::vec2 mSize;
|
glm::vec2 mSize;
|
||||||
|
|
||||||
|
float mBrightness;
|
||||||
float mOpacity;
|
float mOpacity;
|
||||||
float mSaturation;
|
float mSaturation;
|
||||||
float mDimming;
|
float mDimming;
|
||||||
|
|
|
@ -133,6 +133,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
||||||
{"imageColor", COLOR},
|
{"imageColor", COLOR},
|
||||||
{"imageColorEnd", COLOR},
|
{"imageColorEnd", COLOR},
|
||||||
{"imageGradientType", STRING},
|
{"imageGradientType", STRING},
|
||||||
|
{"imageBrightness", FLOAT},
|
||||||
{"imageSaturation", FLOAT},
|
{"imageSaturation", FLOAT},
|
||||||
{"itemTransitions", STRING},
|
{"itemTransitions", STRING},
|
||||||
{"itemHorizontalAlignment", STRING},
|
{"itemHorizontalAlignment", STRING},
|
||||||
|
@ -185,6 +186,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
||||||
{"imageColor", COLOR},
|
{"imageColor", COLOR},
|
||||||
{"imageColorEnd", COLOR},
|
{"imageColorEnd", COLOR},
|
||||||
{"imageGradientType", STRING},
|
{"imageGradientType", STRING},
|
||||||
|
{"imageBrightness", FLOAT},
|
||||||
{"imageSaturation", FLOAT},
|
{"imageSaturation", FLOAT},
|
||||||
{"backgroundImage", PATH},
|
{"backgroundImage", PATH},
|
||||||
{"backgroundRelativeScale", FLOAT},
|
{"backgroundRelativeScale", FLOAT},
|
||||||
|
@ -260,6 +262,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
||||||
{"colorEnd", COLOR},
|
{"colorEnd", COLOR},
|
||||||
{"gradientType", STRING},
|
{"gradientType", STRING},
|
||||||
{"scrollFadeIn", BOOLEAN},
|
{"scrollFadeIn", BOOLEAN},
|
||||||
|
{"brightness", FLOAT},
|
||||||
{"opacity", FLOAT},
|
{"opacity", FLOAT},
|
||||||
{"saturation", FLOAT},
|
{"saturation", FLOAT},
|
||||||
{"visible", BOOLEAN},
|
{"visible", BOOLEAN},
|
||||||
|
@ -286,6 +289,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
||||||
{"delay", FLOAT},
|
{"delay", FLOAT},
|
||||||
{"fadeInTime", FLOAT},
|
{"fadeInTime", FLOAT},
|
||||||
{"scrollFadeIn", BOOLEAN},
|
{"scrollFadeIn", BOOLEAN},
|
||||||
|
{"brightness", FLOAT},
|
||||||
{"opacity", FLOAT},
|
{"opacity", FLOAT},
|
||||||
{"saturation", FLOAT},
|
{"saturation", FLOAT},
|
||||||
{"visible", BOOLEAN},
|
{"visible", BOOLEAN},
|
||||||
|
@ -304,6 +308,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
||||||
{"direction", STRING},
|
{"direction", STRING},
|
||||||
{"keepAspectRatio", BOOLEAN},
|
{"keepAspectRatio", BOOLEAN},
|
||||||
{"interpolation", STRING},
|
{"interpolation", STRING},
|
||||||
|
{"brightness", FLOAT},
|
||||||
{"opacity", FLOAT},
|
{"opacity", FLOAT},
|
||||||
{"saturation", FLOAT},
|
{"saturation", FLOAT},
|
||||||
{"visible", BOOLEAN},
|
{"visible", BOOLEAN},
|
||||||
|
|
|
@ -57,9 +57,10 @@ namespace ThemeFlags
|
||||||
DELAY = 0x00002000,
|
DELAY = 0x00002000,
|
||||||
Z_INDEX = 0x00004000,
|
Z_INDEX = 0x00004000,
|
||||||
ROTATION = 0x00008000,
|
ROTATION = 0x00008000,
|
||||||
OPACITY = 0x00010000,
|
BRIGHTNESS = 0x00010000,
|
||||||
SATURATION = 0x00020000,
|
OPACITY = 0x00020000,
|
||||||
VISIBLE = 0x00040000,
|
SATURATION = 0x00040000,
|
||||||
|
VISIBLE = 0x00080000,
|
||||||
ALL = 0xFFFFFFFF
|
ALL = 0xFFFFFFFF
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
|
@ -495,6 +495,7 @@ void GIFAnimComponent::render(const glm::mat4& parentTrans)
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < 4; ++i)
|
||||||
vertices[i].position = glm::round(vertices[i].position);
|
vertices[i].position = glm::round(vertices[i].position);
|
||||||
|
|
||||||
|
vertices->brightness = mBrightness;
|
||||||
vertices->saturation = mSaturation * mThemeSaturation;
|
vertices->saturation = mSaturation * mThemeSaturation;
|
||||||
vertices->opacity = mOpacity * mThemeOpacity;
|
vertices->opacity = mOpacity * mThemeOpacity;
|
||||||
vertices->dimming = mDimming;
|
vertices->dimming = mDimming;
|
||||||
|
|
|
@ -394,8 +394,9 @@ void ImageComponent::render(const glm::mat4& parentTrans)
|
||||||
else
|
else
|
||||||
fadeIn(mTexture->bind());
|
fadeIn(mTexture->bind());
|
||||||
|
|
||||||
mVertices->saturation = mSaturation * mThemeSaturation;
|
mVertices->brightness = mBrightness;
|
||||||
mVertices->opacity = mThemeOpacity;
|
mVertices->opacity = mThemeOpacity;
|
||||||
|
mVertices->saturation = mSaturation * mThemeSaturation;
|
||||||
mVertices->dimming = mDimming;
|
mVertices->dimming = mDimming;
|
||||||
mVertices->reflectionsFalloff = mReflectionsFalloff;
|
mVertices->reflectionsFalloff = mReflectionsFalloff;
|
||||||
|
|
||||||
|
|
|
@ -484,6 +484,7 @@ void LottieAnimComponent::render(const glm::mat4& parentTrans)
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < 4; ++i)
|
||||||
vertices[i].position = glm::round(vertices[i].position);
|
vertices[i].position = glm::round(vertices[i].position);
|
||||||
|
|
||||||
|
vertices->brightness = mBrightness;
|
||||||
vertices->saturation = mSaturation * mThemeSaturation;
|
vertices->saturation = mSaturation * mThemeSaturation;
|
||||||
vertices->opacity = mOpacity * mThemeOpacity;
|
vertices->opacity = mOpacity * mThemeOpacity;
|
||||||
vertices->dimming = mDimming;
|
vertices->dimming = mDimming;
|
||||||
|
|
|
@ -381,6 +381,8 @@ void VideoComponent::renderSnapshot(const glm::mat4& parentTrans)
|
||||||
if (mStaticImagePath != "") {
|
if (mStaticImagePath != "") {
|
||||||
mStaticImage.setOpacity(mOpacity * mThemeOpacity);
|
mStaticImage.setOpacity(mOpacity * mThemeOpacity);
|
||||||
mStaticImage.setSaturation(mSaturation * mThemeSaturation);
|
mStaticImage.setSaturation(mSaturation * mThemeSaturation);
|
||||||
|
if (mBrightness != 0.0f)
|
||||||
|
mStaticImage.setBrightness(mBrightness);
|
||||||
if (mColorShift != 0xFFFFFFFF)
|
if (mColorShift != 0xFFFFFFFF)
|
||||||
mStaticImage.setColorShift(mColorShift);
|
mStaticImage.setColorShift(mColorShift);
|
||||||
if (mColorShift != mColorShiftEnd)
|
if (mColorShift != mColorShiftEnd)
|
||||||
|
|
|
@ -176,6 +176,7 @@ void VideoFFmpegComponent::render(const glm::mat4& parentTrans)
|
||||||
if (mFadeIn < 1.0f || mThemeOpacity < 1.0f)
|
if (mFadeIn < 1.0f || mThemeOpacity < 1.0f)
|
||||||
vertices->opacity = mFadeIn * mThemeOpacity;
|
vertices->opacity = mFadeIn * mThemeOpacity;
|
||||||
|
|
||||||
|
vertices->brightness = mBrightness;
|
||||||
vertices->saturation = mSaturation * mThemeSaturation;
|
vertices->saturation = mSaturation * mThemeSaturation;
|
||||||
vertices->dimming = mDimming;
|
vertices->dimming = mDimming;
|
||||||
|
|
||||||
|
|
|
@ -147,6 +147,7 @@ private:
|
||||||
unsigned int mImageColorShift;
|
unsigned int mImageColorShift;
|
||||||
unsigned int mImageColorShiftEnd;
|
unsigned int mImageColorShiftEnd;
|
||||||
bool mImageColorGradientHorizontal;
|
bool mImageColorGradientHorizontal;
|
||||||
|
float mImageBrightness;
|
||||||
float mImageSaturation;
|
float mImageSaturation;
|
||||||
bool mInstantItemTransitions;
|
bool mInstantItemTransitions;
|
||||||
Alignment mItemHorizontalAlignment;
|
Alignment mItemHorizontalAlignment;
|
||||||
|
@ -200,6 +201,7 @@ CarouselComponent<T>::CarouselComponent()
|
||||||
, mImageColorShift {0xFFFFFFFF}
|
, mImageColorShift {0xFFFFFFFF}
|
||||||
, mImageColorShiftEnd {0xFFFFFFFF}
|
, mImageColorShiftEnd {0xFFFFFFFF}
|
||||||
, mImageColorGradientHorizontal {true}
|
, mImageColorGradientHorizontal {true}
|
||||||
|
, mImageBrightness {0.0f}
|
||||||
, mImageSaturation {1.0f}
|
, mImageSaturation {1.0f}
|
||||||
, mInstantItemTransitions {false}
|
, mInstantItemTransitions {false}
|
||||||
, mItemHorizontalAlignment {ALIGN_CENTER}
|
, mItemHorizontalAlignment {ALIGN_CENTER}
|
||||||
|
@ -265,6 +267,8 @@ void CarouselComponent<T>::addEntry(Entry& entry, const std::shared_ptr<ThemeDat
|
||||||
item->setMaxSize(glm::round(mItemSize * (mItemScale >= 1.0f ? mItemScale : 1.0f)));
|
item->setMaxSize(glm::round(mItemSize * (mItemScale >= 1.0f ? mItemScale : 1.0f)));
|
||||||
item->setImage(entry.data.imagePath);
|
item->setImage(entry.data.imagePath);
|
||||||
item->applyTheme(theme, "system", "", ThemeFlags::ALL);
|
item->applyTheme(theme, "system", "", ThemeFlags::ALL);
|
||||||
|
if (mImageBrightness != 0.0)
|
||||||
|
item->setBrightness(mImageBrightness);
|
||||||
if (mImageSaturation != 1.0)
|
if (mImageSaturation != 1.0)
|
||||||
item->setSaturation(mImageSaturation);
|
item->setSaturation(mImageSaturation);
|
||||||
if (mImageColorShift != 0xFFFFFFFF)
|
if (mImageColorShift != 0xFFFFFFFF)
|
||||||
|
@ -285,6 +289,8 @@ void CarouselComponent<T>::addEntry(Entry& entry, const std::shared_ptr<ThemeDat
|
||||||
glm::round(mItemSize * (mItemScale >= 1.0f ? mItemScale : 1.0f)));
|
glm::round(mItemSize * (mItemScale >= 1.0f ? mItemScale : 1.0f)));
|
||||||
defaultImage->setImage(entry.data.defaultImagePath);
|
defaultImage->setImage(entry.data.defaultImagePath);
|
||||||
defaultImage->applyTheme(theme, "system", "", ThemeFlags::ALL);
|
defaultImage->applyTheme(theme, "system", "", ThemeFlags::ALL);
|
||||||
|
if (mImageBrightness != 0.0)
|
||||||
|
defaultImage->setBrightness(mImageBrightness);
|
||||||
if (mImageSaturation != 1.0)
|
if (mImageSaturation != 1.0)
|
||||||
defaultImage->setSaturation(mImageSaturation);
|
defaultImage->setSaturation(mImageSaturation);
|
||||||
if (mImageColorShift != 0xFFFFFFFF)
|
if (mImageColorShift != 0xFFFFFFFF)
|
||||||
|
@ -354,6 +360,8 @@ void CarouselComponent<T>::updateEntry(Entry& entry, const std::shared_ptr<Theme
|
||||||
item->setMaxSize(glm::round(mItemSize * (mItemScale >= 1.0f ? mItemScale : 1.0f)));
|
item->setMaxSize(glm::round(mItemSize * (mItemScale >= 1.0f ? mItemScale : 1.0f)));
|
||||||
item->setImage(entry.data.imagePath);
|
item->setImage(entry.data.imagePath);
|
||||||
item->applyTheme(theme, "system", "", ThemeFlags::ALL);
|
item->applyTheme(theme, "system", "", ThemeFlags::ALL);
|
||||||
|
if (mImageBrightness != 0.0)
|
||||||
|
item->setBrightness(mImageBrightness);
|
||||||
if (mImageSaturation != 1.0)
|
if (mImageSaturation != 1.0)
|
||||||
item->setSaturation(mImageSaturation);
|
item->setSaturation(mImageSaturation);
|
||||||
if (mImageColorShift != 0xFFFFFFFF)
|
if (mImageColorShift != 0xFFFFFFFF)
|
||||||
|
@ -1124,6 +1132,9 @@ void CarouselComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (elem->has("imageBrightness"))
|
||||||
|
mImageBrightness = glm::clamp(elem->get<float>("imageBrightness"), -2.0f, 2.0f);
|
||||||
|
|
||||||
if (elem->has("imageSaturation"))
|
if (elem->has("imageSaturation"))
|
||||||
mImageSaturation = glm::clamp(elem->get<float>("imageSaturation"), 0.0f, 1.0f);
|
mImageSaturation = glm::clamp(elem->get<float>("imageSaturation"), 0.0f, 1.0f);
|
||||||
|
|
||||||
|
|
|
@ -148,6 +148,7 @@ private:
|
||||||
unsigned int mImageColor;
|
unsigned int mImageColor;
|
||||||
unsigned int mImageColorEnd;
|
unsigned int mImageColorEnd;
|
||||||
bool mImageColorGradientHorizontal;
|
bool mImageColorGradientHorizontal;
|
||||||
|
float mImageBrightness;
|
||||||
float mImageSaturation;
|
float mImageSaturation;
|
||||||
std::unique_ptr<ImageComponent> mBackgroundImage;
|
std::unique_ptr<ImageComponent> mBackgroundImage;
|
||||||
std::string mBackgroundImagePath;
|
std::string mBackgroundImagePath;
|
||||||
|
@ -205,6 +206,7 @@ GridComponent<T>::GridComponent()
|
||||||
, mImageColor {0xFFFFFFFF}
|
, mImageColor {0xFFFFFFFF}
|
||||||
, mImageColorEnd {0xFFFFFFFF}
|
, mImageColorEnd {0xFFFFFFFF}
|
||||||
, mImageColorGradientHorizontal {true}
|
, mImageColorGradientHorizontal {true}
|
||||||
|
, mImageBrightness {0.0f}
|
||||||
, mImageSaturation {1.0f}
|
, mImageSaturation {1.0f}
|
||||||
, mBackgroundRelativeScale {1.0f}
|
, mBackgroundRelativeScale {1.0f}
|
||||||
, mBackgroundColor {0xFFFFFFFF}
|
, mBackgroundColor {0xFFFFFFFF}
|
||||||
|
@ -258,6 +260,8 @@ void GridComponent<T>::addEntry(Entry& entry, const std::shared_ptr<ThemeData>&
|
||||||
item->setCroppedSize(mItemSize * mImageRelativeScale);
|
item->setCroppedSize(mItemSize * mImageRelativeScale);
|
||||||
item->setImage(entry.data.imagePath);
|
item->setImage(entry.data.imagePath);
|
||||||
item->applyTheme(theme, "system", "", ThemeFlags::ALL);
|
item->applyTheme(theme, "system", "", ThemeFlags::ALL);
|
||||||
|
if (mImageBrightness != 0.0)
|
||||||
|
item->setBrightness(mImageBrightness);
|
||||||
if (mImageSaturation != 1.0)
|
if (mImageSaturation != 1.0)
|
||||||
item->setSaturation(mImageSaturation);
|
item->setSaturation(mImageSaturation);
|
||||||
if (mImageColor != 0xFFFFFFFF)
|
if (mImageColor != 0xFFFFFFFF)
|
||||||
|
@ -284,6 +288,8 @@ void GridComponent<T>::addEntry(Entry& entry, const std::shared_ptr<ThemeData>&
|
||||||
defaultImage->setCroppedSize(mItemSize * mImageRelativeScale);
|
defaultImage->setCroppedSize(mItemSize * mImageRelativeScale);
|
||||||
defaultImage->setImage(entry.data.defaultImagePath);
|
defaultImage->setImage(entry.data.defaultImagePath);
|
||||||
defaultImage->applyTheme(theme, "system", "", ThemeFlags::ALL);
|
defaultImage->applyTheme(theme, "system", "", ThemeFlags::ALL);
|
||||||
|
if (mImageBrightness != 0.0)
|
||||||
|
defaultImage->setBrightness(mImageBrightness);
|
||||||
if (mImageSaturation != 1.0)
|
if (mImageSaturation != 1.0)
|
||||||
defaultImage->setSaturation(mImageSaturation);
|
defaultImage->setSaturation(mImageSaturation);
|
||||||
if (mImageColor != 0xFFFFFFFF)
|
if (mImageColor != 0xFFFFFFFF)
|
||||||
|
@ -335,6 +341,8 @@ void GridComponent<T>::updateEntry(Entry& entry, const std::shared_ptr<ThemeData
|
||||||
item->setCroppedSize(mItemSize * mImageRelativeScale);
|
item->setCroppedSize(mItemSize * mImageRelativeScale);
|
||||||
item->setImage(entry.data.imagePath);
|
item->setImage(entry.data.imagePath);
|
||||||
item->applyTheme(theme, "system", "", ThemeFlags::ALL);
|
item->applyTheme(theme, "system", "", ThemeFlags::ALL);
|
||||||
|
if (mImageBrightness != 0.0)
|
||||||
|
item->setBrightness(mImageBrightness);
|
||||||
if (mImageSaturation != 1.0)
|
if (mImageSaturation != 1.0)
|
||||||
item->setSaturation(mImageSaturation);
|
item->setSaturation(mImageSaturation);
|
||||||
if (mImageColor != 0xFFFFFFFF)
|
if (mImageColor != 0xFFFFFFFF)
|
||||||
|
@ -1027,6 +1035,9 @@ void GridComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (elem->has("imageBrightness"))
|
||||||
|
mImageBrightness = glm::clamp(elem->get<float>("imageBrightness"), -2.0f, 2.0f);
|
||||||
|
|
||||||
if (elem->has("imageSaturation"))
|
if (elem->has("imageSaturation"))
|
||||||
mImageSaturation = glm::clamp(elem->get<float>("imageSaturation"), 0.0f, 1.0f);
|
mImageSaturation = glm::clamp(elem->get<float>("imageSaturation"), 0.0f, 1.0f);
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ public:
|
||||||
glm::vec2 texcoord;
|
glm::vec2 texcoord;
|
||||||
unsigned int color;
|
unsigned int color;
|
||||||
glm::vec4 clipregion;
|
glm::vec4 clipregion;
|
||||||
|
float brightness;
|
||||||
float opacity;
|
float opacity;
|
||||||
float saturation;
|
float saturation;
|
||||||
float dimming;
|
float dimming;
|
||||||
|
@ -69,7 +70,8 @@ public:
|
||||||
unsigned int shaderFlags;
|
unsigned int shaderFlags;
|
||||||
|
|
||||||
Vertex()
|
Vertex()
|
||||||
: opacity {1.0f}
|
: brightness {0.0f}
|
||||||
|
, opacity {1.0f}
|
||||||
, saturation {1.0f}
|
, saturation {1.0f}
|
||||||
, dimming {1.0f}
|
, dimming {1.0f}
|
||||||
, reflectionsFalloff {0.0f}
|
, reflectionsFalloff {0.0f}
|
||||||
|
@ -86,6 +88,7 @@ public:
|
||||||
, texcoord(textureCoord)
|
, texcoord(textureCoord)
|
||||||
, color(color)
|
, color(color)
|
||||||
, clipregion(clipRegion)
|
, clipregion(clipRegion)
|
||||||
|
, brightness {0.0f}
|
||||||
, opacity {1.0f}
|
, opacity {1.0f}
|
||||||
, saturation {1.0f}
|
, saturation {1.0f}
|
||||||
, dimming {1.0f}
|
, dimming {1.0f}
|
||||||
|
|
|
@ -443,6 +443,7 @@ void RendererOpenGL::drawTriangleStrips(const Vertex* vertices,
|
||||||
GL_CHECK_ERROR(glBufferData(GL_ARRAY_BUFFER, sizeof(Vertex) * numVertices, vertices,
|
GL_CHECK_ERROR(glBufferData(GL_ARRAY_BUFFER, sizeof(Vertex) * numVertices, vertices,
|
||||||
GL_DYNAMIC_DRAW));
|
GL_DYNAMIC_DRAW));
|
||||||
mCoreShader->setClipRegion(vertices->clipregion);
|
mCoreShader->setClipRegion(vertices->clipregion);
|
||||||
|
mCoreShader->setBrightness(vertices->brightness);
|
||||||
mCoreShader->setOpacity(vertices->opacity);
|
mCoreShader->setOpacity(vertices->opacity);
|
||||||
mCoreShader->setSaturation(vertices->saturation);
|
mCoreShader->setSaturation(vertices->saturation);
|
||||||
mCoreShader->setDimming(vertices->dimming);
|
mCoreShader->setDimming(vertices->dimming);
|
||||||
|
@ -517,6 +518,7 @@ void RendererOpenGL::drawTriangleStrips(const Vertex* vertices,
|
||||||
GL_CHECK_ERROR(glBufferData(GL_ARRAY_BUFFER, sizeof(Vertex) * numVertices, vertices,
|
GL_CHECK_ERROR(glBufferData(GL_ARRAY_BUFFER, sizeof(Vertex) * numVertices, vertices,
|
||||||
GL_DYNAMIC_DRAW));
|
GL_DYNAMIC_DRAW));
|
||||||
mScanlinelShader->setOpacity(vertices->opacity);
|
mScanlinelShader->setOpacity(vertices->opacity);
|
||||||
|
mScanlinelShader->setBrightness(vertices->brightness);
|
||||||
mScanlinelShader->setSaturation(vertices->saturation);
|
mScanlinelShader->setSaturation(vertices->saturation);
|
||||||
mScanlinelShader->setTextureSize({shaderWidth, shaderHeight});
|
mScanlinelShader->setTextureSize({shaderWidth, shaderHeight});
|
||||||
GL_CHECK_ERROR(glDrawArrays(GL_TRIANGLE_STRIP, 0, numVertices));
|
GL_CHECK_ERROR(glDrawArrays(GL_TRIANGLE_STRIP, 0, numVertices));
|
||||||
|
|
|
@ -19,6 +19,7 @@ ShaderOpenGL::ShaderOpenGL()
|
||||||
, mShaderTextureCoord {0}
|
, mShaderTextureCoord {0}
|
||||||
, mShaderColor {0}
|
, mShaderColor {0}
|
||||||
, mShaderTextureSize {0}
|
, mShaderTextureSize {0}
|
||||||
|
, mShaderBrightness {0}
|
||||||
, mShaderOpacity {0}
|
, mShaderOpacity {0}
|
||||||
, mShaderSaturation {0}
|
, mShaderSaturation {0}
|
||||||
, mShaderDimming {0}
|
, mShaderDimming {0}
|
||||||
|
@ -122,6 +123,7 @@ void ShaderOpenGL::getVariableLocations(GLuint programID)
|
||||||
mShaderColor = glGetAttribLocation(mProgramID, "colorVertex");
|
mShaderColor = glGetAttribLocation(mProgramID, "colorVertex");
|
||||||
mShaderTextureSize = glGetUniformLocation(mProgramID, "textureSize");
|
mShaderTextureSize = glGetUniformLocation(mProgramID, "textureSize");
|
||||||
mShaderClipRegion = glGetUniformLocation(mProgramID, "clipRegion");
|
mShaderClipRegion = glGetUniformLocation(mProgramID, "clipRegion");
|
||||||
|
mShaderBrightness = glGetUniformLocation(mProgramID, "brightness");
|
||||||
mShaderOpacity = glGetUniformLocation(mProgramID, "opacity");
|
mShaderOpacity = glGetUniformLocation(mProgramID, "opacity");
|
||||||
mShaderSaturation = glGetUniformLocation(mProgramID, "saturation");
|
mShaderSaturation = glGetUniformLocation(mProgramID, "saturation");
|
||||||
mShaderDimming = glGetUniformLocation(mProgramID, "dimming");
|
mShaderDimming = glGetUniformLocation(mProgramID, "dimming");
|
||||||
|
@ -166,6 +168,12 @@ void ShaderOpenGL::setClipRegion(glm::vec4 clipRegion)
|
||||||
clipRegion[3]));
|
clipRegion[3]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShaderOpenGL::setBrightness(GLfloat brightness)
|
||||||
|
{
|
||||||
|
if (mShaderBrightness != -1)
|
||||||
|
GL_CHECK_ERROR(glUniform1f(mShaderBrightness, brightness));
|
||||||
|
}
|
||||||
|
|
||||||
void ShaderOpenGL::setOpacity(GLfloat opacity)
|
void ShaderOpenGL::setOpacity(GLfloat opacity)
|
||||||
{
|
{
|
||||||
if (mShaderOpacity != -1)
|
if (mShaderOpacity != -1)
|
||||||
|
|
|
@ -69,6 +69,7 @@ public:
|
||||||
void setAttribPointers();
|
void setAttribPointers();
|
||||||
void setTextureSize(std::array<GLfloat, 2> shaderVec2);
|
void setTextureSize(std::array<GLfloat, 2> shaderVec2);
|
||||||
void setClipRegion(glm::vec4 clipRegion);
|
void setClipRegion(glm::vec4 clipRegion);
|
||||||
|
void setBrightness(GLfloat brightness);
|
||||||
void setOpacity(GLfloat opacity);
|
void setOpacity(GLfloat opacity);
|
||||||
void setSaturation(GLfloat saturation);
|
void setSaturation(GLfloat saturation);
|
||||||
void setDimming(GLfloat dimming);
|
void setDimming(GLfloat dimming);
|
||||||
|
@ -95,6 +96,7 @@ private:
|
||||||
GLint mShaderColor;
|
GLint mShaderColor;
|
||||||
GLint mShaderClipRegion;
|
GLint mShaderClipRegion;
|
||||||
GLint mShaderTextureSize;
|
GLint mShaderTextureSize;
|
||||||
|
GLint mShaderBrightness;
|
||||||
GLint mShaderOpacity;
|
GLint mShaderOpacity;
|
||||||
GLint mShaderSaturation;
|
GLint mShaderSaturation;
|
||||||
GLint mShaderDimming;
|
GLint mShaderDimming;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
// core.glsl
|
// core.glsl
|
||||||
//
|
//
|
||||||
// Core shader functionality:
|
// Core shader functionality:
|
||||||
// Clipping, saturation, opacity, dimming and reflections falloff.
|
// Clipping, brightness, saturation, opacity, dimming and reflections falloff.
|
||||||
//
|
//
|
||||||
|
|
||||||
// Vertex section of code:
|
// Vertex section of code:
|
||||||
|
@ -39,6 +39,7 @@ in vec2 texCoord;
|
||||||
in vec4 color;
|
in vec4 color;
|
||||||
|
|
||||||
uniform vec4 clipRegion;
|
uniform vec4 clipRegion;
|
||||||
|
uniform float brightness;
|
||||||
uniform float saturation;
|
uniform float saturation;
|
||||||
uniform float opacity;
|
uniform float opacity;
|
||||||
uniform float dimming;
|
uniform float dimming;
|
||||||
|
@ -70,6 +71,10 @@ void main()
|
||||||
|
|
||||||
vec4 sampledColor = texture(textureSampler, texCoord);
|
vec4 sampledColor = texture(textureSampler, texCoord);
|
||||||
|
|
||||||
|
// Brightness.
|
||||||
|
if (brightness != 0.0)
|
||||||
|
sampledColor.rgb = sampledColor.rgb * pow(2.0, brightness);
|
||||||
|
|
||||||
// Saturation.
|
// Saturation.
|
||||||
if (saturation != 1.0) {
|
if (saturation != 1.0) {
|
||||||
vec3 grayscale;
|
vec3 grayscale;
|
||||||
|
|
|
@ -58,6 +58,7 @@ precision mediump float;
|
||||||
|
|
||||||
uniform vec2 textureSize;
|
uniform vec2 textureSize;
|
||||||
uniform float opacity;
|
uniform float opacity;
|
||||||
|
uniform float brightness;
|
||||||
uniform float saturation;
|
uniform float saturation;
|
||||||
uniform sampler2D textureSampler;
|
uniform sampler2D textureSampler;
|
||||||
in vec2 texCoord;
|
in vec2 texCoord;
|
||||||
|
@ -155,6 +156,10 @@ void main()
|
||||||
|
|
||||||
vec4 colorTemp = clamp(GAMMA_OUT(color), 0.0, 1.0);
|
vec4 colorTemp = clamp(GAMMA_OUT(color), 0.0, 1.0);
|
||||||
|
|
||||||
|
// Brightness.
|
||||||
|
if (brightness != 0.0)
|
||||||
|
colorTemp.rgb = colorTemp.rgb * pow(2.0, brightness);
|
||||||
|
|
||||||
// Saturation.
|
// Saturation.
|
||||||
if (saturation != 1.0) {
|
if (saturation != 1.0) {
|
||||||
vec3 grayscale;
|
vec3 grayscale;
|
||||||
|
|
Loading…
Reference in a new issue