fix: cube.obj winding order — all faces now CCW from outside
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.
This commit is contained in:
+19
-19
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user