code wiki / (root) / nx_gradient_blend.nx

nx_gradient_blend.nx

buildroot/runtime/nx_gradient_blend.nx

12366 B267 linesdepth 2pulls 2 transitivereach 4 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_gradient_blend.nx -- smooth zone-to-zone transition primitive. Sixth demonstration of the kind-specific-generator cardinal `feedback-kind-specific-generators-not-broad-noise`. Solves the "biome edges are sharp cliffs" problem: when two zones (biomes, elevation bands, climate regions, kind-generators) meet, they SHOULDN'T abruptly snap from one to the other. Real-world biome transitions are gradients over kilometres of varying ecological pressure. This primitive ships the interpolation kernels. Caller pattern: blended = nx_gradient_blend_q14(value_a, value_b, progress, curve) where progress in [0, Q] (0 = pure A, Q = pure B). Sealed-enum easing curves give different aesthetic options: LINEAR -- straight line, equal-weight blend SMOOTHSTEP -- cubic Hermite, smooth at both ends (Perlin's classic fade curve) EASE_IN_OUT -- slow start + slow end (s-curve) SHARP -- nearly-step but with thin transition band CRENULATE -- alternating pattern (used for forest/grassland transitions that look "fingery" rather than a smooth line) V2 follow-ups (queued): - 2D progress (perpendicular + along the transition line) - Noise-perturbed transition for organic edges (composes nx_perlin or nx_worley_noise to roughen the transition line) - Catmull-Rom and bezier easing for N-way blends - Multi-zone blending (3+ neighbours) - "Fingery" forest edge via L-system extension Loss audit: Q14 integer arithmetic; cubic and s-curve evaluation uses 64-bit intermediates to avoid overflow. Clamping at boundary values to keep output bounded. CRENULATE relies on hash for determinism. genealogy_id: perlin_2002_improving_noise + ken_perlin_smoothstep + whittaker_1975_community_ecology lineage_id: nx_gradient_blend_5curve_q14_v1

dependencies 2 imports · 4 importers

nx_syscalls.nx nx_tier.nx nx_gradient_blend.nx nx_timeline_demo.nx nx_transition.nx nx_transition_gate.nx nx_xfade_demo.nx

imports: nx_syscalls.nxnx_tier.nx

imported by: nx_timeline_demo.nxnx_transition.nxnx_transition_gate.nxnx_xfade_demo.nx

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

main nx_gb_curve_is_valid nx_gradient_blend_q14 nx_gb_curve_is_valid ↻ _gb_curve_linear _gb_curve_smoothstep _gb_curve_ease_in_out _gb_curve_sharp _gb_curve_crenulate_fallba _gb_curve_smoothstep ↻ nx_gradient_blend_crenulat nx_gradient_blend_q14 ↻

structs

none

consts

50const NX_MAGIC_2654435761: i64 = 2654435761
53const NX_GB_Q: nx_int = 16384
56const NX_GB_LCG_A: nx_int = 48271
57const NX_GB_LCG_M: nx_int = 2147483647
60const NX_GB_CURVE_LINEAR: nx_int = 0
61const NX_GB_CURVE_SMOOTHSTEP: nx_int = 1
62const NX_GB_CURVE_EASE_IN_OUT: nx_int = 2
63const NX_GB_CURVE_SHARP: nx_int = 3
64const NX_GB_CURVE_CRENULATE: nx_int = 4
66const NX_GB_CURVE_COUNT: nx_int = 5

functions

69func nx_gb_curve_is_valid(c: nx_int) -> nx_int
83func _gb_curve_linear(t: nx_int) -> nx_int { return t }
90func _gb_curve_smoothstep(t: nx_int) -> nx_int
101func _gb_curve_ease_in_out(t: nx_int) -> nx_int
114func _gb_curve_sharp(t: nx_int) -> nx_int
133func _gb_curve_crenulate_fallback(t: nx_int) -> nx_int
142func nx_gradient_blend_q14(
168func nx_gradient_blend_crenulate_q14(
called by 1: main calls 1: nx_gradient_blend_q14
189func main() -> i64