mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
OpenXR - Tony Hawk mirroring hack better
This commit is contained in:
+15
-26
@@ -53,7 +53,7 @@ static bool vrFlatForced = false;
|
||||
static bool vrFlatGame = false;
|
||||
static float vrMatrix[VR_MATRIX_COUNT][16];
|
||||
static bool vrMirroring[VR_MIRRORING_COUNT];
|
||||
static int vrMirroringVariant = -1;
|
||||
static int vrMirroringVariant = 0;
|
||||
static XrView vrView[2];
|
||||
|
||||
static void (*NativeAxis)(const AxisInput &axis);
|
||||
@@ -626,7 +626,6 @@ bool StartVRRender() {
|
||||
bool vrStereo = !PSP_CoreParameter().compat.vrCompat().ForceMono && g_Config.bEnableStereo;
|
||||
|
||||
// Get VR status
|
||||
vrMirroringVariant = -1;
|
||||
for (int eye = 0; eye < ovrMaxNumEyes; eye++) {
|
||||
vrView[eye] = VR_GetView(eye);
|
||||
}
|
||||
@@ -746,52 +745,42 @@ bool Is2DVRObject(float* projMatrix, bool ortho) {
|
||||
return identity || ortho;
|
||||
}
|
||||
|
||||
void UpdateVRParams(float* projMatrix, float* viewMatrix) {
|
||||
void UpdateVRParams(float* projMatrix) {
|
||||
|
||||
// Set mirroring of axes
|
||||
vrMirroring[VR_MIRRORING_AXIS_X] = projMatrix[0] < 0;
|
||||
vrMirroring[VR_MIRRORING_AXIS_Y] = projMatrix[5] < 0;
|
||||
vrMirroring[VR_MIRRORING_AXIS_Z] = projMatrix[10] > 0;
|
||||
|
||||
float up = 0;
|
||||
for (int i = 4; i < 7; i++) {
|
||||
up += viewMatrix[i];
|
||||
}
|
||||
|
||||
int variant = projMatrix[0] < 0;
|
||||
int variant = 1;
|
||||
variant += projMatrix[0] < 0;
|
||||
variant += (projMatrix[5] < 0) << 1;
|
||||
variant += (projMatrix[10] < 0) << 2;
|
||||
variant += (up < 0) << 3;
|
||||
if (PSP_CoreParameter().compat.vrCompat().MirroringVariant > 0) {
|
||||
variant = PSP_CoreParameter().compat.vrCompat().MirroringVariant;
|
||||
}
|
||||
|
||||
switch (variant) {
|
||||
case 0: //e.g. ATV
|
||||
case 8: //e,g, Flatout (dynamic objects only)
|
||||
case 1: //e.g. ATV
|
||||
vrMirroring[VR_MIRRORING_PITCH] = false;
|
||||
vrMirroring[VR_MIRRORING_YAW] = true;
|
||||
vrMirroring[VR_MIRRORING_ROLL] = true;
|
||||
break;
|
||||
case 1: //e.g. Tales of the World
|
||||
case 2: //e.g. Tales of the World
|
||||
vrMirroring[VR_MIRRORING_PITCH] = false;
|
||||
vrMirroring[VR_MIRRORING_YAW] = false;
|
||||
vrMirroring[VR_MIRRORING_ROLL] = false;
|
||||
break;
|
||||
case 2: //e.g.PES 2014
|
||||
case 3: //untested
|
||||
case 5: //e.g Dante's Inferno
|
||||
case 7: //untested
|
||||
case 9: //untested
|
||||
case 10: //untested
|
||||
case 11: //untested
|
||||
case 13: //untested
|
||||
case 15: //untested
|
||||
case 3: //e.g.PES 2014
|
||||
case 4: //untested
|
||||
case 6: //e.g Dante's Inferno
|
||||
case 8: //untested
|
||||
vrMirroring[VR_MIRRORING_PITCH] = true;
|
||||
vrMirroring[VR_MIRRORING_YAW] = true;
|
||||
vrMirroring[VR_MIRRORING_ROLL] = false;
|
||||
break;
|
||||
case 4: //e.g. Assassins Creed
|
||||
case 6: //e.g. Ghost in the shell
|
||||
case 12: //e.g. GTA Vice City
|
||||
case 14: //untested
|
||||
case 5: //e.g. Assassins Creed
|
||||
case 7: //e.g. Ghost in the shell
|
||||
vrMirroring[VR_MIRRORING_PITCH] = true;
|
||||
vrMirroring[VR_MIRRORING_YAW] = false;
|
||||
vrMirroring[VR_MIRRORING_ROLL] = true;
|
||||
|
||||
@@ -56,7 +56,7 @@ bool IsFlatVRGame();
|
||||
bool IsFlatVRScene();
|
||||
bool IsGameVRScene();
|
||||
bool Is2DVRObject(float* projMatrix, bool ortho);
|
||||
void UpdateVRParams(float* projMatrix, float* viewMatrix);
|
||||
void UpdateVRParams(float* projMatrix);
|
||||
void UpdateVRProjection(float* projMatrix, float* leftEye, float* rightEye);
|
||||
void UpdateVRView(float* leftEye, float* rightEye);
|
||||
void UpdateVRViewMatrices();
|
||||
|
||||
@@ -137,6 +137,7 @@ void Compatibility::CheckVRSettings(IniFile &iniFile, const std::string &gameID)
|
||||
CheckSetting(iniFile, gameID, "ForceFlatScreen", &vrCompat_.ForceFlatScreen);
|
||||
CheckSetting(iniFile, gameID, "ForceMono", &vrCompat_.ForceMono);
|
||||
CheckSetting(iniFile, gameID, "IdentityViewHack", &vrCompat_.IdentityViewHack);
|
||||
CheckSetting(iniFile, gameID, "MirroringVariant", &vrCompat_.MirroringVariant);
|
||||
CheckSetting(iniFile, gameID, "Skyplane", &vrCompat_.Skyplane);
|
||||
CheckSetting(iniFile, gameID, "UnitsPerMeter", &vrCompat_.UnitsPerMeter);
|
||||
|
||||
@@ -159,3 +160,9 @@ void Compatibility::CheckSetting(IniFile &iniFile, const std::string &gameID, co
|
||||
iniFile.Get(option, gameID.c_str(), &value, "0");
|
||||
*flag = stof(value);
|
||||
}
|
||||
|
||||
void Compatibility::CheckSetting(IniFile &iniFile, const std::string &gameID, const char *option, int *flag) {
|
||||
std::string value;
|
||||
iniFile.Get(option, gameID.c_str(), &value, "0");
|
||||
*flag = stof(value);
|
||||
}
|
||||
|
||||
@@ -107,6 +107,7 @@ struct VRCompat {
|
||||
bool ForceMono;
|
||||
bool ForceFlatScreen;
|
||||
bool IdentityViewHack;
|
||||
int MirroringVariant;
|
||||
bool Skyplane;
|
||||
float UnitsPerMeter;
|
||||
};
|
||||
@@ -132,6 +133,7 @@ private:
|
||||
void CheckVRSettings(IniFile &iniFile, const std::string &gameID);
|
||||
void CheckSetting(IniFile &iniFile, const std::string &gameID, const char *option, bool *flag);
|
||||
void CheckSetting(IniFile &iniFile, const std::string &gameID, const char *option, float *value);
|
||||
void CheckSetting(IniFile &iniFile, const std::string &gameID, const char *option, int *value);
|
||||
|
||||
CompatFlags flags_{};
|
||||
VRCompat vrCompat_{};
|
||||
|
||||
@@ -429,6 +429,7 @@ void LinkedShader::UpdateUniforms(const ShaderID &vsid, bool useBufferedRenderin
|
||||
} else {
|
||||
UpdateVRProjection(gstate.projMatrix, leftEyeMatrix.m, rightEyeMatrix.m);
|
||||
}
|
||||
UpdateVRParams(gstate.projMatrix);
|
||||
|
||||
FlipProjMatrix(leftEyeMatrix, useBufferedRendering);
|
||||
FlipProjMatrix(rightEyeMatrix, useBufferedRendering);
|
||||
@@ -566,14 +567,13 @@ void LinkedShader::UpdateUniforms(const ShaderID &vsid, bool useBufferedRenderin
|
||||
if (dirty & DIRTY_WORLDMATRIX) {
|
||||
SetMatrix4x3(render_, &u_world, gstate.worldMatrix);
|
||||
}
|
||||
if ((dirty & DIRTY_VIEWMATRIX) || IsVREnabled()) {
|
||||
if (dirty & DIRTY_VIEWMATRIX) {
|
||||
if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) {
|
||||
float leftEyeView[16];
|
||||
float rightEyeView[16];
|
||||
ConvertMatrix4x3To4x4Transposed(leftEyeView, gstate.viewMatrix);
|
||||
ConvertMatrix4x3To4x4Transposed(rightEyeView, gstate.viewMatrix);
|
||||
if (!is2D) {
|
||||
UpdateVRParams(gstate.projMatrix, leftEyeView);
|
||||
UpdateVRView(leftEyeView, rightEyeView);
|
||||
}
|
||||
render_->SetUniformM4x4Stereo("u_view", &u_view, leftEyeView, rightEyeView);
|
||||
|
||||
+11
-1
@@ -84,7 +84,7 @@ ULUS10105 = true
|
||||
|
||||
|
||||
[IdentityViewHack]
|
||||
# Disables head tracking for render passes where view matrix is Identity
|
||||
# Disables head tracking for render passes where view matrix is identity
|
||||
|
||||
# Sonic Rivals 1
|
||||
ULES00622 = true
|
||||
@@ -95,6 +95,16 @@ ULES00940 = true
|
||||
ULUS10323 = true
|
||||
|
||||
|
||||
[MirroringVariant]
|
||||
# Forces mirroring of the view matrix
|
||||
|
||||
# Tony Hawk's Underground 2 Remix
|
||||
ULES00033 = 3
|
||||
ULES00034 = 3
|
||||
ULES00035 = 3
|
||||
ULUS10014 = 3
|
||||
|
||||
|
||||
[Skyplane]
|
||||
# Workaround to remove the background skyplane and add clearing framebuffer with a fog color.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user