Merge pull request #5096 from Armada651/anything-with-a-viewport

VertexShaderGen: Correct for negative viewport dimensions.
This commit is contained in:
Markus Wick 2017-03-20 10:55:56 +01:00 committed by GitHub
commit 5cc55f0fe3
1 changed files with 4 additions and 0 deletions

View File

@ -453,6 +453,10 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const vertex_shader_uid_da
out.Write("o.pos.z = o.pos.z * 2.0 - o.pos.w;\n");
}
// Correct for negative viewports by mirroring all vertices. We need to negate the height here,
// since the viewport height is already negated by the render backend.
out.Write("o.pos.xy *= sign(" I_PIXELCENTERCORRECTION ".xy * float2(1.0, -1.0));\n");
// The console GPU places the pixel center at 7/12 in screen space unless
// antialiasing is enabled, while D3D and OpenGL place it at 0.5. This results
// in some primitives being placed one pixel too far to the bottom-right,