code wiki / (root) / nx_tissuefield_lib.nx

nx_tissuefield_lib.nx

buildroot/runtime/nx_tissuefield_lib.nx

99682 B1947 linesdepth 4pulls 10 transitivereach 6 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_tissuefield_lib.nx -- THE SKULL-BOUND TISSUE-DEPTH SKIN SURFACE (aesthetictwin AT46, 2026-09-18). Operator 2026-09-18: "we were trying to render a skull then every layer up ... controllable every layer up generative capabilities". Today's faces are blended SDF blobs on a frame; nx_faceanat never reads the skull it was meant to sit on (`nxmesh` count 0 in that file). This library builds the FIRST layer ON the generated skull: the skin is an OFFSET SURFACE of the skull mesh, offset along the skull's own vertex normals by a tissue-depth FIELD interpolated from the forensic tissue-depth table at anatomical landmarks that are LOCATED ON THE SKULL ITSELF (midline profile extrema, support directions, canon ratios of the bony span), plus controllable fat compartments and named patches for the features that have no bone behind them (globes and lids over the orbits, the nose over the empty aperture, the vermilion band). EVERY NUMBER IS DATA OR IS DERIVED FROM THE RESOURCE IT DESCRIBES: depths, compartment magnitudes and construction ratios come from knowledge/tissue_depth.conf (each row names its source; rows the research lane has not pinned say PENDING-REF), the interpolation kernel width is the median nearest-landmark spacing of the located landmarks, grid steps are the mesh's own mean edge length, the units are the skull's own (NXMSH2 float32 millimetres read as tenths of a millimetre, so one tissue-depth unit mm10 IS one model unit u10), and the camera distance is derived from the head height and a declared frame fraction. Nothing here reads nx_faceanat, nx_sdfrender or nx_skullsdf as code: the skull is consumed as the MESH those organs emit, and the depth values nx_faceanat typed inline were carried into the conf with their source named. FRAME: the skull mesh is anterior +z, superior +y, the subject's left +x (nx_meshview front view = camera on +z). The rasteriser (nx_trimesh) looks down +z with the camera at -camz, so every vertex is pushed through a rotation of half a turn about y (x -> -x, z -> -z): a proper rotation, never a mirror, so the subject's right eye lands on the image left as in a photograph (the photo ruler's side convention). LIB, no main. Composes nx_nxmesh_lib (the ONE NXMSH2 layout), nx_vecmath (isqrt, float32 codec), nx_trimesh (the rasteriser), nx_png (the encoder), nx_itoa_lib (zero-alloc decimal). license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 6 imports · 4 importers

nx_syscalls.nx nx_vecmath.nx nx_nxmesh_lib.nx nx_trimesh.nx nx_png.nx nx_itoa_lib.nx nx_tissuefield_lib.nx nx_skull_canon_lib.nx nx_skullskin.nx nx_skullskin_gate.nx nx_tfl_decimate_gate.nx

imports: nx_syscalls.nxnx_vecmath.nxnx_nxmesh_lib.nxnx_trimesh.nxnx_png.nxnx_itoa_lib.nx

imported by: nx_skull_canon_lib.nxnx_skullskin.nxnx_skullskin_gate.nxnx_tfl_decimate_gate.nx

structs

none

consts

34const TFL_I64: i64 = 8
35const TFL_Q16: i64 = 256 * 256 // the kernel's fixed point (weights and exp)
36const TFL_NQ: i64 = 64 * 64 // the normal scale surface_nets emits and NXMSH2 stores (4096)
37const TFL_ZNONE: i64 = 0 - 1000 * 1000 * 1000 // "no surface in this cell" for the frontal depth maps
38const TFL_FAR: i64 = 1000 * 1000 * 1000
39const TFL_PERMIL: i64 = 1000
40const TFL_MODE644: i64 = 420
41const TFL_MODE755: i64 = 493
42const TFL_PATHB: i64 = 512
43const TFL_STDOUT: i64 = 1
44const TFL_PIPE: i64 = 124
45const TFL_NL: i64 = 10
46const TFL_HASH: i64 = 35
47const TFL_MINUS: i64 = 45
48const TFL_COMMA: i64 = 44
49const TFL_ZERO: i64 = 48
50const TFL_NINE: i64 = 57
51const TFL_BYTE: i64 = 255
53const TFL_EXP_TERMS: i64 = 12 // Taylor terms for e^-1; the 12th term is below one Q16 unit
54const TFL_EXP_MAX_INT: i64 = 24 // exp(-24) is below one Q16 unit: the weight is zero past this
55const TFL_SUPPORT_SIGMAS: i64 = 3 // a Gaussian compartment's support for the partition tooth: 3 sigma
56const TFL_RIM_SAMPLES: i64 = 16 // boundary samples of the lid ellipse for the rim depth
57const TFL_SPHERE_RINGS: i64 = 12
58const TFL_SPHERE_SEGS: i64 = 16
59const TFL_LID_SUBDIV: i64 = 2 // lid and nose patches are gridded at half the mesh edge
60const TFL_COL_WHITE: i64 = 255 + 255 * 256 + 255 * 256 * 256
61const TFL_COL_IRIS: i64 = 60 + 90 * 256 + 110 * 256 * 256 // a blue-grey iris: hue is a later layer's data
62const TFL_COL_PUPIL: i64 = 8 + 8 * 256 + 8 * 256 * 256
63const TFL_COL_BROW: i64 = 60 + 45 * 256 + 35 * 256 * 256
64const TFL_COL_SEAM: i64 = 70 + 40 * 256 + 40 * 256 * 256
65const TFL_COL_BONE: i64 = 232 + 224 * 256 + 216 * 256 * 256 // the bone tint nx_skullsdf stores (910,890,845 permil)
66const TFL_BG: i64 = 20 + 28 * 256 + 40 * 256 * 256 // the dark slate every mesh render uses (nx_meshview MV_BG)
69const TFL_M_NV: i64 = 0
70const TFL_M_NT: i64 = 1
71const TFL_M_VX: i64 = 2
72const TFL_M_VY: i64 = 3
73const TFL_M_VZ: i64 = 4
74const TFL_M_NX: i64 = 5
75const TFL_M_NY: i64 = 6
76const TFL_M_NZ: i64 = 7
77const TFL_M_TA: i64 = 8
78const TFL_M_TB: i64 = 9
79const TFL_M_TC: i64 = 10
80const TFL_M_X0: i64 = 11
81const TFL_M_X1: i64 = 12
82const TFL_M_Y0: i64 = 13
83const TFL_M_Y1: i64 = 14
84const TFL_M_Z0: i64 = 15
85const TFL_M_Z1: i64 = 16
86const TFL_M_EDGE: i64 = 17 // mean triangle edge length, u10 (the mesh's own resolution)
87const TFL_M_FM: i64 = 18 // frontal depth map ptr (max z per (x,y) cell), or 0
88const TFL_M_FMW: i64 = 19
89const TFL_M_FMH: i64 = 20
90const TFL_M_FMCELL: i64 = 21
91const TFL_M_RAW: i64 = 22 // triangle-soup vertex count before welding
92const TFL_M_N: i64 = 24
95const TFL_T_NROWS: i64 = 0
96const TFL_T_NFAT: i64 = 1
97const TFL_T_NPATCH: i64 = 2
98const TFL_T_NPENDING: i64 = 3
99const TFL_T_MALFORMED: i64 = 4
100const TFL_T_HDR: i64 = 8
101const TFL_R_FIELDS: i64 = 16
102const TFL_R_NAME: i64 = 0
103const TFL_R_DEPTH: i64 = 1 // mm10, or -1 for a row that is located but does not vote
104const TFL_R_SRC: i64 = 2
105const TFL_R_NOTE: i64 = 3
106const TFL_R_X: i64 = 4
107const TFL_R_Y: i64 = 5
108const TFL_R_Z: i64 = 6
109const TFL_R_AX: i64 = 7 // anchor: the skull vertex nearest the located point
110const TFL_R_AY: i64 = 8
111const TFL_R_AZ: i64 = 9
112const TFL_R_AIDX: i64 = 10
113const TFL_R_ADIST: i64 = 11
114const TFL_R_STATE: i64 = 12 // 0 not located, 1 located, 2 located by a named fallback
115const TFL_R_PENDING: i64 = 13
116const TFL_ROWS_CAP: i64 = 64
117const TFL_FAT_CAP: i64 = 16
118const TFL_PATCH_CAP: i64 = 64
119const TFL_T_I64S: i64 = TFL_T_HDR + (TFL_ROWS_CAP + TFL_FAT_CAP + TFL_PATCH_CAP) * TFL_R_FIELDS
120const TFL_ST_NONE: i64 = 0
121const TFL_ST_LOCATED: i64 = 1
122const TFL_ST_FALLBACK: i64 = 2
125const TFL_K_SIGMA: i64 = 0
126const TFL_K_DMIN: i64 = 1
127const TFL_K_DMED: i64 = 2
128const TFL_K_DMAX: i64 = 3
129const TFL_K_LOCATED: i64 = 4
130const TFL_K_FALLBACK: i64 = 5
131const TFL_K_UNLOCATED: i64 = 6
132const TFL_K_ANCHOR_MAX: i64 = 7
133const TFL_K_VOTERS: i64 = 8
134const TFL_K_N: i64 = 16
553const TFL_DECIM_MAX_CELLS: i64 = 6000000

functions

138func tfl_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(TFL_STDOUT, s, n); return 0 }
139func tfl_pn(v: i64) -> i64 { nxi_out(v); return 0 }
140func tfl_kv(k: *u8, v: i64) -> i64 { tfl_puts(k); tfl_pn(v); return 0 }
141func tfl_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
142func tfl_streq(a: *u8, b: *u8) -> i64
149func tfl_atoi(s: *u8) -> i64
157func tfl_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v }
158func tfl_min(a: i64, b: i64) -> i64 { if a < b { return a } return b }
called by 1: main
159func tfl_max(a: i64, b: i64) -> i64 { if a > b { return a } return b }
161func tfl_has(s: *u8, lit: *u8) -> i64
called by 2: tfl_conf_loadtfl_fat_place calls 1: tfl_slen
174func tfl_cat(d: *u8, o: i64, s: *u8) -> i64 { var p: i64 = o; var i: i64 = 0; while s[i] != (0 as u8) { d[p] = s[i]; p = p + 1; i = i + 1 } d[p] = 0 as u8; return p }
175func tfl_catn(d: *u8, o: i64, v: i64) -> i64 { let p: i64 = nxi_buf(d, o, v); d[p] = 0 as u8; return p }
178func tfl_exp_init() -> i64
called by 1: tfl_exp_q16
189func tfl_exp_q16(t: i64) -> i64
called by 2: maintfl_gauss_q16 calls 1: tfl_exp_init
206func tfl_gauss_q16(d2: i64, sigma: i64) -> i64
called by 2: maintfl_depth_field calls 1: tfl_exp_q16
216func tfl_tab_new() -> *i64
called by 4: mainmainmainmain calls 1: sys_mmap
222func tfl_row(T: *i64, i: i64) -> *i64 { return ((T as i64) + (TFL_T_HDR + i * TFL_R_FIELDS) * TFL_I64) as *i64 }
223func tfl_fatrow(T: *i64, i: i64) -> *i64 { return ((T as i64) + (TFL_T_HDR + (TFL_ROWS_CAP + i) * TFL_R_FIELDS) * TFL_I64) as *i64 }
224func tfl_patchrow(T: *i64, i: i64) -> *i64 { return ((T as i64) + (TFL_T_HDR + (TFL_ROWS_CAP + TFL_FAT_CAP + i) * TFL_R_FIELDS) * TFL_I64) as *i64 }
226func tfl_split(line: *u8, f: *i64, cap: i64) -> i64
242func tfl_conf_load(path: *u8, T: *i64) -> i64
315func tfl_row_find(T: *i64, name: *u8) -> i64
320func tfl_fat_find(T: *i64, name: *u8) -> i64
called by 1: tfl_fat_set calls 2: tfl_fatrowtfl_streq
326func tfl_patch(T: *i64, key: *u8) -> i64
332func tfl_patch_set(T: *i64, key: *u8, v: i64) -> i64
338func tfl_material_apply(T: *i64) -> i64
345func tfl_fat_set(T: *i64, name: *u8, v: i64) -> i64
called by 1: main calls 2: tfl_fat_findtfl_fatrow
353func tfl_depths_scale(T: *i64, permil: i64) -> i64
called by 1: main calls 2: tfl_rowtfl_fatrow
362func tfl_mesh_new() -> *i64
368func tfl_hash3(x: i64, y: i64, z: i64) -> i64
called by 1: tfl_mesh_load
376func tfl_mesh_load(path: *u8, M: *i64) -> i64
478func tfl_mesh_clone_positions(M: *i64) -> *i64
490func tfl_mesh_bbox_refresh(M: *i64) -> i64
506func tfl_mesh_write(M: *i64, path: *u8, col_r_permil: i64, col_g_permil: i64, col_b_permil: i64) -> i64
554func tfl_mesh_decimate(M: *i64, cell: i64) -> *i64
called by 1: main calls 2: sys_mmaptfl_mesh_new
624func tfl_frontmap(M: *i64) -> i64
called by 2: tfl_front_attfl_crest calls 1: sys_mmap
644func tfl_front_at(M: *i64, x: i64, y: i64, reach: i64) -> i64
675func tfl_profile(M: *i64, prof: *i64, pidx: *i64, cap: i64) -> i64
695func tfl_noisefloor(prof: *i64, nb: i64, edge: i64) -> i64
722func tfl_extrema(prof: *i64, nb: i64, swing: i64, ex: *i64, ty: *i64, cap: i64) -> i64
754func tfl_support(M: *i64, dx: i64, dy: i64, dz: i64, ylo: i64, yhi: i64, zlo: i64, xside: i64) -> i64
776func tfl_support_lat(M: *i64, dx: i64, dy: i64, dz: i64, ylo: i64, yhi: i64, zlo: i64, xside: i64, xmin: i64) -> i64
799func tfl_crest(M: *i64, x: i64, y: i64, dx: i64, dy: i64, reach: i64, out: *i64) -> i64
815func tfl_nearest(M: *i64, x: i64, y: i64, z: i64, out: *i64) -> i64
called by 2: maintfl_locate calls 1: vm_isqrt
831func tfl_place(T: *i64, name: *u8, x: i64, y: i64, z: i64, state: i64) -> i64
838func tfl_place_v(T: *i64, name: *u8, M: *i64, v: i64, state: i64) -> i64
843func tfl_get(T: *i64, name: *u8, out3: *i64) -> i64
853func tfl_locate(M: *i64, T: *i64, K: *i64) -> i64
1053func tfl_print_rows(T: *i64) -> i64
called by 1: sks_surface calls 3: tfl_rowtfl_putstfl_kv
1072func tfl_sigma(T: *i64) -> i64
1110func tfl_depth_median(T: *i64) -> i64
called by 1: tfl_depth_field calls 2: sys_mmaptfl_row
1130func tfl_fat_place(T: *i64) -> i64
1188func tfl_depth_field(M: *i64, T: *i64, D: *i64, K: *i64) -> i64
1247func tfl_offset(M: *i64, D: *i64, S: *i64) -> i64
1263func tfl_max_displacement(A: *i64, B: *i64) -> i64
called by 1: main calls 1: vm_isqrt
1278func tfl_moved_partition(M: *i64, D0: *i64, D1: *i64, cx: i64, cy: i64, cz: i64, rad: i64, out: *i64) -> i64
called by 1: main
1295func tfl_push(x: i64, y: i64, z: i64, nx: i64, ny: i64, nz: i64, col: i64) -> i64
1301func tfl_push_mesh(M: *i64, col: i64, keep_side: i64) -> i64
called by 2: skn_scenemain calls 3: tm_nvtfl_pushtm_tri
1326func tfl_paint_skin(S: *i64, T: *i64, base: i64, skin_col: i64) -> i64
1380func tfl_push_globe(cx: i64, cy: i64, cz: i64, r: i64, iris: i64, pupil: i64, lid: i64) -> i64
1447func tfl_push_lid(S: *i64, T: *i64, cx: i64, cy: i64, cz: i64, r: i64, semx: i64, semy: i64, flen: i64, fh: i64, tilt10: i64, col: i64) -> i64
1547func tfl_push_eyes(M: *i64, S: *i64, T: *i64, tilt10: i64, skin_col: i64, out: *i64) -> i64
1615func tfl_push_nose(S: *i64, T: *i64, col: i64, out: *i64) -> i64
1714func tfl_smooth_skin(M: *i64, S: *i64, D: *i64, dmed: i64) -> i64
1794func tfl_scene_normals() -> i64 { return tm_compute_normals() }
1797func tfl_render(fb: *i64, W: i64, H: i64, yaw: i64, head_u10: i64, frame_permil: i64) -> i64
1811func tfl_recentre(cx: i64, cy: i64, cz: i64) -> i64
called by 2: mainmain calls 2: tm_nvtm_place
1818func tfl_scene_to_mesh() -> *i64
1852func tfl_pair(a: *i64, b: *i64, W: i64, H: i64, out: *i64) -> i64
called by 1: main
1865func sks_surface(skull_path: *u8, T: *i64, Mout: *i64, Dout: *i64, K: *i64) -> *i64
1894func tfl_peak_rss_kb() -> i64
1919func tfl_run_skullsdf(out: *u8, sex: i64, robust: i64, cell_um: i64) -> i64