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 3 imports · 12 importers
diagram shows first 10 each side; +0 more imports, +2 more importers in the complete lists below.
imports: nx_syscalls.nxnx_itrig.nxnx_vecmath.nx
imported by: nx_camera_anim_gate.nxnx_cloud_volume_gate.nxnx_diversity_gate.nxnx_gen_content.nxnx_gen_unified.nxnx_gi_gate.nxnx_gi_path_lib.nxnx_gt_annotations_gate.nxnx_livingworld_gate.nxnx_worldgen_gate.nxnx_worldgen_showcase.nxnx_worldpop_gate.nx
structs
| none |
consts
| 10 | const WG_MAGIC_374761393: i64 = 374761393 |
| 11 | const WG_MAGIC_668265263: i64 = 668265263 |
| 12 | const WG_MAGIC_65536: i64 = 65536 |
| 13 | const WG_MAGIC_4000: i64 = 4000 |
| 14 | const WG_MAGIC_1024: i64 = 1024 |
| 15 | const WG_MAGIC_32768: i64 = 32768 |
| 16 | const WG_MAGIC_2900: i64 = 2900 |
| 17 | const WG_MAGIC_1048576: i64 = 1048576 |
| 18 | const WG_MAGIC_3000: i64 = 3000 |
| 19 | const WG_MAGIC_40000: i64 = 40000 |
| 20 | const WG_MAGIC_1050: i64 = 1050 |
| 21 | const WG_MAGIC_4096: i64 = 4096 |
| 22 | const WG_MAGIC_9999: i64 = 9999 |
| 23 | const WG_MAGIC_60000: i64 = 60000 |
| 24 | const WG_MAGIC_2000000000: i64 = 2000000000 |
| 25 | const WG_MAGIC_1800: i64 = 1800 |
| 26 | const WG_MAGIC_1500: i64 = 1500 |
| 27 | const WG_MAGIC_1350: i64 = 1350 |
| 28 | const WG_MAGIC_1100: i64 = 1100 |
| 30 | const WG_W: i64 = 1280 // 2x render -> the page downscales it = free anti-aliasing |
| 31 | const WG_H: i64 = 768 |
| 32 | const WG_FOCAL: i64 = 720 |
| 33 | const WG_HORIZON: i64 = 92 // shifts the horizon down (look slightly over the land) |
| 34 | const WATER: i64 = 0 // water level (world units) |
| 35 | const HSCALE: i64 = 4600 |
| 36 | const SNOW: i64 = 2620 |
| 84 | const WG_CLOUD_BASE: i64 = 5200 // world units; terrain tops out near HSCALE, the deck floats above it |
| 85 | const WG_CLOUD_TOP: i64 = 8400 |
| 86 | const WG_CLOUD_RAMP_LO: i64 = 400 // density rises over this many units above the base |
| 87 | const WG_CLOUD_RAMP_HI: i64 = 1200 // and falls over this many units below the top (anvils thin out) |
| 88 | const WG_CLOUD_CELL: i64 = 640 // one noise cell in world units at octave 0 |
| 89 | const WG_CLOUD_OCTAVES: i64 = 4 |
| 90 | const WG_CLOUD_GAIN: i64 = 6 // slope of the coverage threshold |
| 91 | const WG_CLOUD_SEED_SALT: i64 = 7 // the sheet's seed, shared so volume and sheet agree on which sky |
| 92 | const WG_CLOUD_ADVECT: i64 = 12 // world units per time unit at wind Q10 = 1024 |
| 93 | const WG_CLOUD_ORIGIN: i64 = 1048576 // positive offset so >> and & see positive coordinates |
| 94 | const WG_COVER_LOSTVIS_W: i64 = 4 // coverage weights over the Q14 field params: lost visibility dominates |
| 95 | const WG_COVER_PRECIP_W: i64 = 1 |
| 96 | const WG_COVER_FOG_W: i64 = 1 |
| 97 | const WG_SHEET_THR_GAIN: i64 = 5 // the incumbent sheet threshold: 1024 - cloud*5 |
| 210 | const GI_N: i64 = 96 // cells per axis |
| 211 | const GI_CS: i64 = 500 // world units per cell |
| 212 | const GI_X0: i64 = 0 - 24000 // grid origin (covers the visible near field) |
| 213 | const GI_Z0: i64 = 0 |
functions
| 39 | func wg_isqrt(v: i64) -> i64 { return vm_isqrt(v) } |
| 40 | func wg_abs(v: i64) -> i64 { if v<0 {return 0-v} return v } |
| 41 | func wg_min(a: i64, b: i64) -> i64 { if a<b {return a} return b } |
| 42 | func wg_max(a: i64, b: i64) -> i64 { if a>b {return a} return b } |
| 43 | func wg_clamp(v: i64, lo: i64, hi: i64) -> i64 { if v<lo {return lo} if v>hi {return hi} return v } |
| 45 | func wg_hash(ix: i64, iz: i64, seed: i64) -> i64 |
| 50 | func wg_smooth(t: i64) -> i64 { return t*t*(768 - 2*t)/WG_MAGIC_65536 } // smoothstep, t in 0..256 -> 0..256 |
| 51 | func wg_vnoise(x256: i64, z256: i64, seed: i64) -> i64 |
| 62 | func wg_fbm(wx: i64, wz: i64, seed: i64) -> i64 |
| 71 | func wg_terrain_h(wx: i64, wz: i64, seed: i64) -> i64 { return (wg_fbm(wx,wz,seed) - 402) * HSCALE / WG_MAGIC_1024 } |
| 98 | func wg_hash3(ix: i64, iy: i64, iz: i64, seed: i64) -> i64 |
| 103 | func wg_vnoise3(x256: i64, y256: i64, z256: i64, seed: i64) -> i64 |
| 119 | func wg_fbm3(x256: i64, y256: i64, z256: i64, seed: i64) -> i64 |
| 128 | func wg_cover_from_weather(precip_q14: i64, visibility_q14: i64, fog_q14: i64, q: i64) -> i64 |
| 136 | func wg_cloud_envelope(wy: i64) -> i64 |
| 143 | func wg_cloud_volume(wx: i64, wy: i64, wz: i64, t: i64, cover_q10: i64, wind_dx_q10: i64, wind_dz_q10: i64, seed: i64) -> i64 |
| 158 | func wg_cloud_sheet(px: i64, pz: i64, cloud: i64) -> i64 |
| 164 | func wg_weather(mode: i64, W: *i64) -> i64 |
| 183 | func wg_sun_pen(seed: i64, hx: i64, hy: i64, hz: i64, Wp: *i64) -> i64 |
| 216 | func wg_set_gi(on: i64) -> i64 { WG_GION = on; return 0 } |
| 217 | func wg_gi_build(seed: i64, biome: i64, Wp: *i64) -> i64 |
| 265 | func wg_gi_gather(hx: i64, hy: i64, hz: i64, nx: i64, ny: i64, nz: i64, out: *i64) -> i64 |
| 321 | func wg_sky(dx: i64, dy: i64, dz: i64, Wp: *i64, oc: *i64) -> i64 |
| 356 | func wg_cam_base_y(seed: i64) -> i64 { return wg_max(WATER, wg_terrain_h(0,0,seed)) + WG_MAGIC_1050 } |
| 357 | func worldgen_render_full(seed: i64, mode: i64, biome: i64, cam: *i64, fb: *i64, depth: *i64, seg: *i64, nrm: *i64) -> i64 |
| 527 | func wg_ray(px: i64, py: i64, yaw: i64, out: *i64) -> i64 |
| 540 | func wg_project(seed: i64, cam: *i64, Px: i64, Py: i64, Pz: i64, out: *i64) -> i64 |
| 561 | func worldgen_render_bd(seed: i64, mode: i64, biome: i64, fb: *i64, depth: *i64) -> i64 |
| 567 | func worldgen_render_d(seed: i64, mode: i64, fb: *i64, depth: *i64) -> i64 { return worldgen_render_bd(seed, mode, 0, fb, depth) } |
| 568 | func worldgen_render(seed: i64, mode: i64, fb: *i64) -> i64 |
| 573 | func wg_w() -> i64 { return WG_W } |
| 574 | func wg_h() -> i64 { return WG_H } |