code wiki / (root) / nx_nxa_texbake_region_capacity_t278.nx

nx_nxa_texbake_region_capacity_t278.nx

buildroot/runtime/nx_nxa_texbake_region_capacity_t278.nx

78033 B1629 linesdepth 7pulls 25 transitivereach 1 importersview sourcekind librarytopic nxa
docsdependenciesstructsconstsfunctions

about

nx_nxa_texbake_region_lib.nx -- PER-REGION SKIN ATLAS + PERIODIC MICRO-RELIEF TILE, written INTO the asset as a TEXR section (2026-08-30, /compare/graphics GR29 gpe_skin_microsurface -- the ASSET half). THE OPERATOR'S BAR, VERBATIM: "for per region we need texture ... make sure we aren't just doing more smooth surface painting." So this organ bakes RELIEF -- a 16-bit height channel in MICRONS and a normal DERIVED from that height by finite differences -- and it MEASURES, per region, what the chart footprint can actually carry before it prints carried=1 for anything. WHAT WAS MEASURED BEFORE A BYTE WAS BAKED. The estate's adequacy ruler (nx_craft_emit cw_atlas_adequate) is span-based: texel = 1.7m / res, 830um at the shipped 2048. But TEXC (nx_nxa_texc_lib) is a per-JOINT cylindrical unwrap: each bone owns one tile of a g x g grid, u runs the FULL circumference, v the bone length. The physical footprint of a texel is therefore (bone circumference / tile px) on u, and a chest bone's circumference is a metre. The `measure` verb below solves the UV->3D Jacobian on every triangle and reports, per region, the area-weighted footprint and the FRACTION OF SURFACE AREA that carries each band -- the honest number. A per-region UNIQUE atlas at 2048 raises the tile px by ~g/gR and carries the primary band on more of the body; it CANNOT carry the 250um secondary band around a torso at any resolution this estate ships. That is arithmetic, and it is why the three finer bands ride a PERIODIC MICRO TILE (nx_relief_lib rlf_relief_um2_tile): a texel pitch that is physical by construction (two per pore orifice), repeated by the shader per chart at (chart extent / tile repeat) using the per-joint circumference and length this section publishes. This is the field's practice for exactly this case: Epic's skin guidance keeps wrinkles in the unique normal and puts pore detail in a tiling texture [@ue-skin], MetaHuman carries a separate Micro Skin Detail normal layer [@mh-materials], the scan vendors ship the micro band as its own displacement channel [@txyz-vface], Disney's procedural micro-wrinkle synthesis places pores first and grows the furrow graph between them [@disney23], and Nagano et al. measured that microstructure is a DISPLACEMENT that smooths under stretch and roughens under compression [@nagano15] -- the next contract this file names (ntr_tension_attenuate) and does not fake. THE AREOLA IS ANATOMY, NOT A DISC. The torso region's albedo and height carry the nipple-areola complex at the MESH-DERIVED bust apex (nx_nxa_dyna's lateral anchors, then the most anterior vertex near each): nipple radius and projection from published anthropometry and the areola from the published 1:3 nipple-to-areola ratio [@nac-review21], the areola darker than the surrounding skin by a lightness step DERIVED from the estate's own referee band against a published breast-skin tone [@nac-tattoo24], Montgomery glands as a discrete dome field. Every one of those numbers is a ROW in knowledge/areola_relief.conf with its source; this organ READS them (nx_lane_conf, the shared getter) and REFUSES to bake anatomy when a row is missing -- an unsourced default is the magic number rule 11 forbids. The registry row nx_anatomy an_add(AF_MONTGOMERY ...) is the vocabulary; the ledger is the provenance. TEXR PAYLOAD (i64 words). ADDITIVE: TEXM (map set 0) is carried byte-for-byte, never touched -- the shipped page reads TEXM's blob at a hard-coded +144, so growing TEXM would break the live sampler.

dependencies 9 imports · 1 importers

