code wiki / _hdl_build / nx_ng_volrender.nx

nx_ng_volrender.nx

buildroot/runtime/_hdl_build/nx_ng_volrender.nx

7690 B149 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic ng
docsdependenciesstructsconstsfunctions

about

nx_ng_volrender.nx -- CAP-VOLUME-RENDER, generation 7 on the neural-graphics ladder (nx_ng_gap named it the next missing generation after CAP-DIFF-RENDER). The volumetric ALPHA-OVER compositing operator that is the actual render op of NeRF (after the density->alpha map) AND the core of 3D Gaussian Splatting: T_0 = 1 ; C = sum_i T_i * alpha_i * c_i ; T_{i+1} = T_i * (1 - alpha_i) i.e. front-to-back "over" compositing along a ray. Q16 fixed-point, no float, sovereign syscalls only. Honest gated proof (HARD evidence per the genealogy ladder): T1 FORWARD correctness -- opaque front occludes the rest (C==c0); all-transparent shows background (C==0); half-opaque samples composite to the hand-checked weighted sum (transmittance chain is right). T2 DIFFERENTIABLE -- the per-sample compositing weight w_i = T_i*alpha_i IS dC/dc_i; GD on the sample colors drives the composited C -> a target C*, loss -> ~0 (gradients flow through the render). T3 NEG-CONTROL -- ascending that gradient DIVERGES (the gradient has correct direction/teeth). T4 GRADCHECK -- sign(analytic dLoss/dc0) == sign(L(c0+e)-L(c0-e)). NOTE: the NeRF density form alpha=1-exp(-sigma*delta) is a thin wrapper over this (exp helper already in nx_nofloat_autograd); the alpha/sigma gradient is the follow-on rung. license_tier: ORIGINAL expect_exit: 0

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_ng_volrender.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main vp sys_write sys_mmap vr_forward vqm vpn sys_mmap ↻ sys_write ↻ vr_loss vqm ↻ vqm ↻ sys_exit

structs

none

consts

17const K_MAGIC_13107: i64 = 13107
18const K_MAGIC_26214: i64 = 26214
19const K_MAGIC_39321: i64 = 39321
20const K_MAGIC_52429: i64 = 52429
21const K_MAGIC_49000: i64 = 49000
22const K_MAGIC_49300: i64 = 49300
23const K_MAGIC_104856: i64 = 104856
25const Q: i64 = 65536
26const H: i64 = 32768 // 0.5
27const NS: i64 = 4 // samples along the ray
28const LR: i64 = 65536 // 1.0 (Q16); composite is linear in c -> stable
29const NSTEP: i64 = 40
30const NASC: i64 = 6 // neg-control ascent steps (bounded: ascent grows error ~1.66x/step -> avoid i64 overflow)
31const CSTAR: i64 = 26214 // target composited color = 0.4
32const EPS: i64 = 655 // finite-diff step = 0.01

functions

34func vp(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 1: main calls 1: sys_write
35func vpn(v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
44func vqm(a: i64, b: i64) -> i64 { return (a * b) >> 16 }
47func vr_forward(alpha: *i64, col: *i64, w: *i64) -> i64
called by 1: main calls 1: vqm
58func vr_loss(C: i64, cstar: i64) -> i64 { let d: i64 = C - cstar; return vqm(d, d) }
called by 1: main calls 1: vqm
60func main() -> i64