mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-28 05:11:37 +00:00
Interpolate to original 4:3 scale.
This commit is contained in:
parent
0f3c7ccfde
commit
15e809d65b
1 changed files with 16 additions and 15 deletions
|
|
@ -175,8 +175,8 @@ PPC_FUNC(sub_825E2E60)
|
||||||
static constexpr float NARROW_ASPECT_RATIO = 4.0f / 3.0f;
|
static constexpr float NARROW_ASPECT_RATIO = 4.0f / 3.0f;
|
||||||
static constexpr float WIDE_ASPECT_RATIO = 16.0f / 9.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 STEAM_DECK_ASPECT_RATIO = 16.0f / 10.0f;
|
||||||
static constexpr float INV_WIDE_ASPECT_RATIO = 1.0f / WIDE_ASPECT_RATIO;
|
static constexpr float TALL_ASPECT_RATIO = 1.0f / WIDE_ASPECT_RATIO;
|
||||||
static constexpr float INV_WIDE_SCALE = 1280.0f / 960.0f;
|
static constexpr float TALL_SCALE = 1280.0f / 960.0f;
|
||||||
|
|
||||||
static float g_offsetX;
|
static float g_offsetX;
|
||||||
static float g_offsetY;
|
static float g_offsetY;
|
||||||
|
|
@ -184,6 +184,11 @@ static float g_scale;
|
||||||
|
|
||||||
static float g_worldMapOffset;
|
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)
|
static void ComputeOffsets(float width, float height)
|
||||||
{
|
{
|
||||||
float aspectRatio = width / 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_offsetX = 0.5f * (aspectRatio * 720.0f - 1280.0f);
|
||||||
g_offsetY = 0.0f;
|
g_offsetY = 0.0f;
|
||||||
|
|
||||||
// narrow resolutions will zoom the UI in, but we want the gameplay
|
// keep same scale above Steam Deck aspect ratio
|
||||||
// UI to retain the same scale at Steam Deck's aspect ratio
|
|
||||||
if (aspectRatio < WIDE_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);
|
// interpolate to original 4:3 scale
|
||||||
g_scale = 1.0f + factor * (aspectRatio / WIDE_ASPECT_RATIO - 1.0f);
|
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
|
else
|
||||||
|
|
@ -210,17 +218,10 @@ static void ComputeOffsets(float width, float height)
|
||||||
g_offsetY = 0.5f * (960.0f / aspectRatio - 720.0f);
|
g_offsetY = 0.5f * (960.0f / aspectRatio - 720.0f);
|
||||||
|
|
||||||
// scale to 16:9 as the aspect ratio becomes 9:16
|
// 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);
|
float factor = std::clamp((aspectRatio - TALL_ASPECT_RATIO) / (NARROW_ASPECT_RATIO - TALL_ASPECT_RATIO), 0.0f, 1.0f);
|
||||||
g_scale = INV_WIDE_SCALE + factor * (1.0f - INV_WIDE_SCALE);
|
g_scale = TALL_SCALE + factor * (ComputeScale(NARROW_ASPECT_RATIO) - TALL_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);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_worldMapOffset = std::clamp((aspectRatio - NARROW_ASPECT_RATIO) / (WIDE_ASPECT_RATIO - NARROW_ASPECT_RATIO), 0.0f, 1.0f);
|
g_worldMapOffset = std::clamp((aspectRatio - NARROW_ASPECT_RATIO) / (WIDE_ASPECT_RATIO - NARROW_ASPECT_RATIO), 0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue