mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-02-18 04:45:39 +00:00
Added opacity support to the scanline shader.
This commit is contained in:
parent
a9d1f6e307
commit
5ac6bcb902
|
@ -311,12 +311,8 @@ void VideoComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
if (elem->has("pillarboxes"))
|
if (elem->has("pillarboxes"))
|
||||||
mDrawPillarboxes = elem->get<bool>("pillarboxes");
|
mDrawPillarboxes = elem->get<bool>("pillarboxes");
|
||||||
|
|
||||||
// Scanlines are not compatible with video transparency.
|
if (elem->has("scanlines"))
|
||||||
if (elem->has("scanlines")) {
|
|
||||||
mRenderScanlines = elem->get<bool>("scanlines");
|
mRenderScanlines = elem->get<bool>("scanlines");
|
||||||
if (mRenderScanlines && mThemeOpacity != 0.0f)
|
|
||||||
mThemeOpacity = 1.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (elem->has("scrollFadeIn") && elem->get<bool>("scrollFadeIn"))
|
if (elem->has("scrollFadeIn") && elem->get<bool>("scrollFadeIn"))
|
||||||
mComponentThemeFlags |= ComponentThemeFlags::SCROLL_FADE_IN;
|
mComponentThemeFlags |= ComponentThemeFlags::SCROLL_FADE_IN;
|
||||||
|
|
|
@ -216,9 +216,14 @@ void VideoFFmpegComponent::render(const glm::mat4& parentTrans)
|
||||||
// or the video screensaver, then skip this as the scanline rendering is then handled
|
// or the video screensaver, then skip this as the scanline rendering is then handled
|
||||||
// in those modules as a postprocessing step.
|
// in those modules as a postprocessing step.
|
||||||
if (!mScreensaverMode && !mMediaViewerMode) {
|
if (!mScreensaverMode && !mMediaViewerMode) {
|
||||||
|
vertices[0].opacity = mFadeIn * mThemeOpacity;
|
||||||
if ((mLegacyTheme && Settings::getInstance()->getBool("GamelistVideoScanlines")) ||
|
if ((mLegacyTheme && Settings::getInstance()->getBool("GamelistVideoScanlines")) ||
|
||||||
(!mLegacyTheme && mRenderScanlines))
|
(!mLegacyTheme && mRenderScanlines)) {
|
||||||
vertices[0].shaders = Renderer::SHADER_SCANLINES;
|
vertices[0].shaders = Renderer::SHADER_SCANLINES;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
vertices[0].shaders = Renderer::SHADER_OPACITY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -352,6 +352,7 @@ namespace Renderer
|
||||||
if (runShader) {
|
if (runShader) {
|
||||||
runShader->activateShaders();
|
runShader->activateShaders();
|
||||||
runShader->setModelViewProjectionMatrix(getProjectionMatrix() * trans);
|
runShader->setModelViewProjectionMatrix(getProjectionMatrix() * trans);
|
||||||
|
runShader->setOpacity(vertices->opacity);
|
||||||
runShader->setTextureSize({shaderWidth, shaderHeight});
|
runShader->setTextureSize({shaderWidth, shaderHeight});
|
||||||
GL_CHECK_ERROR(glDrawArrays(GL_TRIANGLE_STRIP, 0, numVertices));
|
GL_CHECK_ERROR(glDrawArrays(GL_TRIANGLE_STRIP, 0, numVertices));
|
||||||
runShader->deactivateShaders();
|
runShader->deactivateShaders();
|
||||||
|
@ -363,8 +364,7 @@ namespace Renderer
|
||||||
if (runShader) {
|
if (runShader) {
|
||||||
runShader->activateShaders();
|
runShader->activateShaders();
|
||||||
runShader->setModelViewProjectionMatrix(getProjectionMatrix() * trans);
|
runShader->setModelViewProjectionMatrix(getProjectionMatrix() * trans);
|
||||||
if (vertices->opacity < 1.0f)
|
runShader->setOpacity(vertices->opacity);
|
||||||
runShader->setOpacity(vertices->opacity);
|
|
||||||
GL_CHECK_ERROR(glDrawArrays(GL_TRIANGLE_STRIP, 0, numVertices));
|
GL_CHECK_ERROR(glDrawArrays(GL_TRIANGLE_STRIP, 0, numVertices));
|
||||||
runShader->deactivateShaders();
|
runShader->deactivateShaders();
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,7 @@ uniform COMPAT_PRECISION int FrameCount;
|
||||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||||
uniform COMPAT_PRECISION vec2 InputSize;
|
uniform COMPAT_PRECISION vec2 InputSize;
|
||||||
|
uniform COMPAT_PRECISION float opacity = 1.0;
|
||||||
uniform sampler2D Texture;
|
uniform sampler2D Texture;
|
||||||
COMPAT_VARYING vec4 TEX0;
|
COMPAT_VARYING vec4 TEX0;
|
||||||
COMPAT_VARYING vec2 onex;
|
COMPAT_VARYING vec2 onex;
|
||||||
|
@ -126,10 +127,11 @@ uniform COMPAT_PRECISION float OutputGamma;
|
||||||
#define TEX2D(coords) GAMMA_IN(COMPAT_TEXTURE(Source, coords))
|
#define TEX2D(coords) GAMMA_IN(COMPAT_TEXTURE(Source, coords))
|
||||||
|
|
||||||
// Macro for weights computing.
|
// Macro for weights computing.
|
||||||
#define WEIGHT(w) \
|
#define WEIGHT(w) \
|
||||||
if (w > 1.0) w = 1.0; \
|
if (w > 1.0) \
|
||||||
w = 1.0 - w * w; \
|
w = 1.0; \
|
||||||
w = w * w;
|
w = 1.0 - w * w; \
|
||||||
|
w = w * w;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
@ -143,7 +145,7 @@ void main()
|
||||||
float h_weight_00 = dx / SPOT_WIDTH;
|
float h_weight_00 = dx / SPOT_WIDTH;
|
||||||
WEIGHT(h_weight_00);
|
WEIGHT(h_weight_00);
|
||||||
|
|
||||||
color *= vec4( h_weight_00, h_weight_00, h_weight_00, h_weight_00 );
|
color *= vec4(h_weight_00, h_weight_00, h_weight_00, h_weight_00);
|
||||||
|
|
||||||
// Get closest horizontal neighbour to blend.
|
// Get closest horizontal neighbour to blend.
|
||||||
vec2 coords01;
|
vec2 coords01;
|
||||||
|
@ -184,12 +186,13 @@ void main()
|
||||||
WEIGHT(v_weight_10);
|
WEIGHT(v_weight_10);
|
||||||
|
|
||||||
color = color + colorNB * vec4(v_weight_10 * h_weight_00, v_weight_10 * h_weight_00,
|
color = color + colorNB * vec4(v_weight_10 * h_weight_00, v_weight_10 * h_weight_00,
|
||||||
v_weight_10 * h_weight_00, v_weight_10 * h_weight_00);
|
v_weight_10 * h_weight_00, v_weight_10 * h_weight_00);
|
||||||
colorNB = TEX2D(texture_coords + coords01 + coords10);
|
colorNB = TEX2D(texture_coords + coords01 + coords10);
|
||||||
color = color + colorNB * vec4(v_weight_10 * h_weight_01, v_weight_10 * h_weight_01,
|
color = color + colorNB * vec4(v_weight_10 * h_weight_01, v_weight_10 * h_weight_01,
|
||||||
v_weight_10 * h_weight_01, v_weight_10 * h_weight_01);
|
v_weight_10 * h_weight_01, v_weight_10 * h_weight_01);
|
||||||
color *= vec4(COLOR_BOOST);
|
color *= vec4(COLOR_BOOST);
|
||||||
|
|
||||||
FragColor = clamp(GAMMA_OUT(color), 0.0, 1.0);
|
vec4 colorTemp = clamp(GAMMA_OUT(color), 0.0, 1.0);
|
||||||
|
FragColor = vec4(colorTemp.rgb, colorTemp.a * opacity);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue