code wiki / (root) / nx_nxa_texm.nx

nx_nxa_texm.nx

buildroot/runtime/nx_nxa_texm.nx

24485 B496 linesdepth 6pulls 15 transitivereach 0 importersview sourcekind tooltopic nxa
docsdependenciesstructsconstsfunctions

about

nx_nxa_texm.nx -- WRITE THE TEXM SECTION: the baked PBR map set carried INSIDE the asset. THE MEASURED GAP THIS CLOSES. nx_asset_floor_gate scores the shipped character 4/7 and prints "PBR texture maps (TEXM) -- we shade procedurally from genome: ABSENT". An independent lane measured that this -- not triangle count -- is why renders read as clay: at 28,092 tris the silhouette is already at 0.94x a shipping real-time budget, and the body carries 104 joints against VRM 1.0's 15 required. Adequate FORM with NO SURFACE is the definition of clay. TEXC (the UV unwrap) has been present in the asset for some time and nx_nxa_texbake produces real maps -- but NOTHING WROTE A MAP BACK INTO THE CONTAINER. Proven absence, not assumed: grep TEXM over 23,018 files, coverage_complete=1 corpus_complete=1, returns exactly TWO hits, both inside nx_asset_floor_gate, both READS. This organ is the missing writer. WHICH PBR MODEL TEXM STORES, AND WHY -- SETTLED HERE RATHER THAN LEFT IMPLICIT. TEXM stores SPECULAR-GLOSSINESS: D(albedo) S(specular) G(gloss) N(normal), exactly the set nx_nxa_texbake_lib bakes (NTB_MAP_ALBEDO/SPEC/GLOSS/NORMAL) and exactly the set knowledge/asset_texture_floor.conf measured from 23 real shipped packages ("tex_map_set 4 maps D(diffuse) S(specular) G(gloss) N|NM(normal)"). Storing anything else would mean transcoding at bake time and recording a number no instrument in this estate produces. !!THE CONSEQUENCE, STATED PLAINLY RATHER THAN DISCOVERED LATER: glTF 2.0 core is METALLIC-ROUGHNESS, and KHR_materials_pbrSpecularGlossiness was ARCHIVED by Khronos. So a TEXM set CANNOT be written to core glTF 2.0 without a conversion, and that conversion is LOSSY -- spec-gloss to metal-rough is not bijective (a dielectric with a coloured specular has no exact metal-rough equivalent). Anyone exporting TEXM through glTF owes that conversion step; this organ does not pretend it is free. The alternative -- baking metal-rough instead -- was NOT chosen because it would make our own measured floor unusable as a comparison. ADDITIVE ONLY (rule 13). Every pre-existing section is copied forward and its checksum is RECOMPUTED rather than copied, because a copied checksum validates its own bug -- the same discipline nx_nxa_texc_lib's ntx_apply already applies. An existing TEXM is REPLACED, not duplicated, so the organ is idempotent: running it twice yields one TEXM, never two. RESOLUTION IS NOT MINE TO PICK. The default is READ from knowledge/asset_texture_floor.conf (tex_res_floor, measured at 4096 px from real package image headers). If the conf cannot be read the organ REFUSES rather than inventing a default -- an unmeasured default is exactly the magic number this estate forbids. A caller may override it explicitly, and the organ ANNOUNCES the bytes each map cost so the resource decision is visible instead of buried. nx_nxa_texm <in.nxa> <out.nxa> [res] [seed] [hue] EXITS: 0 OK | 2 usage | 3 bad container | 4 missing prerequisite section | 1 I/O license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 6 imports · 0 importers

nx_syscalls.nx nx_nxa.nx nx_nxa_texc_lib.nx nx_nxa_texbake_lib.nx nx_png.nx nx_relief_lib.nx nx_nxa_texm.nx

imports: nx_syscalls.nxnx_nxa.nxnx_nxa_texc_lib.nxnx_nxa_texbake_lib.nxnx_png.nxnx_relief_lib.nx

imported by: nobody (leaf or entry point)

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

main nt_err sys_write nt_slen sys_exit txm_is_ship txm_atoi txm_ship_res txm_conf_at 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 txm_slen txm_conf_int sys_mmap ↻ sys_read_file ↻ txm_slen ↻ nt_outs sys_write ↻ nt_slen ↻ nt_outn

structs

none

consts

52const TXM_OK: i64 = 0
53const TXM_E_IO: i64 = 1
54const TXM_E_USAGE: i64 = 2
55const TXM_E_BAD: i64 = 3
56const TXM_E_NOSEC: i64 = 4
62const TXM_HDR_WORDS: i64 = 6
63const TXM_MAPREC_WORDS: i64 = 3
64const TXM_W_NMAPS: i64 = 0
65const TXM_W_RES: i64 = 1
66const TXM_W_MODEL: i64 = 2
67const TXM_W_SEED: i64 = 3
68const TXM_W_HUE: i64 = 4
69const TXM_W_BLOBW: i64 = 5
72const TXM_MODEL_SPECGLOSS: i64 = 1
73const TXM_MODEL_METALROUGH: i64 = 2
76const TXM_CONF_PATH: *u8 = "knowledge/asset_texture_floor.conf"
77const TXM_CONF_KEY: *u8 = "tex_res_floor"
78const TXM_CONF_CAP: i64 = 65536
82const TXM_DEFAULT_SEED: i64 = 1
83const TXM_RES_MIN: i64 = 8 // a PNG smaller than one filter block is not a texture
85const TXM_ASCII_NL: i64 = 10
86const TXM_ASCII_SP: i64 = 32
87const TXM_ASCII_TAB: i64 = 9
88const TXM_ASCII_ZERO: i64 = 48
89const TXM_ASCII_NINE: i64 = 57
90const TXM_DECIMAL: i64 = 10
91const TXM_RGB_BYTES: i64 = 3
92const TXM_PIX_G_SHIFT: i64 = 256
93const TXM_PIX_B_SHIFT: i64 = 65536
94const TXM_WORD_BYTES: i64 = 8
95const TXM_MISS: i64 = 0 - 1
100const TXM_SHIP_CONF: *u8 = "knowledge/texture_ship_budget.conf"
101const TXM_SHIP_ARG: *u8 = "ship"
105const TXM_RUNG_4096: i64 = 4096
106const TXM_RUNG_2048: i64 = 2048
107const TXM_RUNG_1024: i64 = 1024
108const TXM_RUNG_512: i64 = 512

functions

110func txm_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
116func txm_atoi(s: *u8) -> i64
called by 1: main
136func txm_conf_int(key: *u8) -> i64
called by 1: main calls 3: sys_mmapsys_read_filetxm_slen
196func txm_apply(inp: *u8, outp: *u8, res: i64, seed: i64, hue: i64) -> i64
368func txm_conf_at(path: *u8, key: *u8) -> i64
424func txm_is_ship(s: *u8) -> i64
called by 1: main
437func txm_ship_res(confpath: *u8) -> i64
called by 1: main calls 1: txm_conf_at
452func main(argc: i64, argv: *i64) -> i64