code wiki / _hdl_build / nx_sphere_gate.nx
nx_sphere_gate.nx
buildroot/runtime/_hdl_build/nx_sphere_gate.nx
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
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
structs
| none |
consts
| 10 | const W: i64 = 320 |
| 11 | const H: i64 = 240 |
| 12 | const HW: i64 = 160 |
| 13 | const HH: i64 = 120 |
| 14 | const G: i64 = 10 // cells per cube-face edge (verts/edge = G+1) |
| 15 | const VPF: i64 = 121 // (G+1)*(G+1) |
| 16 | const NV: i64 = 726 // 6*VPF |
| 17 | const FOCAL: i64 = 560 |
| 18 | const PUSH: i64 = 4 |
| 19 | const ZFAR: i64 = 1073741824 |
functions
| 21 | func imin(a: i64, b: i64) -> i64 { if a < b { return a } return b } |
| 22 | func imax(a: i64, b: i64) -> i64 { if a > b { return a } return b } |
| 23 | func iabs(a: i64) -> i64 { if a < 0 { return 0 - a } return a } |
| 24 | func min3(a: i64, b: i64, c: i64) -> i64 { return imin(a, imin(b, c)) } |
| 25 | func max3(a: i64, b: i64, c: i64) -> i64 { return imax(a, imax(b, c)) } |
| 26 | func clamp255(v: i64) -> i64 { if v < 0 { return 0 } if v > 255 { return 255 } return v } called by 1: render_sphere |
| 27 | func same_sign3(a: i64, b: i64, c: i64) -> i64 called by 1: fill_gour |
| 32 | func fratio(num: i64, den: i64) -> i64 { return f32_div(f32_of(num), f32_of(den)) } |
| 34 | func cube_pt(f: i64, u: i64, v: i64, out: *i64) -> i64 |
| 46 | func fill_gour(fb: *i64, zb: *i64, t: *i64, baseR: i64, baseG: i64, baseB: i64, style: i64) -> i64 |
| 79 | func outline_pass(fb: *i64, zb: *i64) -> i64 called by 1: render_sphere |
| 100 | func put_u32le(b: *u8, o: i64, v: i64) -> i64 called by 1: write_bmp |
| 107 | func write_bmp(fb: *i64, path: *u8) -> i64 |
| 143 | func render_sphere(fb: *i64, zb: *i64, R: *i64, style: i64, baseR: i64, baseG: i64, baseB: i64, |
| 222 | func main() -> i64 |