code wiki / (root) / nx_worldgen.nx

nx_worldgen.nx

buildroot/runtime/nx_worldgen.nx

26086 B483 linesdepth 2pulls 3 transitivereach 8 importersview sourcekind librarytopic worldgen
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_itrig.nx nx_worldgen.nx nx_camera_anim_gate.nx nx_diversity_gate.nx nx_gi_gate.nx nx_gt_annotations_gate.nx nx_livingworld_gate.nx nx_worldgen_gate.nx nx_worldgen_showcase.nx nx_worldpop_gate.nx

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

9const WG_MAGIC_374761393: i64 = 374761393
10const WG_MAGIC_668265263: i64 = 668265263
11const WG_MAGIC_65536: i64 = 65536
12const WG_MAGIC_4000: i64 = 4000
13const WG_MAGIC_1024: i64 = 1024
14const WG_MAGIC_32768: i64 = 32768
15const WG_MAGIC_2900: i64 = 2900
16const WG_MAGIC_1048576: i64 = 1048576
17const WG_MAGIC_3000: i64 = 3000
18const WG_MAGIC_40000: i64 = 40000
19const WG_MAGIC_1050: i64 = 1050
20const WG_MAGIC_4096: i64 = 4096
21const WG_MAGIC_9999: i64 = 9999
22const WG_MAGIC_60000: i64 = 60000
23const WG_MAGIC_2000000000: i64 = 2000000000
24const WG_MAGIC_1800: i64 = 1800
25const WG_MAGIC_1500: i64 = 1500
26const WG_MAGIC_1350: i64 = 1350
27const WG_MAGIC_1100: i64 = 1100
29const WG_W: i64 = 1280 // 2x render -> the page downscales it = free anti-aliasing
30const WG_H: i64 = 768
31const WG_FOCAL: i64 = 720
32const WG_HORIZON: i64 = 92 // shifts the horizon down (look slightly over the land)
33const WATER: i64 = 0 // water level (world units)
34const HSCALE: i64 = 4600
35const SNOW: i64 = 2620
118const GI_N: i64 = 96 // cells per axis
119const GI_CS: i64 = 500 // world units per cell
120const GI_X0: i64 = 0 - 24000 // grid origin (covers the visible near field)
121const GI_Z0: i64 = 0

functions

37func 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 }
38func wg_abs(v: i64) -> i64 { if v<0 {return 0-v} return v }
39func wg_min(a: i64, b: i64) -> i64 { if a<b {return a} return b }
40func wg_max(a: i64, b: i64) -> i64 { if a>b {return a} return b }
41func wg_clamp(v: i64, lo: i64, hi: i64) -> i64 { if v<lo {return lo} if v>hi {return hi} return v }
43func wg_hash(ix: i64, iz: i64, seed: i64) -> i64
called by 1: wg_vnoise
48func 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
49func wg_vnoise(x256: i64, z256: i64, seed: i64) -> i64
60func wg_fbm(wx: i64, wz: i64, seed: i64) -> i64
called by 2: wg_terrain_hwg_sky calls 1: wg_vnoise
69func wg_terrain_h(wx: i64, wz: i64, seed: i64) -> i64 { return (wg_fbm(wx,wz,seed) - 402) * HSCALE / WG_MAGIC_1024 }
72func wg_weather(mode: i64, W: *i64) -> i64
called by 1: worldgen_render_full calls 1: wg_isqrt
91func wg_sun_pen(seed: i64, hx: i64, hy: i64, hz: i64, Wp: *i64) -> i64
124func wg_set_gi(on: i64) -> i64 { WG_GION = on; return 0 }
called by 3: mainmainmain
125func wg_gi_build(seed: i64, biome: i64, Wp: *i64) -> i64
173func wg_gi_gather(hx: i64, hy: i64, hz: i64, nx: i64, ny: i64, nz: i64, out: *i64) -> i64
called by 1: worldgen_render_full calls 1: wg_isqrt
229func wg_sky(dx: i64, dy: i64, dz: i64, Wp: *i64, oc: *i64) -> i64
265func wg_cam_base_y(seed: i64) -> i64 { return wg_max(WATER, wg_terrain_h(0,0,seed)) + WG_MAGIC_1050 }
266func worldgen_render_full(seed: i64, mode: i64, biome: i64, cam: *i64, fb: *i64, depth: *i64, seg: *i64, nrm: *i64) -> i64
436func wg_ray(px: i64, py: i64, yaw: i64, out: *i64) -> i64
called by 1: main calls 3: it_sin4096it_cos4096wg_isqrt
449func wg_project(seed: i64, cam: *i64, Px: i64, Py: i64, Pz: i64, out: *i64) -> i64
470func worldgen_render_bd(seed: i64, mode: i64, biome: i64, fb: *i64, depth: *i64) -> i64
476func worldgen_render_d(seed: i64, mode: i64, fb: *i64, depth: *i64) -> i64 { return worldgen_render_bd(seed, mode, 0, fb, depth) }
called by 1: main calls 1: worldgen_render_bd
477func worldgen_render(seed: i64, mode: i64, fb: *i64) -> i64
482func wg_w() -> i64 { return WG_W }
483func wg_h() -> i64 { return WG_H }