code wiki / (root) / nx_worldgen.nx

nx_worldgen.nx

buildroot/runtime/nx_worldgen.nx

32155 B574 linesdepth 2pulls 4 transitivereach 15 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 3 imports · 12 importers

nx_syscalls.nx nx_itrig.nx nx_vecmath.nx nx_worldgen.nx nx_camera_anim_gate.nx nx_cloud_volume_gate.nx nx_diversity_gate.nx nx_gen_content.nx nx_gen_unified.nx nx_gi_gate.nx nx_gi_path_lib.nx nx_gt_annotations_gate.nx nx_livingworld_gate.nx nx_worldgen_gate.nx

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

10const WG_MAGIC_374761393: i64 = 374761393
11const WG_MAGIC_668265263: i64 = 668265263
12const WG_MAGIC_65536: i64 = 65536
13const WG_MAGIC_4000: i64 = 4000
14const WG_MAGIC_1024: i64 = 1024
15const WG_MAGIC_32768: i64 = 32768
16const WG_MAGIC_2900: i64 = 2900
17const WG_MAGIC_1048576: i64 = 1048576
18const WG_MAGIC_3000: i64 = 3000
19const WG_MAGIC_40000: i64 = 40000
20const WG_MAGIC_1050: i64 = 1050
21const WG_MAGIC_4096: i64 = 4096
22const WG_MAGIC_9999: i64 = 9999
23const WG_MAGIC_60000: i64 = 60000
24const WG_MAGIC_2000000000: i64 = 2000000000
25const WG_MAGIC_1800: i64 = 1800
26const WG_MAGIC_1500: i64 = 1500
27const WG_MAGIC_1350: i64 = 1350
28const WG_MAGIC_1100: i64 = 1100
30const WG_W: i64 = 1280 // 2x render -> the page downscales it = free anti-aliasing
31const WG_H: i64 = 768
32const WG_FOCAL: i64 = 720
33const WG_HORIZON: i64 = 92 // shifts the horizon down (look slightly over the land)
34const WATER: i64 = 0 // water level (world units)
35const HSCALE: i64 = 4600
36const SNOW: i64 = 2620
84const WG_CLOUD_BASE: i64 = 5200 // world units; terrain tops out near HSCALE, the deck floats above it
85const WG_CLOUD_TOP: i64 = 8400
86const WG_CLOUD_RAMP_LO: i64 = 400 // density rises over this many units above the base
87const WG_CLOUD_RAMP_HI: i64 = 1200 // and falls over this many units below the top (anvils thin out)
88const WG_CLOUD_CELL: i64 = 640 // one noise cell in world units at octave 0
89const WG_CLOUD_OCTAVES: i64 = 4
90const WG_CLOUD_GAIN: i64 = 6 // slope of the coverage threshold
91const WG_CLOUD_SEED_SALT: i64 = 7 // the sheet's seed, shared so volume and sheet agree on which sky
92const WG_CLOUD_ADVECT: i64 = 12 // world units per time unit at wind Q10 = 1024
93const WG_CLOUD_ORIGIN: i64 = 1048576 // positive offset so >> and & see positive coordinates
94const WG_COVER_LOSTVIS_W: i64 = 4 // coverage weights over the Q14 field params: lost visibility dominates
95const WG_COVER_PRECIP_W: i64 = 1
96const WG_COVER_FOG_W: i64 = 1
97const WG_SHEET_THR_GAIN: i64 = 5 // the incumbent sheet threshold: 1024 - cloud*5
210const GI_N: i64 = 96 // cells per axis
211const GI_CS: i64 = 500 // world units per cell
212const GI_X0: i64 = 0 - 24000 // grid origin (covers the visible near field)
213const GI_Z0: i64 = 0

functions

39func wg_isqrt(v: i64) -> i64 { return vm_isqrt(v) }
40func wg_abs(v: i64) -> i64 { if v<0 {return 0-v} return v }
41func wg_min(a: i64, b: i64) -> i64 { if a<b {return a} return b }
42func wg_max(a: i64, b: i64) -> i64 { if a>b {return a} return b }
43func wg_clamp(v: i64, lo: i64, hi: i64) -> i64 { if v<lo {return lo} if v>hi {return hi} return v }
45func wg_hash(ix: i64, iz: i64, seed: i64) -> i64
50func wg_smooth(t: i64) -> i64 { return t*t*(768 - 2*t)/WG_MAGIC_65536 } // smoothstep, t in 0..256 -> 0..256
51func wg_vnoise(x256: i64, z256: i64, seed: i64) -> i64
62func wg_fbm(wx: i64, wz: i64, seed: i64) -> i64
71func wg_terrain_h(wx: i64, wz: i64, seed: i64) -> i64 { return (wg_fbm(wx,wz,seed) - 402) * HSCALE / WG_MAGIC_1024 }
98func wg_hash3(ix: i64, iy: i64, iz: i64, seed: i64) -> i64
103func wg_vnoise3(x256: i64, y256: i64, z256: i64, seed: i64) -> i64
119func wg_fbm3(x256: i64, y256: i64, z256: i64, seed: i64) -> i64
128func wg_cover_from_weather(precip_q14: i64, visibility_q14: i64, fog_q14: i64, q: i64) -> i64
136func wg_cloud_envelope(wy: i64) -> i64
143func 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
158func wg_cloud_sheet(px: i64, pz: i64, cloud: i64) -> i64
164func wg_weather(mode: i64, W: *i64) -> i64
183func wg_sun_pen(seed: i64, hx: i64, hy: i64, hz: i64, Wp: *i64) -> i64
216func wg_set_gi(on: i64) -> i64 { WG_GION = on; return 0 }
217func wg_gi_build(seed: i64, biome: i64, Wp: *i64) -> i64
265func wg_gi_gather(hx: i64, hy: i64, hz: i64, nx: i64, ny: i64, nz: i64, out: *i64) -> i64
321func wg_sky(dx: i64, dy: i64, dz: i64, Wp: *i64, oc: *i64) -> i64
356func wg_cam_base_y(seed: i64) -> i64 { return wg_max(WATER, wg_terrain_h(0,0,seed)) + WG_MAGIC_1050 }
357func worldgen_render_full(seed: i64, mode: i64, biome: i64, cam: *i64, fb: *i64, depth: *i64, seg: *i64, nrm: *i64) -> i64
527func wg_ray(px: i64, py: i64, yaw: i64, out: *i64) -> i64
540func wg_project(seed: i64, cam: *i64, Px: i64, Py: i64, Pz: i64, out: *i64) -> i64
561func worldgen_render_bd(seed: i64, mode: i64, biome: i64, fb: *i64, depth: *i64) -> i64
567func worldgen_render_d(seed: i64, mode: i64, fb: *i64, depth: *i64) -> i64 { return worldgen_render_bd(seed, mode, 0, fb, depth) }
568func worldgen_render(seed: i64, mode: i64, fb: *i64) -> i64
573func wg_w() -> i64 { return WG_W }
574func wg_h() -> i64 { return WG_H }