code wiki / _hdl_build / nx_gx_pbr_ggx_gate.nx
nx_gx_pbr_ggx_gate.nx
buildroot/runtime/_hdl_build/nx_gx_pbr_ggx_gate.nx
about
nx_gx_pbr_ggx_gate.nx -- Gx: energy-conserving Cook-Torrance GGX PBR in the SOVEREIGN renderer (integer, no
float). Closes the pbr-material residual "our renderer is Blinn-Phong not an energy-conserving BRDF". Renders
a METALLIC gold roughness sweep (5 spheres, roughness 0.30..0.90): microfacet specular = GGX/Trowbridge-Reitz
normal distribution D + Schlick Fresnel F (F0=albedo, metal) + Smith geometry G, spec = D*F*G/(4*NoV*NoL),
tinted by Fresnel. All Q20 fixed-point i64 + Newton isqrt (started from n, NOT a clamped guess -- a clamped
initial guess below sqrt(n) makes the y>=x termination misfire and returns garbage). D keeps denom^2 at FULL
precision so the highlight is smooth (no quantization rings). HONEST residual: roughness floor 0.30 + no IBL.
license_tier: ORIGINAL expect_exit: 0
dependencies 1 imports · 0 importers
imports: nx_png_write.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| none |
functions
| 11 | func gp_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } called by 1: main |
| 12 | func gp_pn(v: i64) -> i64 { let b: *u8=sys_mmap(32) as *u8; var x: i64=v; var ng: i64=0; if x<0{ng=1;x=0-x} var i: i64=31; if x==0{b[i]=48 as u8;i=i-1} while x>0{b[i]=(48+x%10) as u8;x=x/10;i=i-1} if ng==1{b[i]=45 as u8;i=i-1} sys_write(1,(b as i64+i+1) as *u8,31-i); return 0 } called by 1: main |
| 13 | func gp_isqrt(n: i64) -> i64 { if n<=0 { return 0 } var x: i64=n; var y: i64=(x + n/x)/2; var it: i64=0; while it<64 { if y>=x { it=64 } else { x=y; y=(x + n/x)/2; it=it+1 } } return x } called by 1: main |
| 16 | func gp_ggx(nx: i64,ny: i64,nz: i64, lx: i64,ly: i64,lz: i64, hx: i64,hy: i64,hz: i64, a: i64, a2: i64, albr: i64,albg: i64,albb: i64, out: *i64) -> i64 called by 1: main |
| 79 | func main() -> i64 |