nx_anatstack.nx
buildroot/runtime/nx_anatstack.nx
about
nx_anatstack.nx -- ★LAYERED ANATOMICAL MODEL (operator 2026-07-08: "stop building circles on circles -- you
need the skeleton and muscles and all that so that as you get to the top layer it's anatomically PERFECT for the
final layer brush through"). The RIGHT inside-out architecture: don't eyeball skin ellipsoids -- build the real
stack and let the skin EMERGE from it:
LAYER 0 SKELETON -- the skull's bony forms (cranium, temporals, zygomatics, maxilla, mandible, nasal, brow)
LAYER 1 MUSCLE -- the facial muscles as CAPSULES (temporalis, masseter, zygomaticus, orbicularis, ...)
LAYER 2 FAT/SOFT -- the fat pads (malar, buccal, periorbital, labial, submental)
-> SKIN = the smooth-union ENVELOPE over all layers + a dermal offset = anatomically DERIVED, not sculpted.
Self-contained (own SDF + integer ray-march) so it doesn't destabilize the sdf_render pipeline. Capsules are a
real muscle shape (beyond ellipsoids). Every position is anatomically reasoned in the faceanat landmark frame
(y up: chin -676, mouth -390, subnasale -150, eye +178, brow +322, crown +760; -z = front/toward camera).
license_tier: ORIGINAL
dependencies 2 imports · 6 importers
imports: nx_syscalls.nxnx_itrig.nx
imported by: nx_anatstack_gate.nxnx_creaturegen.nxnx_face_expr_gate.nxnx_facesculpt_gate.nxnx_facs.nxnx_figuregen.nx
structs
| none |
consts
| 15 | const AS_MAGIC_1024: i64 = 1024 |
| 16 | const AS_MAGIC_374761393: i64 = 374761393 |
| 17 | const AS_MAGIC_668265263: i64 = 668265263 |
| 18 | const AS_MAGIC_1274126177: i64 = 1274126177 |
| 19 | const AS_MAGIC_2654435761: i64 = 2654435761 |
| 20 | const AS_MAGIC_1013904223: i64 = 1013904223 |
| 21 | const AS_MAGIC_4096: i64 = 4096 |
| 22 | const AS_MAGIC_1048576: i64 = 1048576 |
| 23 | const AS_MAGIC_65536: i64 = 65536 |
| 24 | const AS_MAGIC_1000000: i64 = 1000000 |
| 25 | const AS_MAGIC_1000000000: i64 = 1000000000 |
| 26 | const AS_MAGIC_1400: i64 = 1400 |
| 27 | const AS_MAGIC_16777215: i64 = 16777215 |
| 29 | const AS_STRIDE: i64 = 12 // per-part: layer,type, p1(3), r(3), p2(3), _ |
| 30 | const AS_BONE: i64 = 0 |
| 31 | const AS_MUSCLE: i64 = 1 |
| 32 | const AS_FAT: i64 = 2 |
| 33 | const AS_ELLIP: i64 = 0 |
| 34 | const AS_CAPS: i64 = 1 |
| 35 | const AS_W: i64 = 512 |
| 36 | const AS_H: i64 = 512 |
| 37 | const AS_FOCAL: i64 = 640 |
| 38 | const AS_K: i64 = 46 // smooth-union blend radius (units) |
| 63 | const AS_FEAT: i64 = 16777216 |
| 64 | const AS_FUZZ: i64 = 33554432 |
| 65 | const AS_FUZZAMP: i64 = 7 // displacement amplitude (units) |
| 66 | const AS_FUZZCELL: i64 = 13 // noise lattice cell (units) |
| 72 | const AS_GLOSS: i64 = 67108864 |
| 73 | const AS_MATTE: i64 = 134217728 |
| 74 | const AS_HAIRM: i64 = 201326592 |
functions
| 40 | func as_isqrt(v: i64) -> i64 { if v <= 0 { return 0 } var x: i64 = v; var y: i64 = (x+1)/2; while y < x { x=y; y=(x+v/x)/2 } return x } |
| 41 | func as_iabs(v: i64) -> i64 { if v < 0 { return 0-v } return v } |
| 42 | func as_min(a: i64, b: i64) -> i64 { if a < b { return a } return b } |
| 43 | func as_clamp(v: i64, lo: i64, hi: i64) -> i64 { if v<lo {return lo} if v>hi {return hi} return v } called by 1: as_part_sdf |
| 45 | func as_ellip(P: *i64, i: i64, cx: i64, cy: i64, cz: i64, rx: i64, ry: i64, rz: i64, layer: i64) -> i64 |
| 49 | func as_caps(P: *i64, i: i64, ax: i64, ay: i64, az: i64, bx: i64, by: i64, bz: i64, r: i64, layer: i64) -> i64 |
| 82 | func as_set_skintex(ptr: i64, w: i64, scale: i64) -> i64 { AS_SKINTEX = ptr; AS_SKINTEXW = w; AS_SKINTEXS = scale; return 0 } |
| 83 | func as_color_last(P: *i64, i_after: i64, rgb: i64) -> i64 { P[i_after - AS_STRIDE + 11] = rgb; return i_after } |
| 84 | func as_feature_last(P: *i64, i_after: i64, rgb: i64) -> i64 { P[i_after - AS_STRIDE + 11] = rgb + AS_FEAT; return i_after } |
| 85 | func as_fuzz_last(P: *i64, i_after: i64) -> i64 { P[i_after - AS_STRIDE + 11] = P[i_after - AS_STRIDE + 11] + AS_FUZZ; return i_after } |
| 92 | func anat_set_expr(e: i64, inten: i64) -> i64 { AS_EXPR = e; AS_EXPRI = inten; return 0 } |
| 93 | func as_shifty(P: *i64, idx: i64, dy: i64) -> i64 { let b: i64 = idx*AS_STRIDE; P[b+3]=P[b+3]+dy; if P[b+1]==AS_CAPS { P[b+9]=P[b+9]+dy } return 0 } |
| 94 | func as_shiftz(P: *i64, idx: i64, dz: i64) -> i64 { let b: i64 = idx*AS_STRIDE; P[b+4]=P[b+4]+dz; if P[b+1]==AS_CAPS { P[b+10]=P[b+10]+dz } return 0 } |
| 95 | func as_growx(P: *i64, idx: i64, dx: i64) -> i64 { P[idx*AS_STRIDE+5]=P[idx*AS_STRIDE+5]+dx; return 0 } |
| 96 | func as_growy(P: *i64, idx: i64, dy: i64) -> i64 { P[idx*AS_STRIDE+6]=P[idx*AS_STRIDE+6]+dy; return 0 } |
| 99 | func as_apply_expr(P: *i64) -> i64 |
| 124 | func as_h3(ix: i64, iy: i64, iz: i64) -> i64 called by 1: as_noise3 |
| 130 | func as_noise3(x: i64, y: i64, z: i64) -> i64 |
| 151 | func anatstack_build(P: *i64) -> i64 |
| 211 | func as_part_sdf(P: *i64, k: i64, x: i64, y: i64, z: i64) -> i64 |
| 232 | func as_smin(a: i64, b: i64, k: i64) -> i64 |
| 241 | func anatstack_sdf(P: *i64, np: i64, x: i64, y: i64, z: i64, maxlayer: i64, inflate: i64) -> i64 |
| 263 | func anatstack_nearest_fl(P: *i64, np: i64, x: i64, y: i64, z: i64, maxlayer: i64, inflate: i64) -> i64 |
| 281 | func anatstack_render(P: *i64, np: i64, yaw: i64, camz: i64, maxlayer: i64, inflate: i64, cr: i64, cg: i64, cb: i64, fb: *i64) -> i64 called by 10: mainmainmainmainmainface_col+4 calls 6: it_sin4096it_cos4096as_isqrtanatstack_sdfanatstack_nearest_flas_iabs |
| 409 | func as_w() -> i64 { return AS_W } called by 1: main |
| 410 | func as_h() -> i64 { return AS_H } |