mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-04-28 13:27:58 +03:00
Implemented support for maintaining aspect ratio for movies (#73)
* video_patches: aspect ratio support for CPlayMovieWrapper * config: remove movie scale mode option * video_patches: improve movie aspect ratio correction, support intro logos Co-Authored-By: Darío <538504+DarioSamo@users.noreply.github.com> Co-Authored-By: Skyth (Asilkan) <19259897+blueskythlikesclouds@users.noreply.github.com> * api: upload Inspire research * api: move Vertex struct --------- Co-authored-by: Darío <538504+DarioSamo@users.noreply.github.com> Co-authored-by: Skyth (Asilkan) <19259897+blueskythlikesclouds@users.noreply.github.com>
This commit is contained in:
parent
0737ff771d
commit
9a29b187cd
13 changed files with 139 additions and 62 deletions
|
@ -60,6 +60,10 @@
|
|||
#include "SWA/HUD/Pause/HudPause.h"
|
||||
#include "SWA/HUD/SaveIcon/SaveIcon.h"
|
||||
#include "SWA/HUD/Sonic/HudSonicStage.h"
|
||||
#include "SWA/Inspire/InspireMovieOverlay.h"
|
||||
#include "SWA/Inspire/InspireMovieOverlayInfo.h"
|
||||
#include "SWA/Inspire/InspireTextureOverlay.h"
|
||||
#include "SWA/Inspire/InspireTextureOverlayInfo.h"
|
||||
#include "SWA/Movie/MovieDisplayer.h"
|
||||
#include "SWA/Movie/MovieManager.h"
|
||||
#include "SWA/Player/Character/EvilSonic/EvilSonic.h"
|
||||
|
|
17
UnleashedRecomp/api/SWA/Inspire/InspireMovieOverlay.h
Normal file
17
UnleashedRecomp/api/SWA/Inspire/InspireMovieOverlay.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#include <SWA.inl>
|
||||
#include <SWA/Inspire/InspireMovieOverlayInfo.h>
|
||||
|
||||
namespace SWA::Inspire
|
||||
{
|
||||
class CScene;
|
||||
|
||||
class CMovieOverlay
|
||||
{
|
||||
public:
|
||||
boost::shared_ptr<CMovieOverlayInfo> m_spInfo;
|
||||
xpointer<CScene> m_pScene;
|
||||
xpointer<Hedgehog::Mirage::CTextureData> m_pTextureData;
|
||||
};
|
||||
}
|
17
UnleashedRecomp/api/SWA/Inspire/InspireMovieOverlayInfo.h
Normal file
17
UnleashedRecomp/api/SWA/Inspire/InspireMovieOverlayInfo.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#include <SWA.inl>
|
||||
|
||||
namespace SWA::Inspire
|
||||
{
|
||||
class CMovieOverlayInfo
|
||||
{
|
||||
public:
|
||||
Hedgehog::Base::CSharedString m_MovieName;
|
||||
be<float> m_StartTime;
|
||||
be<float> m_FadeInStartTime;
|
||||
be<float> m_FadeInEndTime;
|
||||
be<float> m_FadeOutStartTime;
|
||||
be<float> m_FadeOutEndTime;
|
||||
};
|
||||
}
|
18
UnleashedRecomp/api/SWA/Inspire/InspireTextureOverlay.h
Normal file
18
UnleashedRecomp/api/SWA/Inspire/InspireTextureOverlay.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
|
||||
#include <SWA.inl>
|
||||
#include <SWA/Inspire/InspireTextureOverlayInfo.h>
|
||||
|
||||
namespace SWA::Inspire
|
||||
{
|
||||
class CScene;
|
||||
|
||||
class CTextureOverlay
|
||||
{
|
||||
public:
|
||||
xpointer<void> m_pVftable;
|
||||
boost::shared_ptr<CInspireTextureOverlayInfo> m_spInfo;
|
||||
xpointer<CScene> m_pScene;
|
||||
boost::shared_ptr<Hedgehog::Mirage::CTextureData> m_spTextureData;
|
||||
};
|
||||
}
|
15
UnleashedRecomp/api/SWA/Inspire/InspireTextureOverlayInfo.h
Normal file
15
UnleashedRecomp/api/SWA/Inspire/InspireTextureOverlayInfo.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#pragma once
|
||||
|
||||
#include <SWA.inl>
|
||||
|
||||
namespace SWA::Inspire
|
||||
{
|
||||
class CInspireTextureOverlayInfo
|
||||
{
|
||||
public:
|
||||
Hedgehog::Base::CSharedString m_CameraName;
|
||||
be<uint32_t> m_Unk1;
|
||||
be<uint32_t> m_Unk2;
|
||||
be<uint32_t> m_Unk3;
|
||||
};
|
||||
}
|
|
@ -11,23 +11,24 @@ namespace SWA::Sequence::Utility
|
|||
class CRender : public Hedgehog::Mirage::CRenderable
|
||||
{
|
||||
public:
|
||||
struct SVertexData
|
||||
{
|
||||
be<float> X;
|
||||
be<float> Y;
|
||||
be<float> Z;
|
||||
be<float> U;
|
||||
be<float> V;
|
||||
};
|
||||
|
||||
be<uint32_t> m_ScreenWidth;
|
||||
be<uint32_t> m_ScreenHeight;
|
||||
be<float> m_MovieWidth;
|
||||
be<float> m_MovieHeight;
|
||||
SWA_INSERT_PADDING(0x74);
|
||||
be<float> m_TopLeftX;
|
||||
be<float> m_TopLeftY;
|
||||
SWA_INSERT_PADDING(0x0C);
|
||||
be<float> m_TopRightX;
|
||||
be<float> m_TopRightY;
|
||||
SWA_INSERT_PADDING(0x0C);
|
||||
be<float> m_BottomRightX;
|
||||
be<float> m_BottomRightY;
|
||||
SWA_INSERT_PADDING(0x0C);
|
||||
be<float> m_BottomLeftX;
|
||||
be<float> m_BottomLeftY;
|
||||
SWA_INSERT_PADDING(0xD4);
|
||||
SVertexData m_TopLeft;
|
||||
SVertexData m_TopRight;
|
||||
SVertexData m_BottomRight;
|
||||
SVertexData m_BottomLeft;
|
||||
bool m_MaintainAspectRatio;
|
||||
SWA_INSERT_PADDING(0x18);
|
||||
be<float> m_TimeElapsed;
|
||||
|
|
|
@ -92,6 +92,10 @@ PixelShaderOutput main(in Interpolators In)
|
|||
Out.Color.b = ValY + ValU * 2.017;
|
||||
}
|
||||
Out.Color.a = ValA;
|
||||
|
||||
if (any(In.UV < 0.0) || any(In.UV > 1.0))
|
||||
Out.Color.rgb = 0.0;
|
||||
|
||||
Out.Depth = ValD;
|
||||
return Out;
|
||||
}
|
||||
|
|
|
@ -275,23 +275,6 @@ CONFIG_DEFINE_LOCALE(XboxColorCorrection)
|
|||
{ ELanguage::English, { "Xbox Color Correction", "Use the warm tint from the Xbox version of the game." } }
|
||||
};
|
||||
|
||||
CONFIG_DEFINE_LOCALE(MovieScaleMode)
|
||||
{
|
||||
{ ELanguage::English, { "Movie Scale Mode", "Change how the movie player scales to the display." } }
|
||||
};
|
||||
|
||||
CONFIG_DEFINE_ENUM_LOCALE(EMovieScaleMode)
|
||||
{
|
||||
{
|
||||
ELanguage::English,
|
||||
{
|
||||
{ EMovieScaleMode::Stretch, { "STRETCH", "Stretch: the movie will stretch to the display." } },
|
||||
{ EMovieScaleMode::Fit, { "FIT", "Fit: the movie will maintain its aspect ratio and fit to the display." } },
|
||||
{ EMovieScaleMode::Fill, { "FILL", "Fill: the movie will scale past the bounds of the display if it doesn't match the aspect ratio." } },
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
CONFIG_DEFINE_LOCALE(UIScaleMode)
|
||||
{
|
||||
{ ELanguage::English, { "UI Scale Mode", "Change how the UI scales to the display." } }
|
||||
|
|
|
@ -2,27 +2,62 @@
|
|||
#include <api/SWA.h>
|
||||
#include <ui/game_window.h>
|
||||
|
||||
// TODO: to be removed.
|
||||
constexpr float m_baseAspectRatio = 16.0f / 9.0f;
|
||||
using SVertexData = SWA::Sequence::Utility::CPlayMovieWrapper::CRender::SVertexData;
|
||||
|
||||
// TODO: to be removed.
|
||||
void CSDAspectRatioMidAsmHook(PPCRegister& f1, PPCRegister& f2)
|
||||
// Update movie player aspect ratio.
|
||||
PPC_FUNC_IMPL(__imp__sub_82AE30D8);
|
||||
PPC_FUNC(sub_82AE30D8)
|
||||
{
|
||||
if (Config::UIScaleMode == EUIScaleMode::Stretch)
|
||||
return;
|
||||
auto movieWidth = *(be<float>*)g_memory.Translate(ctx.r4.u32 - 0x10);
|
||||
auto movieHeight = *(be<float>*)g_memory.Translate(ctx.r4.u32 - 0x0C);
|
||||
auto movieAspectRatio = movieWidth / movieHeight;
|
||||
auto windowAspectRatio = (float)GameWindow::s_width / (float)GameWindow::s_height;
|
||||
|
||||
auto newAspectRatio = (float)GameWindow::s_width / (float)GameWindow::s_height;
|
||||
auto pTopLeft = (SVertexData*)g_memory.Translate(ctx.r4.u32 + 0x6C);
|
||||
auto pTopRight = (SVertexData*)g_memory.Translate(ctx.r4.u32 + 0x6C + sizeof(SVertexData));
|
||||
auto pBottomRight = (SVertexData*)g_memory.Translate(ctx.r4.u32 + 0x6C + sizeof(SVertexData) * 2);
|
||||
auto pBottomLeft = (SVertexData*)g_memory.Translate(ctx.r4.u32 + 0x6C + sizeof(SVertexData) * 3);
|
||||
|
||||
if (newAspectRatio > m_baseAspectRatio)
|
||||
auto a = -1.00078f;
|
||||
auto b = 1.00139f;
|
||||
auto scaleU = 1.0f;
|
||||
auto scaleV = 1.0f;
|
||||
auto centreV = (pTopLeft->V + pBottomRight->V) / 2.0f;
|
||||
|
||||
if (windowAspectRatio > movieAspectRatio)
|
||||
{
|
||||
f1.f64 = 1280.0f / ((newAspectRatio * 720.0f) / 1280.0f);
|
||||
scaleU = movieAspectRatio / windowAspectRatio;
|
||||
}
|
||||
else if (newAspectRatio < m_baseAspectRatio)
|
||||
else
|
||||
{
|
||||
f2.f64 = 720.0f / ((1280.0f / newAspectRatio) / 720.0f);
|
||||
scaleV = windowAspectRatio / movieAspectRatio;
|
||||
}
|
||||
|
||||
pTopLeft->X = a;
|
||||
pTopLeft->Y = b;
|
||||
pTopLeft->U = (pTopLeft->U - centreV) / scaleU + centreV;
|
||||
pTopLeft->V = (pTopLeft->V - centreV) / scaleV + centreV;
|
||||
|
||||
pTopRight->X = b;
|
||||
pTopRight->Y = b;
|
||||
pTopRight->U = (pTopRight->U - centreV) / scaleU + centreV;
|
||||
pTopRight->V = (pTopRight->V - centreV) / scaleV + centreV;
|
||||
|
||||
pBottomLeft->X = a;
|
||||
pBottomLeft->Y = a;
|
||||
pBottomLeft->U = (pBottomLeft->U - centreV) / scaleU + centreV;
|
||||
pBottomLeft->V = (pBottomLeft->V - centreV) / scaleV + centreV;
|
||||
|
||||
pBottomRight->X = b;
|
||||
pBottomRight->Y = a;
|
||||
pBottomRight->U = (pBottomRight->U - centreV) / scaleU + centreV;
|
||||
pBottomRight->V = (pBottomRight->V - centreV) / scaleV + centreV;
|
||||
|
||||
__imp__sub_82AE30D8(ctx, base);
|
||||
}
|
||||
|
||||
void RemoveMoviePlayerLetterboxMidAsmHook() {}
|
||||
|
||||
bool MotionBlurMidAsmHook()
|
||||
{
|
||||
return Config::MotionBlur != EMotionBlur::Off;
|
||||
|
|
|
@ -910,7 +910,6 @@ static void DrawConfigOptions()
|
|||
DrawConfigOption(rowCount++, yOffset, &Config::GITextureFiltering, true);
|
||||
DrawConfigOption(rowCount++, yOffset, &Config::MotionBlur, true);
|
||||
DrawConfigOption(rowCount++, yOffset, &Config::XboxColorCorrection, true);
|
||||
DrawConfigOption(rowCount++, yOffset, &Config::MovieScaleMode, true);
|
||||
DrawConfigOption(rowCount++, yOffset, &Config::UIScaleMode, true);
|
||||
|
||||
break;
|
||||
|
|
|
@ -117,7 +117,6 @@ void LoadThumbnails()
|
|||
g_xboxColorCorrectionThumbnails[false] = LOAD_ZSTD_TEXTURE(g_xbox_color_correction_false);
|
||||
g_xboxColorCorrectionThumbnails[true] = LOAD_ZSTD_TEXTURE(g_xbox_color_correction_true);
|
||||
|
||||
g_configThumbnails[&Config::MovieScaleMode] = LOAD_ZSTD_TEXTURE(g_movie_scale_mode);
|
||||
g_configThumbnails[&Config::UIScaleMode] = LOAD_ZSTD_TEXTURE(g_ui_scale_mode);
|
||||
}
|
||||
|
||||
|
|
|
@ -252,20 +252,6 @@ CONFIG_DEFINE_ENUM_TEMPLATE(EMotionBlur)
|
|||
{ "Enhanced", EMotionBlur::Enhanced }
|
||||
};
|
||||
|
||||
enum class EMovieScaleMode : uint32_t
|
||||
{
|
||||
Stretch,
|
||||
Fit,
|
||||
Fill
|
||||
};
|
||||
|
||||
CONFIG_DEFINE_ENUM_TEMPLATE(EMovieScaleMode)
|
||||
{
|
||||
{ "Stretch", EMovieScaleMode::Stretch },
|
||||
{ "Fit", EMovieScaleMode::Fit },
|
||||
{ "Fill", EMovieScaleMode::Fill }
|
||||
};
|
||||
|
||||
enum class EUIScaleMode : uint32_t
|
||||
{
|
||||
Stretch,
|
||||
|
@ -662,7 +648,6 @@ public:
|
|||
CONFIG_DEFINE_ENUM("Video", EDepthOfFieldQuality, DepthOfFieldQuality, EDepthOfFieldQuality::Auto);
|
||||
CONFIG_DEFINE_ENUM_LOCALISED("Video", EMotionBlur, MotionBlur, EMotionBlur::Original);
|
||||
CONFIG_DEFINE_LOCALISED("Video", bool, XboxColorCorrection, false);
|
||||
CONFIG_DEFINE_ENUM_LOCALISED("Video", EMovieScaleMode, MovieScaleMode, EMovieScaleMode::Fit);
|
||||
CONFIG_DEFINE_ENUM_LOCALISED("Video", EUIScaleMode, UIScaleMode, EUIScaleMode::Edge);
|
||||
|
||||
// TODO: remove these once the exports are implemented.
|
||||
|
|
|
@ -102,11 +102,6 @@ address = 0x8246BDA0
|
|||
registers = ["r31", "f0", "f10", "f12"]
|
||||
jump_address_on_true = 0x8246BDAC
|
||||
|
||||
[[midasm_hook]]
|
||||
name = "CSDAspectRatioMidAsmHook"
|
||||
address = 0x830C0A28
|
||||
registers = ["f1", "f2"]
|
||||
|
||||
[[midasm_hook]]
|
||||
name = "ResetScoreOnRestartMidAsmHook"
|
||||
address = 0x82304374
|
||||
|
@ -590,3 +585,8 @@ address = 0x825360C8
|
|||
registers = ["r31"]
|
||||
jump_address_on_true = 0x825360C8
|
||||
jump_address_on_false = 0x82536140
|
||||
|
||||
[[midasm_hook]]
|
||||
name = "RemoveMoviePlayerLetterboxMidAsmHook"
|
||||
address = 0x82B723A8
|
||||
jump_address = 0x82B723BC
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue