code wiki / (root) / nx_gi_path.nx

nx_gi_path.nx

buildroot/runtime/nx_gi_path.nx

7302 B126 linesdepth 5pulls 8 transitivereach 0 importersview sourcekind tooltopic gi
docsdependenciesstructsconstsfunctions

about

nx_gi_path.nx -- THE BEAUTY TIER'S FIRST BYTE: a sovereign INTEGER PATH TRACER over the procgen heightfield. graphics GR42 (env_beauty_scene) + GR10 (gp_bounce_gi); operator 2026-09-02, looking at /world/beach: "that looks like our junk cpu stuff ... lets get things infinigen generating to photoreal". Infinigen renders offline through a path tracer; this organ is that twin, first byte up: no float, no library, no third party -- the same fx1024 arithmetic, the same fBm heightfield (nx_worldgen wg_terrain_h), the same sky model (wg_sky), the same soft-shadow march (wg_sun_pen) and the same PNG writer the estate already ships. What is NEW is the light transport: every pixel is the mean of spp Monte Carlo paths, each path = primary ray -> Lambertian hit (direct sun x soft shadow) -> cosine- weighted bounce (BRDF x cos / pdf = albedo, so no division noise) -> up to GP_BOUNCES hits -> sky gather when the path escapes. Colour bleed and sky occlusion therefore emerge from transport instead of being painted on, which is the difference between the raymarcher's "ambient = 42" and a beauty tier. DETERMINISM: the sampler is a seeded integer LCG advanced per draw; two runs with the same argv are byte-identical, so a gate can diff frames (the GR10 cache-vs-rebuild law carried into path tracing). NO TERRACING: the march step grows with distance (footprint-sized) and every hit is REFINED by GP_REFINE bisections, so the surface lands within a fraction of a unit -- the stair-steps visible in every nx_worldgen slope are gone. HONEST LIMITS OF THIS FIRST BYTE, stated so the next reader does not credit them: terrain is Lambertian only (no specular, no BRDF model beyond albedo); water is a single mirror event tinted by a deep colour, not refraction; the sky is nx_worldgen's gradient+sun+cloud model, not GR26's Rayleigh/Mie atmosphere; no cast meshes yet; no depth/normal/semantic ground-truth siblings yet (the dataset half of GR42). Each of those is a named rung. UNITS: directions are fx1024 unit vectors; radiance is carried as throughput(fx1024) x colour(0..255), then averaged, Reinhard-mapped and display-encoded ONCE at output (GR14's linear-light law: all transport in linear). nx_gi_path <out.png> [seed] [spp] [weather 0 clear | 1 sunset | 2 overcast] [yaw 0..4095] exit: 0 written | 2 usage | 5 png-write-fail. license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_gi_path_lib.nx nx_gi_path.nx

imports: nx_syscalls.nxnx_gi_path_lib.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap nxa_die sys_write sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ gp_cat sys_write ↻ sys_exit ↻ gp_atoi wg_w sys_write ↻ sys_now_ms sys_mmap ↻ sys_clock_gettime_mono it_sin4096 it_cos4096 it_sin4096 ↻ gp_rnd gp_norm3 vm_isqrt gp_bounce_gi gp_trace gp_march gp_lin gp_clamp gp_normal gp_norm3 ↻ gp_albedo gp_cosine_dir

structs

none

consts

none

functions

30func gp_bounce_gi(ox: i64, oy: i64, oz: i64, dx: i64, dy: i64, dz: i64, seed: i64, Wp: *i64, st: *i64,
called by 1: main calls 1: gp_trace
35func main(argc: i64, argv: *i64) -> i64