Improved the scaling of the scanline shader in relation to screen resolution.

This commit is contained in:
Leon Styhre 2021-03-18 19:52:48 +01:00
parent a46222030c
commit 5f727f8c00

View file

@ -323,9 +323,25 @@ namespace Renderer
if (_vertices->shaders & SHADER_SCANLINES) { if (_vertices->shaders & SHADER_SCANLINES) {
Shader* runShader = getShaderProgram(SHADER_SCANLINES); Shader* runShader = getShaderProgram(SHADER_SCANLINES);
float shaderWidth = width * 1.2f; float shaderWidth = width * 1.2f;
// Workaround to get the scanlines to render somehow proportional to the // Scale the scanlines relative to screen resolution.
// resolution. A better solution is for sure needed. float screenHeightModifier = getScreenHeightModifier();
float shaderHeight = height + height / (static_cast<int>(height) >> 7) * 2.0f; float relativeHeight = height / getScreenHeight();
float shaderHeight = 0.0f;
if (relativeHeight == 1.0f) {
// Full screen.
float modifier = 1.30f - (0.1f * screenHeightModifier);
shaderHeight = height * modifier;
}
else {
// Portion of screen, e.g. gamelist view.
// Average the relative width and height to avoid applying exaggerated
// scanlines to videos with non-standard aspect ratios.
float relativeWidth = width / getScreenWidth();
float relativeAdjustment = (relativeWidth + relativeHeight) / 2.0f;
float modifier = 1.41f + relativeAdjustment / 7.0f -
(0.14f * screenHeightModifier);
shaderHeight = height * modifier;
}
if (runShader) { if (runShader) {
runShader->activateShaders(); runShader->activateShaders();
runShader->setModelViewProjectionMatrix(getProjectionMatrix() * _trans); runShader->setModelViewProjectionMatrix(getProjectionMatrix() * _trans);