From 813ba593e3fe263c79139fc8fe4079e2570155be Mon Sep 17 00:00:00 2001 From: Yuval Dolev Date: Sun, 5 Jan 2020 03:44:16 +0200 Subject: [PATCH] Fixed flipped projection matrix. --- metal/4ed_metal_render.mm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/metal/4ed_metal_render.mm b/metal/4ed_metal_render.mm index 442a3e50..99a6de2f 100644 --- a/metal/4ed_metal_render.mm +++ b/metal/4ed_metal_render.mm @@ -73,7 +73,7 @@ vertexShader(uint vertexID [[vertex_id]], // To convert from positions in pixel space to positions in clip-space, // divide the pixel coordinates by half the size of the viewport. - out.position = float4(pixelSpacePosition, 0.0, 1.0) * projMatrix; + out.position = projMatrix * float4(pixelSpacePosition, 0.0, 1.0); // Pass the input color directly to the rasterizer. out.color = vertices[vertexID].color; @@ -315,7 +315,7 @@ metal_render(Metal_Renderer *renderer, Render_Target *t){ 0.0f, 2.0f / (top - bottom), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f / (far_depth - near_depth), 0.0f, -((right + left) / (right - left)), -((top + bottom) / (top - bottom)), - (-near_depth) * (far_depth - near_depth), 1.0f + (-near_depth) / (far_depth - near_depth), 1.0f }; float sLength = 1.0f / (right - left); @@ -330,21 +330,21 @@ metal_render(Metal_Renderer *renderer, Render_Target *t){ P.x = 2.0f * sLength; P.y = 0.0f; P.z = 0.0f; - P.w = -((right + left) / (right - left)); + P.w = 0.0f; Q.x = 0.0f; Q.y = 2.0f * sHeight; Q.z = 0.0f; - Q.w = -((top + bottom) / (top - bottom)); + Q.w = 0.0f; R.x = 0.0f; R.y = 0.0f; R.z = sDepth; - R.w = -near_depth * sDepth; + R.w = 0.0f; - S.x = 0.0f; - S.y = 0.0f; - S.z = 0.0f; + S.x = -((right + left) / (right - left)); + S.y = -((top + bottom) / (top - bottom)); + S.z = -near_depth * sDepth; S.w = 1.0f; simd_float4x4 proj = simd::float4x4(P, Q, R, S);