code wiki / (root) / nx_nxa_texc_lib.nx

nx_nxa_texc_lib.nx

buildroot/runtime/nx_nxa_texc_lib.nx

18760 B404 linesdepth 4pulls 7 transitivereach 35 importersview sourcekind librarytopic nxa
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_nxa.nx nx_pose_retarget.nx nx_nxa_texc_lib.nx nx_nxa_morf.nx nx_nxa_texbake_decode_t279.nx nx_nxa_texbake_gate.nx nx_nxa_texbake_lib.nx nx_nxa_texbake_region_capacity_t27 nx_nxa_texbake_region_edge_t278.nx nx_nxa_texbake_region_lib.nx nx_nxa_texc.nx nx_nxa_texc_gate.nx nx_nxa_texm.nx

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

27const NT_HDR: i64 = 32
28const NT_TOCE: i64 = 32
29const NT_MAXSEC: i64 = 64
30const NT_MODE: i64 = 0x1a4
31const NT_ERRFD: i64 = 2
32const NT_Q12: i64 = 4096
33const NT_Q16: i64 = 65536
34const NT_Q16M: i64 = 65535
35const NT_HALFC: i64 = 12868
36const NT_FULLC: i64 = 25736
37const NT_PRESH: i64 = 16
38const NT_STRIDE: i64 = 3
39const NT_PHDR: i64 = 4
40const NT_PAD: i64 = 4096
61const NT_RECT_W: i64 = 4 // words per joint in the rect table: ox, oy, w, h (Q16)
62const NT_REST_Q: i64 = 3 // the three quadrants the non-face joints share
63const NT_MIN_CELL: i64 = 3 // a cell narrower than this has no interior after the 1px inset
68const NT_OK: i64 = 0
69const NT_E_IO: i64 = 1
70const NT_E_BAD: i64 = 3
71const NT_E_NOSEC: i64 = 4
72const NT_E_MISMATCH: i64 = 5

functions

65func 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
66func 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
74func nt_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 2: nt_errnt_outs
75func nt_err(s: *u8) -> i64 { sys_write(NT_ERRFD, s, nt_slen(s)); return 0 }
76func nt_outs(s: *u8) -> i64 { sys_write(1, s, nt_slen(s)); return 0 }
77func nt_outn(v: i64) -> i64
90func nt_rd64(b: *u8, off: i64) -> i64
96func nt_wr64(b: *u8, off: i64, v: i64) -> i64
102func nt_tageq(b: *u8, off: i64, t: *u8) -> i64
107func nt_grid(n: i64) -> i64
125func ntx_jmap(bb: *u8, flen: i64, res: i64, nj: i64, jm: *i64) -> i64
173func ntx_apply(inp: *u8, outp: *u8) -> i64