A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Map: roads read as wide, pale dirt tracks at the gameplay zoom (refs #35) (#508)
Eyal Golan50a4691e5e4b
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 407c4367e..93a13a38d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -228,6 +228,9 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB(refs #34): over the wet hill country where the land use is garrigue and terraces, outside the groves, the towns'footprints and the hex-edge midpoints. The olives already planted stay where they are; the map has about 20,000 treesinstead of 8,400.+- Map roads read as wide, pale dirt tracks at the gameplay zoom, as in promo 03 (refs #35): 420 m wide (was 300 m), cream+ dirt varied in patches, softer verges. The pale band is a median 9 px at gameplay03 (was 4) and 19 px at 30 km (was+ 7). The route ribbons are re-baked; no route was added.- The trees are warm olive-brown instead of bright green, like the groves in promo 03 (refs #34): citrus groves, olivecrowns, palms and cypresses. Only the leaf colours change; the fruit, meshes and frame cost are the same.- Map: settlement quick wins (refs #31). The White City's blocks are lime white, with a solid-parapet balcony on eachdiff --git a/docs/routes.md b/docs/routes.mdindex 29e1f27b9..b1efc57da 100644--- a/docs/routes.md+++ b/docs/routes.md@@ -140,7 +140,7 @@ measurement in `docs/units.md`:|---|---|---|| Railway bed | about 16 px | 680 m (its soft edges take about a sixth) || Sleeper spacing | about 4 px | 150 m |-| Dirt road | about 8 px | 300 m |+| Dirt road | about 8 px | 420 m (its pale core, inside the soft verges, about 280 m) || Burma Road | (not in the promo) | 200 m || Train (six cars) | about 250 px, about 8.8 km | 8.8 km: locomotive, tender and four coaches at 80x real length and 1.5x stockier across (at a uniform 65x the first checkpoint drew a thin dark line) |@@ -198,10 +198,22 @@ measurement in `docs/units.md`:- u runs across the ribbon and v along it, in metres.**The shader** (`Statecraft/Route`). It is transparent and has no new keywords; the shadow keywords are the terrain's.-- The road is pale dirt with faint wheel ruts and darker worn verges (0.32 of the width either side of the line, about- 1 px each at gameplay03), so it reads on pale sand and dry grass by its edges, as promo 03's tracks do. At the- country-wide pose (a pixel over 60–150 m), it darkens to a grey-brown line, so it reads as the promo diorama's roads- do instead of vanishing on pale ground.+- The road is a wide, pale dirt track (refs #35, `roads-dirt`): cream dirt, varied with a warmer dust in patches+ hundreds of metres long (two octaves of map-position noise, `RoadPatchM` 900 m, a few pixels at gameplay03, so it does+ not shimmer), faint wheel ruts, and narrow soft verges (0.33 of the width either side of the line, strength 0.6)+ where the soft edge begins. At the country-wide pose (a pixel over 60–150 m), it darkens to a grey-brown line, so it+ reads as the promo diorama's roads do instead of vanishing on pale ground.+ - **Why.** At 300 m with dark verges (#404), the pale core was about 4 px at gameplay03, a thin line between two dark+ ones that almost vanished; promo 03's tracks are about 8 px of pale dirt with soft edges.+ - **Measured** (`RoadsReadAsWidePaleTracks`): across every road in the frame's middle (6 points each, tilt-shift off),+ the run of pixels from the line out that the routes make paler than the ground by 0.03 luma, measured on screen.+ Median at gameplay03: 4 px on main, 9 px here (bound 6); at close30 (30 km): 7 px on main, 19 px here (bound 12).+ The core stands a median 0.19 luma over the ground (main 0.15).+ - It stays under the railway (680 m, dark ballast and bright rails) and the region borders (saturated blue).+ - The kits' corridor along a road stays 250 m either side of the line, as on main: half the 420 m width plus+ `RoadCorridorMarginM` (40 m, other routes keep 100 m). The road's outer 22% is its soft edge, so lots and crowns+ still keep about 130 m from the visible dirt. With 100 m (a 310 m corridor) the kits lost Jerusalem's Haram+ al-Sharif landmarks and Beersheba's houses (`TownCensusTests`).- The railway is a cool grey stone ballast bed with darker shoulders, dark sleepers every 100 m and two bright steelrails, after promo 03 and the video's 0:21 close-up (refs #35, `.superpowers/borders-routes-r1/PLAN.md` R1 and R2).- A rail is 0.036 of the 680 m bed, about 0.7 px at gameplay03, so its box filter left it faint: averaged along the@@ -209,8 +221,10 @@ measurement in `docs/units.md`:the bed beside it. It is now drawn at least 0.8 px wide (`RailMinPx`) and brighter, and stands 0.18–0.21 above it(bound 0.15). The two fade out where they would merge, under 3 px apart (the overview).- Roads: on the eight palest-ground road crossings in the gameplay03 frame (`RoadsReadOnPaleGroundByTheirVerges`),- the verges are darker than the core by at least 0.04 and darker than the ground beside them on 6 of 8 (bound 5);- with main's shader on 0 of 8.+ the verges are darker than the core by at least 0.04, and either darker than the ground beside them (#404's dark+ verges) or the core is paler than the ground under it by 0.08 (the wide pale track): 7 of 8 (bound 5). The verge+ windows scale with the road's width (0.2–0.43 of it, 60–130 m at 300 m). With the soft verges alone and #404's+ rule, 1 of 8 read; the pale core is what carries them now.- The sleepers were every 150 m at a duty of 0.4: a dark bar of about 1.7 px every 4.3 px, a coarse ladder. At 100 mand 0.35 they are a fine texture, as the promo's.- The ballast was a grey-brown (0.50, 0.46, 0.41) close to the land's ochre; it is now a stone grey (0.56, 0.54, 0.50),@@ -276,7 +290,7 @@ does (#320, docs/visual-v1.md).**Kits keep off the routes** (settlement kits and trees, #179).- `MapScene` reads the routes before building the kits, and hands `KitLayer.Build` every route's corridor- (`RouteLayer.Corridors`): half the drawn width plus `CorridorMarginM` (100 m).+ (`RouteLayer.Corridors`): half the drawn width plus `CorridorMarginM` (100 m; 40 m for roads, `RoadCorridorMarginM`).- `KitGround.OnRoute` (a 2 km segment grid) keeps building lots, landmarks and tree crowns out of these corridors.B9 still keeps trees out of building lots.- Every route gets its corridor, whatever its date: the kits are built once, not per date, so the Burma Road's corridor@@ -298,7 +312,8 @@ All of these are on `promo-roads`.**Look test** (`RouteTests.AtTheGameplayPoseTheRailwayIsDarkAndTheRoadPale`, gameplay03, editor, review round):- the railway renders RGB (0.46, 0.40, 0.31) over ground (0.62, 0.59, 0.33);-- the road renders (0.81, 0.71, 0.50) over ground (0.60, 0.57, 0.32).+- the road renders (0.81, 0.71, 0.50) over ground (0.60, 0.57, 0.32); with the wide pale track (`roads-dirt`, a later+ point of the frame) (0.86, 0.75, 0.55) over (0.50, 0.51, 0.29), main (0.77, 0.67, 0.47) at the same point.**Frame time.** Headless `?vprofile`, 1920x1080 at DPR 1, `machine_lock.py --exclusive`.- These numbers come from the first round, with the train shown in the profile.diff --git a/unity/Assets/Resources/Routes/RouteRibbons.bytes b/unity/Assets/Resources/Routes/RouteRibbons.bytesindex c1dd2729f..919a67da0 100644Binary files a/unity/Assets/Resources/Routes/RouteRibbons.bytes and b/unity/Assets/Resources/Routes/RouteRibbons.bytes differdiff --git a/unity/Assets/Scripts/Map/Routes/RouteLayer.cs b/unity/Assets/Scripts/Map/Routes/RouteLayer.csindex e50aeb6ff..8ae9fac17 100644--- a/unity/Assets/Scripts/Map/Routes/RouteLayer.cs+++ b/unity/Assets/Scripts/Map/Routes/RouteLayer.cs@@ -12,8 +12,8 @@ namespace Statecraft.Game.Map.Routes/// shows only while the game date is inside its window (RoutePath.From/To; review C1: the Burma Road from 14 June/// 1948): routes are grouped by window, one ribbon pair per group, and <see cref="ShowAt"/> switches the groups. A/// steam train on the Jaffa–Jerusalem line is a showcase, never normal play (review I1, <see cref="ModeFor"/>). Widths are symbolic, measured on the- /// promo's gameplay frame like the settlements and units (docs/routes.md): a road about 8 px and the railway about- /// 16 px wide at 1920 px (the soft edges take about a sixth of the railway's width, so its bed is drawn 680 m), so they read at the gameplay zoom as the promo draws them. Registers the "routes" (ribbons)+ /// promo's gameplay frame like the settlements and units (docs/routes.md): a road's pale core about 8 px and the railway+ /// about 16 px wide at 1920 px (the soft edges take about a sixth of the railway's width, so its bed is drawn 680 m), so they read at the gameplay zoom as the promo draws them. Registers the "routes" (ribbons)/// and "train" visual toggles, so the frame profile prices each. Pure geometry from the data: the same file gives the/// same meshes, vertex for vertex.</summary>public static class RouteLayer@@ -22,8 +22,10 @@ namespace Statecraft.Game.Map.Routespublic const string RailMaterialResource = "Routes/Rail", RoadMaterialResource = "Routes/Road";public const string Folder = "Assets/Resources/Routes";- /// <summary>Full ribbon widths (m), soft edges included (the shader fades the outer 16-30%).</summary>- public const float RailWidthM = 680f, RoadWidthM = 300f, TrackWidthM = 200f;+ /// <summary>Full ribbon widths (m), soft edges included (the shader fades the outer 16-30%). A road is 420 m: its pale+ /// core, inside the verges, is about 280 m, about 8 px at the gameplay zoom, as promo 03's dirt tracks (at 300 m the+ /// core was about 4 px, a thin line between dark verges); still well under the railway's bed.</summary>+ public const float RailWidthM = 680f, RoadWidthM = 420f, TrackWidthM = 200f;/// <summary>Spacing (m) of the ribbon's cross-sections along its line: under the heightmap's 211 m N-S spacing, so/// every terrain row gets a section; about 3 px at the gameplay zoom.</summary>public const float StepM = 120f;@@ -74,12 +76,17 @@ namespace Statecraft.Game.Map.Routes/// <summary>Clearance (m) beyond a ribbon's drawn half-width that kit buildings and trees keep from it, so a lot's or/// crown's edge never touches the soft edge of the road or the ballast.</summary>public const float CorridorMarginM = 100f;+ /// <summary>The roads' clearance (m) beyond their drawn half-width: 40 m, so their corridor stays the 250 m half-width+ /// it had when roads were 300 m wide. A wider corridor pushed town kits off the roads that run through the towns+ /// (Jerusalem's Haram al-Sharif, Beersheba's houses: TownCensusTests). The road's outer 22% is its soft edge, so a+ /// lot or crown still keeps about 130 m from the visible dirt.</summary>+ public const float RoadCorridorMarginM = 40f;/// <summary>Every route's line (world x, z) with the half-width kits must keep clear of: half the drawn width plus- /// <see cref="CorridorMarginM"/>. All routes, whatever their window: the kits are built once, not per date, so a route- /// that appears later (the Burma Road) has its corridor from the start.</summary>+ /// <see cref="CorridorMarginM"/> (<see cref="RoadCorridorMarginM"/> for roads). All routes, whatever their window: the+ /// kits are built once, not per date, so a route that appears later (the Burma Road) has its corridor from the start.</summary>public static List<(List<Vector2> line, float halfWidth)> Corridors(GeoFrame frame, IEnumerable<RoutePath> routes) =>- routes.Select(r => (World(frame, r), WidthOf(r.Kind) / 2f + CorridorMarginM)).ToList();+ routes.Select(r => (World(frame, r), WidthOf(r.Kind) / 2f + (r.Kind == RoutePaths.Road ? RoadCorridorMarginM : CorridorMarginM))).ToList();public static float WidthOf(string kind) => kind switch{diff --git a/unity/Assets/Shaders/Route.shader b/unity/Assets/Shaders/Route.shaderindex 3c665a077..8f3fb1a7c 100644--- a/unity/Assets/Shaders/Route.shader+++ b/unity/Assets/Shaders/Route.shader@@ -1,5 +1,5 @@// The 1948 railways and roads (issue #35, RouteLayer): ribbons draped on the terrain at the promo's symbolic width. One-// shader for both looks, chosen by _Kind (a material value, so a uniform branch): 0 a pale dirt road with faint wheel ruts,+// shader for both looks, chosen by _Kind (a material value, so a uniform branch): 0 a pale dirt road with faint wheel ruts and patchy colour,// 1 a railway (a ballast bed, sleepers and two rails). The mesh gives u across the ribbon (0..1) and v along it (metres),// so the sleepers repeat at a fixed spacing; every pattern is box-filtered to the pixel (fwidth), so it fades to its mean// instead of shimmering as the camera pulls back. Lit like the ground beside it: the sun with its shadows plus the ambient@@ -26,12 +26,17 @@ Shader "Statecraft/Route"float _Opacity;CBUFFER_END- // Colours (sRGB) after the promo's gameplay frame (promo/final/03): pale packed dirt with darker worn verges that- // outline it on pale ground, as the promo's tracks read; a cool grey stone ballast bed with dark timber sleepers and+ // Colours (sRGB) after the promo's gameplay frame (promo/final/03): a wide, pale packed-dirt track with soft,+ // slightly darker worn verges, as the promo's tracks read; a cool grey stone ballast bed with dark timber sleepers and// bright steel rails (promo video 0:21).- static const float3 RoadSrgb = float3(0.86, 0.78, 0.62);- static const float3 RutSrgb = float3(0.72, 0.63, 0.48);- static const float3 VergeSrgb = float3(0.42, 0.35, 0.26);+ // The road: pale packed dirt (promo 03's tracks render about (0.97, 0.84, 0.74) after its grade), varied between a+ // cream and a warmer, darker dust in patches hundreds of metres long (RoadPatchM: a few pixels at the gameplay zoom,+ // so the variation never shimmers), so a long road does not read as one flat painted stripe.+ static const float3 RoadSrgb = float3(0.98, 0.92, 0.80);+ static const float3 RoadDustSrgb = float3(0.92, 0.83, 0.68);+ static const float RoadPatchM = 900.0;+ static const float3 RutSrgb = float3(0.82, 0.73, 0.59);+ static const float3 VergeSrgb = float3(0.46, 0.39, 0.29);static const float3 BallastSrgb = float3(0.56, 0.54, 0.50);static const float3 BankSrgb = float3(0.44, 0.42, 0.39); // the embankment's shoulders, darkerstatic const float3 SleeperSrgb = float3(0.30, 0.22, 0.15);@@ -47,10 +52,10 @@ Shader "Statecraft/Route"// A rail is drawn at least RailMinPx wide, so at the gameplay zoom (its true 0.036 of the bed is under a pixel) it// still reads as a bright line; the rails fade out where the two would merge (under RailFadeToPx apart).static const float RailMinPx = 0.8, RailFadeFromPx = 1.5, RailFadeToPx = 3.0;- static const float RutOffset = 0.16, RutHalfWidth = 0.05;- // The verges: a darker worn strip either side of the dirt, just inside the soft edge (RoadEdge), where the road is- // still nearly opaque, so the dark line outlines the pale core on pale ground.- static const float VergeOffset = 0.31, VergeHalfWidth = 0.09, VergeStrength = 0.9, RoadEdge = 0.18;+ static const float RutOffset = 0.12, RutHalfWidth = 0.035, RutStrength = 0.4;+ // The verges: a narrow, softer darker worn strip either side of the dirt, where the soft edge (RoadEdge) begins, so+ // it outlines the wide pale core on pale ground without reading as a dark line of its own.+ static const float VergeOffset = 0.33, VergeHalfWidth = 0.07, VergeStrength = 0.6, RoadEdge = 0.22;struct Attributes { float4 positionOS : POSITION; float3 normalOS : NORMAL; float2 uv : TEXCOORD0; };struct Varyings { float4 positionCS : SV_POSITION; float3 positionWS : TEXCOORD0; float3 normalWS : TEXCOORD1; float2 uv : TEXCOORD2; };@@ -111,9 +116,11 @@ Shader "Statecraft/Route"}else{- albedo = SRGBToLinear(RoadSrgb);+ // Two octaves of value noise on the map position: low frequency, so its box filter is not needed.+ float patch = 0.65 * ScNoise(mapM / RoadPatchM) + 0.35 * ScNoise(mapM / (0.37 * RoadPatchM) + 17.0);+ albedo = lerp(SRGBToLinear(RoadSrgb), SRGBToLinear(RoadDustSrgb), smoothstep(0.3, 0.75, patch));float ruts = saturate(Band(u, 0.5 - RutOffset, RutHalfWidth, du) + Band(u, 0.5 + RutOffset, RutHalfWidth, du));- albedo = lerp(albedo, SRGBToLinear(RutSrgb), 0.6 * ruts);+ albedo = lerp(albedo, SRGBToLinear(RutSrgb), RutStrength * ruts);float verges = saturate(Band(u, 0.5 - VergeOffset, VergeHalfWidth, du) + Band(u, 0.5 + VergeOffset, VergeHalfWidth, du));albedo = lerp(albedo, SRGBToLinear(VergeSrgb), VergeStrength * verges);albedo = lerp(albedo, SRGBToLinear(RoadFarSrgb), smoothstep(FarFromM, FarToM, dv));diff --git a/unity/Assets/Tests/EditMode/RouteTests.cs b/unity/Assets/Tests/EditMode/RouteTests.csindex 5d4fe8cc7..80f4ac235 100644--- a/unity/Assets/Tests/EditMode/RouteTests.cs+++ b/unity/Assets/Tests/EditMode/RouteTests.cs@@ -471,6 +471,11 @@ public class RouteTests// Plus one segment per unit clearing (a unit token in a town: docs/units.md, "Placement").Assert.AreEqual(corridors.Sum(c => c.line.Count - 1) + map.UnitClearings.Count, map.KitStats.CorridorSegments, "the map hands every route to the kits");Assert.IsTrue(routes.Any(r => r.Id == "burma_road"), "the dated Burma Road keeps its corridor from the start");+ // Every corridor clears its drawn ribbon by at least the roads' margin, and the roads' stays main's 250 m (so the+ // wider road moves no town kit).+ for (int i = 0; i < routes.Count; i++)+ Assert.GreaterOrEqual(corridors[i].halfWidth, RouteLayer.WidthOf(routes[i].Kind) / 2f + RouteLayer.RoadCorridorMarginM, routes[i].Id);+ Assert.AreEqual(250f, RouteLayer.RoadWidthM / 2f + RouteLayer.RoadCorridorMarginM, "the roads' kit corridor");// The same placement the map runs, with the same corridors.var g = new Statecraft.Game.Map.Kits.KitGround(map.Terrain, map.Frame, map.Hexes, HeightmapLoader.Load(Paths.StreamingMap).meta.elev_min_m);@@ -667,7 +672,7 @@ public class RouteTests/// <summary>A walk across a route at gameplay03's pose: the pixels from -<paramref name="halfM"/> to +halfM across the/// line at the line point nearest (lon, lat), with the routes on and off, and each pixel's offset (m) from the line.</summary>- sealed class Across { public readonly List<Color> On = new List<Color>(), Off = new List<Color>(); public readonly List<float> M = new List<float>(); }+ sealed class Across { public readonly List<Color> On = new List<Color>(), Off = new List<Color>(); public readonly List<float> M = new List<float>(); public readonly List<Vector2> P = new List<Vector2>(); }static List<Across> WalkAcross(MapScene map, Camera cam, List<Vector2> line, IEnumerable<int> at, float halfM, float stepM){@@ -695,7 +700,7 @@ public class RouteTests{int x = Mathf.FloorToInt(px[k].x), y = Mathf.FloorToInt(px[k].y);if (!seen.Add((offs[k].walk, x, y))) continue;- var w = walks[offs[k].walk]; w.On.Add(on.At(x, y)); w.Off.Add(off.At(x, y)); w.M.Add(offs[k].m);+ var w = walks[offs[k].walk]; w.On.Add(on.At(x, y)); w.Off.Add(off.At(x, y)); w.M.Add(offs[k].m); w.P.Add(px[k]);}return walks;}@@ -775,9 +780,10 @@ public class RouteTests/// <summary>Bound for the rail test, set from its log.</summary>const float RailContrast = 0.15f; // measured 0.18-0.21 (main's shader: 0.10-0.11)- /// <summary>Promo 03's dirt tracks read on any ground by their darker worn edges. On the palest ground a road crosses in- /// the gameplay03 frame (the sand and dry grass, where a pale road alone melts in), across the road the verges are- /// darker than its core by VergeStep, and darker than the ground beside them with the routes off.</summary>+ /// <summary>Promo 03's dirt tracks read on any ground. On the palest ground a road crosses in the gameplay03 frame (the+ /// sand and dry grass, where a pale road alone could melt in), across the road the verges are darker than its core by+ /// VergeStep, and either darker than the ground beside them with the routes off, or the core is paler than the ground+ /// under it by CoreAboveGround (the wide pale tracks, where the verges are soft and no longer a dark line).</summary>[Test]public void RoadsReadOnPaleGroundByTheirVerges(){@@ -796,9 +802,9 @@ public class RouteTestsvar line = RouteLayer.World(map.Frame, r);var at = InFrame(map, cam, line, 6);if (at == null) continue;- foreach (var w in WalkAcross(map, cam, line, at, 300f, 5f))+ foreach (var w in WalkAcross(map, cam, line, at, Road, 5f)){- var g = w.M.Select((m, k) => (m, k)).Where(x => Mathf.Abs(x.m) > 200f).Select(x => RenderSample.Luma(w.Off[x.k])).ToList();+ var g = w.M.Select((m, k) => (m, k)).Where(x => Mathf.Abs(x.m) > 0.67f * Road).Select(x => RenderSample.Luma(w.Off[x.k])).ToList();if (g.Count > 0) walks.Add((r.Id, w, g.Average()));}}@@ -808,14 +814,18 @@ public class RouteTestsforeach (var (id, w, ground) in pale){float Mean(float lo, float hi, List<Color> c) { var v = w.M.Select((m, k) => (m, k)).Where(x => Mathf.Abs(x.m) >= lo && Mathf.Abs(x.m) <= hi).Select(x => RenderSample.Luma(c[x.k])).ToList(); return v.Count == 0 ? float.NaN : v.Average(); }- float core = Mean(0f, 30f, w.On);- // The verge's darkest pixel on each side.- float VergeSide(int sign) { var v = w.M.Select((m, k) => (m, k)).Where(x => Mathf.Sign(x.m) == sign && Mathf.Abs(x.m) >= 60f && Mathf.Abs(x.m) <= 130f).Select(x => RenderSample.Luma(w.On[x.k])).ToList(); return v.Count == 0 ? float.NaN : v.Min(); }+ float core = Mean(0f, 0.1f * Road, w.On);+ // The verge's darkest pixel on each side (the verges lie about a third of the width out from the line).+ float VergeSide(int sign) { var v = w.M.Select((m, k) => (m, k)).Where(x => Mathf.Sign(x.m) == sign && Mathf.Abs(x.m) >= VergeFrom * Road && Mathf.Abs(x.m) <= VergeTo * Road).Select(x => RenderSample.Luma(w.On[x.k])).ToList(); return v.Count == 0 ? float.NaN : v.Min(); }float verge = Mathf.Max(VergeSide(-1), VergeSide(+1)); // the weaker side- float off = Mean(60f, 130f, w.Off);- bool ok = core - verge >= VergeStep && verge < off - VergeBelowGround;+ float off = Mean(VergeFrom * Road, VergeTo * Road, w.Off), under = Mean(0f, 0.1f * Road, w.Off);+ // It reads when the verges outline the core (darker than the core) and either the verges are darker than+ // the ground beside them (main's dark-verge look, #404) or the core is clearly paler than the ground under it+ // (the wide pale track's look).+ bool outlined = core - verge >= VergeStep;+ bool ok = outlined && (verge < off - VergeBelowGround || core - under >= CoreAboveGround);if (ok) read++;- TestContext.WriteLine($"{id}: ground {ground:0.000} core {core:0.000} verge {verge:0.000} (off {off:0.000}) -> {(ok ? "reads" : "melts")}");+ TestContext.WriteLine($"{id}: ground {ground:0.000} core {core:0.000} (under {under:0.000}) verge {verge:0.000} (off {off:0.000}) -> {(ok ? "reads" : "melts")}");}TestContext.WriteLine($"{read} of {pale.Count} pale-ground walks read");Assert.GreaterOrEqual(read / (float)pale.Count, PaleReadShare, "roads read on pale ground");@@ -824,7 +834,58 @@ public class RouteTests}/// <summary>Bounds for the road test, set from its log.</summary>- const float VergeStep = 0.04f, VergeBelowGround = 0.01f, PaleReadShare = 0.6f;+ const float VergeStep = 0.04f, VergeBelowGround = 0.01f, CoreAboveGround = 0.08f, PaleReadShare = 0.6f;+ /// <summary>The road's width, and where its verges lie across it (shares of the width from the line; 60-130 m when the+ /// road was 300 m wide).</summary>+ const float Road = RouteLayer.RoadWidthM, VergeFrom = 0.2f, VergeTo = 0.43f;++ /// <summary>Promo 03's roads are wide, pale dirt tracks (about 8 px at 1920 px); main's 300 m road drew a pale core of+ /// about 4 px between dark verges that almost vanished at gameplay03. Across every road in the frame's middle (6 points+ /// each, tilt-shift off, the train hidden), the pale band is the run of pixels the routes make paler than the ground+ /// (luma up by PaleStep), from the line out, measured on screen; its median width in pixels must reach RoadPalePx at gameplay03 (60 km) and more at close30+ /// (30 km). Logged per pose, with the median contrast of the band's core over the ground.</summary>+ [TestCase("gameplay03", 34.86, 32.00, 60000f, RoadPalePx)]+ [TestCase("close30", 34.83, 32.00, 30000f, 2 * RoadPalePx)]+ public void RoadsReadAsWidePaleTracks(string pose, double lon, double lat, float distance, float minPx)+ {+ var map = BuildMap();+ try+ {+ RenderSample.TiltShift(false);+ VisualToggles.Set(RouteLayer.TrainToggle, false);+ var cam = Camera.main; var rig = cam.GetComponent<CameraRig>();+ new PromoPose(pose, lon, lat, distance, 10f).Apply(rig, map.Frame); rig.TopInset = 0; rig.Apply();+ var routes = RoutePaths.Parse(CommittedYaml, Bounds);+ var widths = new List<float>(); var lifts = new List<float>();+ foreach (var r in routes.Where(r => r.Kind == RoutePaths.Road))+ {+ var line = RouteLayer.World(map.Frame, r);+ var at = InFrame(map, cam, line, 6);+ if (at == null) continue;+ foreach (var w in WalkAcross(map, cam, line, at, Road, 2f))+ {+ // The run of pale samples around the line (the walk is in order across it), measured on screen.+ bool Pale(int k) => RenderSample.Luma(w.On[k]) - RenderSample.Luma(w.Off[k]) >= PaleStep;+ int mid = Enumerable.Range(0, w.M.Count).OrderBy(k => Mathf.Abs(w.M[k])).First(), lo = mid, hi = mid;+ if (!Pale(mid)) { widths.Add(0f); continue; }+ while (lo > 0 && Pale(lo - 1)) lo--;+ while (hi + 1 < w.M.Count && Pale(hi + 1)) hi++;+ widths.Add((w.P[hi] - w.P[lo]).magnitude + 1f);+ var coreLift = Enumerable.Range(0, w.M.Count).Where(k => Mathf.Abs(w.M[k]) <= 0.1f * Road).Select(k => RenderSample.Luma(w.On[k]) - RenderSample.Luma(w.Off[k])).ToList();+ if (coreLift.Count > 0) lifts.Add(coreLift.Average());+ }+ }+ Assert.GreaterOrEqual(widths.Count, 12, "roads cross the frame");+ float Median(List<float> v) { var o = v.OrderBy(x => x).ToList(); return o[o.Count / 2]; }+ float px = Median(widths), lift = Median(lifts);+ TestContext.WriteLine($"{pose}: {widths.Count} walks, pale band median {px:0} px (p25 {widths.OrderBy(x => x).ElementAt(widths.Count / 4):0}), core over ground median {lift:+0.000}");+ Assert.GreaterOrEqual(px, minPx, $"{pose}: the roads read as wide pale tracks");+ }+ finally { VisualToggles.SetAll(true); Object.DestroyImmediate(map.gameObject); }+ }++ /// <summary>Bounds for the road width test, set from its log.</summary>+ const float PaleStep = 0.03f, RoadPalePx = 6f;/// <summary>Issue #321: the baked ribbons (RouteRibbonFile.AssetPath, Editor RouteRibbonBake.Bake) are what the shipped/// heightmap and route file give now, byte for byte; the map scene places them without deriving; and what it places