Skip to content

First Light: triangulate concave OBJ faces (ASSET-417) - #5111

Open
whattheflop wants to merge 1 commit into
ItsNotRexed:mainfrom
whattheflop:fix/first-light-concave-obj
Open

whattheflop wants to merge 1 commit into
ItsNotRexed:mainfrom
whattheflop:fix/first-light-concave-obj

Conversation

@whattheflop

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as ASSET-417. Claim · Coordinator confirmation

What and why

First Light emitted a first-corner fan for every polygon, which could draw across the notch of a concave OBJ face. Use the GLB exporter's existing triangulator for larger faces. Keep the original fan when it already fits, preserve vertex numbering and UV seams, and resolve positive forward references after reading the OBJ as before.

Tested

On Windows, uv CPython 3.12.13, CPU only. The synthetic notch test failed on upstream in both windings: the fan covered the notch and emitted 2.75 units of triangle area for a polygon of area 1.75. After the fix both windings leave the notch clear with area 1.75. The forward-reference, UV seam and valid triangle/quad/pentagon fan control matched upstream.

AI-assisted: yes.

Checklist

  • No game data, keys or decryption, including in logs or reports quoted here.

Reuse the GLB face triangulator after loading all positions. Keep corner-based vertex numbering and the existing fan for faces that do not need ear clipping.

Claim: ItsNotRexed#5032 (comment)

AI-assisted.
@whattheflop

Copy link
Copy Markdown
Contributor Author

Native Windows Radeon A/B at upstream 3faac557 and this PR's 9f9f7499, AI-assisted. Both revisions produced a mesh from the same synthetic U-shaped OBJ via First Light read_obj/write_mesh. The vertex bytes were identical. I used the same stock Release vk_harness from the PR head and the same validated hand-written GLSL position and solid-color shaders in all four 128×128 draws.

  • The 9×9 notch probe changed from 81 solid pixels to 81 clear pixels. Both arms and the base stayed solid, and the outside probe stayed clear.
  • Coverage changed from 8,448 to 7,168 pixels. All 1,280 changed pixels were in the notch. Every head pixel matched the expected polygon mask, and reversing the winding produced byte-identical readbacks within each revision.

Ryzen 7 9800X3D Radeon iGPU, AMD Windows Vulkan driver 25.10.30.02, MSVC, glslang 16.6.0, Khronos validation 1.4.363. Khronos loaded explicitly, with zero validation warnings or errors in all four runs. Synthetic inputs only.

@kacper-serewis kacper-serewis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows CPU comparison at 9f9f749 vs 3faac55: First Light read_obj returned identical ordered position/UV vertices and triangle indices for all 11,624 distinct cached model exports (14,631 paths, 78,634,922 faces). Every cached export face was triangular. An independent asymmetric concave five-corner fixture distinguished the implementations: head preserved winding, polygon area and per-corner UV assignments. Head's two focused suites passed 29 tests with four skips. No GPU or archive access. AI-assisted.

@Atomic258

Copy link
Copy Markdown
Contributor

Tested 9f9f749 on Windows Server 2022, CPython 3.13.12: pass

  • python -I tests/test_first_light_mesh_draw.py -> Ran 4 tests, OK
  • Negative control (tools/first_light.py swapped to upstream/main): FAILED (failures=2)

git diff --check clean; python -m compileall -q exit 0. No game files, no GPU. AI-assisted (Devin).

@kotekompotek

Copy link
Copy Markdown

Independent Windows CPU verification on 9f9f7499:

  • python -m pytest tests/test_first_light.py tests/test_first_light_mesh_draw.py --basetemp D:\temp\pytest_tmp -q: 29 passed, 4 skipped in 1.86s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants