nx_gradient_blend.nx
buildroot/runtime/nx_gradient_blend.nx
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
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
structs
| none |
consts
| 50 | const NX_MAGIC_2654435761: i64 = 2654435761 |
| 53 | const NX_GB_Q: nx_int = 16384 |
| 56 | const NX_GB_LCG_A: nx_int = 48271 |
| 57 | const NX_GB_LCG_M: nx_int = 2147483647 |
| 60 | const NX_GB_CURVE_LINEAR: nx_int = 0 |
| 61 | const NX_GB_CURVE_SMOOTHSTEP: nx_int = 1 |
| 62 | const NX_GB_CURVE_EASE_IN_OUT: nx_int = 2 |
| 63 | const NX_GB_CURVE_SHARP: nx_int = 3 |
| 64 | const NX_GB_CURVE_CRENULATE: nx_int = 4 |
| 66 | const NX_GB_CURVE_COUNT: nx_int = 5 |
functions
| 69 | func nx_gb_curve_is_valid(c: nx_int) -> nx_int |
| 83 | func _gb_curve_linear(t: nx_int) -> nx_int { return t } called by 1: nx_gradient_blend_q14 |
| 90 | func _gb_curve_smoothstep(t: nx_int) -> nx_int |
| 101 | func _gb_curve_ease_in_out(t: nx_int) -> nx_int called by 1: nx_gradient_blend_q14 |
| 114 | func _gb_curve_sharp(t: nx_int) -> nx_int called by 1: nx_gradient_blend_q14 |
| 133 | func _gb_curve_crenulate_fallback(t: nx_int) -> nx_int |
| 142 | func nx_gradient_blend_q14( |
| 168 | func nx_gradient_blend_crenulate_q14( |
| 189 | func main() -> i64 |