Interpolate to original 4:3 scale.

This commit is contained in:
Skyth 2025-01-06 16:14:56 +03:00
parent 0f3c7ccfde
commit 15e809d65b

View file

@ -175,8 +175,8 @@ PPC_FUNC(sub_825E2E60)
static constexpr float NARROW_ASPECT_RATIO = 4.0f / 3.0f;
static constexpr float WIDE_ASPECT_RATIO = 16.0f / 9.0f;
static constexpr float STEAM_DECK_ASPECT_RATIO = 16.0f / 10.0f;
static constexpr float INV_WIDE_ASPECT_RATIO = 1.0f / WIDE_ASPECT_RATIO;
static constexpr float INV_WIDE_SCALE = 1280.0f / 960.0f;
static constexpr float TALL_ASPECT_RATIO = 1.0f / WIDE_ASPECT_RATIO;
static constexpr float TALL_SCALE = 1280.0f / 960.0f;
static float g_offsetX;
static float g_offsetY;
@ -184,6 +184,11 @@ static float g_scale;
static float g_worldMapOffset;
static float ComputeScale(float aspectRatio)
{
return ((aspectRatio * 720.0f) / 1280.0f) / sqrt((aspectRatio * 720.0f) / 1280.0f);
}
static void ComputeOffsets(float width, float height)
{
float aspectRatio = width / height;
@ -195,12 +200,15 @@ static void ComputeOffsets(float width, float height)
g_offsetX = 0.5f * (aspectRatio * 720.0f - 1280.0f);
g_offsetY = 0.0f;
// narrow resolutions will zoom the UI in, but we want the gameplay
// UI to retain the same scale at Steam Deck's aspect ratio
// keep same scale above Steam Deck aspect ratio
if (aspectRatio < WIDE_ASPECT_RATIO)
{
float factor = std::clamp((aspectRatio - NARROW_ASPECT_RATIO) / (STEAM_DECK_ASPECT_RATIO - NARROW_ASPECT_RATIO), 0.0f, 1.0f);
g_scale = 1.0f + factor * (aspectRatio / WIDE_ASPECT_RATIO - 1.0f);
// interpolate to original 4:3 scale
float steamDeckScale = aspectRatio / WIDE_ASPECT_RATIO;
float narrowScale = ComputeScale(NARROW_ASPECT_RATIO);
float lerpFactor = std::clamp((aspectRatio - NARROW_ASPECT_RATIO) / (STEAM_DECK_ASPECT_RATIO - NARROW_ASPECT_RATIO), 0.0f, 1.0f);
g_scale = narrowScale + (steamDeckScale - narrowScale) * lerpFactor;
}
}
else
@ -210,15 +218,8 @@ static void ComputeOffsets(float width, float height)
g_offsetY = 0.5f * (960.0f / aspectRatio - 720.0f);
// scale to 16:9 as the aspect ratio becomes 9:16
float factor = std::clamp((aspectRatio - INV_WIDE_ASPECT_RATIO) / (NARROW_ASPECT_RATIO - INV_WIDE_ASPECT_RATIO), 0.0f, 1.0f);
g_scale = INV_WIDE_SCALE + factor * (1.0f - INV_WIDE_SCALE);
}
// use original 4:3 scaling if requested
if (Config::AspectRatio == EAspectRatio::OriginalNarrow)
{
aspectRatio = std::clamp(aspectRatio, NARROW_ASPECT_RATIO, WIDE_ASPECT_RATIO);
g_scale = ((aspectRatio * 720.0f) / 1280.0f) / sqrt((aspectRatio * 720.0f) / 1280.0f);
float factor = std::clamp((aspectRatio - TALL_ASPECT_RATIO) / (NARROW_ASPECT_RATIO - TALL_ASPECT_RATIO), 0.0f, 1.0f);
g_scale = TALL_SCALE + factor * (ComputeScale(NARROW_ASPECT_RATIO) - TALL_SCALE);
}
g_worldMapOffset = std::clamp((aspectRatio - NARROW_ASPECT_RATIO) / (WIDE_ASPECT_RATIO - NARROW_ASPECT_RATIO), 0.0f, 1.0f);