Allow tuning bicubic sharpness

This commit is contained in:
Splendide Imaginarius 2023-11-22 20:22:34 +00:00
parent 939b67f4fa
commit a3e9316438
6 changed files with 18 additions and 2 deletions

View file

@ -88,6 +88,14 @@
// "smoothScaling": 0, // "smoothScaling": 0,
// Sharpness when using Bicubic scaling.
// A good starting range is 0 to 100,
// but you may wish to go outside that range in either direction.
// (default: 100)
//
// "bicubicSharpness": 100,
// Replace the game's Bitmap files with external high-res files // Replace the game's Bitmap files with external high-res files
// provided in the "Hires" directory. // provided in the "Hires" directory.
// (You'll also need to set the below Scaling Factors.) // (You'll also need to set the below Scaling Factors.)

View file

@ -135,6 +135,7 @@ void Config::read(int argc, char *argv[]) {
{"fullscreen", false}, {"fullscreen", false},
{"fixedAspectRatio", true}, {"fixedAspectRatio", true},
{"smoothScaling", 0}, {"smoothScaling", 0},
{"bicubicSharpness", 100},
{"enableHires", false}, {"enableHires", false},
{"textureScalingFactor", 1.}, {"textureScalingFactor", 1.},
{"framebufferScalingFactor", 1.}, {"framebufferScalingFactor", 1.},
@ -263,6 +264,7 @@ try { exp } catch (...) {}
SET_OPT(fullscreen, boolean); SET_OPT(fullscreen, boolean);
SET_OPT(fixedAspectRatio, boolean); SET_OPT(fixedAspectRatio, boolean);
SET_OPT(smoothScaling, integer); SET_OPT(smoothScaling, integer);
SET_OPT(bicubicSharpness, integer);
SET_OPT(enableHires, boolean); SET_OPT(enableHires, boolean);
SET_OPT(textureScalingFactor, number); SET_OPT(textureScalingFactor, number);
SET_OPT(framebufferScalingFactor, number); SET_OPT(framebufferScalingFactor, number);

View file

@ -44,6 +44,7 @@ struct Config {
bool fullscreen; bool fullscreen;
bool fixedAspectRatio; bool fixedAspectRatio;
int smoothScaling; int smoothScaling;
int bicubicSharpness;
bool enableHires; bool enableHires;
double textureScalingFactor; double textureScalingFactor;
double framebufferScalingFactor; double framebufferScalingFactor;

View file

@ -161,6 +161,7 @@ static void _blitBegin(FBO::ID fbo, const Vec2i &size)
shader.applyViewportProj(); shader.applyViewportProj();
shader.setTranslation(Vec2i()); shader.setTranslation(Vec2i());
shader.setTexSize(Vec2i(size.x, size.y)); shader.setTexSize(Vec2i(size.x, size.y));
shader.setSharpness(shState->config().bicubicSharpness);
} }
break; break;

View file

@ -777,9 +777,11 @@ BicubicShader::BicubicShader()
GET_U(texOffsetX); GET_U(texOffsetX);
GET_U(sourceSize); GET_U(sourceSize);
GET_U(bc); GET_U(bc);
}
// TODO: Maybe expose this as a setting? void BicubicShader::setSharpness(int sharpness)
gl.Uniform2f(u_bc, 0.0, 0.5); {
gl.Uniform2f(u_bc, 1.f - sharpness * 0.01f, sharpness * 0.005f);
} }
Lanczos3Shader::Lanczos3Shader() Lanczos3Shader::Lanczos3Shader()

View file

@ -346,6 +346,8 @@ class BicubicShader : public Lanczos3Shader
public: public:
BicubicShader(); BicubicShader();
void setSharpness(int sharpness);
protected: protected:
GLint u_bc; GLint u_bc;
}; };