Skip to content

feat: add gltf-export-roundtrip example witnessing glTF interchange contracts#75

Merged
TMHSDigital merged 1 commit into
mainfrom
feat/gltf-export-roundtrip
Jul 19, 2026
Merged

feat: add gltf-export-roundtrip example witnessing glTF interchange contracts#75
TMHSDigital merged 1 commit into
mainfrom
feat/gltf-export-roundtrip

Conversation

@TMHSDigital

Copy link
Copy Markdown
Owner

Summary

First example of a "game asset pipeline" arc: a sci-fi supply crate (35 beveled box shells, 3 material slots, box-mapped UVs) exported with bpy.ops.export_scene.gltf and re-imported, with the round-trip verified against the depsgraph-evaluated mesh. glTF is the game-engine interchange format, and its silent-drift conventions are classic AI-miss territory.

Contract witnessed

  1. +Y-up is baked into vertex data(x, y, z) → (x, z, −y) in the POSITION buffer, no node rotation/scale. The check parses the .gltf JSON and asserts accessor bounds equal the axis-converted evaluated bbox (measured err 0.0). export_yup=False ships Z-up data every engine displays lying down.
  2. export_apply=True ships the evaluated mesh, not the base cage — flat shading + UV seams split exactly one vertex per evaluated loop (7,560), so the on-disk POSITION count is an exact witness. export_apply=False silently writes the 624-vertex cage.
  3. The round-trip is faithful — positions (bit-exact), loop normals (≤2e-4), box-mapped UVs (≤3e-5), per-triangle material bindings; UVs are V-flipped on disk (top-left texture origin), proven by reading the .bin directly.

Version witness (probed on both binaries): exporter (109 props) and importer (20 props) RNA signatures are byte-identical between Blender 4.5.11 LTS and 5.1.2; exported JSON differs only in asset.generator (v4.5.51 vs v5.1.20). The example runs identical kwargs on both and guards the kwarg set explicitly so a future rename fails loudly. One genuine 5.x removal surfaced during authoring: Mesh.calc_normals() is gone — pinned in code comments.

Falsification evidence (temporary one-line breaks in scratch copies, 5.1.2, restored after measurement):

Probe Break Exit Measured
A export_yup=False 9 on-disk POSITION bounds err 8.400e-01 vs axis-converted bbox
B export_apply=False 10 on-disk POSITION count 624 vs 7,560 evaluated loops
C export_normals=False 10 on-disk POSITION count 2,496 vs 7,560 (no normal-driven split)

Visual / contact-sheet gate: gltf-export-roundtrip-contact-sheet.webp — candidate beside the pinned set (armature-bend, damped-track-aim, bmesh-gear). Per-criterion verdicts: stage darkness ✓ (matches the set's near-black), wedge warmth ✓ (warm pool behind both crates), subject fill ✓ (comparable to bmesh-gear/tubes), saturation ✓ (designed military palette; teal glow accents, not washed), thumbnail legibility ✓ ("two identical props" story reads at 640×360). Mean luminance: candidate 129.9 vs calibration 139.4 / 100.1 / 143.4 (sRGB luma, 0–255) — inside the set's range, not the extreme.

Proven by live run vs inspection:

  • Live run, local: check-only exit 0 on .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 measured values on both (verts=280 eval_loops=7560 disk_verts=7560 tris=3780, pos_err=0, nrm_err=6.35e-05, uv_err=3.11e-07). Render path exit 0 on both binaries (EEVEE), pixels iterated on this machine (4 drafts; framing/clip/design revisions). Falsification probes above all live on 5.1.2.
  • Live run, CI: both smoke series (4.5 LTS, 5.1) on the PR head SHA — see checks below.
  • Inspection only: nothing claims otherwise.

Test plan

  • Validate (structure/frontmatter), validate-manifest (plugin.json vs disk + VERSION), validate-counts (README substring 24 examples)
  • Blender 5.1 smoke — new step runs examples/gltf-export-roundtrip/gltf_export_roundtrip.py -- check-only, plus the 23 existing steps
  • Blender 4.5 smoke — same
  • Ecosystem drift check; Socket Security checks
  • Local binaries used for evidence: .scratch/blender-5.1.2-windows-x64/blender.exe (Blender 5.1.2) and .scratch/blender-4.5.11-windows-x64/blender.exe (Blender 4.5.11 LTS)

Integration: example dir + README, gallery.json entry, plugin manifest, smoke step, top-level README (new "Game asset pipeline" category, counts 23→24), generated gallery pages (read character-by-character: card alt and witnesses callout verified full, no truncation/dotted-path artifacts), ROADMAP shipped entry.

🤖 Generated with Kimi Code

…ontracts

The game-engine interchange path is where AI-generated Blender code drifts
silently: the +Y-up convention, modifier application at export, UV V-flips.
This example pins them: a supply crate exported GLTF_SEPARATE and
re-imported, checked against the depsgraph-evaluated mesh (positions,
normals, UVs, per-triangle material bindings), with the on-disk JSON/buffer
parsed directly for the axis-conversion and V-flip witnesses.

Probed during authoring on 4.5.11 and 5.1.2: exporter/importer RNA is
byte-identical, so the example guards the kwarg set explicitly instead of
papering over a divergence that does not exist. Mesh.calc_normals() being
removed on 5.x surfaced as a real authoring hazard and is pinned in code.

Signed-off-by: fOuttaMyPaint <TMhospitalitystrategies@gmail.com>
@github-actions github-actions Bot added documentation Improvements or additions to documentation ci labels Jul 19, 2026
@TMHSDigital
TMHSDigital merged commit 26396cd into main Jul 19, 2026
9 checks passed
@TMHSDigital
TMHSDigital deleted the feat/gltf-export-roundtrip branch July 19, 2026 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant