diff --git a/Common/GPU/OpenGL/GLRenderManager.cpp b/Common/GPU/OpenGL/GLRenderManager.cpp index 4a4fee3a30..ebeb4ee346 100644 --- a/Common/GPU/OpenGL/GLRenderManager.cpp +++ b/Common/GPU/OpenGL/GLRenderManager.cpp @@ -221,7 +221,7 @@ bool GLRenderManager::ThreadFrame() { VR_SetConfig(VR_CONFIG_3D_GEOMETRY_COUNT, VR_GetConfig(VR_CONFIG_3D_GEOMETRY_COUNT) / 2); // Set customizations - VR_SetConfig(VR_CONFIG_6DOF, g_Config.bEnable6DoF); + VR_SetConfig(VR_CONFIG_6DOF_ENABLED, g_Config.bEnable6DoF); VR_SetConfig(VR_CONFIG_FOV_SCALE, g_Config.iFieldOfViewPercentage); // hack to quick enable 2D mode in game diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index 3cf9b9c5ac..f772fe283e 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -477,10 +477,11 @@ ovrMatrix4f VR_GetMatrix( VRMatrix matrix ) { } output = ovrMatrix4f_CreateFromQuaternion(&invView.orientation); - if (vrConfig[VR_CONFIG_6DOF]) { - output.M[0][3] -= hmdposition.x * (vrConfig[VR_CONFIG_MIRROR_AXIS_X] ? -1.0f : 1.0f); - output.M[1][3] -= hmdposition.y * (vrConfig[VR_CONFIG_MIRROR_AXIS_Y] ? -1.0f : 1.0f); - output.M[2][3] -= hmdposition.z * (vrConfig[VR_CONFIG_MIRROR_AXIS_Z] ? -1.0f : 1.0f); + if (vrConfig[VR_CONFIG_6DOF_ENABLED]) { + float scale = (float)VR_GetConfig(VR_CONFIG_6DOF_SCALE) * 0.001f; + output.M[0][3] -= hmdposition.x * (vrConfig[VR_CONFIG_MIRROR_AXIS_X] ? -1.0f : 1.0f) * scale; + output.M[1][3] -= hmdposition.y * (vrConfig[VR_CONFIG_MIRROR_AXIS_Y] ? -1.0f : 1.0f) * scale; + output.M[2][3] -= hmdposition.z * (vrConfig[VR_CONFIG_MIRROR_AXIS_Z] ? -1.0f : 1.0f) * scale; } } else { assert(false); diff --git a/Common/VR/VRRenderer.h b/Common/VR/VRRenderer.h index 70ac5b288c..3e41a0bef5 100644 --- a/Common/VR/VRRenderer.h +++ b/Common/VR/VRRenderer.h @@ -5,7 +5,8 @@ enum VRConfig { VR_CONFIG_MODE, - VR_CONFIG_6DOF, + VR_CONFIG_6DOF_ENABLED, + VR_CONFIG_6DOF_SCALE, VR_CONFIG_MIRROR_AXIS_X, VR_CONFIG_MIRROR_AXIS_Y, VR_CONFIG_MIRROR_AXIS_Z, diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index edfdb0cdc3..9bc11320f2 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -538,6 +538,10 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu ConvertMatrix4x3To4x4Transposed(m4x4, gstate.viewMatrix); memcpy(gameView.M, m4x4, 16 * sizeof(float)); + // Set 6DoF scale + float scale = pow(fabs(gstate.projMatrix[14]), 1.15f); + VR_SetConfig(VR_CONFIG_6DOF_SCALE, (int)(scale * 1000)); + // Get view matrix from the headset ovrMatrix4f hmdView = VR_GetMatrix(VR_VIEW_MATRIX_LEFT_EYE);