diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 423b74bd27..0a0ac9dd2f 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -316,9 +316,9 @@ void UpdateVRInput(bool(*NativeAxis)(const AxisInput &axis), bool(*NativeKey)(co g_Config.fCameraHeight = clampFloat(g_Config.fCameraHeight, -50.0f, 50.0f); break; case JOYSTICK_AXIS_Z: - if (axis.second < -0.75f) g_Config.fFieldOfViewPercentage -= 1.0f; - if (axis.second > 0.75f) g_Config.fFieldOfViewPercentage += 1.0f; - g_Config.fFieldOfViewPercentage = clampFloat(g_Config.fFieldOfViewPercentage, 100.0f, 200.0f); + 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.2f, 1.0f); break; case JOYSTICK_AXIS_RZ: if (axis.second > 0.75f) g_Config.fCameraDistance -= 0.1f; @@ -430,7 +430,7 @@ bool UpdateVRKeys(const KeyInput &key) { g_Config.fCameraHeight = 0; g_Config.fCameraSide = 0; g_Config.fCameraDistance = 0; - g_Config.fFieldOfViewPercentage = 100; + g_Config.fHeadUpDisplayScale = 0.3f; } //block keys by camera adjust @@ -727,7 +727,7 @@ bool Is2DVRObject(float* projMatrix, bool ortho) { if (!identity && !ortho) { vr3DGeometryCount++; } - return identity; + return identity || ortho; } void UpdateVRParams(float* projMatrix, float* viewMatrix) { diff --git a/Core/Config.cpp b/Core/Config.cpp index 35a05ba910..cb17b4881e 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1214,6 +1214,7 @@ static ConfigSetting vrSettings[] = { ConfigSetting("VRCameraSide", &g_Config.fCameraSide, 0.0f), ConfigSetting("VRCanvasDistance", &g_Config.fCanvasDistance, 6.0f), ConfigSetting("VRFieldOfView", &g_Config.fFieldOfViewPercentage, 100.0f), + ConfigSetting("VRHeadUpDisplayScale", &g_Config.fHeadUpDisplayScale, 0.3f), ConfigSetting("VRMotionLength", &g_Config.fMotionLength, 0.5f), ConfigSetting(false), diff --git a/Core/Config.h b/Core/Config.h index af20f6289e..8b517889b0 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -471,6 +471,7 @@ public: float fCameraSide; float fCanvasDistance; float fFieldOfViewPercentage; + float fHeadUpDisplayScale; float fMotionLength; // Debugger diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index 7195bcd8af..d36a68fe7a 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -353,6 +353,33 @@ static inline void FlipProjMatrix(Matrix4x4 &in, bool useBufferedRendering) { } } +static inline bool GuessVRDrawingHUD(bool is2D, bool flatScreen) { + + bool hud = true; + //HUD cannot be rendered in flatscreen + if (flatScreen) hud = false; + //HUD has to be 2D + else if (!is2D) hud = false; + //HUD has to be blended + else if (!gstate.isAlphaBlendEnabled()) hud = false; + //HUD cannot be rendered with clear color mask + else if (gstate.isClearModeColorMask()) hud = false; + //HUD cannot be rendered with fog on + else if (gstate.isFogEnabled()) hud = false; + //HUD cannot be rendered with lights on + else if (gstate.isLightingEnabled()) hud = false; + //HUD texture has to contain alpha channel + else if (!gstate.isTextureAlphaUsed()) hud = false; + //HUD cannot have full alpha + else if (gstate_c.textureFullAlpha) hud = false; + //HUD cannot render FB screenshot + else if (gstate_c.curTextureHeight == 272) hud = false; + //HUD cannot render far plane + else if ((fabs(gstate.viewMatrix[9]) > 100) || (fabs(gstate.viewMatrix[11]) > 100)) hud = false; + + return hud; +} + void LinkedShader::use(const ShaderID &VSID) { render_->BindProgram(program); // Note that we no longer track attr masks here - we do it for the input layouts instead. @@ -385,16 +412,9 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu // Set HUD mode if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { - bool is3D = gstate.isDepthWriteEnabled(); - bool hud = is2D && !is3D && !flatScreen && - gstate.isModeThrough() && //2D content requires orthographic projection - gstate.isAlphaBlendEnabled() && //2D content has to be blended - !gstate.isLightingEnabled() && //2D content cannot be rendered with lights on - !gstate.isFogEnabled(); //2D content cannot be rendered with fog on - if (hud) { - float scale = 0.5f; - render_->SetUniformF1(&u_scaleX, scale); - render_->SetUniformF1(&u_scaleY, scale / 480.0f * 272.0f); + if (GuessVRDrawingHUD(is2D, flatScreen)) { + render_->SetUniformF1(&u_scaleX, g_Config.fHeadUpDisplayScale * 480.0f / 272.0f); + render_->SetUniformF1(&u_scaleY, g_Config.fHeadUpDisplayScale); } else { render_->SetUniformF1(&u_scaleX, 1.0f); render_->SetUniformF1(&u_scaleY, 1.0f); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 9c483cf750..3cc50182d9 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1055,6 +1055,7 @@ void GameSettingsScreen::CreateViews() { vrSettings->Add(new ItemHeader(vr->T("VR camera"))); vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCanvasDistance, 1.0f, 15.0f, vr->T("Distance to 2D menus and scenes"), 1.0f, screenManager(), "")); vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fFieldOfViewPercentage, 100.0f, 200.0f, vr->T("Field of view scale"), 10.0f, screenManager(), vr->T("% of native FoV"))); + vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fHeadUpDisplayScale, 0.2f, 1.0f, vr->T("Heads-up display scale"), 0.1f, screenManager(), "")); vrSettings->Add(new ItemHeader(vr->T("VR controllers"))); vrSettings->Add(new CheckBox(&g_Config.bEnableMotions, vr->T("Map controller movements to keys")));