The sample's cube and plane are wound counter-clockwise from outside #107

Merged
crowmaki merged 2 commits from fix/cube-winding into main 2026-09-07 01:28:35 +00:00
Owner

The cube indices were deliberately clockwise, on the reasoning that the projection's Y negation reverses a triangle's orientation, so a counter-clockwise face in the world would arrive clockwise on screen and be culled. That misses the second flip: Vulkan maps NDC onto a framebuffer whose Y runs down, and frontFace is judged in framebuffer space. The two flips cancel, so counter-clockwise world winding was already the front face and only the inner faces of every cube and the plane were drawn.

The plane shares the cube mesh through attach_cube_renderer, so the same change fixes it.

cube_mesh now emits 0,1,2 and 0,2,3, the misleading winding comment is gone, and the perspective comment states why Y is negated. The winding test is renamed the_cube_winds_counter_clockwise_seen_from_outside and asserts outward-facing triangles.

just test passes all 63 tests.

The cube indices were deliberately clockwise, on the reasoning that the projection's Y negation reverses a triangle's orientation, so a counter-clockwise face in the world would arrive clockwise on screen and be culled. That misses the second flip: Vulkan maps NDC onto a framebuffer whose Y runs down, and `frontFace` is judged in framebuffer space. The two flips cancel, so counter-clockwise world winding was already the front face and only the inner faces of every cube and the plane were drawn. The plane shares the cube mesh through `attach_cube_renderer`, so the same change fixes it. `cube_mesh` now emits 0,1,2 and 0,2,3, the misleading winding comment is gone, and the `perspective` comment states why Y is negated. The winding test is renamed `the_cube_winds_counter_clockwise_seen_from_outside` and asserts outward-facing triangles. `just test` passes all 63 tests.
The cube indices were deliberately clockwise, on the reasoning that the
projection's Y negation reverses a triangle's orientation, so a
counter-clockwise face in the world would arrive clockwise on screen and
be culled. That misses the second flip: Vulkan maps NDC onto a framebuffer
whose Y runs down, and frontFace is judged in framebuffer space. The two
flips cancel, so counter-clockwise world winding was already the front
face and only the inner faces of every cube and the plane were drawn.

The winding test now asserts outward-facing triangles.
The eye moves round the camera target at a constant distance, driven by
the frame delta so the rate is independent of frame rate.

The upright test projected the camera target itself, whose screen Y is
zero and whose sign is rounding noise once the eye leaves the Z axis. It
now compares points beside and above the target against the target.
crowmaki deleted branch fix/cube-winding 2026-09-07 01:28:35 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
crowmaki/cinnabar!107
No description provided.