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: one band per shared region edge, and a blue line at the overview (refs #196) (#403)

Eyal Golanfa1063304c47
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a4d2e2328..fb012b0fe 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -195,6 +195,10 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
+0.9 ms at the gameplay zoom), not yet on an idle one.
### Changed
+- Map: a boundary between two regions of the same border style (two Mandate sub-districts) draws one band of the promo's
+ width, centred on the edge, instead of two full bands side by side; the Mandate frontier and a primary-secondary edge
+ keep the full band. Far off (a band under about 4 px, the overview) a band is a thin line of its colour, not a white
+ one. Visual only (refs #196).
- Land round 2 (refs #33): the ground's colours move from yellow-olive and gold to promo 03's warm dry ground, in the
biome palette and the land-use bake. Hedges, tree lines and farm tracks are drawn about 150 m wide, so the fields read
at the gameplay zoom. The hills get round bushes with a soft shadow, a stronger garrigue and clearer terraces. It is a
diff --git a/docs/visual-v1.md b/docs/visual-v1.md
index 1b68242a5..8be124a77 100644
--- a/docs/visual-v1.md
+++ b/docs/visual-v1.md
@@ -1108,6 +1108,25 @@ the game's start: the Administrative Divisions (Amendment) Proclamation, 1947 (P
while the lines leave gaps. A line is visible as a band only where it bounds a zone or is the Mandate frontier; at
5-km hexes two of the three Syrian DMZ parts take no hex (true-polyline overlay: #237).
+**Shared edges and the far line (refs #196, `.superpowers/borders-routes-r1/PLAN.md` B1 and B3).** Every sub-district
+is Primary, so where two meet both drew their full band: blue, white, white, blue, about 11-13 px across at gameplay03
+against promo 03's one band of about 8 px, on every internal boundary. Promo 03 never shows two same-colour regions side
+by side. `MapBorders.Use` now also bakes, per hex, which border edges the neighbour draws in the same style (b's upper six
+bits; the style keeps the low two), and `ScBorderApply` draws 0.6 of the band and of the wash each side of such a shared
+edge (`ScSharedBand`), so the two make one band of the promo's width centred on the edge, with no jog where the drawing
+side would change. At exactly half, each half lost its partly covered outer pixel and the pair measured 6 px at
+gameplay03 against a full band's 8; at 0.6 the pair measures as one full band.
+The nearest edge is chosen in units of its own band, so where a shared edge meets the frontier at a corner each keeps
+its own width. Edges against a region of style none (the Mandate frontier against "outside") and primary-secondary edges
+(the double band promo 03 draws near Tel Aviv) keep the full band. Still one texel a pixel (`TheBordersReadOneTexelAPixel`).
+Far off, where the band is under about 4 px (diorama02), the 2 px floor band was mostly its light stripe and read as a
+white line; the light stripe now turns into the colour between 4.5 and 2.5 px and the wash fades with it, so a far band
+is a thin line of its colour. At gameplay03 (about 8 px) nothing changes. Tests:
+`ASharedEdgeDrawsOneCentredBandAndTheFrontierKeepsTheFullBand` (the proof's blocks, all primary and then primary
+against none), `AtTheOverviewTheBandsAreThin` (now also: few near-white pixels, a blueness gain), and
+`UseBakesWhichEdgesBorderAnotherRegion` (the shared bits). The proof pattern alternates styles, so the proof's
+measurements and `ColourBlindPlayersTellTheBorderStylesApart` are unchanged.
+
**Research item: region data (to source, then the owner's sensitivity review).**
- *What:* per-hex region labels for (a) the sub-districts of Mandatory Palestine at the end of the Mandate (six districts:
Galilee, Haifa, Samaria, Jerusalem, Lydda, Gaza; sixteen sub-districts: Acre, Beisan, Nazareth, Safad, Tiberias, Haifa,
@@ -1131,7 +1150,7 @@ the game's start: the Administrative Divisions (Amendment) Proclamation, 1947 (P
shareable build (chapters design §13).
- *Limits of the renderer's data seam (review M8), for the data work to plan around:*
1. Two drawn styles (Primary, Secondary) plus None. The 1949 lines set Israel against four neighbours; with two styles
- the four share the red-orange band (the texel's style byte allows 255, but each new style needs colours that stay
+ the four share the red-orange band (the texel's style takes b's low two bits since the shared edges, so one more style fits; each new style needs colours that stay
apart for colour-blind players, so it is a design task, not a constant). Districts may want a neutral third style.
2. One layer at a time: districts and armistice lines cannot show together.
3. Styles are per region, not per edge: an edge's look comes from the regions on its two sides.
diff --git a/unity/Assets/Scripts/Map/MapBorders.cs b/unity/Assets/Scripts/Map/MapBorders.cs
index 85d1c14bc..40bc55938 100644
--- a/unity/Assets/Scripts/Map/MapBorders.cs
+++ b/unity/Assets/Scripts/Map/MapBorders.cs
@@ -144,15 +144,21 @@ namespace Statecraft.Game.Map
foreach (var (q, r) in layer.Hexes)
{
if (!mapHexes.Contains((q, r))) throw new ArgumentException($"{layer.Name}: hex ({q}, {r}) is not on the map");
- int id = layer.RegionOf(q, r), edges = 0;
+ int id = layer.RegionOf(q, r), edges = 0, shared = 0;
+ var style = layer.StyleOf(id);
// Edge i borders another region when that neighbour is in one (an unlisted hex, on the map or off it,
- // is 0: the coast and the data's edge get no band) and it is not this one.
+ // is 0: the coast and the data's edge get no band) and it is not this one. It is shared when the neighbour
+ // draws its band there in the same style: two sub-districts side by side. Each side then draws part of the
+ // band, so the boundary reads as one band of the promo's width, not two (the Mandate frontier, against
+ // the "outside" region of style none, and a primary-secondary edge keep the full band each side).
for (int i = 0; i < NeighbourSteps.Length; i++)
{
int other = layer.RegionOf(q + NeighbourSteps[i].dq, r + NeighbourSteps[i].dr);
- if (other > 0 && other != id) edges |= 1 << i;
+ if (other <= 0 || other == id) continue;
+ edges |= 1 << i;
+ if (style != BorderStyle.None && layer.StyleOf(other) == style) shared |= 1 << i;
}
- px[(r - rMin) * w + (q - qMin)] = Encode(id, layer.StyleOf(id), edges);
+ px[(r - rMin) * w + (q - qMin)] = Encode(id, style, edges, shared);
}
texture.SetPixels32(px); texture.Apply(false, false);
Current = layer; hasLayer = layer != null && layer.Count > 0;
@@ -163,11 +169,14 @@ namespace Statecraft.Game.Map
static void DestroyObject(UnityEngine.Object o) { if (Application.isPlaying) UnityEngine.Object.Destroy(o); else UnityEngine.Object.DestroyImmediate(o); }
- /// <summary>The texel of a hex: r + 256 g the region id, b the style, a 192 plus a bit per edge that borders another
- /// region, in <see cref="NeighbourSteps"/> order (StatecraftBorders.hlsl, ScRegionAt). Baked here so the terrain's
- /// shader reads one texel, not seven (issue #195). The default, every edge, is 255.</summary>
- public static Color32 Encode(int id, BorderStyle style, int borderEdges = 0x3F) =>
- new Color32((byte)(id & 0xFF), (byte)(id >> 8), (byte)style, (byte)(0xC0 | (borderEdges & 0x3F)));
+ /// <summary>The texel of a hex: r + 256 g the region id; b the style in its low two bits and, above them, a bit per
+ /// shared edge (one whose neighbour draws a band in the same style, so each side draws part of it: StatecraftBorders.hlsl, ScSharedBand); a 192 plus a bit per edge
+ /// that borders another region; edge bits in <see cref="NeighbourSteps"/> order (StatecraftBorders.hlsl, ScRegionAt).
+ /// Baked here so the terrain's shader reads one texel, not seven (issue #195). The default, every edge a border and
+ /// none shared, is a = 255.</summary>
+ public static Color32 Encode(int id, BorderStyle style, int borderEdges = 0x3F, int sharedEdges = 0) =>
+ new Color32((byte)(id & 0xFF), (byte)(id >> 8), (byte)((int)style | (sharedEdges & borderEdges & 0x3F) << 2),
+ (byte)(0xC0 | (borderEdges & 0x3F)));
/// <summary>Axial steps to a hex's six neighbours, in tools/hexgrid.py's NEIGHBOURS order: the order of
/// StatecraftBorders.hlsl's ScHexNormals, so bit i of the edge mask is the edge shared with neighbour i.</summary>
diff --git a/unity/Assets/Shaders/StatecraftBorders.hlsl b/unity/Assets/Shaders/StatecraftBorders.hlsl
index c0a28c56e..97dd914c6 100644
--- a/unity/Assets/Shaders/StatecraftBorders.hlsl
+++ b/unity/Assets/Shaders/StatecraftBorders.hlsl
@@ -6,8 +6,10 @@
// texel per hex (_ScRegionTex) and sets the globals; with no region data, or the "borders" toggle off, _ScBorders.w is 0 and
// nothing is drawn. Included at the end of StatecraftMap.hlsl; the terrain calls ScBorderApply last.
-TEXTURE2D(_ScRegionTex); // one texel per hex, linear RGBA8: r + 256 g the region id (0 = none), b the style (0 = none, 1, 2),
- // a's low six bits which edges border another region (MapBorders.Use bakes them; issue #195)
+TEXTURE2D(_ScRegionTex); // one texel per hex, linear RGBA8: r + 256 g the region id (0 = none), b's low two bits the style
+ // (0 = none, 1, 2) and its upper six which border edges the neighbour also draws in the same style (a
+ // shared edge: each side draws ScSharedBand of the band, so the two make one band centred on the edge), a's low
+ // six bits which edges border another region (MapBorders.Use bakes them; issue #195)
float4 _ScRegionInfo; // x q of texel column 0, y r of texel row 0, z width, w height (texels)
float4 _ScBorders; // x least band width (px), y widest band (+ wash) as a share of the hex's inradius,
// z 1 = no early-out (tests prove the early-out exact), w 1 = on
@@ -18,16 +20,21 @@ float4 _ScBorderColour2, _ScBorderLight2, _ScBorderShape2;
// The outward unit normals of a hex's edges (p space: x east, y south), in tools/hexgrid.py's NEIGHBOURS order (axial
// steps (1, 0), (1, -1), (0, -1), (-1, 0), (-1, 1), (0, 1): MapBorders.NeighbourSteps). Bit i of a hex's edge mask is edge i.
+// The share of its band each side of a shared edge draws. At exactly half, each half loses its partly covered outer pixel
+// and the pair measured 6 px at gameplay03 against a full band's 8 (promo 03: about 8); at 0.6 the two measure as one band.
+static const float ScSharedBand = 0.6;
+
static const float2 ScHexNormals[6] = { float2(1, 0), float2(0.5, -0.8660254), float2(-0.5, -0.8660254), float2(-1, 0),
float2(-0.5, 0.8660254), float2(0.5, 0.8660254) };
-// Region id, style and border-edge mask of axial hex (q, r); (0, 0, 0) off the texture.
-float3 ScRegionAt(float2 qr)
+// Region id, style, border-edge mask and shared-edge mask of axial hex (q, r); 0 off the texture.
+float4 ScRegionAt(float2 qr)
{
int2 t = int2(qr - _ScRegionInfo.xy);
- if (t.x < 0 || t.y < 0 || t.x >= (int)_ScRegionInfo.z || t.y >= (int)_ScRegionInfo.w) return float3(0.0, 0.0, 0.0);
+ if (t.x < 0 || t.y < 0 || t.x >= (int)_ScRegionInfo.z || t.y >= (int)_ScRegionInfo.w) return float4(0.0, 0.0, 0.0, 0.0);
float4 v = LOAD_TEXTURE2D(_ScRegionTex, t) * 255.0;
- return float3(round(v.r) + 256.0 * round(v.g), round(v.b), (float)((int)round(v.a) & 63));
+ int b = (int)round(v.b);
+ return float4(round(v.r) + 256.0 * round(v.g), (float)(b & 3), (float)((int)round(v.a) & 63), (float)((b >> 2) & 63));
}
// The axial hex containing p (cube rounding: ScHexEdgeDistance's layout, p.x east and p.y south of the north-west corner)
@@ -68,12 +75,14 @@ void ScBorderApply(float2 mapM, float water, inout float3 baseColor, inout float
float reach = max(max(_ScBorderShape1.x, _ScBorderShape2.x), 1.5 * _ScBorders.x * footprint) * washMul + 1.5 * footprint;
reach = _ScBorders.z > 0.5 ? 1e9 : reach;
float edge = inradius - max(abs(v.x), max(abs(0.5 * v.x + 0.8660254 * v.y), abs(0.5 * v.x - 0.8660254 * v.y)));
- float3 own = edge < reach && water < 1.0 ? ScRegionAt(qr) : float3(0.0, 0.0, 0.0);
- int edges = (int)own.z;
+ float4 own = edge < reach && water < 1.0 ? ScRegionAt(qr) : float4(0.0, 0.0, 0.0, 0.0);
+ int edges = (int)own.z, sharedEdges = (int)own.w;
// A hex with no border edge draws nothing (the loop below would leave cover 0), so it skips the work.
[branch] if (own.x > 0.5 && own.y > 0.5 && edges != 0)
{
- float bestPx = 1e9, bestAa = 1.0;
+ // bestPx: the distance (px) to the nearest band, measured in units of that edge's band (a shared edge draws
+ // ScSharedBand of it on each side), so where a shared and an unshared edge meet at a corner each keeps its own width.
+ float bestPx = 1e9, bestAa = 1.0, bestHalf = 1.0;
[unroll] for (int i = 0; i < 6; i++)
{
float2 n = ScHexNormals[i];
@@ -91,7 +100,8 @@ void ScBorderApply(float2 mapM, float water, inout float3 baseColor, inout float
float d = length(e);
float2 g = d > 1e-3 ? e / d : -n;
float aa = max(length(float2(dot(px, g), dot(py, g))), 1e-3);
- if (d / aa < bestPx) { bestPx = d / aa; bestAa = aa; }
+ float share = ((sharedEdges >> i) & 1) != 0 ? ScSharedBand : 1.0;
+ if (d / aa / share < bestPx / bestHalf) { bestPx = d / aa; bestAa = aa; bestHalf = share; }
}
}
bool primary = own.y < 1.5;
@@ -102,13 +112,18 @@ void ScBorderApply(float2 mapM, float water, inout float3 baseColor, inout float
// width, and the band plus its wash never wider than _ScBorders.y of the inradius (far zooms: a hex stays a hex).
float widest = _ScBorders.y * inradius / bestAa;
float bandPx = min(max(shape.x / bestAa, _ScBorders.x), widest / (1.0 + shape.z));
+ // Far off (a band under about 4 px: the overview), the light stripe would read as a white line, so it turns
+ // into the colour and the wash fades: a far band is a thin line of the region's colour.
+ float near = smoothstep(2.5, 4.5, bandPx);
+ // A shared edge: this side draws ScSharedBand of the band (and of the wash), the neighbour as much again.
+ bandPx *= bestHalf;
float washPx = bandPx * shape.z;
// Box-filtered stripes: the colour from the edge to shape.y of the band, the light stripe to its end.
float cColour = saturate(shape.y * bandPx - bestPx + 0.5);
float cBand = saturate(bandPx - bestPx + 0.5);
// max(): a style with no wash (shape.z 0) must not make smoothstep divide by zero (review M3).
- float wash = shape.w * (1.0 - smoothstep(bandPx, bandPx + max(washPx, 1e-3), bestPx)) * (1.0 - cBand);
- float3 stripe = lerp(light.rgb, colour.rgb, cBand > 0.0 ? cColour / cBand : 0.0);
+ float wash = near * shape.w * (1.0 - smoothstep(bandPx, bandPx + max(washPx, 1e-3), bestPx)) * (1.0 - cBand);
+ float3 stripe = lerp(lerp(colour.rgb, light.rgb, near), colour.rgb, cBand > 0.0 ? cColour / cBand : 0.0);
float cover = saturate(cBand + wash);
float3 c = cBand > 0.0 || wash > 0.0 ? (stripe * cBand + colour.rgb * wash) / max(cover, 1e-4) : colour.rgb;
float a = cover * (1.0 - water);
diff --git a/unity/Assets/Tests/EditMode/BorderEdgeTests.cs b/unity/Assets/Tests/EditMode/BorderEdgeTests.cs
index 90c120422..06d02efb8 100644
--- a/unity/Assets/Tests/EditMode/BorderEdgeTests.cs
+++ b/unity/Assets/Tests/EditMode/BorderEdgeTests.cs
@@ -21,23 +21,31 @@ public class BorderEdgeTests
{
EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);
var map = Object.FindFirstObjectByType<MapScene>(); map.Build();
- // A hex whose six neighbours are on the map: region 1 at the centre and at neighbours 0 and 3, region 2 at
- // neighbour 1, neighbour 2 in no region (no band against it), neighbours 4 and 5 in region 3 (style none: still
- // another region).
+ // A hex whose six neighbours are on the map: region 1 (primary) at the centre and at neighbours 0 and 3, region 2
+ // (secondary) at neighbour 1, neighbour 2 in no region (no band against it), region 4 (primary, like the centre: a
+ // shared edge, each side draws part of the band) at neighbour 4, region 3 (style none: still another region, as the
+ // "outside" beyond the Mandate frontier) at neighbour 5.
var steps = MapBorders.NeighbourSteps;
var onMap = new HashSet<(int q, int r)>(map.Hexes.hexes.Select(h => (h.q, h.r)));
var c = map.Hexes.hexes.First(h => steps.All(s => onMap.Contains((h.q + s.dq, h.r + s.dr))));
- int[] ids = { 1, 2, 0, 1, 3, 3 };
+ int[] ids = { 1, 2, 0, 1, 4, 3 };
var hexes = new Dictionary<(int q, int r), int> { [(c.q, c.r)] = 1 };
for (int i = 0; i < 6; i++) if (ids[i] > 0) hexes[(c.q + steps[i].dq, c.r + steps[i].dr)] = ids[i];
- var styles = new Dictionary<int, BorderStyle> { [1] = BorderStyle.Primary, [2] = BorderStyle.Secondary, [3] = BorderStyle.None };
+ var styles = new Dictionary<int, BorderStyle> { [1] = BorderStyle.Primary, [2] = BorderStyle.Secondary, [3] = BorderStyle.None, [4] = BorderStyle.Primary };
MapBorders.Use(new RegionLayer("edges", hexes, styles));
var tex = (Texture2D)Shader.GetGlobalTexture("_ScRegionTex");
var info = Shader.GetGlobalVector("_ScRegionInfo");
Color32 At(int q, int r) => tex.GetPixel(q - (int)info.x, r - (int)info.y);
var centre = At(c.q, c.r);
- Assert.AreEqual((1, 0, 1), ((int)centre.r, (int)centre.g, (int)centre.b), "region and style as before");
+ // b: the style (primary, 1) in the low two bits, and above them the shared edges: only edge 4, whose neighbour is
+ // primary too. Edge 1 (against secondary) and edge 5 (against style none, the frontier) keep the full band.
+ Assert.AreEqual((1, 0, 1 | 1 << 4 << 2), ((int)centre.r, (int)centre.g, (int)centre.b), "region, style and the shared edge 4");
Assert.AreEqual(0xC0 | 0b110010, (int)centre.a, "edges 1, 4 and 5 border another region; 0 and 3 are its own, 2 none");
+ var n4 = At(c.q + steps[4].dq, c.r + steps[4].dr);
+ Assert.AreEqual(1, n4.b & 3, "neighbour 4 is primary");
+ Assert.AreNotEqual(0, (n4.b >> 2) & 1 << 1, "neighbour 4 shares its edge 1 (the opposite of 4) with the centre");
+ Assert.AreEqual(2, (int)At(c.q + steps[1].dq, c.r + steps[1].dr).b, "the secondary neighbour shares no edge with the primary centre");
+ Assert.AreEqual(0, (int)At(c.q + steps[5].dq, c.r + steps[5].dr).b, "a region of style none draws nothing, so shares nothing");
Assert.AreEqual(0xC0 | 1 << 4 | 1 << 5, (int)At(c.q + steps[1].dq, c.r + steps[1].dr).a,
"neighbour 1 sees the centre across its edge 4 (the opposite of 1) and neighbour 0 across its edge 5");
MapBorders.Use(null);
diff --git a/unity/Assets/Tests/EditMode/BorderTests.cs b/unity/Assets/Tests/EditMode/BorderTests.cs
index d73a833c9..8e05db873 100644
--- a/unity/Assets/Tests/EditMode/BorderTests.cs
+++ b/unity/Assets/Tests/EditMode/BorderTests.cs
@@ -49,6 +49,9 @@ public class BorderTests
{
var c = MapBorders.Encode(300, BorderStyle.Secondary);
Assert.AreEqual((44, 1, 2, 255), ((int)c.r, (int)c.g, (int)c.b, (int)c.a));
+ // Shared edges ride above the style in b, and only border edges can be shared.
+ var shared = MapBorders.Encode(300, BorderStyle.Primary, 0b100011, 0b110001);
+ Assert.AreEqual((1 | 0b100001 << 2, 0xC0 | 0b100011), ((int)shared.b, (int)shared.a));
Assert.AreEqual(RegionLayer.MaxId, MapBorders.Encode(RegionLayer.MaxId, BorderStyle.None).r + 256 * MapBorders.Encode(RegionLayer.MaxId, BorderStyle.None).g);
}
@@ -377,6 +380,53 @@ public class BorderTests
Assert.Greater(pm, sm, "the primary band is the heavier");
}
+ /// <summary>The proof's checker blocks with every block in one region, styled by <paramref name="style"/> from its
+ /// checker parity (true: the proof's primary blocks): for the shared-edge test below.</summary>
+ static RegionLayer Blocks(MapScene map, System.Func<bool, BorderStyle> style)
+ {
+ var regions = new Dictionary<(int q, int r), int>(); var styles = new Dictionary<int, BorderStyle>();
+ foreach (var h in map.Hexes.hexes)
+ {
+ if (!h.land) continue;
+ var (bq, br) = BorderProof.Block(h.q, h.r);
+ int id = 1 + (bq + 64) + 128 * br;
+ regions[(h.q, h.r)] = id;
+ styles[id] = style(((bq + br) & 1) == 0);
+ }
+ return new RegionLayer("blocks (test)", regions, styles);
+ }
+
+ /// <summary>Promo 03 draws one blue band where a region meets another, never two side by side. Two primary regions
+ /// (two sub-districts) share their edge: each side draws part of the band, so the boundary is one band of the promo's
+ /// width, centred on the edge (about 8 px at gameplay03), not the double band (about 16 px) of two full bands. A
+ /// primary region against one of style none (the Mandate frontier against "outside") keeps its full band on its own
+ /// side, and nothing is drawn on the other. Measured at gameplay03's distance on the proof's coastal-plain edge.</summary>
+ [UnityTest]
+ public IEnumerator ASharedEdgeDrawsOneCentredBandAndTheFrontierKeepsTheFullBand()
+ {
+ var (map, cam, rig) = Open();
+ yield return null;
+ RenderSample.TiltShift(false);
+ BorderProof.Show(map);
+ var (inner, outer) = ProofEdge(map, PromoPose.Gameplay03.Lon, PromoPose.Gameplay03.Lat, "coastal_plain");
+ LookAtEdge(map, rig, inner);
+ float Total(List<Walk> walks, int sign) => Median(walks.Select(w => Read(w, sign, Blueness, 0.45f).WidthPx).ToList());
+
+ MapBorders.Use(Blocks(map, _ => BorderStyle.Primary));
+ var shared = WalkEdge(map, cam, inner, outer, 9, 1920, 1080);
+ float sIn = Total(shared, -1), sOut = Total(shared, +1);
+ MapBorders.Use(Blocks(map, primary => primary ? BorderStyle.Primary : BorderStyle.None));
+ var frontier = WalkEdge(map, cam, inner, outer, 9, 1920, 1080);
+ float fIn = Total(frontier, -1), fOut = Total(frontier, +1);
+ TestContext.WriteLine($"edge {inner}-{outer}: shared {sIn:0.0} + {sOut:0.0} = {sIn + sOut:0.0} px; frontier {fIn:0.0} + {fOut:0.0} px");
+ Assert.That(sIn + sOut, Is.InRange(6.5f, 11f), "a shared edge: one band of the promo's width (about 8 px), not two");
+ Assert.LessOrEqual(Mathf.Abs(sIn + sOut - fIn), 1.5f, "the shared band is as wide as one full band");
+ Assert.Greater(Mathf.Min(sIn, sOut), 2f, "the shared band lies on both sides of the edge");
+ Assert.LessOrEqual(Mathf.Abs(sIn - sOut), 2f, "the shared band is centred on the edge");
+ Assert.That(fIn, Is.InRange(6f, 11f), "the frontier keeps the full band on the region's side");
+ Assert.Less(fOut, 1f, "nothing is drawn beyond the frontier");
+ }
+
/// <summary>Review M6: the early-out (pixels beyond any band's reach fetch nothing) is exact: with it switched off
/// (_ScBorders.z) the proof renders pixel for pixel the same, at both promo poses.</summary>
[UnityTest]
@@ -487,6 +537,20 @@ public class BorderTests
float share = Changed(on, off, 0.06f);
TestContext.WriteLine($"diorama02: {share:P2} of pixels changed by the proof's outlines");
Assert.That(share, Is.InRange(0.01f, 0.15f));
+ // A far band is a thin line of its colour, not a white one (the light stripe turns into the colour under about
+ // 4 px): of the pixels the primary (blue) bands change, few are near-white, and on average they gain in blueness.
+ int changed = 0, white = 0; float gain = 0f;
+ for (int i = 0; i < on.Pixels.Length; i++)
+ {
+ Color a = on.Pixels[i], b = off.Pixels[i];
+ if (Mathf.Max(Mathf.Abs(a.r - b.r), Mathf.Max(Mathf.Abs(a.g - b.g), Mathf.Abs(a.b - b.b))) <= 0.06f || Blueness(a) <= Blueness(b)) continue;
+ changed++; gain += Blueness(a) - Blueness(b);
+ if (Mathf.Min(a.r, Mathf.Min(a.g, a.b)) > 0.80f) white++;
+ }
+ float whiteShare = white / (float)Mathf.Max(changed, 1), meanGain = gain / Mathf.Max(changed, 1);
+ TestContext.WriteLine($"diorama02: {changed} bluer pixels, {whiteShare:P1} near-white, mean blueness gain {meanGain:0.000}");
+ Assert.Less(whiteShare, FarWhiteShare, "far bands read as the region's colour, not white");
+ Assert.Greater(meanGain, FarBluenessGain, "far primary bands read blue");
}
/// <summary>The same layer and pose give the same pixels (no time, no randomness in the borders). The pattern is shown
@@ -513,5 +577,8 @@ public class BorderTests
finally { UnityEditor.ShaderUtil.allowAsyncCompilation = async; }
}
+ /// <summary>Bounds for the overview's colour (AtTheOverviewTheBandsAreThin), set from its log.</summary>
+ const float FarWhiteShare = 0.08f, FarBluenessGain = 0.30f;
+
static float Median(List<float> v) { var s = v.OrderBy(x => x).ToList(); return s[s.Count / 2]; }
}