diff --git a/GPU/Common/ShaderUniforms.cpp b/GPU/Common/ShaderUniforms.cpp index f8fb3456e912..46ad4470e245 100644 --- a/GPU/Common/ShaderUniforms.cpp +++ b/GPU/Common/ShaderUniforms.cpp @@ -30,16 +30,18 @@ void CalcCullRange(float minValues[4], float maxValues[4], bool flipViewport, bo // Account for the projection viewport adjustment when viewport is too large. auto reverseViewportX = [](float x) { float pspViewport = (x - gstate.getViewportXCenter()) * (1.0f / gstate.getViewportXScale()); - return (pspViewport - gstate_c.vpXOffset) * gstate_c.vpWidthScale; + return (pspViewport * gstate_c.vpWidthScale) - gstate_c.vpXOffset; }; auto reverseViewportY = [flipViewport](float y) { float heightScale = gstate_c.vpHeightScale; + float yOffset = gstate_c.vpYOffset; if (flipViewport) { // For D3D11 and GLES non-buffered. heightScale = -heightScale; + yOffset = -yOffset; } float pspViewport = (y - gstate.getViewportYCenter()) * (1.0f / gstate.getViewportYScale()); - return (pspViewport - gstate_c.vpYOffset) * heightScale; + return (pspViewport * heightScale) - yOffset; }; auto reverseViewportZ = [hasNegZ](float z) { float vpZScale = gstate.getViewportZScale();