code wiki / (root) / nx_fbx_texm.nx

nx_fbx_texm.nx

buildroot/runtime/nx_fbx_texm.nx

54891 B1301 linesdepth 9pulls 30 transitivereach 0 importersview sourcekind tooltopic fbx
docsdependenciesstructsconstsfunctions

about

nx_fbx_texm.nx -- AUTHORED FBX MATERIALS -> TEXC + TEXM. The donor half of the clay fix. THE MEASURED GAP THIS CLOSES. The four Fab donors (toon3d8 / dark_witch / dark_knight / stylized_paladin) were ingested rigged (nx_fbx2nxa + nx_nxa_skin) but FLAT: their AUTHORED texture maps were never carried, so the shipped cw_npc_atlas sampling path (TEXC+TEXM -> world shader) has nothing to sample on them. nx_nxa_texm ship-mode BAKES maps from the genome; a donor's surface is not bakeable -- it is authored, and the honest carry is the author's own pixels behind the author's own UVs. RECON-MEASURED FACTS THIS DESIGN RESTS ON (2026-08-23, full 4-donor census, not sampled): - Every geometry's UV layer is ByPolygonVertex + IndexToDirect. One resolution path. - LayerElementMaterial is AllSame on 75 of 79 geometries; ByPolygon on 4. Policy for ByPolygon: FIRST POLYGON WINS per control point -- a declared approximation at material boundaries, never a fabricated map. - Map roles come from OP connections (DiffuseColor / ShininessExponent / ReflectionFactor / NormalMap / TransparencyFactor), never from filename guessing. - Albedo sources: PNG-8 (ctype 0/2/3/6) and BASELINE JPEG (every toon JPG is SOF0). Depth-16 PNG appears ONLY in normal maps -> the normal map is declared absent by depth. - Knight hair material has no DiffuseColor texture -> authored scalar diffuse (P prop) fills its chart. Authored scalar, not a fabricated pixel. SHAPE: one chart per DISTINCT diffuse source (scalar-filled charts get their own cell), grid g = smallest g with g*g >= ncharts (derived), atlas res from knowledge/texture_ship_budget.conf (the SAME owner nx_nxa_texm ship-mode reads -- one owner per number). TEXC stores FINAL atlas-space Q16 UVs with chart ids, exactly the section shape nx_nxa_texc_lib writes, so the shipped world sampler needs NO new convention. FBX v (origin bottom-left) is flipped to the atlas row space (origin top-left) at ingest; declared here, applied once. Tiling UVs outside [0,1] wrap by modulo before the cell mapping (a clamp would smear the border texel). GRAMMAR: nx_fbx_texm <in.fbx> <texdir> <in_rigged.nxa> <out.nxa> EXITS: 0 OK | 1 io | 2 usage | 3 bad-input | 4 missing-section | 5 desync-refused REFUSALS ARE NAMED. Every skipped map and every unreadable source prints WHICH rule fired.

dependencies 6 imports · 0 importers

nx_syscalls.nx nx_nxa.nx nx_fbx_core.nx nx_inflate.nx nx_png.nx nx_jpeg_ascii.nx nx_fbx_texm.nx

imports: nx_syscalls.nxnx_nxa.nxnx_fbx_core.nxnx_inflate.nxnx_png.nxnx_jpeg_ascii.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main ft_err sys_write ft_slen sys_mmap nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_munmap sys_close fbxc_version fbxc_u32 fbxc_big fbxc_hdr fbxc_u64 fbxc_u32 ↻ fbxc_u32 ↻ fbxc_name_is ft_prop_i64 fbxc_i64le fbxc_i32 fbxc_u32 ↻ ft_prop_str fbxc_u32 ↻

structs

none

consts

