Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenXR - Enhancements of cinema-style screen #17704

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions Common/VR/PPSSPPVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,15 @@ void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) {
g_Config.fCameraHeight = clampFloat(g_Config.fCameraHeight, -150.0f, 150.0f);
break;
case JOYSTICK_AXIS_Z:
if (axis.second < -0.75f) g_Config.fHeadUpDisplayScale -= 0.01f;
if (axis.second > 0.75f) g_Config.fHeadUpDisplayScale += 0.01f;
g_Config.fHeadUpDisplayScale = clampFloat(g_Config.fHeadUpDisplayScale, 0.0f, 1.5f);
if (g_Config.bEnableVR) {
if (axis.second < -0.75f) g_Config.fHeadUpDisplayScale -= 0.01f;
if (axis.second > 0.75f) g_Config.fHeadUpDisplayScale += 0.01f;
g_Config.fHeadUpDisplayScale = clampFloat(g_Config.fHeadUpDisplayScale, 0.0f, 1.5f);
} else {
if (axis.second < -0.75f) g_Config.fCanvas3DDistance += 0.1f;
if (axis.second > 0.75f) g_Config.fCanvas3DDistance -= 0.1f;
g_Config.fCanvas3DDistance = clampFloat(g_Config.fCanvas3DDistance, 1.0f, 15.0f);
}
break;
case JOYSTICK_AXIS_RZ:
if (axis.second > 0.75f) g_Config.fCameraDistance -= 0.1f;
Expand Down Expand Up @@ -432,6 +438,7 @@ void UpdateVRInput(bool haptics, float dp_xscale, float dp_yscale) {
VR_SetConfig(VR_CONFIG_MOUSE_X, (int)x);
VR_SetConfig(VR_CONFIG_MOUSE_Y, (int)y);
VR_SetConfig(VR_CONFIG_MOUSE_SIZE, 6 * (int)pow(VR_GetConfigFloat(VR_CONFIG_CANVAS_DISTANCE), 0.25f));
VR_SetConfig(VR_CONFIG_CANVAS_6DOF, g_Config.bEnable6DoF);

//inform engine about the status
TouchInput touch;
Expand Down Expand Up @@ -526,6 +533,7 @@ bool UpdateVRKeys(const KeyInput &key) {

// Reset camera adjust
if (pspKeys[VIRTKEY_VR_CAMERA_ADJUST] && pspKeys[VIRTKEY_VR_CAMERA_RESET]) {
g_Config.fCanvas3DDistance = 3.0f;
g_Config.fCameraHeight = 0;
g_Config.fCameraSide = 0;
g_Config.fCameraDistance = 0;
Expand Down Expand Up @@ -672,7 +680,7 @@ bool StartVRRender() {

// Set customizations
__DisplaySetFramerate(g_Config.bForce72Hz ? 72 : 60);
VR_SetConfigFloat(VR_CONFIG_CANVAS_DISTANCE, g_Config.fCanvasDistance);
VR_SetConfigFloat(VR_CONFIG_CANVAS_DISTANCE, vrScene && (appMode == VR_GAME_MODE) ? g_Config.fCanvas3DDistance : g_Config.fCanvasDistance);
VR_SetConfig(VR_CONFIG_PASSTHROUGH, g_Config.bPassthrough);
return true;
}
Expand Down
15 changes: 8 additions & 7 deletions Common/VR/VRRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,14 +428,15 @@ void VR_FinishFrame( engine_t* engine ) {
} else if ((vrMode == VR_MODE_MONO_SCREEN) || (vrMode == VR_MODE_STEREO_SCREEN)) {

// Flat screen pose
float distance = VR_GetConfigFloat(VR_CONFIG_CANVAS_DISTANCE);
float distance = VR_GetConfigFloat(VR_CONFIG_CANVAS_DISTANCE) / 4.0f - 1.0f;
float menuPitch = ToRadians(VR_GetConfigFloat(VR_CONFIG_MENU_PITCH));
float menuYaw = ToRadians(VR_GetConfigFloat(VR_CONFIG_MENU_YAW));
XrVector3f pos = {
invViewTransform[0].position.x - sinf(menuYaw) * distance,
invViewTransform[0].position.y,
invViewTransform[0].position.z - cosf(menuYaw) * distance
};
XrVector3f pos = {-sinf(menuYaw) * distance, 0, -cosf(menuYaw) * distance};
if (!VR_GetConfig(VR_CONFIG_CANVAS_6DOF)) {
pos.x += invViewTransform[0].position.x;
pos.y += invViewTransform[0].position.y;
pos.z += invViewTransform[0].position.z;
}
XrQuaternionf pitch = XrQuaternionf_CreateFromVectorAngle({1, 0, 0}, -menuPitch);
XrQuaternionf yaw = XrQuaternionf_CreateFromVectorAngle({0, 1, 0}, menuYaw);

Expand All @@ -453,7 +454,7 @@ void VR_FinishFrame( engine_t* engine ) {
cylinder_layer.subImage.imageArrayIndex = 0;
cylinder_layer.pose.orientation = XrQuaternionf_Multiply(pitch, yaw);
cylinder_layer.pose.position = pos;
cylinder_layer.radius = 12.0f;
cylinder_layer.radius = 2.0f;
cylinder_layer.centralAngle = (float)(M_PI * 0.5);
cylinder_layer.aspectRatio = VR_GetConfigFloat(VR_CONFIG_CANVAS_ASPECT);

Expand Down
2 changes: 1 addition & 1 deletion Common/VR/VRRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

enum VRConfig {
//switching between mode
VR_CONFIG_MODE, VR_CONFIG_PASSTHROUGH,
VR_CONFIG_MODE, VR_CONFIG_PASSTHROUGH, VR_CONFIG_CANVAS_6DOF,
//mouse cursor
VR_CONFIG_MOUSE_SIZE, VR_CONFIG_MOUSE_X, VR_CONFIG_MOUSE_Y,
//viewport setup
Expand Down
1 change: 1 addition & 0 deletions Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,7 @@ static const ConfigSetting vrSettings[] = {
ConfigSetting("VRCameraSide", &g_Config.fCameraSide, 0.0f, CfgFlag::PER_GAME),
ConfigSetting("VRCameraPitch", &g_Config.iCameraPitch, 0, CfgFlag::PER_GAME),
ConfigSetting("VRCanvasDistance", &g_Config.fCanvasDistance, 12.0f, CfgFlag::DEFAULT),
ConfigSetting("VRCanvas3DDistance", &g_Config.fCanvas3DDistance, 3.0f, CfgFlag::DEFAULT),
ConfigSetting("VRFieldOfView", &g_Config.fFieldOfViewPercentage, 100.0f, CfgFlag::PER_GAME),
ConfigSetting("VRHeadUpDisplayScale", &g_Config.fHeadUpDisplayScale, 0.3f, CfgFlag::PER_GAME),
ConfigSetting("VRMotionLength", &g_Config.fMotionLength, 0.5f, CfgFlag::DEFAULT),
Expand Down
1 change: 1 addition & 0 deletions Core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ struct Config {
float fCameraHeight;
float fCameraSide;
float fCanvasDistance;
float fCanvas3DDistance;
float fFieldOfViewPercentage;
float fHeadUpDisplayScale;
float fMotionLength;
Expand Down
4 changes: 2 additions & 2 deletions UI/GameSettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1085,8 +1085,7 @@ void GameSettingsScreen::CreateVRSettings(UI::ViewGroup *vrSettings) {

vrSettings->Add(new ItemHeader(vr->T("Virtual reality")));
vrSettings->Add(new CheckBox(&g_Config.bEnableVR, vr->T("Virtual reality")));
CheckBox *vr6DoF = vrSettings->Add(new CheckBox(&g_Config.bEnable6DoF, vr->T("6DoF movement")));
vr6DoF->SetEnabledPtr(&g_Config.bEnableVR);
vrSettings->Add(new CheckBox(&g_Config.bEnable6DoF, vr->T("6DoF movement")));
vrSettings->Add(new CheckBox(&g_Config.bEnableStereo, vr->T("Stereoscopic vision (Experimental)")));
vrSettings->Add(new CheckBox(&g_Config.bForce72Hz, vr->T("Force 72Hz update")));
if (IsPassthroughSupported()) {
Expand All @@ -1095,6 +1094,7 @@ void GameSettingsScreen::CreateVRSettings(UI::ViewGroup *vrSettings) {

vrSettings->Add(new ItemHeader(vr->T("VR camera")));
vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCanvasDistance, 1.0f, 15.0f, 12.0f, vr->T("Distance to 2D menus and scenes"), 1.0f, screenManager(), ""));
vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCanvas3DDistance, 1.0f, 15.0f, 3.0f, vr->T("Distance to 3D scenes when VR disabled"), 1.0f, screenManager(), ""));
vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fFieldOfViewPercentage, 100.0f, 200.0f, 100.0f, vr->T("Field of view scale"), 10.0f, screenManager(), vr->T("% of native FoV")));
vrSettings->Add(new CheckBox(&g_Config.bRescaleHUD, vr->T("Heads-up display detection")));
PopupSliderChoiceFloat* vrHudScale = vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fHeadUpDisplayScale, 0.0f, 1.5f, 0.3f, vr->T("Heads-up display scale"), 0.1f, screenManager(), ""));
Expand Down