code wiki / _hdl_build / nx_sdfrender_gate.nx
nx_sdfrender_gate.nx
buildroot/runtime/_hdl_build/nx_sdfrender_gate.nx
about
nx_sdfrender_gate.nx -- gate for the SMOOTH-UNION SDF body (sovereign software GPU, continuous surface).
T1 the body renders (solid skin block)
T2 per-pixel shading gradient (SDF-gradient normals -> real lighting)
T3 full figure top->bottom
T4 CONTINUOUS: the centre column is ONE fused run (the parts FUSED, not disjoint blobs) -- the whole
point of smooth-union over the rasterized ellipsoids
T5 THE CAPTURE ACTUALLY LANDS -- four teeth where there used to be one, see the block below
T6 pre-integrated SSS (sr_sss_preint), the non-gameable quad
===================================================================================================
WHY T5 IS FOUR TEETH NOW (debt 1787678931, MEASURED 2026-08-25 -- this gate WAS the defect).
The old T5 was one line:
write_png(fb, ww(), hh(), "knowledge/nx_sdfbody.png"); if diff == 0 { PASS "determinism + PNG" }
It DISCARDED write_png's return and gated on DETERMINISM ONLY. Determinism is trivially satisfied by
WRITING NOTHING TWICE, so the tooth could not distinguish a landed capture from no capture at all.
PROOF IT DID NOT: two runs whose framebuffers provably DIFFERED (skin 37624 vs 37626, bands
10352/18040/9232 vs 10353/18042/9231) left knowledge/nx_sdfbody.png byte-identical at
827bc7718e15f0437a1600326e7bc7ec46a34dfc7c189d2a51607f7ccdf185a5 / 142629 B across BOTH -- while this
gate printed "T5 PASS determinism + PNG". A whole rung shipped with no trustworthy before/after image.
A TOOTH THAT DISCARDS ITS ACTUATOR'S RETURN CANNOT SEE THE ACTUATOR FAIL.
DETERMINISM IS NECESSARY AND IS NOT SUFFICIENT, AND THE TOOTH THAT NAMES ONLY THE NECESSARY HALF
READS EXACTLY LIKE A PROOF OF THE WHOLE.
The four that replace it, each named for what it can refute:
T5a the publish RETURNS a byte count and the ARTIFACT ON DISK IS THAT SIZE -- receipt AND artifact
T5b determinism, RENAMED so it can never again be read as evidence the file was written
T5c A/B: two captures whose SHADER PROVABLY DIFFERS must be DIFFERENT FILES. This is the tooth a
no-op writer, a stale-file writer and an open-that-silently-failed all die at, and the one the
old gate had no analogue of.
T5d fixture-reached-the-condition: the two swatches' shader values really do differ, asserted
ARITHMETICALLY and FIRST, so a T5c failure can never be blamed on a fixture that never varied.
plus two neg-controls that must FAIL for the teeth above to mean anything.
AND THE OWED ARTIFACT. T5c's A/B pair is not a synthetic fixture -- it IS the before/after this rung
owes. nx_sdfrender's own shading site says "curv=0 reproduces the former fixed 120/60/26 widths
bit-for-bit", so evaluating the SHIPPED sr_sss_preint over the whole (N.L x curvature) domain with
curvature PASSED THROUGH gives the rung, and with curvature FORCED TO ZERO gives the pre-rung shader
exactly. Two images, one shipped function, no second implementation to be wrong:
knowledge/nx_sdfsss_before.png pre-rung fixed wrap (every row identical: curvature ignored)
knowledge/nx_sdfsss_after.png the shipped rung (rows widen with curvature)
dependencies 4 imports · 0 importers
imports: nx_syscalls.nxnx_gate_verdict.nxnx_png.nxnx_sdfrender.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 53 | const SDG_SKIN_MIN_PX: i64 = 8000 // T1 floor: fewer than this and no body rendered |
| 54 | const SDG_SKIN_MAX_PX: i64 = 90000 // T1 ceiling: more than this and the frame is flooded |
| 55 | const SDG_LUM_SPAN_MIN: i64 = 200 // T2: summed-RGB luminance span that proves per-pixel shading |
| 56 | const SDG_BAND_TOP_MIN: i64 = 300 // T3: head band |
| 57 | const SDG_BAND_MID_MIN: i64 = 1500 // T3: torso band |
| 58 | const SDG_BAND_BOT_MIN: i64 = 300 // T3: legs band |
| 59 | const SDG_TRUNK_RUNS_MAX: i64 = 3 // T4: chin/crotch may break the centre column, nothing more |
| 60 | const SDG_BANDS: i64 = 3 // T3 splits the frame into three equal horizontal bands |
| 61 | const SDG_TRUNK_MIN_DIV: i64 = 2 // T4: the trunk spans more than hh()/2 |
| 65 | const SDG_OLDWRAP_R: i64 = 120 |
| 66 | const SDG_OLDWRAP_G: i64 = 60 |
| 67 | const SDG_OLDWRAP_B: i64 = 26 |
| 70 | const SDG_SSS_PK: i64 = 1024 // the (wR,wG,wB) packing radix of sr_sss_preint_n (nx_sdfrender) |
| 71 | const SDG_PACK_G: i64 = 256 // write_png contract: c = r + g*256 + b*65536 |
| 72 | const SDG_PACK_B: i64 = 65536 |
| 73 | const SDG_PNG_CH_MAX: i64 = 255 // 8-bit PNG channel maximum -- fixed by the FORMAT, not chosen |
| 74 | const SDG_PERMIL: i64 = 1000 |
| 75 | const SDG_DIR_MODE_0755: i64 = 0x1ed // rwxr-xr-x, for the gate's own /tmp scratch directory |
| 76 | const SDG_SEEK_END: i64 = 2 |
| 77 | const SDG_PTR_BYTES: i64 = 8 // one i64 out-parameter slot |
| 78 | const SDG_PX_BYTES: i64 = 8 // the framebuffer write_png consumes is one packed i64 per pixel |
| 80 | const SDG_YAW: i64 = 0 |
| 81 | const SDG_CAMZ: i64 = 5 |
| 82 | const SDG_SKIN_R: i64 = 240 |
| 83 | const SDG_SKIN_G: i64 = 184 |
| 84 | const SDG_SKIN_B: i64 = 160 |
| 86 | const SDG_CURV_PASSTHROUGH: i64 = 1 // the shipped rung: curvature varies down the image |
| 87 | const SDG_CURV_FORCED_FLAT: i64 = 0 // the pre-rung shader: curvature ignored, every row identical |
functions
| 89 | func sdg_is_skin(px: i64) -> i64 { let r: i64 = px & 255; let b: i64 = (px >> 16) & 255; if r >= b { return 1 } return 0 } called by 1: main |
| 90 | func sdg_lum(px: i64) -> i64 { return (px & 255) + ((px >> 8) & 255) + ((px >> 16) & 255) } called by 1: main |
| 93 | func sdg_size(path: *u8) -> i64 |
| 102 | func sdg_did_not_land(path: *u8, claimed: i64) -> i64 |
| 109 | func sdg_noop_writer(path: *u8) -> i64 { return 0 } called by 1: main |
| 113 | func sdg_files_differ(a: *u8, b: *u8, outoff: *i64) -> i64 |
| 139 | func sdg_swatch(fb: *i64, w: i64, h: i64, usecurv: i64) -> i64 |
| 162 | func main() -> i64 |