code wiki / _hdl_build / nx_sphere_gate.nx

nx_sphere_gate.nx

buildroot/runtime/_hdl_build/nx_sphere_gate.nx

10018 B244 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_sphere_gate.nx -- realism/anime on an OBJECT (not terrain): a smooth Gouraud-lit sphere on the sovereign f32 raster path. Geometry = spherified cube (no trig; normalize a cube grid via nx_f32_sqrt, same bit layout as hw f32). Per-vertex lambert brightness (normal=unit position) interpolated PER PIXEL = smooth shading. Rendered twice: style 0 realism (smooth), style 1 toon (2-tone + black outline). 2 BMPs. exit 0 = rendered. license_tier: ORIGINAL

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_f32_hw.nx nx_f32.nx nx_sphere_gate.nx

imports: nx_syscalls.nxnx_f32_hw.nxnx_f32.nx

imported by: nobody (leaf or entry point)

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

main sys_mmap m4_roty m4_identity f32_of f32_neg fratio f32_div f32_of ↻ m4_rotx m4_identity ↻ f32_neg ↻ m4_mul f32_of ↻ f32_add f32_mul render_sphere fratio ↻ f32_neg ↻ sys_mmap ↻ cube_pt f32_of ↻ f32_neg ↻ f32_add ↻ f32_mul ↻ nx_f32_sqrt nx_f32_classify nx_f32_exp_field nx_f32_mant_field nx_f32_sign nx_f32_exp_field ↻ nx_f32_mant_field ↻ _f32_isqrt f32_div ↻ f32_of ↻ m4_vec4 f32_of ↻ f32_add ↻ f32_mul ↻ v3_dot

structs

none

consts

10const W: i64 = 320
11const H: i64 = 240
12const HW: i64 = 160
13const HH: i64 = 120
14const G: i64 = 10 // cells per cube-face edge (verts/edge = G+1)
15const VPF: i64 = 121 // (G+1)*(G+1)
16const NV: i64 = 726 // 6*VPF
17const FOCAL: i64 = 560
18const PUSH: i64 = 4
19const ZFAR: i64 = 1073741824

functions

21func imin(a: i64, b: i64) -> i64 { if a < b { return a } return b }
called by 2: min3fill_gour
22func imax(a: i64, b: i64) -> i64 { if a > b { return a } return b }
called by 2: max3fill_gour
23func iabs(a: i64) -> i64 { if a < 0 { return 0 - a } return a }
24func min3(a: i64, b: i64, c: i64) -> i64 { return imin(a, imin(b, c)) }
called by 1: fill_gour calls 1: imin
25func max3(a: i64, b: i64, c: i64) -> i64 { return imax(a, imax(b, c)) }
called by 1: fill_gour calls 1: imax
26func clamp255(v: i64) -> i64 { if v < 0 { return 0 } if v > 255 { return 255 } return v }
called by 1: render_sphere
27func same_sign3(a: i64, b: i64, c: i64) -> i64
called by 1: fill_gour
32func fratio(num: i64, den: i64) -> i64 { return f32_div(f32_of(num), f32_of(den)) }
called by 2: render_spheremain calls 2: f32_divf32_of
34func cube_pt(f: i64, u: i64, v: i64, out: *i64) -> i64
called by 1: render_sphere calls 2: f32_off32_neg
46func fill_gour(fb: *i64, zb: *i64, t: *i64, baseR: i64, baseG: i64, baseB: i64, style: i64) -> i64
79func outline_pass(fb: *i64, zb: *i64) -> i64
called by 1: render_sphere
100func put_u32le(b: *u8, o: i64, v: i64) -> i64
called by 1: write_bmp
107func write_bmp(fb: *i64, path: *u8) -> i64
143func render_sphere(fb: *i64, zb: *i64, R: *i64, style: i64, baseR: i64, baseG: i64, baseB: i64,
222func main() -> i64