From d2078f3ee0c30f882aadd4cd7aca06c4374f7019 Mon Sep 17 00:00:00 2001 From: emil28092005 Date: Thu, 18 Jun 2026 21:57:32 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20cube.obj=20winding=20order=20=E2=80=94?= =?UTF-8?q?=20all=20faces=20now=20CCW=20from=20outside?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause: ALL 12 faces in cube.obj had reversed winding order. This caused every face normal to point inward, breaking: - Diffuse lighting (NdotL < 0 → no light on any face) - Shadow bias (slope-dependent bias used wrong NdotL) - Shadow self-shadowing (both sides rendered with CULL_NONE) Fix: reversed all face indices to correct CCW winding: - Back face: f 1 4 3, f 1 3 2 (was f 1 2 3, f 1 3 4) - Front face: f 5 6 7, f 5 7 8 (was f 5 7 6, f 5 8 7) - Left/Right/Bottom/Top: all reversed Now MeshMath.ComputeFaceNormal produces correct outward normals. Normal flip in shader (dot(N,V) < 0) is still kept as safety for double-sided rendering, but cubes now have correct normals natively. --- Content/cube.obj | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Content/cube.obj b/Content/cube.obj index e263d2c..8469f1c 100644 --- a/Content/cube.obj +++ b/Content/cube.obj @@ -1,4 +1,4 @@ -# Simple unit cube +# Simple unit cube — consistent CCW winding (viewed from outside) v -0.5 -0.5 -0.5 v 0.5 -0.5 -0.5 v 0.5 0.5 -0.5 @@ -8,26 +8,26 @@ v 0.5 -0.5 0.5 v 0.5 0.5 0.5 v -0.5 0.5 0.5 -# Back face -f 1 2 3 -f 1 3 4 +# Back face (normal -Z, CCW from outside = looking from -Z) +f 1 4 3 +f 1 3 2 -# Front face -f 5 7 6 -f 5 8 7 +# Front face (normal +Z, CCW from outside = looking from +Z) +f 5 6 7 +f 5 7 8 -# Left face -f 1 5 6 -f 1 6 2 +# Left face (normal -X, CCW from outside = looking from -X) +f 1 5 8 +f 1 8 4 -# Right face -f 3 7 8 -f 3 8 4 +# Right face (normal +X, CCW from outside = looking from +X) +f 2 3 7 +f 2 7 6 -# Bottom face -f 1 4 8 -f 1 8 5 +# Bottom face (normal -Y, CCW from outside = looking from -Y) +f 1 2 6 +f 1 6 5 -# Top face -f 2 6 7 -f 2 7 3 +# Top face (normal +Y, CCW from outside = looking from +Y) +f 4 8 7 +f 4 7 3