nx_syscalls.nx nx_nxa.nx nx_nxa_texc_lib.nx nx_nxa_texbake_lib.nx nx_relief_lib.nx nx_png.nx nx_skin_ita.nx nx_lane_conf.nx nx_fsops_lib.nx nx_nxa_texbake_region_capacity nx_nxa_texbake_region_job_t278.nx

imports: nx_syscalls.nxnx_nxa.nxnx_nxa_texc_lib.nxnx_nxa_texbake_lib.nxnx_relief_lib.nxnx_png.nxnx_skin_ita.nxnx_lane_conf.nxnx_fsops_lib.nx

imported by: nx_nxa_texbake_region_job_t278.nx

structs

none

consts

61const NTR_HDR_WORDS: i64 = 16
62const NTR_JOINT_WORDS: i64 = 4
63const NTR_SET_META: i64 = 16
64const NTR_NMAPS: i64 = 5
65const NTR_MAPREC: i64 = 3
66const NTR_VERSION: i64 = 1
67const NTR_REGIONS: i64 = 4
68const NTR_MAP_ALBEDO: i64 = 0
69const NTR_MAP_DISP: i64 = 1
70const NTR_MAP_NORMAL: i64 = 2
71const NTR_MAP_TDISP: i64 = 3
72const NTR_MAP_TNORMAL: i64 = 4
74const NTR_W_NSETS: i64 = 0
75const NTR_W_RES: i64 = 1
76const NTR_W_MODEL: i64 = 2
77const NTR_W_SEED: i64 = 3
78const NTR_W_HUE: i64 = 4
79const NTR_W_BLOBW: i64 = 5
80const NTR_W_NMAPS: i64 = 6
81const NTR_W_MPX: i64 = 7
82const NTR_W_MREP: i64 = 8
83const NTR_W_RANGE: i64 = 9
84const NTR_W_NJ: i64 = 10
85const NTR_W_SETW: i64 = 11
86const NTR_W_JW: i64 = 12
87const NTR_W_VER: i64 = 13
89const NTR_S_REGION: i64 = 0
90const NTR_S_GR: i64 = 1
91const NTR_S_NJR: i64 = 2
92const NTR_S_TPX: i64 = 3
93const NTR_S_FMEAN: i64 = 4
94const NTR_S_FWORST: i64 = 5
95const NTR_S_BANDS_U: i64 = 6
96const NTR_S_BANDS_M: i64 = 7
97const NTR_S_PERIOD: i64 = 8
98const NTR_S_ALX: i64 = 9
99const NTR_S_ALY: i64 = 10
100const NTR_S_ARX: i64 = 11
101const NTR_S_ARY: i64 = 12
102const NTR_S_ARPX: i64 = 13
103const NTR_S_DL: i64 = 14
104const NTR_S_CARRIED: i64 = 15
106const NTR_MODEL_SPECGLOSS: i64 = 1
111const NTR_DISP_RANGE_UM: i64 = 16384
112const NTR_Q16: i64 = 65536
113const NTR_U16_HALF: i64 = 32768
114const NTR_U16_MAX: i64 = 65535
115const NTR_BYTE: i64 = 256
116const NTR_BYTE_MAX: i64 = 255
117const NTR_RGB: i64 = 3
118const NTR_WORD: i64 = 8
119const NTR_SUB: i64 = 16 // rasterizer sub-pixel scale
120const NTR_PI_E3: i64 = 3142
121const NTR_E3: i64 = 1000
122const NTR_E6: i64 = 1000000
123const NTR_MISS: i64 = 0 - 1
125const NTR_TEXELS_PER_BAND: i64 = 2
127const NTR_NGON: i64 = 16
129const NTR_CTL_RELIEF: i64 = 1 // unique-atlas micro-relief bands
130const NTR_CTL_ANATOMY: i64 = 2 // nipple dome + Montgomery glands in the height channel
131const NTR_CTL_PIGMENT: i64 = 4 // areola lightness step in the albedo
132const NTR_CTL_MICRO: i64 = 8 // micro tile carries secondary+pore (else primary only = smooth control)
133const NTR_CTL_SETS: i64 = 16 // write the region sets at all (0 = nsets 0, the adequacy neg-control)
134const NTR_CTL_ALL: i64 = 31
135const NTR_CTL_ONLY_TORSO: i64 = 32 // bake only the torso set (the gate's 2048 probe run); NOT in ALL
137const NTR_OK: i64 = 0
138const NTR_E_IO: i64 = 1
139const NTR_E_BAD: i64 = 3
140const NTR_E_NOSEC: i64 = 4
141const NTR_E_MISMATCH: i64 = 5
142const NTR_E_CONF: i64 = 6
144const NTR_CONF_REL: *u8 = "knowledge/areola_relief.conf"
145const NTR_CONF_ABS: *u8 = "/volume1/homes/elderwesto/nishihost/knowledge/areola_relief.conf"
147const NTR_AN_RA: i64 = 0
148const NTR_AN_RN: i64 = 1
149const NTR_AN_HN: i64 = 2
150const NTR_AN_DL: i64 = 3
151const NTR_AN_NMONT: i64 = 4
152const NTR_AN_RG: i64 = 5
153const NTR_AN_HG: i64 = 6
154const NTR_AN_SEED: i64 = 7
155const NTR_AN_N: i64 = 8
157const NTR_HP_PAD: i64 = 1
159const CX_W: i64 = 0
160const CX_VWO: i64 = 1
161const CX_TWO: i64 = 2
162const CX_XWO: i64 = 3
163const CX_SWO: i64 = 4
164const CX_NV: i64 = 5
165const CX_NTR: i64 = 6
166const CX_NJ: i64 = 7
167const CX_G: i64 = 8
168const CX_RES: i64 = 9
169const CX_UNUM: i64 = 10
170const CX_UDEN: i64 = 11
171const CX_REGS: i64 = 12
172const CX_JRANK: i64 = 13
173const CX_AX: i64 = 14
174const CX_APEX: i64 = 15
175const CX_N: i64 = 16

