mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
Fixed multiple issues with the shader post-processing.
Also removed an unnecessary parameter for the createTexture() function.
This commit is contained in:
parent
bebc9d58cf
commit
32251e0264
|
@ -348,11 +348,10 @@ void Screensaver::renderScreensaver()
|
|||
#if defined(USE_OPENGL_21)
|
||||
Renderer::postProcessingParams dimParameters;
|
||||
dimParameters.dimming = mDimValue;
|
||||
dimParameters.saturation = mSaturationAmount;
|
||||
Renderer::shaderPostprocessing(Renderer::SHADER_CORE, dimParameters);
|
||||
if (mDimValue > 0.63)
|
||||
mDimValue = glm::clamp(mDimValue - 0.015f, 0.68f, 1.0f);
|
||||
dimParameters.saturation = mSaturationAmount;
|
||||
Renderer::shaderPostprocessing(Renderer::SHADER_CORE, dimParameters);
|
||||
if (mSaturationAmount > 0.0)
|
||||
mSaturationAmount = glm::clamp(mSaturationAmount - 0.035f, 0.0f, 1.0f);
|
||||
#else
|
||||
|
|
|
@ -209,8 +209,7 @@ void VideoFFmpegComponent::render(const glm::mat4& parentTrans)
|
|||
|
||||
// Render scanlines if this option is enabled. However, if this is the media viewer
|
||||
// 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 post-processing step.
|
||||
if (!mScreensaverMode && !mMediaViewerMode) {
|
||||
vertices[0].opacity = mFadeIn * mThemeOpacity;
|
||||
if ((mLegacyTheme && Settings::getInstance()->getBool("GamelistVideoScanlines")) ||
|
||||
|
|
|
@ -96,7 +96,8 @@ namespace Renderer
|
|||
namespace Texture
|
||||
{
|
||||
enum Type {
|
||||
RGBA, // Replace with AllowShortEnumsOnASingleLine: false (clang-format >=11.0).
|
||||
RGB, // Replace with AllowShortEnumsOnASingleLine: false (clang-format >=11.0).
|
||||
RGBA,
|
||||
BGRA,
|
||||
ALPHA
|
||||
};
|
||||
|
@ -186,7 +187,6 @@ namespace Renderer
|
|||
bool createContext();
|
||||
void destroyContext();
|
||||
unsigned int createTexture(const Texture::Type type,
|
||||
const Texture::Type format,
|
||||
const bool linearMinify,
|
||||
const bool linearMagnify,
|
||||
const bool repeat,
|
||||
|
|
|
@ -46,6 +46,7 @@ namespace Renderer
|
|||
{
|
||||
// clang-format off
|
||||
switch (_type) {
|
||||
case Texture::RGB: { return GL_RGB; } break;
|
||||
case Texture::RGBA: { return GL_RGBA; } break;
|
||||
case Texture::BGRA: { return GL_BGRA; } break;
|
||||
case Texture::ALPHA: { return GL_LUMINANCE_ALPHA; } break;
|
||||
|
@ -144,16 +145,18 @@ namespace Renderer
|
|||
return false;
|
||||
}
|
||||
|
||||
postProcTexture1 = createTexture(Texture::RGBA, Texture::RGBA, false, false, false,
|
||||
// For the post-processing textures we want to discard the alpha channel to avoid
|
||||
// weird problems with some graphics drivers.
|
||||
postProcTexture1 = createTexture(Texture::RGB, false, false, false,
|
||||
static_cast<unsigned int>(getScreenWidth()),
|
||||
static_cast<unsigned int>(getScreenHeight()), nullptr);
|
||||
|
||||
postProcTexture2 = createTexture(Texture::RGBA, Texture::RGBA, false, false, false,
|
||||
postProcTexture2 = createTexture(Texture::RGB, false, false, false,
|
||||
static_cast<unsigned int>(getScreenWidth()),
|
||||
static_cast<unsigned int>(getScreenHeight()), nullptr);
|
||||
|
||||
uint8_t data[4] = {255, 255, 255, 255};
|
||||
whiteTexture = createTexture(Texture::RGBA, Texture::RGBA, false, false, true, 1, 1, data);
|
||||
whiteTexture = createTexture(Texture::RGBA, false, false, true, 1, 1, data);
|
||||
|
||||
GL_CHECK_ERROR(glClearColor(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
GL_CHECK_ERROR(glEnable(GL_TEXTURE_2D));
|
||||
|
@ -183,7 +186,6 @@ namespace Renderer
|
|||
}
|
||||
|
||||
unsigned int createTexture(const Texture::Type type,
|
||||
const Texture::Type /*format*/,
|
||||
const bool linearMinify,
|
||||
const bool linearMagnify,
|
||||
const bool repeat,
|
||||
|
@ -448,7 +450,7 @@ namespace Renderer
|
|||
GLuint height {static_cast<GLuint>(heightf)};
|
||||
|
||||
// Set vertex positions and texture coordinates to full screen as all
|
||||
// postprocessing is applied to the complete screen area.
|
||||
// post-processing is applied to the complete screen area.
|
||||
// clang-format off
|
||||
vertices[0] = {{0.0f, 0.0f }, {0.0f, 1.0f}, 0xFFFFFFFF};
|
||||
vertices[1] = {{0.0f, heightf}, {0.0f, 0.0f}, 0xFFFFFFFF};
|
||||
|
@ -524,12 +526,14 @@ namespace Renderer
|
|||
bindTexture(postProcTexture2);
|
||||
GL_CHECK_ERROR(glBindFramebuffer(GL_READ_FRAMEBUFFER, shaderFBO2));
|
||||
GL_CHECK_ERROR(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, shaderFBO1));
|
||||
GL_CHECK_ERROR(glClear(GL_COLOR_BUFFER_BIT));
|
||||
firstFBO = false;
|
||||
}
|
||||
else {
|
||||
bindTexture(postProcTexture1);
|
||||
GL_CHECK_ERROR(glBindFramebuffer(GL_READ_FRAMEBUFFER, shaderFBO1));
|
||||
GL_CHECK_ERROR(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, shaderFBO2));
|
||||
GL_CHECK_ERROR(glClear(GL_COLOR_BUFFER_BIT));
|
||||
firstFBO = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -199,8 +199,8 @@ bool Font::FontTexture::findEmpty(const glm::ivec2& size, glm::ivec2& cursor_out
|
|||
void Font::FontTexture::initTexture()
|
||||
{
|
||||
assert(textureId == 0);
|
||||
textureId = Renderer::createTexture(Renderer::Texture::ALPHA, Renderer::Texture::ALPHA, false,
|
||||
false, false, textureSize.x, textureSize.y, nullptr);
|
||||
textureId = Renderer::createTexture(Renderer::Texture::ALPHA, false, false, false,
|
||||
textureSize.x, textureSize.y, nullptr);
|
||||
}
|
||||
|
||||
void Font::FontTexture::deinitTexture()
|
||||
|
|
|
@ -27,7 +27,6 @@ TextureData::TextureData(bool tile)
|
|||
: mTile {tile}
|
||||
, mTextureID {0}
|
||||
, mDataRGBA {}
|
||||
, mFormat {Renderer::Texture::RGBA}
|
||||
, mWidth {0}
|
||||
, mHeight {0}
|
||||
, mSourceWidth {0.0f}
|
||||
|
@ -219,7 +218,7 @@ bool TextureData::uploadAndBind()
|
|||
|
||||
// Upload texture.
|
||||
mTextureID =
|
||||
Renderer::createTexture(Renderer::Texture::RGBA, mFormat, true, mLinearMagnify, mTile,
|
||||
Renderer::createTexture(Renderer::Texture::RGBA, true, mLinearMagnify, mTile,
|
||||
static_cast<const unsigned int>(mWidth),
|
||||
static_cast<const unsigned int>(mHeight), mDataRGBA.data());
|
||||
}
|
||||
|
|
|
@ -64,8 +64,6 @@ public:
|
|||
// Whether to rasterize the image even if a size has not been set yet.
|
||||
void setForceRasterization(bool setting) { mForceRasterization = setting; }
|
||||
|
||||
void setFormat(Renderer::Texture::Type format) { mFormat = format; }
|
||||
|
||||
// Has the image been loaded but not yet been rasterized as the size was not known?
|
||||
bool getPendingRasterization() { return mPendingRasterization; }
|
||||
|
||||
|
@ -80,7 +78,6 @@ private:
|
|||
std::string mPath;
|
||||
std::atomic<unsigned int> mTextureID;
|
||||
std::vector<unsigned char> mDataRGBA;
|
||||
Renderer::Texture::Type mFormat;
|
||||
std::atomic<int> mWidth;
|
||||
std::atomic<int> mHeight;
|
||||
std::atomic<float> mSourceWidth;
|
||||
|
|
|
@ -45,7 +45,6 @@ public:
|
|||
return (mTextureData != nullptr ? mTextureData->getPendingRasterization() : false);
|
||||
}
|
||||
|
||||
void setFormat(Renderer::Texture::Type format) { mTextureData->setFormat(format); }
|
||||
void setLinearMagnify(bool setting) { mTextureData->setLinearMagnify(setting); }
|
||||
|
||||
std::string getTextureFilePath();
|
||||
|
|
|
@ -56,14 +56,16 @@ void main()
|
|||
|
||||
// Saturation.
|
||||
if (saturation != 1.0f) {
|
||||
vec3 grayscale = vec3(dot(color.rgb, vec3(0.3f, 0.59f, 0.11f)));
|
||||
vec3 grayscale = vec3(dot(color.rgb, vec3(0.34f, 0.55f, 0.11f)));
|
||||
vec3 blendedColor = mix(grayscale, color.rgb, saturation);
|
||||
color = vec4(blendedColor, color.a);
|
||||
}
|
||||
|
||||
// Dimming
|
||||
vec4 dimColor = vec4(dimming, dimming, dimming, 1.0f);
|
||||
color = vec4(color.rgba) * dimColor;
|
||||
if (dimming != 1.0f) {
|
||||
vec4 dimColor = vec4(dimming, dimming, dimming, 1.0f);
|
||||
color *= dimColor;
|
||||
}
|
||||
|
||||
// BGRA to RGBA conversion.
|
||||
if (BGRAToRGBA == 1)
|
||||
|
|
Loading…
Reference in a new issue