diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index b1ae563c08..16c69f92e4 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -122,11 +122,21 @@ void VertexShaderManager::SetProjectionMatrix(XFStateManager& xf_state_manager) if (xf_state_manager.DidProjectionChange() || g_freelook_camera.GetController()->IsDirty()) { xf_state_manager.ResetProjection(); - auto corrected_matrix = LoadProjectionMatrix(); + auto corrected_matrix = LoadProjectionMatrix() * m_last_camera_modifier; memcpy(constants.projection.data(), corrected_matrix.data.data(), 4 * sizeof(float4)); } } +void VertexShaderManager::ForceProjectionMatrixUpdate(XFStateManager& xf_state_manager, + const Common::Matrix44& modifier) +{ + m_last_camera_modifier = modifier; + xf_state_manager.ResetProjection(); + auto corrected_matrix = LoadProjectionMatrix() * m_last_camera_modifier; + memcpy(constants.projection.data(), corrected_matrix.data.data(), 4 * sizeof(float4)); + dirty = true; +} + bool VertexShaderManager::UseVertexDepthRange() { // We can't compute the depth range in the vertex shader if we don't support depth clamp. @@ -388,7 +398,7 @@ void VertexShaderManager::SetConstants(XFStateManager& xf_state_manager) { xf_state_manager.ResetProjection(); - auto corrected_matrix = LoadProjectionMatrix(); + auto corrected_matrix = LoadProjectionMatrix() * m_last_camera_modifier; memcpy(constants.projection.data(), corrected_matrix.data.data(), 4 * sizeof(float4)); dirty = true; diff --git a/Source/Core/VideoCommon/VertexShaderManager.h b/Source/Core/VideoCommon/VertexShaderManager.h index 4ba4b6216b..e29c2b6267 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.h +++ b/Source/Core/VideoCommon/VertexShaderManager.h @@ -25,6 +25,8 @@ public: // constant management void SetProjectionMatrix(XFStateManager& xf_state_manager); + void ForceProjectionMatrixUpdate(XFStateManager& xf_state_manager, + const Common::Matrix44& modifier); void SetConstants(XFStateManager& xf_state_manager); // data: 3 floats representing the X, Y and Z vertex model coordinates and the posmatrix index. @@ -81,5 +83,7 @@ private: alignas(16) std::array m_projection_matrix; // track changes + Common::Matrix44 m_last_camera_modifier = Common::Matrix44::Identity(); + Common::Matrix44 LoadProjectionMatrix(); };