Skip to content

ASSET-570: clamp signed normalized GLB accessor endpoints - #6837

Merged
shayderrr merged 1 commit into
ItsNotRexed:mainfrom
Hiiva:fix/ped-snorm-endpoints
Nov 23, 2026
Merged

shayderrr merged 1 commit into
ItsNotRexed:mainfrom
Hiiva:fix/ped-snorm-endpoints

Conversation

@Hiiva

@Hiiva Hiiva commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

ASSET-570: clamp signed normalized GLB accessor endpoints

Claim

The existing ped GLB reader divides signed normalized BYTE/SHORT values by 127/32767 without clamping their minimum encoding. The real assemble command succeeds but writes coordinates below -1: -128 becomes -1.007874 in emitted float data, and -32768 becomes -1.0000305. Their equivalent -127/-32767 encodings already produce -1.

The accessor reader now clamps only signed normalized minima before division. Both dense rows and sparse replacements use this existing shared path. Unsigned normalized, raw signed and float conversions retain their behavior. Document validation, implicit-row budgets and accessor layouts are unchanged.

The glTF accessor conversion rules define the redundant signed minimum encodings. KHR_mesh_quantization permits the tested signed POSITION/TEXCOORD representations. Fixtures declare that extension as required and used, with four-byte aligned vertex offsets/strides. This corrects the existing conversion without claiming broader extension support.

Validation

Windows x64, CPython 3.14.6, CPU only, synthetic inputs. No game files or GPU.

AI-assisted: yes

@neoisg8

neoisg8 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Independent Windows CPU verification (Python 3.14.3, Windows 11 Build 26300, head 7bc7167ca, base 1cc6e3c12, zero game data):

  • Negative control on main (1cc6e3c12):
    Running tests/test_ped_snorm.py on main reproduced exactly 12 failing subcases across test_dense_signed_endpoints_with_packed_and_interleaved_rows, test_sparse_signed_endpoints_with_dense_and_implicit_bases, test_cli_equivalent_signed_minimum_encodings, and test_cli_sparse_signed_endpoints:
    • Signed byte minimum -128 unnormalized became -1.0078740119934082 instead of -1.0.
    • Signed short minimum -32768 became -1.000030517578125 instead of -1.0.
  • On PR head 7bc7167ca:
    • vals = tuple(max(v, -denom) / denom for v in vals) correctly clamps the redundant signed minimum encodings (-128 -> -127, -32768 -> -32767) to -1.0 per glTF accessor specification.
    • Unsigned, raw signed, and float conversions remain completely unaffected.
  • Verification:
    • git diff --check origin/main...HEAD: clean.
    • python -m compileall -q tools/ped_assemble.py tests/test_ped_snorm.py: clean.
    • python -I tests/test_ped_snorm.py: 5/5 OK (all 12 subcase failures resolved).
    • python -I tests/test_ped_assemble.py: 14/14 OK.

Clean and ready to merge.

AI-assisted.

@shayderrr shayderrr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Summary

tools/ped_assemble.py _read_glb_accessor() clamps signed normalized values to -denom before division, so both -128 and -127 (and their 16-bit counterparts) map to -1.0 per the glTF contract. A new test_ped_snorm.py drives dense, interleaved, sparse, raw-signed, and CLI cases through the real importer.

Why merge

Quantized POSITION/TEXCOORD data under KHR_mesh_quantization was decoding the signed minimum below -1, corrupting endpoints. The fix matches the accessor-normalization rule and is exercised end to end.

Verdict: Approve

@shayderrr

Copy link
Copy Markdown
Collaborator

Summary

tools/ped_assemble.py _read_glb_accessor() clamps signed normalized values to -denom before division, so both -128 and -127 (and their 16-bit counterparts) map to -1.0 per the glTF contract. A new test_ped_snorm.py drives dense, interleaved, sparse, raw-signed, and CLI cases through the real importer.

Why merge

Quantized POSITION/TEXCOORD data under KHR_mesh_quantization was decoding the signed minimum below -1, corrupting endpoints. The fix matches the accessor-normalization rule and is exercised end to end.

Verdict: Approve

@shayderrr
shayderrr merged commit f25ba44 into ItsNotRexed:main Nov 23, 2026
0 of 2 checks passed
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.

3 participants