42const FT_OK: i64 = 0
43const FT_E_IO: i64 = 1
44const FT_E_USAGE: i64 = 2
45const FT_E_BAD: i64 = 3
46const FT_E_NOSEC: i64 = 4
47const FT_E_DESYNC: i64 = 5
50const FT_HDR: i64 = 32
51const FT_TOCE: i64 = 32
52const FT_MAXSEC: i64 = 64
53const FT_MODE: i64 = 0x1a4
54const FT_PAD: i64 = 4096
55const FT_WORD: i64 = 8
58const FT_TX_PHDR: i64 = 4
59const FT_TX_STRIDE: i64 = 3
60const FT_Q16: i64 = 65536
63const FT_TM_HDRW: i64 = 6
64const FT_TM_RECW: i64 = 3
65const FT_TM_NMAP: i64 = 4
66const FT_TM_MODEL_METALROUGH: i64 = 2
69const FT_SLOT_ALBEDO: i64 = 0
70const FT_SLOT_METAL: i64 = 1
71const FT_SLOT_ROUGH: i64 = 2
74const FT_SHIP_CONF: *u8 = "knowledge/texture_ship_budget.conf"
79const FT_MAXGEOM: i64 = 128
80const FT_MAXMAT: i64 = 128
81const FT_MAXTEX: i64 = 256
82const FT_MAXCONN: i64 = 65536
83const FT_MAXMODEL: i64 = 1024
84const FT_MAXCHART: i64 = 64
85const FT_MAXSLOT: i64 = 64
86const FT_NAMECAP: i64 = 256
90const FT_STACK_MIN: i64 = 1024
92const FT_FX_ONE: i64 = 1024 // fbxc_f64_fx unit (nx_fbx_core law)

functions

94func ft_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
95func ft_err(s: *u8) -> i64 { sys_write(2, s, ft_slen(s)); return 0 }
96func ft_out(s: *u8) -> i64 { sys_write(1, s, ft_slen(s)); return 0 }
called by 1: main calls 2: sys_writeft_slen
97func ft_outn(v: i64) -> i64
116func ft_nl() -> i64 { let b: *u8 = sys_mmap(8); b[0] = 10 as u8; sys_write(1, b, 1); sys_munmap(b, 8); return 0 }
118func ft_streq(a: *u8, b: *u8) -> i64
called by 1: main
126func ft_basename(src: *u8, srclen: i64, dst: *u8) -> i64
called by 1: main
144func ft_pathjoin(dir: *u8, base: *u8, dst: *u8) -> i64
called by 1: main
160func ft_png_load(path: *u8, prgb: *i64, pw: *i64, ph: *i64) -> i64
274func ft_img_load(path: *u8, prgb: *i64, pw: *i64, ph: *i64) -> i64
299func ft_cell_load(path: *u8, dst: *u8, res: i64, cx0: i64, cy0: i64, cell: i64, tmpp: *u8) -> i64
354func ft_downsample_into(src: *u8, w: i64, h: i64, atlas: *u8, res: i64, cx0: i64, cy0: i64, cell: i64) -> i64
called by 1: ft_cell_load
398func ft_conf_at(path: *u8, key: *u8) -> i64
454func ft_ship_res() -> i64
called by 1: main calls 1: ft_conf_at
472func ft_prop_i64(b: *u8, p: i64) -> i64
called by 2: ft_conn_rowmain calls 2: fbxc_i64lefbxc_i32
480func ft_prop_str(b: *u8, p: i64, out: *i64) -> i64
called by 1: main calls 2: fbxc_u32sys_mmap
492func ft_str_is(s: *u8, n: i64, t: *u8) -> i64
called by 2: ft_conn_rowmain
504func ft_prop_dcolor(b: *u8, p0: i64, rr: *i64, gg: *i64, bb: *i64, mi: i64) -> i64
538func ft_conn_row(b: *u8, p0: i64, ca: *i64, cb: *i64, cp: *i64, n: i64) -> i64
called by 1: main calls 3: fbxc_u32ft_prop_i64ft_str_is
574func nt2_rd64(b: *u8, off: i64) -> i64
580func nt2_wr64(b: *u8, off: i64, v: i64) -> i64
called by 1: ft_write_out
586func nt2_tageq(b: *u8, off: i64, t: *u8) -> i64
called by 2: ft_write_outmain calls 2: nt2_rd64nxa_tag4
592func ft_write_out(xb: *u8, xns: i64, uvq: *i64, uvwords: i64, res: i64, grid: i64,
687func main(argc: i64, argv: *i64) -> i64