Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

Map: the surf is wide on the dune coasts and narrow under the kurkar, from one DuneCoasts.json (refs #690, #388) (#838)

Eyal Golan8da1d64ddfe8
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9f9297cfd..542665d41 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -69,6 +69,9 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
- The olive crowns are darker, with pale tops (visual gap L2, refs #34; owner, 15 October 2026: "Darker, with pale
sunlit tops"). At gameplay03 their body is luma 0.29 (main 0.50, promo 03 0.30) and their sunlit top stands 0.18 above
it (main 0.14, promo 0.18). Vertex colours only: no tree count, size, shader or grade change.
+- The surf is wide on the dune coasts and narrow under the kurkar, as promo 03 draws it (refs #690, #388): 3.0 km from
+ Jaffa south and in Haifa Bay, 1.5 km elsewhere (2.4 km everywhere before). The dune coasts are one definition,
+ `unity/Assets/Resources/Map/DuneCoasts.json`, which the water pass reads through `MapShaderGlobals`. Presentation only.
- The surf reaches further out to sea (refs #690, #388): the breakers' zone widens from 1.8 to 2.4 km, so south of Jaffa
the white foam band reads 30.8 px at the gameplay zoom, inside promo 03's 25-55 px band (20.3 before; the promo reads
44), and the northern frontage reads 25.0 px (18.3 before), inside its 6-30 px band. Presentation only.
diff --git a/docs/visual-v1.md b/docs/visual-v1.md
index d0f9cbf30..23399786c 100644
--- a/docs/visual-v1.md
+++ b/docs/visual-v1.md
@@ -1352,7 +1352,8 @@ Review round 1 (staff review I1-I2, M1-M8) is folded in; the values below are th
budget (0.89 / 0.13 ms in promo-sea round 1); p95 with everything on is 10 / 14 ms, under 16.7 ms.
- **Surf** (review I2).
- A swash line, full to `ScSwashM` 180 m and gone by 324 m.
- - Breakers through a `ScSurfM` zone (900 m here; 1.8 km since sea round 3; 2.4 km since #690). They are a squared triangle wave in the
+ - Breakers through a `ScSurfM` zone (900 m here; 1.8 km since sea round 3; 2.4 km in #693; since #690's option C,
+ 3.0 km on the dune coasts of `DuneCoasts.json` and 1.5 km elsewhere). They are a squared triangle wave in the
distance from the shore, spacing `ScBreakerSpacingM` (300 m here; 450 m since sea round 3), rolling shoreward at
`ScBreakerRate` 0.05 cycles/s (15 m/s here, a quarter pixel a frame at gameplay03 and 60 fps; 22.5 m/s, about half a
pixel, since sea round 3).
diff --git a/tools/README.md b/tools/README.md
index 12a790151..1ba82a3ba 100644
--- a/tools/README.md
+++ b/tools/README.md
@@ -72,9 +72,9 @@ Offline data tools (uv inline-script Python). Run from the repo root.
prints diorama02's warmth per material (sand, sea, wood) against promo 02's (#695);
`art_checkpoint.sh [--no-build] <name>` builds WebGL, takes the screenshots (`web_check.py --shots`) and runs it
(docs/visual-v1.md).
-- `coast_measure.py <shots...> --window south|north [--promo] [--check]` measures the beach width, foam band, lace lines
- and sand lightness across the coast of a gameplay03 screenshot (or promo 03's same coast), the median over several
- shots, against bands set from promo 03 (#388).
+- `coast_measure.py <shots...> --window south|north [--promo] [--check]` measures the beach width, foam band, lace
+ lines, striped rows and sand lightness across the coast of a gameplay03 screenshot (or promo 03's same coast), the
+ median over several shots, against bands set from promo 03 (#388).
- `machine_lock.py` serialises frame-time measurements against every other Unity job on the machine (all worktrees,
batch runs and open editors).
- `unity_postmerge.py` runs the full Unity EditMode suite on each new `main` commit, on the owner's Mac, and reports a
diff --git a/tools/coast_measure.py b/tools/coast_measure.py
index 8754a801b..8fc597ef5 100644
--- a/tools/coast_measure.py
+++ b/tools/coast_measure.py
@@ -14,11 +14,13 @@ those medians with BANDS (set from promo 03 before any change) and exits 1 when
Classes (sRGB 0-255): water: b > r + 15 (docs/visual-v1.md promo-sea's sea pixel); foam: luma >= 0.72 and max-min <= 30;
sand: luma >= 0.60 and r - b >= 25; crown: any other pixel under luma 0.40 (a tree crown or its shadow). Per row: the
-shore is where the sea ends, the first run of 3 sand or crown pixels after >= 6 water/foam pixels: a crown stands on land,
-so one over the waterline (main's citrus south of Jaffa) marks the shore as sand would, instead of moving it to the sand
-past the crown. The beach is the sand run from the first 3 sand pixels at or after the shore, bridging gaps <= 12 px (a
-border band, a pebble); the foam band is the seaward stretch [shore-80, shore) from the farthest foam pixel in it; lace lines are foam runs >= 2 px in that band. Widths are corrected
-to across the coast with a least-squares fit of the shore's slope over the rows."""
+shore is where the sea ends, the first run of 3 sand or crown pixels after >= 6 water/foam pixels: a crown stands on
+land, so one over the waterline (main's citrus south of Jaffa) marks the shore as sand would, instead of moving it to
+the sand past the crown. The beach is the sand run from the first 3 sand pixels at or after the shore, bridging gaps <=
+12 px (a border band, a pebble); the foam band is the seaward stretch [shore-80, shore) from the farthest foam pixel in
+it; lace lines are foam runs >= 2 px in that band; stripe_rows is the share of rows with 3 or more of them (#690: evenly
+spaced white bands read as combed stripes; promo 03's frontage reads 0.05). Widths are corrected to across the coast
+with a least-squares fit of the shore's slope over the rows."""
import argparse
import statistics as st
import sys
@@ -132,11 +134,12 @@ def measure(im: Image.Image, y0: int, y1: int, x0: int, x1: int, step: int = 2)
"foam_px": st.median(r["foam_px"] * f for r in rows),
"lace_lines": st.median(r["lace_lines"] for r in rows),
"foam_share": st.median(r["foam_share"] for r in rows),
+ "stripe_rows": sum(r["lace_lines"] >= 3 for r in rows) / len(rows),
"sand_luma_p50": quantile(pool, 0.5) if pool else 0.0,
"sand_luma_p90": quantile(pool, 0.9) if pool else 0.0}
-METRICS = ("beach_px", "foam_px", "lace_lines", "foam_share", "sand_luma_p50", "sand_luma_p90")
+METRICS = ("beach_px", "foam_px", "lace_lines", "foam_share", "stripe_rows", "sand_luma_p50", "sand_luma_p90")
def combine(summaries: list[dict]) -> dict:
@@ -180,7 +183,7 @@ def main(argv: list[str] | None = None) -> int:
"lace_lines=%(lace_lines)d foam_share=%(foam_share).2f" % r)
print(f"{path}: rows={len(s['rows'])} perp_factor={s['perp_factor']:.2f} beach_px={s['beach_px']:.1f} "
f"(p25 {s['beach_p25']:.1f}, p75 {s['beach_p75']:.1f}) foam_px={s['foam_px']:.1f} "
- f"lace_lines={s['lace_lines']} foam_share={s['foam_share']:.2f} "
+ f"lace_lines={s['lace_lines']} foam_share={s['foam_share']:.2f} stripe_rows={s['stripe_rows']:.2f} "
f"sand_luma p50={s['sand_luma_p50']:.2f} p90={s['sand_luma_p90']:.2f}")
med = combine(sums)
print("MEDIAN " + " ".join(f"{m}={v:.2f}" for m, v in med.items()) if med else "MEDIAN no shore")
diff --git a/tools/terrain_bake.py b/tools/terrain_bake.py
index e47f37082..65cef5748 100644
--- a/tools/terrain_bake.py
+++ b/tools/terrain_bake.py
@@ -54,10 +54,13 @@ COAST_RANGE_M = 12000.0 # StatecraftMap.hlsl ScCoastRangeM
# the coast from Tel Aviv northwards (Wikipedia: "Kurkar", "Haifa Bay", "Holon", "Nitzanim", retrieved 2026-10-15). The
# widths are art direction, and the cut-off at Jaffa is interpolated between Jaffa (32.05 N) and Tel Aviv, not a sourced
# line. Each band is (lon west, lon east, lat south, lat north, ramp in degrees): the extra width is full inside it and
-# falls to 0 over the ramp at each edge. Unity's tree keep-out reads a twin (Kits/BeachBands.cs, pinned by a test).
+# falls to 0 over the ramp at each edge. The bands are DuneCoasts.json (#690: the one definition, which Unity's kits and the
+# water pass's surf read too): Jaffa south to the map's southern coast (full south of 32.03 N), and Haifa Bay from the
+# Kishon's mouth to the Na'aman's (32.91 N).
BEACH_EXTRA_M = 1800.0 # ScShore's 900 m beach becomes about 2.7 km
-BEACH_BANDS = ((34.0, 34.86, 31.0, 32.07, 0.04), # Jaffa south to the map's southern coast (full south of 32.03 N)
- (35.02, 35.2, 32.77, 32.91, 0.02)) # Haifa Bay, from the Kishon's mouth to the Na'aman's (32.91 N)
+DUNE_COASTS = ROOT / "unity" / "Assets" / "Resources" / "Map" / "DuneCoasts.json"
+BEACH_BANDS = tuple((b["lon0"], b["lon1"], b["lat0"], b["lat1"], b["ramp"])
+ for b in json.loads(DUNE_COASTS.read_text(encoding="utf-8"))["bands"])
# Acre was not dune country (owner, 16 October 2026): Haifa and Acre are the bay's capes and its centre is lined with dunes
# (Wikipedia, "Haifa Bay"); the Na'aman empties into the bay south of Acre (Wikipedia, "Na'aman River" and "Acre, Israel"),
# at 32.909 N 35.081 E (he.wikipedia, "נחל נעמן"; all retrieved 2026-10-16). So the bay's band ends at the Na'aman's mouth,
diff --git a/tools/tests/test_coast_measure.py b/tools/tests/test_coast_measure.py
index 1419cc776..606b5ba41 100644
--- a/tools/tests/test_coast_measure.py
+++ b/tools/tests/test_coast_measure.py
@@ -68,6 +68,17 @@ def test_a_crown_over_the_waterline_does_not_move_the_shore_or_the_foam():
assert b["beach_px"] == 46 # the sand still reads from where it shows
+def test_stripe_rows_is_the_share_of_rows_with_3_or_more_foam_lines():
+ """#690: evenly spaced white bands on the northern frontage read as combed stripes; the share of rows with 3 or more
+ lines in the foam band counts them (promo 03's frontage: 0.05)."""
+ three = coast(beach=60, foam=[(0, 4), (10, 3), (20, 3)])
+ two = coast(beach=60, foam=[(0, 4), (10, 3)])
+ assert cm.measure(three, 0, 40, 100, 400)["stripe_rows"] == 1.0
+ assert cm.measure(two, 0, 40, 100, 400)["stripe_rows"] == 0.0
+ mixed = cm.combine([cm.measure(im, 0, 40, 100, 400) for im in (three, two, two)])
+ assert mixed["stripe_rows"] == 0.0
+
+
def test_a_slanted_coast_is_measured_across_it():
im = coast(beach=50, foam=[(0, 10)], h=200, slope=1.0) # 45 degrees: rows cross the strip at sqrt(2) its width
s = cm.measure(im, 0, 200, 100, 600)
diff --git a/tools/tests/test_dune_coasts.py b/tools/tests/test_dune_coasts.py
new file mode 100644
index 000000000..3553fdb63
--- /dev/null
+++ b/tools/tests/test_dune_coasts.py
@@ -0,0 +1,23 @@
+"""unity/Assets/Resources/Map/DuneCoasts.json (#690 option C): the dune coasts' one definition, read by DuneCoasts.cs
+(the kits and the water pass) and by the tools."""
+import json
+from pathlib import Path
+
+import pytest
+
+ROOT = Path(__file__).resolve().parents[2]
+FILE = ROOT / "unity" / "Assets" / "Resources" / "Map" / "DuneCoasts.json"
+
+
+def test_each_band_is_a_lon_lat_box_with_a_ramp_inside_it():
+ bands = json.loads(FILE.read_text())["bands"]
+ assert [b["name"] for b in bands] == ["Jaffa south to the map's southern coast", "Haifa Bay"]
+ for b in bands:
+ assert b["lon0"] < b["lon1"] and b["lat0"] < b["lat1"]
+ assert 0 < 2 * b["ramp"] <= min(b["lon1"] - b["lon0"], b["lat1"] - b["lat0"])
+
+
+def test_jaffa_south_ends_between_32_03_and_32_07_n():
+ """Full south of 32.03 N and gone by 32.07 N: the edge #685's beach and #690's surf share."""
+ jaffa = json.loads(FILE.read_text())["bands"][0]
+ assert jaffa["lat1"] == 32.07 and jaffa["lat1"] - jaffa["ramp"] == pytest.approx(32.03)
diff --git a/tools/tests/test_terrain_bake.py b/tools/tests/test_terrain_bake.py
index 8f161e381..63cd0ebec 100644
--- a/tools/tests/test_terrain_bake.py
+++ b/tools/tests/test_terrain_bake.py
@@ -310,13 +310,17 @@ def test_the_committed_coast_draws_a_wide_beach_south_of_jaffa_and_a_narrow_one_
def test_the_csharp_twin_of_the_beach_bands_matches_the_bake():
+ """#690: the bands are one file, DuneCoasts.json, which the bake and BeachBands (through DuneCoasts.cs) both read;
+ neither keeps a copy of them."""
+ import json
import re
cs = (ROOT / "unity/Assets/Scripts/Map/Kits/BeachBands.cs").read_text()
hlsl = (ROOT / "unity/Assets/Shaders/StatecraftMap.hlsl").read_text()
assert float(re.search(r"const float ExtraM = ([0-9.]+)f", cs).group(1)) == tb.BEACH_EXTRA_M
- bands = [tuple(float(v) for v in m) for m in re.findall(
- r"\(([0-9.]+), ([0-9.]+), ([0-9.]+), ([0-9.]+), ([0-9.]+)\)", cs.split("Bands =", 1)[1].split(";", 1)[0])]
- assert bands == [tuple(b) for b in tb.BEACH_BANDS]
+ dune = json.loads((ROOT / "unity/Assets/Resources/Map/DuneCoasts.json").read_text(encoding="utf-8"))["bands"]
+ assert tb.BEACH_BANDS == tuple((b["lon0"], b["lon1"], b["lat0"], b["lat1"], b["ramp"]) for b in dune)
+ assert "DuneCoasts.Weight(lon, lat)" in cs and "DuneCoasts.Bands" in cs and "Bands =" not in cs, \
+ "BeachBands reads DuneCoasts.json, no copy of its own"
beach = float(re.search(r"static const float ScBeachM = ([0-9.]+);", hlsl).group(1))
full = float(re.search(r"const float FullSandM = ([0-9.]+)f", cs).group(1))
assert full == pytest.approx(0.55 * 1.4 * beach, abs=0.5), "ScShore's widest full sand"
diff --git a/unity/Assets/Resources/Map/DuneCoasts.json b/unity/Assets/Resources/Map/DuneCoasts.json
new file mode 100644
index 000000000..beda55bb5
--- /dev/null
+++ b/unity/Assets/Resources/Map/DuneCoasts.json
@@ -0,0 +1,8 @@
+{
+ "note": "The dune coasts (#388, #690): the sand coasts where the beach and the surf are wide. The one definition: tools/terrain_bake.py bakes the wider beach into coast.png from it, Kits/BeachBands.cs reads it through DuneCoasts.cs for the trees and lots, and MapShaderGlobals hands it to the water pass for the wider surf. Each band is a lon/lat box whose weight ramps from 0 to 1 over `ramp` degrees inside each edge.",
+ "bands": [
+ { "name": "Jaffa south to the map's southern coast", "lon0": 34.0, "lon1": 34.86, "lat0": 31.0, "lat1": 32.07, "ramp": 0.04 },
+ { "name": "Haifa Bay", "lon0": 35.02, "lon1": 35.2, "lat0": 32.77, "lat1": 32.91, "ramp": 0.02,
+ "source": "From the Kishon's mouth to the Na'aman's, at 32.909 N 35.081 E (he.wikipedia, \"נחל נעמן\", retrieved 2026-10-16), south of Acre (owner, 16 October 2026: Acre was not dune country)" }
+ ]
+}
diff --git a/unity/Assets/Resources/Map/DuneCoasts.json.meta b/unity/Assets/Resources/Map/DuneCoasts.json.meta
new file mode 100644
index 000000000..410300c90
--- /dev/null
+++ b/unity/Assets/Resources/Map/DuneCoasts.json.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 1f0ba63083aa4d0c85e4848906d524fd
+TextScriptImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Scripts/Map/DuneCoasts.cs b/unity/Assets/Scripts/Map/DuneCoasts.cs
new file mode 100644
index 000000000..2ef5ca0f0
--- /dev/null
+++ b/unity/Assets/Scripts/Map/DuneCoasts.cs
@@ -0,0 +1,68 @@
+#nullable enable
+using System;
+using UnityEngine;
+
+namespace Statecraft.Game.Map
+{
+ /// <summary>The dune coasts (#388, #690): the sand coasts, Jaffa south and Haifa Bay, where the beach and the surf are
+ /// wide; under the kurkar north of Tel Aviv both stay narrow. One definition, Resources/Map/DuneCoasts.json, read here
+ /// (Resources.Load, so the web build reads it at once) and by the tools; MapShaderGlobals hands it to the water pass as
+ /// map-metre boxes. Each band is a lon/lat box whose weight ramps from 0 to 1 over its ramp (degrees) inside each edge,
+ /// with a smoothstep on each axis; the weight at a point is the largest band's.</summary>
+ public static class DuneCoasts
+ {
+ public const string Resource = "Map/DuneCoasts";
+ public const string AssetPath = "Assets/Resources/Map/DuneCoasts.json";
+ /// <summary>The water pass's band count (StatecraftMap.hlsl's _ScDuneRect / _ScDuneRamp).</summary>
+ public const int MaxBands = 4;
+
+ [Serializable] public sealed class Band { public string name = ""; public double lon0, lon1, lat0, lat1, ramp; }
+ [Serializable] sealed class FileJson { public Band[] bands = Array.Empty<Band>(); }
+
+ static Band[]? bands;
+
+ /// <summary>The bands as the file gives them; none (and an error logged) when the file is missing or unreadable.</summary>
+ public static Band[] Bands => bands ??= Parse(Resources.Load<TextAsset>(Resource)?.text);
+
+ public static Band[] Parse(string? json)
+ {
+ if (string.IsNullOrEmpty(json)) { Debug.LogError($"DuneCoasts: {AssetPath} is missing"); return Array.Empty<Band>(); }
+ try { return JsonUtility.FromJson<FileJson>(json)?.bands ?? Array.Empty<Band>(); }
+ catch (ArgumentException e) { Debug.LogError($"DuneCoasts: {AssetPath} unreadable: {e.Message}"); return Array.Empty<Band>(); }
+ }
+
+ static double Smooth(double t) { t = t < 0 ? 0 : t > 1 ? 1 : t; return t * t * (3 - 2 * t); }
+
+ /// <summary>0 off the dune coasts, 1 inside a band, ramped at its edges.</summary>
+ public static float WeightAt(double lon, double lat) => (float)Weight(lon, lat);
+
+ /// <summary><see cref="WeightAt"/> in double precision, as tools/terrain_bake.py computes it (BeachBands.ExtraAt).</summary>
+ public static double Weight(double lon, double lat)
+ {
+ double w = 0;
+ foreach (var b in Bands)
+ w = Math.Max(w, Smooth((lon - b.lon0) / b.ramp) * Smooth((b.lon1 - lon) / b.ramp) * Smooth((lat - b.lat0) / b.ramp) * Smooth((b.lat1 - lat) / b.ramp));
+ return w;
+ }
+
+ /// <summary>The bands in map metres from the south-west corner, as the water pass reads them: per band (x0, x1, z0, z1)
+ /// and its ramp (east-west, north-south metres), and the count. A band past <see cref="MaxBands"/> is dropped with an
+ /// error, not silently.</summary>
+ public static int ToMapMetres(GeoFrame frame, Vector4[] rects, Vector4[] ramps)
+ {
+ var all = Bands;
+ if (all.Length > MaxBands) Debug.LogError($"DuneCoasts: {all.Length} bands, the water pass reads {MaxBands}");
+ int n = Math.Min(all.Length, MaxBands);
+ double mx = frame.WidthM / (frame.Lon1 - frame.Lon0), mz = frame.LengthM / (frame.Lat1 - frame.Lat0);
+ for (int i = 0; i < MaxBands; i++)
+ {
+ if (i >= n) { rects[i] = Vector4.zero; ramps[i] = Vector4.zero; continue; }
+ var b = all[i];
+ Vector3 a = frame.ToWorld(b.lon0, b.lat0, 0f), c = frame.ToWorld(b.lon1, b.lat1, 0f);
+ rects[i] = new Vector4(a.x, c.x, a.z, c.z);
+ ramps[i] = new Vector4((float)(b.ramp * mx), (float)(b.ramp * mz), 0f, 0f);
+ }
+ return n;
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/DuneCoasts.cs.meta b/unity/Assets/Scripts/Map/DuneCoasts.cs.meta
new file mode 100644
index 000000000..75b8567ef
--- /dev/null
+++ b/unity/Assets/Scripts/Map/DuneCoasts.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 3b6bfc8cf0334748b54413ca3e0525c6
diff --git a/unity/Assets/Scripts/Map/Kits/BeachBands.cs b/unity/Assets/Scripts/Map/Kits/BeachBands.cs
index 573788dc0..46310bf3a 100644
--- a/unity/Assets/Scripts/Map/Kits/BeachBands.cs
+++ b/unity/Assets/Scripts/Map/Kits/BeachBands.cs
@@ -6,19 +6,12 @@ namespace Statecraft.Game.Map.Kits
{
/// <summary>Sea round 3 (#388): the dune coasts' wider beach, for the kits. The terrain draws it from coast.png, whose
/// land side tools/terrain_bake.py bakes beach-scaled there (BEACH_EXTRA_M, BEACH_BANDS, beach_keep); KitGround does not
- /// read coast.png, so this is its C# twin, pinned to the bake by tools/tests/test_terrain_bake.py.</summary>
+ /// read coast.png, so this is its C# twin: the bands are DuneCoasts.json, which the bake reads too (#690), and the
+ /// constants are pinned to the bake by tools/tests/test_terrain_bake.py.</summary>
public static class BeachBands
{
/// <summary>The extra beach width (m) inside a band: ScShore's 900 m beach becomes about 2.7 km.</summary>
public const float ExtraM = 1800f;
- /// <summary>(lon west, lon east, lat south, lat north, ramp in degrees): Jaffa south to the map's southern coast, and
- /// Haifa Bay from the Kishon's mouth to the Na'aman's, south of Acre (owner, 16 October 2026: Acre was not dune
- /// country). The extra width falls to 0 over the ramp at each edge.</summary>
- static readonly (double lon0, double lon1, double lat0, double lat1, double ramp)[] Bands =
- {
- (34.0, 34.86, 31.0, 32.07, 0.04),
- (35.02, 35.2, 32.77, 32.91, 0.02),
- };
/// <summary>Option (c) (owner, 16 October 2026: each settlement's own lots and fields stay off the sand): the extra
/// width is 0 inside a settlement's plot reach (SettlementKits.FootprintRadiusM x PlotReach) and comes back over this
/// many metres beyond it.</summary>
@@ -35,9 +28,7 @@ namespace Statecraft.Game.Map.Kits
/// the settlements' yield.</summary>
public static float ExtraAt(double lon, double lat)
{
- double w = 0;
- foreach (var (lon0, lon1, lat0, lat1, ramp) in Bands)
- w = System.Math.Max(w, Smooth((lon - lon0) / ramp) * Smooth((lon1 - lon) / ramp) * Smooth((lat - lat0) / ramp) * Smooth((lat1 - lat) / ramp));
+ double w = DuneCoasts.Weight(lon, lat); // the bands: DuneCoasts.json, the one definition (#690)
return (float)(w * ExtraM);
}
@@ -52,8 +43,8 @@ namespace Statecraft.Game.Map.Kits
float reach = SettlementKits.FootprintRadiusM(s, ground.HexSizeM) * SettlementKits.PlotReach, rim = reach + YieldRampM;
var (lonW, latS) = ground.Frame.ToLonLat(new Vector3(w.x - rim, 0f, w.z - rim));
var (lonE, latN) = ground.Frame.ToLonLat(new Vector3(w.x + rim, 0f, w.z + rim));
- foreach (var (lon0, lon1, lat0, lat1, _) in Bands)
- if (lonE > lon0 && lonW < lon1 && latN > lat0 && latS < lat1) { list.Add((new Vector2(w.x, w.z), reach)); break; }
+ foreach (var b in DuneCoasts.Bands)
+ if (lonE > b.lon0 && lonW < b.lon1 && latN > b.lat0 && latS < b.lat1) { list.Add((new Vector2(w.x, w.z), reach)); break; }
}
return list;
}
diff --git a/unity/Assets/Scripts/Map/MapShaderGlobals.cs b/unity/Assets/Scripts/Map/MapShaderGlobals.cs
index 222640826..b58a4a614 100644
--- a/unity/Assets/Scripts/Map/MapShaderGlobals.cs
+++ b/unity/Assets/Scripts/Map/MapShaderGlobals.cs
@@ -13,7 +13,8 @@ namespace Statecraft.Game.Map
HazeRange = Shader.PropertyToID("_ScHazeRange"), WaterOn = Shader.PropertyToID("_ScWaterOn"), Grid = Shader.PropertyToID("_ScGrid"),
WaterTime = Shader.PropertyToID("_ScWaterTime"), LandOn = Shader.PropertyToID("_ScLandOn"),
SeaTexture = Shader.PropertyToID("_ScSeaTexture"), SeaCalm = Shader.PropertyToID("_ScSeaCalm"),
- SeaFoam = Shader.PropertyToID("_ScSeaFoam");
+ SeaFoam = Shader.PropertyToID("_ScSeaFoam"), DuneRect = Shader.PropertyToID("_ScDuneRect"),
+ DuneRamp = Shader.PropertyToID("_ScDuneRamp"), DuneCount = Shader.PropertyToID("_ScDuneCount");
/// <summary>Pins the water's clock (waves, surf) to the given seconds, or back to Unity's time with null: for tests and
/// frame captures that must render chosen moments (promo-sea review I2, M5).</summary>
@@ -75,6 +76,12 @@ namespace Statecraft.Game.Map
// Sea round 3 (#388, StatecraftMap.hlsl): the surf's lace net; its own toggle, so the profile prices it.
Shader.SetGlobalFloat(SeaFoam, 1f);
assets.OnTeardown(VisualToggles.Register("foam", on => Shader.SetGlobalFloat(SeaFoam, on ? 1f : 0f)));
+ // The dune coasts (#690, DuneCoasts.json): the water pass widens the surf there, in map metres.
+ var duneRect = new Vector4[DuneCoasts.MaxBands]; var duneRamp = new Vector4[DuneCoasts.MaxBands];
+ int dunes = DuneCoasts.ToMapMetres(new GeoFrame(meta.lon0, meta.lon1, meta.lat0, meta.lat1, size.x, size.z), duneRect, duneRamp);
+ Shader.SetGlobalVectorArray(DuneRect, duneRect);
+ Shader.SetGlobalVectorArray(DuneRamp, duneRamp);
+ Shader.SetGlobalFloat(DuneCount, dunes);
assets.OnTeardown(VisualToggles.Register("haze", on =>
{
Shader.SetGlobalVector(Haze, on ? haze : new Vector4(haze.x, haze.y, haze.z, 0f));
diff --git a/unity/Assets/Shaders/StatecraftMap.hlsl b/unity/Assets/Shaders/StatecraftMap.hlsl
index db6eaa205..0a37d1a92 100644
--- a/unity/Assets/Shaders/StatecraftMap.hlsl
+++ b/unity/Assets/Shaders/StatecraftMap.hlsl
@@ -127,8 +127,23 @@ static const float ScWaveTilt = 0.6; // wave normal
// on the northern frontage (promo 03: 12.3, band 6-30); at 2.4 km it reads 30.8 and 25.0. The zone is one width along the
// whole coast, so 2.4 km is the widest step that keeps the north at least 5 px under 30 (gameplay03 editor renders: 2.4 km
// reads 29 px south and 24 north, 2.7 km 33 and 28); a wider surf south of Jaffa only is an owner option on #690.
+// #690 option C (owner, 16 October 2026: "merge, then do C next"): the surf is wide on the dune coasts and narrow under
+// the kurkar, as promo 03 draws it (44 px south of Jaffa, 12.3 px on the northern frontage at gameplay03). One zone width
+// for the whole coast had to trade the two: 2.4 km read 30.8 px south and 25.0 north, with 3 or more evenly spaced white
+// lines in 40% of the frontage's rows (coast_measure's stripe_rows; promo 03 0.05). The dune coasts are DuneCoasts.json's
+// bands, which MapShaderGlobals hands over in map metres (_ScDuneRect: x0, x1, z0, z1; _ScDuneRamp: the ramp east-west and
+// north-south): ScSurfDuneM inside them, ScSurfM elsewhere, smoothstepped across each band's ramp as DuneCoasts.WeightAt
+// is. Chosen on gameplay03 editor renders (median of 3 moments). ScSurfM 1.5 km: 15.9 px on the frontage, foam share
+// 0.66, stripe_rows 0.07 (promo 03: 12.3 px, 0.63, 0.05). 1.2 km read 12.2 px but packed the foam into a near-solid band
+// (share 0.76; SeaTests' lace test read 0.81 at 32.08 N against its 0.7 bound), so the frontage keeps 1.5 km. ScSurfDuneM
+// 3.0 km: 35.6 px south, 2 lines, stripe_rows 0.45 (3.3 km: 37.3, 3 lines, 0.56; 3.6 km: 40.9, 3 lines, 0.59; promo 03:
+// 44.0, 2 lines, 0.30); the owner chose 3.0 km, with breaking up the evenly spaced lines before any wider surf (#716).
float _ScSeaFoam; // 1 = on, 0 = off (the "foam" toggle)
-static const float ScSwashM = 180.0, ScSurfM = 2400.0, ScBreakerSpacingM = 450.0, ScBreakerRate = 0.05, ScFoamWhite = 0.95;
+float4 _ScDuneRect[4];
+float4 _ScDuneRamp[4];
+float _ScDuneCount;
+static const float ScSurfDuneM = 3000.0;
+static const float ScSwashM = 180.0, ScSurfM = 1500.0, ScBreakerSpacingM = 450.0, ScBreakerRate = 0.05, ScFoamWhite = 0.95;
static const float ScLaceCellM = 200.0, ScLaceCover = 0.62, ScLaceEdge = 0.25;
// Sea round 2 (#388): the far sea's texture, which promo 02 and 03 show at the gameplay and overview zooms where the waves
// above have faded to a smooth surface (sea detail 0.013 against promo 03's 0.060 at gameplay03, 0.019 against 0.063 at
@@ -198,6 +213,21 @@ float ScTriSqBox(float x, float w)
// The water's clock: Unity's time, or the pinned seconds (MapShaderGlobals.PinWaterTime).
float ScWaterClock() { return _ScWaterTime.y > 0.5 ? _ScWaterTime.x : _Time.y; }
+// 0 off the dune coasts, 1 inside a band (DuneCoasts.WeightAt's smoothstep on each axis, in map metres). A slot past
+// _ScDuneCount reads 0 (its zero ramp is never used).
+float ScDuneWeight(float2 mapM)
+{
+ float w = 0.0;
+ [unroll] for (int i = 0; i < 4; i++)
+ {
+ float4 r = _ScDuneRect[i]; float2 ramp = _ScDuneRamp[i].xy;
+ float b = smoothstep(r.x, r.x + ramp.x, mapM.x) * (1.0 - smoothstep(r.y - ramp.x, r.y, mapM.x))
+ * smoothstep(r.z, r.z + ramp.y, mapM.y) * (1.0 - smoothstep(r.w - ramp.y, r.w, mapM.y));
+ w = max(w, (float)i < _ScDuneCount ? b : 0.0);
+ }
+ return w;
+}
+
// The breakers' phase (cycles; crests at whole numbers) and its box width: fwidth(phase) x ScBreakerFilterPx. The phase's
// true gradient is not 1 / ScBreakerSpacingM: its noise term adds up to 0.0025 cycles/m and the 8-bit coast's slope varies
// up to 2x, so the width comes from the phase itself (review N2). Call it in uniform control flow (outside any [branch]);
@@ -306,7 +336,7 @@ float3 ScWaterShade(float coast, float elevM, float3 positionWS, float2 mapM, fl
// Sea round 2: the swash line is never under 1.5 pixels wide, so the white rim reads at the overview as well.
float swashM = max(ScSwashM, 1.5 * footprintM);
float swash = 1.0 - smoothstep(swashM, swashM * 1.8, offshoreM);
- float zone = 1.0 - smoothstep(ScSwashM, ScSurfM, offshoreM);
+ float zone = 1.0 - smoothstep(ScSwashM, lerp(ScSurfM, ScSurfDuneM, ScDuneWeight(mapM)), offshoreM);
float crest = ScTriSqBox(breakers.x, breakers.y);
float broken = smoothstep(0.3, 0.7, ScNoise(mapM / 300.0 + float2(0.0, time * 0.02)));
float lace = ScNoise(mapM / ScLaceCellM + float2(5.1, 2.3) + float2(time * 0.03, 0.0));
diff --git a/unity/Assets/Tests/EditMode/DuneCoastsTests.cs b/unity/Assets/Tests/EditMode/DuneCoastsTests.cs
new file mode 100644
index 000000000..75867005b
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/DuneCoastsTests.cs
@@ -0,0 +1,48 @@
+#nullable enable
+using NUnit.Framework;
+using Statecraft.Game.Map;
+using UnityEditor.SceneManagement;
+using UnityEngine;
+
+/// <summary>#690 option C: the dune coasts' one definition (Resources/Map/DuneCoasts.json) and its hand-over to the water
+/// pass.</summary>
+public class DuneCoastsTests
+{
+ [TearDown]
+ public void Reset() => EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);
+
+ [Test]
+ public void TheFileGivesJaffaSouthAndHaifaBay()
+ {
+ var bands = DuneCoasts.Bands;
+ Assert.AreEqual(2, bands.Length);
+ Assert.AreEqual(32.07, bands[0].lat1, 1e-9, "Jaffa south: full south of 32.03 N, gone by 32.07 N");
+ Assert.AreEqual(0.04, bands[0].ramp, 1e-9);
+ Assert.AreEqual(1f, DuneCoasts.WeightAt(34.70, 31.95), 1e-6f, "south of Jaffa");
+ Assert.AreEqual(0f, DuneCoasts.WeightAt(34.78, 32.10), 1e-6f, "the kurkar coast north of Tel Aviv");
+ Assert.AreEqual(0.5f, DuneCoasts.WeightAt(34.70, 32.05), 1e-6f, "half way across the ramp");
+ Assert.AreEqual(1f, DuneCoasts.WeightAt(35.08, 32.85), 1e-6f, "Haifa Bay");
+ }
+
+ [Test]
+ public void AMissingOrBrokenFileGivesNoBandsAndAnError()
+ {
+ UnityEngine.TestTools.LogAssert.Expect(LogType.Error, new System.Text.RegularExpressions.Regex("DuneCoasts: .* missing"));
+ Assert.IsEmpty(DuneCoasts.Parse(""));
+ Assert.IsEmpty(DuneCoasts.Parse("{\"bands\": []}"));
+ }
+
+ [Test]
+ public void TheWaterPassGetsTheBandsInMapMetres()
+ {
+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);
+ var map = Object.FindFirstObjectByType<MapScene>(); map.Build();
+ Assert.AreEqual(2f, Shader.GetGlobalFloat("_ScDuneCount"));
+ var rects = Shader.GetGlobalVectorArray("_ScDuneRect"); var ramps = Shader.GetGlobalVectorArray("_ScDuneRamp");
+ var b = DuneCoasts.Bands[0];
+ Vector3 sw = map.Frame.ToWorld(b.lon0, b.lat0, 0f), ne = map.Frame.ToWorld(b.lon1, b.lat1, 0f);
+ Assert.AreEqual(new Vector4(sw.x, ne.x, sw.z, ne.z), rects[0]);
+ float rampZ = (float)(b.ramp / (map.Frame.Lat1 - map.Frame.Lat0) * map.Frame.LengthM);
+ Assert.AreEqual(rampZ, ramps[0].y, 0.5f, "the ramp north-south, in metres");
+ }
+}
diff --git a/unity/Assets/Tests/EditMode/DuneCoastsTests.cs.meta b/unity/Assets/Tests/EditMode/DuneCoastsTests.cs.meta
new file mode 100644
index 000000000..fdf040ecb
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/DuneCoastsTests.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: c17694a39e0a4db3bbadd69e86df7158
diff --git a/unity/Assets/Tests/EditMode/SeaTests.cs b/unity/Assets/Tests/EditMode/SeaTests.cs
index d873ef4d1..69513b61c 100644
--- a/unity/Assets/Tests/EditMode/SeaTests.cs
+++ b/unity/Assets/Tests/EditMode/SeaTests.cs
@@ -434,8 +434,35 @@ public class SeaTests
VisualToggles.Set("grid", false);
var cam = Camera.main; var rig = cam.GetComponent<CameraRig>();
var log = new System.Text.StringBuilder();
- var bands = new System.Collections.Generic.List<int>();
- foreach (var lat in new[] { 31.90f, 31.92f, 31.94f, 31.96f })
+ var bands = SurfWalks(map, cam, rig, SouthWindowLats, log).Select(w => w.band).ToList();
+ float mean = (float)bands.Average();
+ TestContext.WriteLine(log.ToString());
+ TestContext.WriteLine($"mean foam band over {bands.Count} walks: {mean:0.0} px");
+ Assert.That(mean, Is.InRange(SurfBandSouthPx.x, SurfBandSouthPx.y), "south of Jaffa: the surf's foam band in promo 03's band");
+ }
+
+ /// <summary>TheSurfReachesPromo03sBandSouthOfJaffa's bounds, coast_measure's southern band for gameplay03 (#690).</summary>
+ static readonly Vector2 SurfBandSouthPx = new Vector2(25f, 55f);
+
+ /// <summary>The latitudes coast_measure's windows cover at gameplay03 (rows projected from the pose, with and without the
+ /// top bar's inset): south 31.89-31.98 N, north 32.10-32.26 N.</summary>
+ static readonly float[] SouthWindowLats = { 31.90f, 31.92f, 31.94f, 31.96f }, NorthWindowLats = { 32.12f, 32.16f, 32.20f, 32.24f };
+
+ /// <summary>Whether <see cref="SurfWalks"/> renders the far sea's texture ("seatexture": mottle, ripple and the
+ /// whitecap flecks). Off: the walks measure the surf alone (the surf terms do not read _ScSeaTexture), as the seam test
+ /// pins the texture off; a whitecap fleck is not surf (<see cref="TheSurfWalksSeeTheBreakersAndNotTheWhitecaps"/>).</summary>
+ const bool WalkSeaTexture = false;
+
+ /// <summary>#690's walk: at the breaker test's pose (30 km at 960x540) and four pinned moments, a one-pixel line from the
+ /// shore 3 km out to sea at each latitude. Per walk, the foam band (px to the end of the farthest run of 2 or more foam
+ /// pixels, the breaker test's line; a lone white pixel such as a boat does not count), the number of such lines and the
+ /// foam pixels themselves (index 0 at the shore). The far sea's texture is <see cref="WalkSeaTexture"/> unless
+ /// <paramref name="seaTexture"/> says otherwise.</summary>
+ static System.Collections.Generic.List<(int band, int lines, bool[] foam)> SurfWalks(MapScene map, Camera cam, CameraRig rig, float[] lats, System.Text.StringBuilder log, bool? seaTexture = null)
+ {
+ VisualToggles.Set("seatexture", seaTexture ?? WalkSeaTexture);
+ var walks = new System.Collections.Generic.List<(int band, int lines, bool[] foam)>();
+ foreach (var lat in lats)
{
var (col, row) = ShoreTexel(lat);
const float texelM = 161529f / 2048f; // a coast.png texel east-west
@@ -447,7 +474,8 @@ public class SeaTests
var px = new Vector2[2];
var r = RenderSample.Render(cam, 960, 540, new[] { shore, reach }, px);
int n = Mathf.CeilToInt(Mathf.Max(Mathf.Abs(px[1].x - px[0].x), Mathf.Abs(px[1].y - px[0].y)));
- int band = 0, run = 0;
+ int band = 0, run = 0, lines = 0;
+ var foamAt = new bool[n + 1];
var trace = new System.Text.StringBuilder();
for (int k = 0; k <= n + 1; k++)
{
@@ -457,23 +485,83 @@ public class SeaTests
var p = Vector2.Lerp(px[0], px[1], k / (float)n);
var c = r.At(Mathf.RoundToInt(p.x), Mathf.RoundToInt(p.y));
foam = Luma(c) >= 0.72f && Mathf.Max(c.r, c.g, c.b) - Mathf.Min(c.r, c.g, c.b) <= 30f / 255f;
+ foamAt[k] = foam;
trace.Append(foam ? '#' : '.');
}
if (foam) run++;
- else { if (run >= 2) band = k; run = 0; } // the band ends where the farthest line of 2+ px ends
+ else { if (run >= 2) { band = k; lines++; } run = 0; } // the band ends where the farthest line of 2+ px ends
}
- bands.Add(band);
- log.AppendLine($"{lat:0.00} N t={t}: foam band {band} px of {n + 1} {trace}");
+ walks.Add((band, lines, foamAt));
+ log.AppendLine($"{lat:0.00} N t={t}: foam band {band} px of {n + 1}, {lines} lines {trace}");
}
}
- float mean = (float)bands.Average();
+ return walks;
+ }
+
+ /// <summary>#690 option C: the surf is wide on the dune coast south of Jaffa and narrow under the kurkar north of Tel
+ /// Aviv, as promo 03 draws it (coast_measure at gameplay03: 44 px south, 12.3 px on the northern frontage). One zone
+ /// width for the whole coast (2.4 km) read 30.8 and 25.0 px. Walked at the latitudes of coast_measure's two windows (16
+ /// walks each, <see cref="SurfWalks"/>): the north's mean band is at most <see cref="NorthToSouthMax"/> of the south's.
+ /// The evenly spaced lines ("combed stripes") are not asserted here: they are read with coast_measure's stripe_rows on
+ /// the WebGL shots, the measure #716 is defined by (a walk counts lines over 3 km, where the tool counts them in the
+ /// foam band, so a walk's count is not that measure).</summary>
+ [UnityTest]
+ public IEnumerator TheSurfIsWideOnTheDuneCoastAndNarrowUnderTheKurkar()
+ {
+ var map = OpenMap();
+ yield return null;
+ VisualToggles.Set("grid", false);
+ var cam = Camera.main; var rig = cam.GetComponent<CameraRig>();
+ var log = new System.Text.StringBuilder();
+ var south = SurfWalks(map, cam, rig, SouthWindowLats, log);
+ var north = SurfWalks(map, cam, rig, NorthWindowLats, log);
+ float s = (float)south.Average(w => w.band), n = (float)north.Average(w => w.band);
TestContext.WriteLine(log.ToString());
- TestContext.WriteLine($"mean foam band over {bands.Count} walks: {mean:0.0} px");
- Assert.That(mean, Is.InRange(SurfBandSouthPx.x, SurfBandSouthPx.y), "south of Jaffa: the surf's foam band in promo 03's band");
+ TestContext.WriteLine($"mean foam band: south {s:0.0} px, north {n:0.0} px (ratio {n / s:0.00})");
+ Assert.That(s, Is.InRange(SurfBandSouthPx.x, SurfBandSouthPx.y), "south of Jaffa: the surf's foam band in promo 03's band");
+ Assert.LessOrEqual(n / s, NorthToSouthMax, "the kurkar coast's surf is narrower than the dune coast's");
}
- /// <summary>TheSurfReachesPromo03sBandSouthOfJaffa's bounds, coast_measure's southern band for gameplay03 (#690).</summary>
- static readonly Vector2 SurfBandSouthPx = new Vector2(25f, 55f);
+ /// <summary>#690 option C: the surf walks measure the surf, not the far sea's whitecaps. A whitecap fleck (sea round 2:
+ /// one per 120 m cell, at a fixed spot, flickering with the mottle) stands still, where breakers roll in about 3 px every
+ /// 5 s; at 32.24 N one sat 70 px out at all 4 moments and read as a 71 px foam band. With the far sea's texture on, a
+ /// pixel <see cref="FleckFromPx"/> or more out is white at all 4 moments (the case this guards); in the walk's own render
+ /// none is, and inside that reach the walk keeps at least 80% of the foam pixels it has with the sea texture on (the
+ /// texture's ripple shifts a few pixels across the foam threshold), so the moving surf still counts.</summary>
+ [UnityTest]
+ public IEnumerator TheSurfWalksSeeTheBreakersAndNotTheWhitecaps()
+ {
+ var map = OpenMap();
+ yield return null;
+ VisualToggles.Set("grid", false);
+ var cam = Camera.main; var rig = cam.GetComponent<CameraRig>();
+ var log = new System.Text.StringBuilder();
+ var lats = new[] { 32.24f };
+ var on = SurfWalks(map, cam, rig, lats, log, seaTexture: true);
+ var walk = SurfWalks(map, cam, rig, lats, log);
+ int Still(System.Collections.Generic.List<(int band, int lines, bool[] foam)> w)
+ {
+ int n = w.Min(x => x.foam.Length), still = 0;
+ for (int k = FleckFromPx; k < n; k++) if (w.All(x => x.foam[k])) still++;
+ return still;
+ }
+ TestContext.WriteLine(log.ToString());
+ TestContext.WriteLine($"pixels {FleckFromPx}+ out white at all 4 moments: sea texture on {Still(on)}, the walk {Still(walk)}");
+ Assert.Greater(Still(on), 0, "the case: a whitecap fleck stands still out at sea with the sea texture on");
+ Assert.AreEqual(0, Still(walk), "the walk does not count the whitecaps");
+ int Surf(System.Collections.Generic.List<(int band, int lines, bool[] foam)> w) => w.Sum(x => x.foam.Take(FleckFromPx).Count(f => f));
+ TestContext.WriteLine($"foam pixels inside {FleckFromPx} px over 4 moments: sea texture on {Surf(on)}, the walk {Surf(walk)}");
+ Assert.GreaterOrEqual(Surf(walk), 0.8f * Surf(on), "the walk keeps the surf");
+ Assert.Greater(Surf(walk), 0, "the walk sees the surf");
+ }
+
+ /// <summary>TheSurfWalksSeeTheBreakersAndNotTheWhitecaps' reach: 60 px is about 2.1 km at the walk's 35 m a pixel,
+ /// past the surf under the kurkar (1.5 km, about 43 px).</summary>
+ const int FleckFromPx = 60;
+
+ /// <summary>TheSurfIsWideOnTheDuneCoastAndNarrowUnderTheKurkar's bound: promo 03's ratio is 0.28 (12.3 / 44), one width
+ /// for the whole coast read 0.81 (25.0 / 30.8).</summary>
+ const float NorthToSouthMax = 0.6f;
/// <summary>promo-sea review I2 / M5 / N1: the breakers are box-filtered over the pixel, so they never alias. Around
/// the surf zone west of Tel Aviv, at the gameplay footprint (30 km at 960x540: about 45 m a pixel, the same as