functions

196func ntr_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v }
197func ntr_max(a: i64, b: i64) -> i64 { if a > b { return a } return b }
198func ntr_min(a: i64, b: i64) -> i64 { if a < b { return a } return b }
called by 1: ntr_raster
199func ntr_clamp(v: i64, lo: i64, hi: i64) -> i64 { if v < lo { return lo } if v > hi { return hi } return v }
200func ntr_copy(dst: *u8, src: *u8, n: i64) -> i64 { var i: i64 = 0; while i < n { dst[i] = src[i]; i = i + 1 } return 0 }
called by 1: ntr_dup
201func ntr_dup(src: *u8, n: i64) -> i64 { let d: *u8 = sys_mmap(n + 64); ntr_copy(d, src, n); return d as i64 }
called by 1: ntr_run calls 2: sys_mmapntr_copy
203func ntr_conf(key: *u8) -> i64 { return lc_geti(NTR_CONF_REL, NTR_CONF_ABS, key, NTR_MISS) }
called by 1: ntr_read_ledger calls 1: lc_geti
205func ntr_region_name(r: i64) -> *u8
called by 1: ntr_run
213func ntr_bands_at_footprint(f_um: i64) -> i64
223func ntr_h_enc(h_um: i64) -> i64
called by 2: ntr_bake_tilentr_run calls 1: ntr_clamp
226func ntr_h_dec(v: i64) -> i64 { return (v - NTR_U16_HALF) * NTR_DISP_RANGE_UM / NTR_U16_HALF }
230func ntr_source_safe(b:*u8,flen:i64)->i64
269func ntr_blob_capacity(res:i64,mpx:i64,nsets:i64)->i64
called by 1: ntr_run calls 1: png_buf_cap
279func ntr_png_checked(rgb:*u8,w:i64,h:i64,fbp:*i64,fb_pixels:i64,out:*u8,capacity:i64)->i64
290func ntr_png(rgb: *u8, w: i64, h: i64, fbp: *i64, out: *u8) -> i64
calls 1: write_png_buf
300func ntr_cos16(s: i64) -> i64
called by 2: ntr_sin16ntr_anat_h
318func ntr_sin16(s: i64) -> i64 { return ntr_cos16((s + 12) % NTR_NGON) }
called by 1: ntr_anat_h calls 1: ntr_cos16
324func ntr_axes(w: *i64, vwo: i64, nv: i64, out: *i64) -> i64
called by 1: ntr_run calls 1: ntb_axspan
364func ntr_layout(b: *u8, flen: i64, regs: *i64, jrank: *i64, gR: *i64, njr: *i64, rj: *i64) -> i64
393func ntr_joint_extents(cx: *i64, upax: i64, circ: *i64, blen: *i64, nown: *i64) -> i64
called by 1: ntr_run calls 3: sys_mmaptm_isqrtsys_munmap
472func ntr_px_sub(uv: i64, j: i64, axis: i64, mode: i64, g: i64, gR: i64, tpR: i64, rank: i64, res: i64) -> i64
489func ntr_footprint(cx: *i64, mode: i64, gRt: *i64, tpRt: *i64, fsum: *i64, asum: *i64, fmax: *i64, carea: *i64, rarea: *i64, straddle: *i64) -> i64
569func ntr_region_footprint(r: i64, nj: i64, regs: *i64, fsum: *i64, asum: *i64, out: *i64) -> i64
called by 1: ntr_run
595func ntr_apex(cx: *i64, dwo: i64, out: *i64) -> i64
called by 1: ntr_run calls 3: sys_mmapntr_abssys_munmap
665func ntr_raster(cx: *i64, reg: i64, gRr: i64, tpRr: i64, fa: *i64, fb: *i64, cov: *u8) -> i64
778func ntr_anat_h(a: i64, b: i64, an: *i64) -> i64
called by 1: ntr_run calls 3: rlf_hash3ntr_cos16ntr_sin16
818func ntr_bake_tile(seed: i64, mask: i64, hq: *i64, nrgb: *u8, drgb: *u8) -> i64
859func ntr_mean_slope_e3(hq: *i64, px: i64, run_um: i64, per: i64) -> i64
called by 1: ntr_run calls 3: rlf_wrapntr_clampntr_abs
881func ntr_mean_slope_sel_e3(hq: *i64, res: i64, run_um: i64, sel: *u8) -> i64
907func ntr_pore_period(hq: *i64, px: i64, repeat_um: i64, out: *i64) -> i64
978func ntr_toc_index(b: *u8, ns: i64, tag: *u8) -> i64
called by 1: ntr_run calls 1: nt_tageq
984func ntr_read_ledger(an: *i64) -> i64
called by 1: ntr_run calls 1: ntr_conf
1009func ntr_run(inp: *u8, outp: *u8, res_in: i64, seed: i64, hue: i64, ctl: i64, mode: i64) -> i64
1535func ntr_measure(inp: *u8, res: i64) -> i64 { return ntr_run(inp, inp, res, 0, 0, NTR_CTL_ALL, 0) }
called by 1: main calls 1: ntr_run
1536func ntr_apply(inp: *u8, outp: *u8, res: i64, seed: i64, hue: i64) -> i64 { return ntr_run(inp, outp, res, seed, hue, NTR_CTL_ALL, 1) }
called by 1: main calls 1: ntr_run
1537func ntr_apply_ctl(inp: *u8, outp: *u8, res: i64, seed: i64, hue: i64, ctl: i64) -> i64 { return ntr_run(inp, outp, res, seed, hue, ctl, 1) }
calls 1: ntr_run
1545func ntr_texr_validate(b:*u8,flen:i64)->i64
1596func ntr_texr_find(b: *u8, flen: i64) -> i64 { return ntr_texr_validate(b, flen) }
1597func ntr_texr_adequate(b: *u8, flen: i64) -> i64
calls 1: ntr_texr_find
1615func ntr_texr_set(b: *u8, flen: i64, region: i64) -> i64
calls 1: ntr_texr_find