From 398cc88ae21cafc2a07896bc9b1a74035c286198 Mon Sep 17 00:00:00 2001 From: emil28092005 Date: Thu, 18 Jun 2026 16:56:44 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20remove=20row=5Fmajor=20from=20GLSL=20?= =?UTF-8?q?=E2=80=94=20fixes=20fish-eye=20and=20broken=20projection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause: System.Numerics.Matrix4x4 uses row-major storage with row-vector convention (v * M). GLSL with layout(row_major) does column-vector (M * v), which effectively transposes the matrix, breaking the projection. Fix: remove row_major from layout qualifiers. GLSL then interprets the row-major data as column-major (effectively transposing it), so M * v in GLSL equals v * M in System.Numerics — correct result. The Y-flip (M22 *= -1) is still needed for Vulkan's Y-down clip space. --- .../Shaders/triangle.vert | 4 ++-- .../Shaders/triangle.vert.spv | Bin 1544 -> 1544 bytes 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Engine.Graphics.Vulkan/Shaders/triangle.vert b/src/Engine.Graphics.Vulkan/Shaders/triangle.vert index d587a87..8cfb483 100644 --- a/src/Engine.Graphics.Vulkan/Shaders/triangle.vert +++ b/src/Engine.Graphics.Vulkan/Shaders/triangle.vert @@ -6,11 +6,11 @@ layout(location = 2) in vec3 inNormal; layout(location = 0) out vec3 fragColor; -layout(row_major, set = 0, binding = 0) uniform CameraUBO { +layout(set = 0, binding = 0) uniform CameraUBO { mat4 vp; }; -layout(row_major, push_constant) uniform PC { +layout(push_constant) uniform PC { mat4 model; } pc; diff --git a/src/Engine.Graphics.Vulkan/Shaders/triangle.vert.spv b/src/Engine.Graphics.Vulkan/Shaders/triangle.vert.spv index edfeddb33d4d1e99fac4fcba0ca89073fe8ad874..7107a91cdfce10518468e6a18b36ad69da9120b0 100644 GIT binary patch delta 20 bcmeC+>EPL5z{JQp*^nujk#+M_rebCQHgyF6 delta 20 bcmeC+>EPL5z{JQh*^nujk!AB#rebCQHe&?-