From b8e155bd4a9a79109116334d54bab08e628625ef Mon Sep 17 00:00:00 2001 From: Samuliak Date: Thu, 4 Jul 2024 11:42:25 +0200 Subject: [PATCH] fix: incorrect depth map logic --- src/host_shaders/metal_shaders.metal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/host_shaders/metal_shaders.metal b/src/host_shaders/metal_shaders.metal index 8fb02b7d..9f7ba05b 100644 --- a/src/host_shaders/metal_shaders.metal +++ b/src/host_shaders/metal_shaders.metal @@ -156,12 +156,12 @@ vertex DrawVertexOutWithClip vertexDraw(DrawVertexIn in [[stage_in]], constant P out.position = in.position; // Flip the y position out.position.y = -out.position.y; - out.position.xyz /= out.position.w; + out.position.xy /= out.position.w; // Apply depth uniforms out.position.z = out.position.z * depthUniforms.depthScale + depthUniforms.depthOffset; // TODO: is this correct? - if (!depthUniforms.depthMapEnable) { // Divide z by w if depthmap enable == 0 (ie using W-buffering) + if (depthUniforms.depthMapEnable) { // Divide z by w if depthmap enable == 0 (ie using W-buffering) out.position.z /= out.position.w; }