nx_nxa_texc_lib.nx
buildroot/runtime/nx_nxa_texc_lib.nx
about
nx_nxa_texc_lib.nx -- ★TEXC: UV TEXTURE COORDINATES AS A FORMAT CAPABILITY (debt 1785794796 rung 1).
The measured fact that forced this: ref9.nxa declares VERT TRIS CLUS SKEL SKIN ANIM HSTR GVRT GTRI
GPIN POSE -- NO TEXC, NO UV -- so sampling ANY texture map was IMPOSSIBLE, and 'we shade procedurally
from genome' was a CONSTRAINT wearing the costume of a choice. This lib computes a bone-anchored
cylindrical unwrap from sections the asset ALREADY carries (SKEL world bind positions + SKIN top-4
weights) and writes a TEXC section: every vertex gets a stable atlas coordinate AND a region tag.
UNWRAP (integer, deterministic): per vertex take its PRIMARY bone (max SKIN weight slot). v = clamped
position along the parent->joint bind segment (Q12 -> Q16). u = angle around the bone's DOMINANT axis
(rt_atan2, full circle 25736 it-units -> Q16). Each joint owns one TILE of a g x g atlas grid
(g = ceil(sqrt(nj))), so charts from different bones are DISJOINT BY CONSTRUCTION -- a bake and a
sampler sharing this section can never bleed one body part into another. Seams sit at weight
boundaries (rigid ownership); bake+sample use the SAME mapping so sampling stays self-consistent.
TEXC payload (i64 words): [0]=nv [1]=stride(3) [2]=atlas grid g [3]=reserved(0), then per vertex:
[u q16 0..65535][v q16 0..65535][owning joint]. The joint word IS the region tag (rung 2 seed):
finer than Face|Torso|Limbs and groupable through SKEL parents later.
ADDITIVE AND IDEMPOTENT like its siblings (nx_nxa_dyna): the input is never modified; an existing
TEXC is REPLACED, so running twice is identical to running once. FAIL-CLOSED: refuses with a NAMED
reason rather than fabricate (no SKIN -> no invented ownership; count mismatch -> refuse).
license_tier: ORIGINAL No hw writes (Rule 26).
dependencies 3 imports · 11 importers
diagram shows first 10 each side; +0 more imports, +1 more importers in the complete lists below.
imports: nx_syscalls.nxnx_nxa.nxnx_pose_retarget.nx
imported by: nx_nxa_morf.nxnx_nxa_texbake_decode_t279.nxnx_nxa_texbake_gate.nxnx_nxa_texbake_lib.nxnx_nxa_texbake_region_capacity_t278.nxnx_nxa_texbake_region_edge_t278.nxnx_nxa_texbake_region_lib.nxnx_nxa_texc.nxnx_nxa_texc_gate.nxnx_nxa_texm.nxnx_skin_pbr_gate.nx
structs
| none |
consts
| 27 | const NT_HDR: i64 = 32 |
| 28 | const NT_TOCE: i64 = 32 |
| 29 | const NT_MAXSEC: i64 = 64 |
| 30 | const NT_MODE: i64 = 0x1a4 |
| 31 | const NT_ERRFD: i64 = 2 |
| 32 | const NT_Q12: i64 = 4096 |
| 33 | const NT_Q16: i64 = 65536 |
| 34 | const NT_Q16M: i64 = 65535 |
| 35 | const NT_HALFC: i64 = 12868 |
| 36 | const NT_FULLC: i64 = 25736 |
| 37 | const NT_PRESH: i64 = 16 |
| 38 | const NT_STRIDE: i64 = 3 |
| 39 | const NT_PHDR: i64 = 4 |
| 40 | const NT_PAD: i64 = 4096 |
| 61 | const NT_RECT_W: i64 = 4 // words per joint in the rect table: ox, oy, w, h (Q16) |
| 62 | const NT_REST_Q: i64 = 3 // the three quadrants the non-face joints share |
| 63 | const NT_MIN_CELL: i64 = 3 // a cell narrower than this has no interior after the 1px inset |
| 68 | const NT_OK: i64 = 0 |
| 69 | const NT_E_IO: i64 = 1 |
| 70 | const NT_E_BAD: i64 = 3 |
| 71 | const NT_E_NOSEC: i64 = 4 |
| 72 | const NT_E_MISMATCH: i64 = 5 |
functions
| 65 | func ntx_quad_ox(q: i64) -> i64 { if q == 1 { return NT_Q16/2 } if q == 3 { return NT_Q16/2 } return 0 } called by 1: ntx_apply |
| 66 | func ntx_quad_oy(q: i64) -> i64 { if q == 2 { return NT_Q16/2 } if q == 3 { return NT_Q16/2 } return 0 } called by 1: ntx_apply |
| 74 | func nt_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 75 | func nt_err(s: *u8) -> i64 { sys_write(NT_ERRFD, s, nt_slen(s)); return 0 } |
| 76 | func nt_outs(s: *u8) -> i64 { sys_write(1, s, nt_slen(s)); return 0 } |
| 77 | func nt_outn(v: i64) -> i64 |
| 90 | func nt_rd64(b: *u8, off: i64) -> i64 |
| 96 | func nt_wr64(b: *u8, off: i64, v: i64) -> i64 |
| 102 | func nt_tageq(b: *u8, off: i64, t: *u8) -> i64 |
| 107 | func nt_grid(n: i64) -> i64 |
| 125 | func ntx_jmap(bb: *u8, flen: i64, res: i64, nj: i64, jm: *i64) -> i64 |
| 173 | func ntx_apply(inp: *u8, outp: *u8) -> i64 |