mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-29 09:35: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"))
|
||||
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");
|
||||
if (mRenderScanlines && mThemeOpacity != 0.0f)
|
||||
mThemeOpacity = 1.0f;
|
||||
}
|
||||
|
||||
if (elem->has("scrollFadeIn") && elem->get<bool>("scrollFadeIn"))
|
||||
mComponentThemeFlags |= ComponentThemeFlags::SCROLL_FADE_IN;
|
||||
|
|
|
@ -216,10 +216,15 @@ void VideoFFmpegComponent::render(const glm::mat4& parentTrans)
|
|||
// or the video screensaver, then skip this as the scanline rendering is then handled
|
||||
// in those modules as a postprocessing step.
|
||||
if (!mScreensaverMode && !mMediaViewerMode) {
|
||||
vertices[0].opacity = mFadeIn * mThemeOpacity;
|
||||
if ((mLegacyTheme && Settings::getInstance()->getBool("GamelistVideoScanlines")) ||
|
||||
(!mLegacyTheme && mRenderScanlines))
|
||||
(!mLegacyTheme && mRenderScanlines)) {
|
||||
vertices[0].shaders = Renderer::SHADER_SCANLINES;
|
||||
}
|
||||
else {
|
||||
vertices[0].shaders = Renderer::SHADER_OPACITY;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Render it.
|
||||
|
|
|
@ -352,6 +352,7 @@ namespace Renderer
|
|||
if (runShader) {
|
||||
runShader->activateShaders();
|
||||
runShader->setModelViewProjectionMatrix(getProjectionMatrix() * trans);
|
||||
runShader->setOpacity(vertices->opacity);
|
||||
runShader->setTextureSize({shaderWidth, shaderHeight});
|
||||
GL_CHECK_ERROR(glDrawArrays(GL_TRIANGLE_STRIP, 0, numVertices));
|
||||
runShader->deactivateShaders();
|
||||
|
@ -363,7 +364,6 @@ namespace Renderer
|
|||
if (runShader) {
|
||||
runShader->activateShaders();
|
||||
runShader->setModelViewProjectionMatrix(getProjectionMatrix() * trans);
|
||||
if (vertices->opacity < 1.0f)
|
||||
runShader->setOpacity(vertices->opacity);
|
||||
GL_CHECK_ERROR(glDrawArrays(GL_TRIANGLE_STRIP, 0, numVertices));
|
||||
runShader->deactivateShaders();
|
||||
|
|
|
@ -93,6 +93,7 @@ uniform COMPAT_PRECISION int FrameCount;
|
|||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform COMPAT_PRECISION float opacity = 1.0;
|
||||
uniform sampler2D Texture;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
COMPAT_VARYING vec2 onex;
|
||||
|
@ -127,9 +128,10 @@ uniform COMPAT_PRECISION float OutputGamma;
|
|||
|
||||
// Macro for weights computing.
|
||||
#define WEIGHT(w) \
|
||||
if (w > 1.0) w = 1.0; \
|
||||
w = 1.0 - w * w; \
|
||||
w = w * w;
|
||||
if (w > 1.0) \
|
||||
w = 1.0; \
|
||||
w = 1.0 - w * w; \
|
||||
w = w * w;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
@ -143,7 +145,7 @@ void main()
|
|||
float h_weight_00 = dx / SPOT_WIDTH;
|
||||
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.
|
||||
vec2 coords01;
|
||||
|
@ -190,6 +192,7 @@ void main()
|
|||
v_weight_10 * h_weight_01, v_weight_10 * h_weight_01);
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue