mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-27 12:51:42 +00:00
Fix movie patches not accounting for half pixel properly. (#119)
This commit is contained in:
parent
53331d5760
commit
c53df15578
1 changed files with 17 additions and 14 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
#include <user/config.h>
|
#include <user/config.h>
|
||||||
#include <api/SWA.h>
|
#include <api/SWA.h>
|
||||||
#include <ui/game_window.h>
|
#include <ui/game_window.h>
|
||||||
|
#include <gpu/video.h>
|
||||||
|
#include "aspect_ratio_patches.h"
|
||||||
|
|
||||||
using SVertexData = SWA::Sequence::Utility::CPlayMovieWrapper::CRender::SVertexData;
|
using SVertexData = SWA::Sequence::Utility::CPlayMovieWrapper::CRender::SVertexData;
|
||||||
|
|
||||||
|
|
@ -20,40 +22,41 @@ PPC_FUNC(sub_82AE30D8)
|
||||||
auto quadHeight = std::fabs(pTopLeft->Y - pBottomLeft->Y) * ((float)*pViewportHeight / 2);
|
auto quadHeight = std::fabs(pTopLeft->Y - pBottomLeft->Y) * ((float)*pViewportHeight / 2);
|
||||||
|
|
||||||
auto movieAspectRatio = quadWidth / quadHeight;
|
auto movieAspectRatio = quadWidth / quadHeight;
|
||||||
auto windowAspectRatio = (float)GameWindow::s_width / (float)GameWindow::s_height;
|
|
||||||
|
|
||||||
auto a = -1.00078f;
|
|
||||||
auto b = 1.00139f;
|
|
||||||
auto scaleU = 1.0f;
|
auto scaleU = 1.0f;
|
||||||
auto scaleV = 1.0f;
|
auto scaleV = 1.0f;
|
||||||
auto centreV = (pTopLeft->V + pBottomRight->V) / 2.0f;
|
auto centreV = (pTopLeft->V + pBottomRight->V) / 2.0f;
|
||||||
|
|
||||||
if (windowAspectRatio > movieAspectRatio)
|
if (g_aspectRatio > movieAspectRatio)
|
||||||
{
|
{
|
||||||
scaleU = movieAspectRatio / windowAspectRatio;
|
scaleU = movieAspectRatio / g_aspectRatio;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
scaleV = windowAspectRatio / movieAspectRatio;
|
scaleV = g_aspectRatio / movieAspectRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
pTopLeft->X = a;
|
auto backBuffer = Video::GetBackBuffer();
|
||||||
pTopLeft->Y = b;
|
float halfPixelX = 1.0f / backBuffer->width;
|
||||||
|
float halfPixelY = 1.0f / backBuffer->height;
|
||||||
|
|
||||||
|
pTopLeft->X = -1.0f - halfPixelX;
|
||||||
|
pTopLeft->Y = 1.0f + halfPixelY;
|
||||||
pTopLeft->U = (pTopLeft->U - centreV) / scaleU + centreV;
|
pTopLeft->U = (pTopLeft->U - centreV) / scaleU + centreV;
|
||||||
pTopLeft->V = (pTopLeft->V - centreV) / scaleV + centreV;
|
pTopLeft->V = (pTopLeft->V - centreV) / scaleV + centreV;
|
||||||
|
|
||||||
pTopRight->X = b;
|
pTopRight->X = 1.0f - halfPixelX;
|
||||||
pTopRight->Y = b;
|
pTopRight->Y = 1.0f + halfPixelY;
|
||||||
pTopRight->U = (pTopRight->U - centreV) / scaleU + centreV;
|
pTopRight->U = (pTopRight->U - centreV) / scaleU + centreV;
|
||||||
pTopRight->V = (pTopRight->V - centreV) / scaleV + centreV;
|
pTopRight->V = (pTopRight->V - centreV) / scaleV + centreV;
|
||||||
|
|
||||||
pBottomLeft->X = a;
|
pBottomLeft->X = -1.0f - halfPixelX;
|
||||||
pBottomLeft->Y = a;
|
pBottomLeft->Y = -1.0f + halfPixelY;
|
||||||
pBottomLeft->U = (pBottomLeft->U - centreV) / scaleU + centreV;
|
pBottomLeft->U = (pBottomLeft->U - centreV) / scaleU + centreV;
|
||||||
pBottomLeft->V = (pBottomLeft->V - centreV) / scaleV + centreV;
|
pBottomLeft->V = (pBottomLeft->V - centreV) / scaleV + centreV;
|
||||||
|
|
||||||
pBottomRight->X = b;
|
pBottomRight->X = 1.0f - halfPixelX;
|
||||||
pBottomRight->Y = a;
|
pBottomRight->Y = -1.0f + halfPixelY;
|
||||||
pBottomRight->U = (pBottomRight->U - centreV) / scaleU + centreV;
|
pBottomRight->U = (pBottomRight->U - centreV) / scaleU + centreV;
|
||||||
pBottomRight->V = (pBottomRight->V - centreV) / scaleV + centreV;
|
pBottomRight->V = (pBottomRight->V - centreV) / scaleV + centreV;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue