feat: add triangulate-tangents example witnessing the mikktspace contract#87
Merged
Conversation
…ract A game engine's normal mapping lives or dies by the tangent frame: the basis must be unit and orthogonal, follow the UVs, and carry a consistent bitangent sign. This example verifies all of it on a machined buckler with three UV chart styles, against the independently derived edge/UV formula, plus the two hazards that actually bite: calc_tangents aborting on any ngon, and a MeshUVLoopLayer handle dangling across the call on 4.5 (471 phantom flips, silent exit 0) while the mikktspace math is byte-identical on 4.5.11 and 5.1.2. Signed-off-by: fOuttaMyPaint <TMhospitalitystrategies@gmail.com>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The fourth direction of the game-asset pipeline arc (from the ROADMAP pool): a machined buckler — lathed dome with polar UVs, unwrapped rim/underside strips, fanned back cap — verifying the tangent-space contract a game engine's normal mapping depends on.
Contract witnessed
calc_loop_trianglesyields the closed-form count (720 = 2×336 quads + 48-cap fan); every loop tangent is unit (err 1.34e-07) and orthogonal to its normal (err 5.96e-08); bitangent exactlysign * (n × t)(err 0.0). One ngon anywhere andcalc_tangentsaborts the whole call — the cap is a fan for that reason (caught live during authoring).MeshUVLoopLayerhandle held acrosscalc_tangents()dangles: on 4.5.11 reads return garbage — measured as 471 phantom flips + 385 phantom seam positions, exit 0, a silent wrong answer. On 5.1.2 the same stale read survives by luck. The mikktspace math is byte-identical on both versions; the apparent 471-vs-9 "version divergence" I first measured was entirely the corrupt handle.Version witness: mikktspace output identical on 4.5.11 and 5.1.2 (same weld deviations, same seam flips);
calc_tangents(uvmap=)signature stable; the lifetime hazard is the only behavioral split.Falsification evidence (temporary breaks in scratch copies, restored after measurement):
Contact-sheet gate: triangulate-tangents-contact-sheet.webp — verdicts: stage darkness ✓, wedge warmth ✓, subject fill ✓, saturation ✓ (monochrome machined steel, bmesh-gear's sibling), thumbnail legibility ✓ (disc + cradle reads instantly). Mean luminance 139.7 vs calibration 139.4 / 100.1 / 143.4 — mid-range.
Proven by live run vs inspection:
.scratch/blender-5.1.2-windows-x64/blender.exe(Blender 5.1.2, hash ec6e62d40fa9) and.scratch/blender-4.5.11-windows-x64/blender.exe(Blender 4.5.11 LTS, hash 4db51e9d1e1e) — identical printed values (tris=720 unit=1.34e-07 dot=5.96e-08 btn=0 weld=2.27e-06 clean_flips=0 seam_flips=42 chart_flips=9). Render exit 0 on both binaries (EEVEE), pixels iterated (3 drafts: zebra/clip fix, cradle, hot-region check). All probes live as tabled.Test plan
27 examples)examples/triangulate-tangents/triangulate_tangents.py --.scratch/blender-5.1.2-windows-x64/blender.exe(5.1.2),.scratch/blender-4.5.11-windows-x64/blender.exe(4.5.11 LTS)Integration: example dir + README, gallery.json entry (alt 126 chars, no cap truncation), plugin manifest, smoke step, top-level README ("Game asset pipeline" category now 4, counts 26→27), generated pages read character-by-character, ROADMAP drained (subject shipped) and restocked (UV-handle lifetime snippet).
🤖 Generated with Kimi Code