nx_worldgen.nx
buildroot/runtime/nx_worldgen.nx
about
nx_worldgen.nx -- ★SOVEREIGN INFINIGEN, RUNG 1: procedural NATURE (operator 2026-07-08, sharing princeton-vl/
infinigen: "build a WORLD full of living people, animals, environments, weather"). Infinigen = seed->procedural
photoreal 3D, NO ML, NO external assets -- EXACTLY our doctrine. This is the nature/"hello world" module: a
seed grows a whole LANDSCAPE -- fBm terrain (grass/rock/snow by height+slope) + water (lakes/sea) + sky gradient
+ sun + procedural clouds + atmospheric fog. All INTEGER, sovereign, our own heightfield ray-marcher. Different
seed = different world; a weather param retints sun/sky/fog (clear / sunset / overcast). license_tier: ORIGINAL
dependencies 2 imports · 8 importers
imports: nx_syscalls.nxnx_itrig.nx
imported by: nx_camera_anim_gate.nxnx_diversity_gate.nxnx_gi_gate.nxnx_gt_annotations_gate.nxnx_livingworld_gate.nxnx_worldgen_gate.nxnx_worldgen_showcase.nxnx_worldpop_gate.nx
structs
| none |
consts
| 9 | const WG_MAGIC_374761393: i64 = 374761393 |
| 10 | const WG_MAGIC_668265263: i64 = 668265263 |
| 11 | const WG_MAGIC_65536: i64 = 65536 |
| 12 | const WG_MAGIC_4000: i64 = 4000 |
| 13 | const WG_MAGIC_1024: i64 = 1024 |
| 14 | const WG_MAGIC_32768: i64 = 32768 |
| 15 | const WG_MAGIC_2900: i64 = 2900 |
| 16 | const WG_MAGIC_1048576: i64 = 1048576 |
| 17 | const WG_MAGIC_3000: i64 = 3000 |
| 18 | const WG_MAGIC_40000: i64 = 40000 |
| 19 | const WG_MAGIC_1050: i64 = 1050 |
| 20 | const WG_MAGIC_4096: i64 = 4096 |
| 21 | const WG_MAGIC_9999: i64 = 9999 |
| 22 | const WG_MAGIC_60000: i64 = 60000 |
| 23 | const WG_MAGIC_2000000000: i64 = 2000000000 |
| 24 | const WG_MAGIC_1800: i64 = 1800 |
| 25 | const WG_MAGIC_1500: i64 = 1500 |
| 26 | const WG_MAGIC_1350: i64 = 1350 |
| 27 | const WG_MAGIC_1100: i64 = 1100 |
| 29 | const WG_W: i64 = 1280 // 2x render -> the page downscales it = free anti-aliasing |
| 30 | const WG_H: i64 = 768 |
| 31 | const WG_FOCAL: i64 = 720 |
| 32 | const WG_HORIZON: i64 = 92 // shifts the horizon down (look slightly over the land) |
| 33 | const WATER: i64 = 0 // water level (world units) |
| 34 | const HSCALE: i64 = 4600 |
| 35 | const SNOW: i64 = 2620 |
| 118 | const GI_N: i64 = 96 // cells per axis |
| 119 | const GI_CS: i64 = 500 // world units per cell |
| 120 | const GI_X0: i64 = 0 - 24000 // grid origin (covers the visible near field) |
| 121 | const GI_Z0: i64 = 0 |
functions
| 37 | func wg_isqrt(v: i64) -> i64 { if v<=0 {return 0} var x: i64=v; var y: i64=(x+1)/2; while y<x {x=y; y=(x+v/x)/2} return x } |
| 38 | func wg_abs(v: i64) -> i64 { if v<0 {return 0-v} return v } |
| 39 | func wg_min(a: i64, b: i64) -> i64 { if a<b {return a} return b } |
| 40 | func wg_max(a: i64, b: i64) -> i64 { if a>b {return a} return b } |
| 41 | func wg_clamp(v: i64, lo: i64, hi: i64) -> i64 { if v<lo {return lo} if v>hi {return hi} return v } |
| 43 | func wg_hash(ix: i64, iz: i64, seed: i64) -> i64 called by 1: wg_vnoise |
| 48 | func wg_smooth(t: i64) -> i64 { return t*t*(768 - 2*t)/WG_MAGIC_65536 } // smoothstep, t in 0..256 -> 0..256 called by 1: wg_vnoise |
| 49 | func wg_vnoise(x256: i64, z256: i64, seed: i64) -> i64 |
| 60 | func wg_fbm(wx: i64, wz: i64, seed: i64) -> i64 |
| 69 | func wg_terrain_h(wx: i64, wz: i64, seed: i64) -> i64 { return (wg_fbm(wx,wz,seed) - 402) * HSCALE / WG_MAGIC_1024 } |
| 72 | func wg_weather(mode: i64, W: *i64) -> i64 |
| 91 | func wg_sun_pen(seed: i64, hx: i64, hy: i64, hz: i64, Wp: *i64) -> i64 |
| 124 | func wg_set_gi(on: i64) -> i64 { WG_GION = on; return 0 } |
| 125 | func wg_gi_build(seed: i64, biome: i64, Wp: *i64) -> i64 |
| 173 | func wg_gi_gather(hx: i64, hy: i64, hz: i64, nx: i64, ny: i64, nz: i64, out: *i64) -> i64 |
| 229 | func wg_sky(dx: i64, dy: i64, dz: i64, Wp: *i64, oc: *i64) -> i64 |
| 265 | func wg_cam_base_y(seed: i64) -> i64 { return wg_max(WATER, wg_terrain_h(0,0,seed)) + WG_MAGIC_1050 } |
| 266 | func worldgen_render_full(seed: i64, mode: i64, biome: i64, cam: *i64, fb: *i64, depth: *i64, seg: *i64, nrm: *i64) -> i64 called by 4: mainmainmainworldgen_render_bd calls 14: sys_mmapwg_weatherwg_gi_buildwg_cam_base_yit_sin4096it_cos4096+8 |
| 436 | func wg_ray(px: i64, py: i64, yaw: i64, out: *i64) -> i64 |
| 449 | func wg_project(seed: i64, cam: *i64, Px: i64, Py: i64, Pz: i64, out: *i64) -> i64 |
| 470 | func worldgen_render_bd(seed: i64, mode: i64, biome: i64, fb: *i64, depth: *i64) -> i64 |
| 476 | func worldgen_render_d(seed: i64, mode: i64, fb: *i64, depth: *i64) -> i64 { return worldgen_render_bd(seed, mode, 0, fb, depth) } |
| 477 | func worldgen_render(seed: i64, mode: i64, fb: *i64) -> i64 |
| 482 | func wg_w() -> i64 { return WG_W } |
| 483 | func wg_h() -> i64 { return WG_H } |