islaApocalypse-v2/Tools/Scripts/NoiseDefaultsProbe.cs
beezm 9af5c73b04 Phase 1: port the crown-jewel noise and pass-1, and render the island
Ports MapGenerator.GenerateTopography's pass-1 loop (reference ~:553-619 at tag
pre-rewrite-reference / ab78883) into Tools/. Working code and its tuned constants
carried over verbatim, read from source rather than re-derived from a design
summary (D-050). Six elements, in the reference's execution order — the order is
load-bearing: the sinker lands before the Pow (superlinear), the Trench after it
(a raw additive wall), preTrenchFalloff captured between them.

The fractal config is now PINNED. The reference set only NoiseType/Seed/Frequency,
so the island's entire fractal character was Godot 4.7.1 constructor defaults that
nothing recorded. Measured on 4.7.2 (NoiseDefaultsProbe): Fbm / 5 / 0.5 / 2.0 / 0.0
— identical to the 4.7.1 values, so pinning reproduces the look with no delta. The
terrain no longer depends on an engine default, and the probe makes a future drift
visible instead of silent.

Two deliberate departures from the reference's literals, both flagged in-code:
  - the latitude noise offset is expressed in map widths, not the reference's raw
    +1000 px, so a resize no longer samples a different slice of the noise field
    (chat1/00 §4.2). Pinned to 1000/8192 so the 8K realization is unchanged.
  - the `if (temperature < 0.65f)` spine gate is dropped as the provable no-op it
    is — southernFade already reaches exactly 0 at 0.65. Bit-identical.

The reference's "temperature" is ported as a latitude field and deliberately NOT
named temperature: it is stage-1-local input to terrain geometry, and climate is
stage 3 (D-049 §2, D-056). The ±0.1 wobble is kept — it is what stops the spine's
southern terminus being a ruler-straight line.

Deferred to Phase 2 with the seam open: coast shelf and offshore islets (below-sea,
judged once water renders). Pass1Result exposes PreTrenchFalloff at their exact
consumption point, plus HMaxSeed for the seed-dependent curve.

Render is a direct Godot.Image, not the SubViewport capture path — that machinery
exists to composite vector overlays and is why --headless hangs; Phase 1 has none.
Hypsometric above 0.15, bathymetric below, fixed ramp anchors so seeds and ablation
rungs are comparable. No biome words anywhere.

Verified: land fraction 51.5% identical at 1024, 2048 and 10240 — the scaling
discipline holds across a 10x resize. Full-size 10240 pass: 36.3 s.

No curve, erosion, rivers, water, crater, biomes, roads, or mesher.
2026-08-19 21:27:20 -04:00

86 lines
4.5 KiB
C#

using Godot;
namespace IslaApocalypse.Tools
{
/// <summary>
/// A print-and-quit diagnostic: reports this engine build's <see cref="FastNoiseLite"/>
/// CONSTRUCTOR DEFAULTS, and checks them against the values the ported terrain expects.
///
/// ═══ WHY THIS EXISTS ═══
///
/// The reference prototype set only three noise properties — NoiseType, Seed, Frequency — and
/// left fractal type, octaves, gain, lacunarity and weighted-strength untouched. So the island's
/// entire fractal character was Godot 4.7.1's CONSTRUCTOR DEFAULTS, not code. Nothing in that
/// repo recorded what they were. (chat1/00 §4.1.)
///
/// <see cref="TerrainNoise"/> now pins every one of them explicitly, so the terrain no longer
/// depends on an engine default. This probe is the other half of that guarantee: it makes a
/// silent default change VISIBLE on an engine upgrade instead of quietly reshaping the island.
///
/// Run it after any Godot version bump:
///
/// Godot_v4.7.2-stable_mono_linux.x86_64 --headless \
/// --path ~/celerNexus/islaApocalypse-v2 res://Tools/Scenes/NoiseDefaultsProbe.tscn
///
/// Exits non-zero if this engine's defaults have drifted from the recorded baseline — so it
/// works as a pre-flight check, not just by eye. A non-zero exit is NOT "the terrain is broken":
/// the terrain is pinned and fine. It means the baseline note below needs updating, and that
/// anyone reading old code which relied on defaults should be warned.
/// </summary>
public partial class NoiseDefaultsProbe : Node
{
// The defaults measured on Godot 4.7.2.stable.mono (this project's pinned engine), which
// match the Godot 4 documented defaults the reference implicitly rode on 4.7.1.
private const FastNoiseLite.FractalTypeEnum BaselineFractalType = FastNoiseLite.FractalTypeEnum.Fbm;
private const int BaselineOctaves = 5;
private const float BaselineGain = 0.5f;
private const float BaselineLacunarity = 2.0f;
private const float BaselineWeightedStrength = 0.0f;
public override void _Ready()
{
var n = new FastNoiseLite();
GD.Print("==================================================================");
GD.Print(" FastNoiseLite CONSTRUCTOR DEFAULTS — this engine build");
GD.Print("==================================================================");
GD.Print($"engine : {Engine.GetVersionInfo()["string"]}");
GD.Print("------------------------------------------------------------------");
GD.Print($"NoiseType : {n.NoiseType}");
GD.Print($"Frequency : {n.Frequency}");
GD.Print($"FractalType : {n.FractalType}");
GD.Print($"FractalOctaves : {n.FractalOctaves}");
GD.Print($"FractalGain : {n.FractalGain}");
GD.Print($"FractalLacunarity : {n.FractalLacunarity}");
GD.Print($"FractalWeightedStrength : {n.FractalWeightedStrength}");
GD.Print($"Seed : {n.Seed}");
GD.Print("------------------------------------------------------------------");
GD.Print(" DRIFT CHECK vs the recorded 4.7.2 baseline");
GD.Print("------------------------------------------------------------------");
bool drift = false;
drift |= Check("FractalType", n.FractalType.ToString(), BaselineFractalType.ToString());
drift |= Check("FractalOctaves", n.FractalOctaves.ToString(), BaselineOctaves.ToString());
drift |= Check("FractalGain", n.FractalGain.ToString(), BaselineGain.ToString());
drift |= Check("FractalLacunarity", n.FractalLacunarity.ToString(), BaselineLacunarity.ToString());
drift |= Check("FractalWeightedStrength", n.FractalWeightedStrength.ToString(), BaselineWeightedStrength.ToString());
GD.Print("------------------------------------------------------------------");
GD.Print(drift
? " ⚠ DRIFT — this engine's defaults differ from the recorded baseline.\n" +
" The PORTED TERRAIN IS UNAFFECTED: TerrainNoise pins every value explicitly.\n" +
" Update the baseline constants in this probe, and note the delta."
: " ✓ NO DRIFT — defaults match the recorded baseline.");
GD.Print("==================================================================");
GetTree().Quit(drift ? 1 : 0);
}
private static bool Check(string name, string actual, string expected)
{
bool differs = actual != expected;
GD.Print($" {(differs ? "" : "")} {name,-24} actual={actual,-12} baseline={expected}");
return differs;
}
}
}