code wiki / _hdl_build / nx_ng_avatar_rig.nx

nx_ng_avatar_rig.nx

buildroot/runtime/_hdl_build/nx_ng_avatar_rig.nx

10398 B174 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic ng
docsdependenciesstructsconstsfunctions

about

nx_ng_avatar_rig.nx -- CAP-NEURAL-AVATAR RUNG-2: the SKELETAL RIG. Extends nx_ng_avatar's 1-DOF single- gaussian deform to a multi-gaussian character driven by a multi-BONE skeleton via LINEAR BLEND SKINNING (LBS) -- the exact deformation math a DAZ Genesis figure / Unreal MetaHuman rig uses: each gaussian k's posed center = mu0[k] + SUM_b w[k][b]*pose[b] (a learned per-gaussian skinning weight w binds it to the bones). The KEY S-class rung toward beating DAZ/Unreal characters (shared primitive behind offline + real- time). Honest gated proof, Q16 no-float, reuses the gaussian-splat + GD-fit spine from nx_ng_avatar: T1 LEARNED-RIG: fit the skinning weights from posed frames -> loss->~0 AND w recovers the true binding. T2 NOVEL-POSE: an untrained skeleton pose renders correctly (LBS is linear = generalizes, not memorized). T3 NEG-CONTROL: a RIGID rig (all gaussians share one bone) CANNOT match a pose where the bones differ = the skeleton is load-bearing. T4 BIT-EXACT. HONEST: 1D positions, 2 bones, 2 gaussians, translation-LBS (no rotation), linear skinning. Full production = 3D + rotational LBS + blendshapes (expression) + many bones/gaussians = the follow-on rungs. Sovereign: nx_nofloat_autograd + syscalls. license_tier: ORIGINAL expect_exit: 0

dependencies 2 imports · 0 importers

nx_nofloat_autograd.nx nx_syscalls.nx nx_ng_avatar_rig.nx

imports: nx_nofloat_autograd.nxnx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main ap sys_write sys_mmap render_rig rig_center aqm gval aqm ↻ nfa_fxexp fit_skin sys_mmap ↻ render_rig ↻ aqm ↻ rig_center ↻ gval ↻ ap ↻ apn sys_mmap ↻ sys_write ↻ a_abs sse aqm ↻ aqm ↻ apn ↻ sys_openat_append rl_ws sys_write ↻ rl_wn sys_mmap ↻ sys_write ↻ sys_close sys_exit

structs

none

consts

16const K_MAGIC_1500: i64 = 1500
17const K_MAGIC_22938: i64 = 22938
18const K_MAGIC_42598: i64 = 42598
19const K_MAGIC_19661: i64 = 19661
20const K_MAGIC_32768: i64 = 32768
21const K_MAGIC_8192: i64 = 8192
22const K_MAGIC_26214: i64 = 26214
23const K_MAGIC_3000: i64 = 3000
25const RLOG: *u8 = "knowledge/status/ng_avatar_rig.log"
26const Q16: i64 = 65536
27const NP: i64 = 16
28const INV2S2: i64 = 2275555 // 1/(2 sigma^2) Q16, sigma=0.12
29const EPOCHS: i64 = 6000
30const LRQ: i64 = 48
31const NB: i64 = 2 // bones
32const NK: i64 = 2 // gaussians (character parts)
33const NPOSE: i64 = 4 // training skeleton poses

functions

35func ap(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 2: fit_skinmain calls 1: sys_write
36func apn(v: i64) -> i64 { let b: *u8=sys_mmap(28); var x: i64=v; if x<0{b[0]=45;sys_write(1,b,1);x=0-x} if x==0{b[0]=48;sys_write(1,b,1);return 0} var d: i64=0; var y: i64=x; while y>0{d=d+1;y=y/10} var i: i64=d-1; y=x; while i>=0{b[i]=(48+(y%10)) as u8; y=y/10; i=i-1} sys_write(1,b,d); return 0 }
called by 2: fit_skinmain calls 2: sys_mmapsys_write
37func a_abs(v: i64) -> i64 { if v<0 { return 0-v } return v }
called by 1: main
38func aqm(a: i64, b: i64) -> i64 { return (a*b)>>16 }
39func rl_ws(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 }
called by 1: main calls 1: sys_write
40func rl_wn(fd: i64, v: i64) -> i64 { let b: *u8=sys_mmap(28); var m: i64=v; if m<0{sys_write(fd,"-" as *u8,1);m=0-m} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(fd,b,k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
43func gval(center: i64, p: i64) -> i64
called by 2: render_rigfit_skin calls 2: aqmnfa_fxexp
50func rig_center(mu0: *i64, w: *i64, pose: *i64, k: i64) -> i64
called by 2: render_rigfit_skin calls 1: aqm
57func render_rig(mu0: *i64, w: *i64, pose: *i64, out: *i64) -> i64
called by 2: fit_skinmain calls 2: rig_centergval
69func sse(a: *i64, b: *i64) -> i64 { var s: i64=0; var p: i64=0; while p<NP { let d: i64=a[p]-b[p]; s=s+aqm(d,d); p=p+1 } return s }
called by 1: main calls 1: aqm
73func fit_skin(mu0: *i64, poses: *i64, frames: *i64, w: *i64, lf: *i64, ll: *i64) -> i64
114func main() -> i64