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: land round 2, the promo's warm ground, readable fields and hill bushes, baked (refs #33) (#392)

Eyal Golane5bbf0fb85ef
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b6a5fcdcd..9bee821c2 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
+- 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
+ re-bake of `landuse.png` (same size and format) and a palette change, so the frame time and boot are unchanged.
- Inland lowlands are no longer labelled "Coastal plain" (refs #204). `tools/hexgrid.py` now measures the distance from
each hex centre to the shore and keeps `coastal_plain` for 0 to 200 m land within 25 km of it. Further inland the new
biome `lowland` ("Inland lowland") applies: 30 of the 109 coastal plain hexes change, among them the hex that holds
diff --git a/docs/visual-v1.md b/docs/visual-v1.md
index d916a9395..46b70ade7 100644
--- a/docs/visual-v1.md
+++ b/docs/visual-v1.md
@@ -1430,6 +1430,71 @@ Still different from the promo: soft at close zoom (rows, hedges and bushes read
and closer); terraces read faintly; the orchard ground and promo-art's groves follow separate rules; the promo's ground is warmer and browner under
its grade.
+### Land round 2 (branch `land-round2`, refs #33)
+Round 1's land read as yellow-olive. It also lost most of its field lines, because the bake's 2 x 2 supersampling averages
+an 18 m hedge or a 30 m track away inside a 79 x 105 m texel. Round 2 changes only the colours and the bake; the shader,
+the texture's size and format, the trees and the sea are untouched.
+- **Ground colour.** The land's colours in `tools/land_bake.py` (`SRGB`) and the plain, valley, lowland, hill and mountain
+ colours in `MapPalette.Ground` move toward promo 03's ground, (177, 144, 114) in the ground crop below: less green, more
+ blue, at its hue (28.6 degrees). The hill colours (soil, hillgrass, stone, and MapPalette's hills and mountains) are an
+ orange brown at 22-25 degrees, saturation 0.24-0.34. With round 2's first values (soil at 8 degrees and saturation 0.26;
+ stone, dust and fallow at about 18) the Judean hills read rose (review of #392): a red hue at low saturation. At 28.6
+ degrees they rendered at 34, yellower than promo 03's hills (26) and the video's (28), and diorama02 lost promo 02's
+ browns, about (208, 144, 112) and (176, 112, 80). The brightness (luma) of each colour is kept. The desert is unchanged.
+- **Fields.** Hedges and tree lines are `HEDGE_HALF_M` 75 m either side of a parcel edge. Farm tracks are `TRACK_HALF_M`
+ 70 m either side of a block edge. Each line is chosen once per edge, so the parcels on both sides draw it. The crops are
+ further apart in luma: a darker green, darker ploughland, paler stubble and fallow.
+ `test_field_lines_are_wide_enough_for_the_texture` holds both lines to at least 1.5 texels across. It fails at round 1's
+ widths, measuring 15 m and 28 m.
+- **Hills.** Round bushes about 200 m across, at most one per 300 m cell. A 1.5 km noise sets the share of cells with one
+ (20-80%), so they clump. Each sample takes its dot from the 2 x 2 cells round it, so no dot is cut. Each bush has a
+ softer shadow offset east-south-east, away from the sun (`MapLighting.SunAzimuth` 285 degrees). The garrigue's weight
+ rises from 0.7 to 0.9. Terraces cover more of the slopes, with stronger stone lines.
+- **Bake.** About 30 s. Two runs give byte-identical PNGs. `test_the_committed_texture_is_the_bake` passes. The land weight
+ mean is 0.192 (round 1: 0.171), because the garrigue's weight rose.
+
+Measured: WebGL `?shot` at main `4abb64f`, then the branch on it, art-log rows `lc-r2-main` and `land-round2-fix5`. The
+ground crop is gameplay03's land (x 0.36-0.88, y 0.30-0.82), pixels at luma >= 0.4. The towns' tan walls and their ground
+tint are in it and unchanged, so it moves less than the ground does. The Judean hills are `-extraPose
+judea30:35.10:31.85:30000:10` (editor, web tier): the median hue of their pixels at luma >= 0.25.
+
+| | main | round 2 | promo |
+|---|---|---|---|
+| gameplay03 saturation / contrast / warmth | 0.447 / 0.181 / 0.070 | 0.429 / 0.178 / 0.062 | 0.38 / 0.203 / 0.064 |
+| gameplay03 palette distance | 0.435 | **0.378** | - |
+| diorama02 saturation / contrast / warmth | 0.414 / 0.184 / 0.113 | 0.406 / 0.183 / 0.109 | 0.43 / 0.200 / 0.145 |
+| diorama02 palette distance | 0.5633 | 0.5643 | - |
+| gameplay03 ground crop (sRGB) | (166, 148, 99) | (169, 143, 106) | (177, 144, 114) |
+| judea30 hill hue (degrees) | 39.8 | 30.5 | 26 (promo 03), 28 (video 0:21) |
+
+The bars hold: diorama02 warmth 0.109 is inside [0.087, 0.145], and its saturation is under 0.48. diorama02's palette
+distance is 0.001 above main's; promo 02's browns (about (208, 144, 112)) are what the hills' hue trades against.
+Every ground channel is within 8 levels of the promo's (it was within 15).
+
+Frame time: headless, main and the branch back to back under one exclusive lock, 3 rounds, rotated. The load average was
+about 6 from other sessions, so the absolute times are inflated. The table gives medians over the rounds, in ms:
+
+| pose | `all` main / branch | `-land` | `none` |
+|---|---|---|---|
+| gameplay03 | 8.13 / 8.05 | 8.05 / 7.81 | 5.09 / 4.97 |
+| diorama02 | 19.49 / 19.71 | 19.08 / 19.45 | 12.36 / 12.72 |
+
+Every difference is within about 0.4 ms, which is also how far `none` moves between the two builds. The review fix (the hill hues) changes only colours: the same texture size and format, no shader, so these numbers and the boot below stand. The shader and the
+texture's size are the same. diorama02's p95 is 21-22 ms on main and on the branch alike, under that load.
+
+Boot: `headed.py boot --runs 3 --cpu 4`, 3 rounds interleaved, 9 cold loads each, medians:
+- `map_build_ms`: main 3032, branch 3039;
+- `first_frame_ms`: main 10842, branch 10819;
+- `biome texture baked` (MapPalette's colours): main 437, branch 431;
+- `downloaded 53 files`: main 1048, branch 1040.
+
+Both builds' map build is over #321's budget at this load; that is main's, not this change's.
+The goldens and the smoke run are unchanged: `GOLDEN OK 1950 71e9904d...`, `GOLDEN OK 1952 62f8ec61...` and
+`SMOKE OK 5 turns 1948-06-19 d3fdd459...`. The tree count is unchanged (7,814).
+
+Still different from the promo: the trees and bushes, so far only painted in the bake (promo 03's land is 27% dark trees
+and shadow; ours is 10%). The grade's shadows are cool, where the promo's are warm brown (#391).
+
## Open items for the art track
Each item below was ruled to the art track (controller, rank 10). None blocks landing the branch.
diff --git a/tools/land_bake.py b/tools/land_bake.py
index 11bdba814..559c7b2c9 100644
--- a/tools/land_bake.py
+++ b/tools/land_bake.py
@@ -55,12 +55,25 @@ SUPERSAMPLE = 2 # samples per texel per axis, box-filtered (the
BLOCK_M = 5200.0 # a farm block, one angle per block
STRIP_M = 1000.0 # strip width across the block (symbolic scale, like the kits)
TERRACE_STEP_M = 40.0 # real metres of rise per terrace
+# Land round 2: lines and dots at the symbolic scale, like the kits, so the texture can hold them (a texel is about
+# 79 x 105 m; round 1's 18 m hedges and 30 m tracks were averaged away by the supersampling).
+HEDGE_HALF_M = 75.0 # a hedge or tree line along a parcel edge: about 150 m, 1.5-2 texels
+TRACK_HALF_M = 70.0 # a farm track along a block edge: about 140 m
+BUSH_CELL_M, BUSH_R_M = 300.0, 100.0 # at most one bush per cell, about 2.5 texels across, with a baked shadow
+BUSH_SHADOW = (0.966, -0.259) # east-south-east: away from the sun (MapLighting.SunAzimuth 285 degrees)
VERTICAL_EXAGGERATION = tb.VERTICAL_EXAGGERATION
PALETTE_BRIGHTNESS, PALETTE_MAX = 1.107, 0.95 # MapPalette.Brightness and MaxChannel: the land sits in the biome palette
-SRGB = { # the land's colours (sRGB, before PALETTE_BRIGHTNESS), sampled from promo/final/03's ground and tuned on renders
- "green": (0.46, 0.50, 0.31), "ochre": (0.78, 0.66, 0.44), "plough": (0.58, 0.47, 0.34), "fallow": (0.72, 0.66, 0.51),
- "grass": (0.52, 0.54, 0.33), "orchard": (0.52, 0.47, 0.31), "hedge": (0.27, 0.30, 0.18), "dust": (0.84, 0.76, 0.61),
- "soil": (0.66, 0.57, 0.46), "hillgrass": (0.56, 0.55, 0.37), "stone": (0.74, 0.68, 0.56), "scrub": (0.34, 0.36, 0.22),
+SRGB = { # the land's colours (sRGB, before PALETTE_BRIGHTNESS), sampled from promo/final/03's ground and tuned on renders.
+ # Land round 2: warm sand and dry grass rather than yellow-olive, and a wider spread between the crops, so the parcels
+ # read at 30-60 km. The ground colours sit at promo 03's ground hue, about 28.6 degrees (its ground between the trees
+ # renders about (177, 144, 114)); review of #392: soil at 8 degrees and saturation 0.26, and stone, dust and fallow at
+ # about 18, read rose. The hill colours (soil, hillgrass, stone, and MapPalette's hills and mountains) are an orange
+ # brown at 22-25 degrees and saturation 0.24-0.34: rose is a red hue at low saturation, promo 03's hills and promo 02's
+ # browns (about (208, 144, 112) and (176, 112, 80)) are warmer and fuller; at 28.6 the Judean hills rendered at 34,
+ # yellower than promo 03's (26) and the video's (28), and diorama02 lost promo 02's browns.
+ "green": (0.42, 0.48, 0.28), "ochre": (0.802, 0.63, 0.483), "plough": (0.533, 0.416, 0.31), "fallow": (0.761, 0.651, 0.559),
+ "grass": (0.62, 0.525, 0.445), "orchard": (0.50, 0.42, 0.31), "hedge": (0.24, 0.23, 0.15), "dust": (0.858, 0.732, 0.626),
+ "soil": (0.689, 0.54, 0.455), "hillgrass": (0.653, 0.542, 0.463), "stone": (0.812, 0.689, 0.617), "scrub": (0.27, 0.25, 0.18),
}
@@ -185,13 +198,19 @@ def paint_samples(x: np.ndarray, y: np.ndarray, fields: np.ndarray, orchards: np
crop[grove] = col["orchard"]; gain[grove] = 0.12
rows = 0.6 * np.sin(lx * (2 * math.pi / 320.0)) # rows (symbolic: 320 m apart, about 3 texels)
crop *= ((1 + gain * rows) * (0.92 + 0.16 * pv))[..., None]
- rim = smoothstep(20.0, 90.0, edge_m)[..., None] # soft grassy rims (promo 03)
+ rim = smoothstep(30.0, 100.0, edge_m)[..., None] # soft grassy rims (promo 03)
farmed = col["grass"] * (1 - rim) + crop * rim
- hedge = ((edge_m < 18.0) & (pv > 0.45))[..., None]
- farmed = np.where(hedge, farmed * 0.3 + col["hedge"] * 0.7, farmed)
- block_edge_m = np.minimum(np.minimum(bfx, 1 - bfx), np.minimum(bfy, 1 - bfy)) * BLOCK_M
- edge_track = ((block_edge_m < 30.0) & (hash01(np.floor(bpx + 0.5), np.floor(bpy + 0.5), bix, biy, 7) > 0.65))[..., None]
- farmed = np.where(edge_track, col["dust"] * 0.85 + farmed * 0.15, farmed)
+ # Hedges and tree lines: chosen per edge (the hash of the edge itself), so both parcels draw the same line, HEDGE_HALF_M
+ # either side of it.
+ across_m = np.minimum(sx - ci, ci + 1 - sx) * STRIP_M
+ along_m = np.minimum(sy - pj, pj + 1 - sy) * len_m
+ hedge = (((across_m < HEDGE_HALF_M) & (hash01(np.floor(sx + 0.5), bix, biy, 9) > 0.45))
+ | ((along_m < HEDGE_HALF_M) & (hash01(ci, np.floor(sy + 0.5), bix, biy, 10) > 0.45)))[..., None]
+ farmed = np.where(hedge, farmed * 0.25 + col["hedge"] * 0.75, farmed)
+ # Farm tracks along some block edges, likewise one choice per edge.
+ track_x = (np.minimum(bfx, 1 - bfx) * BLOCK_M < TRACK_HALF_M) & (hash01(np.floor(bpx + 0.5), biy, 7) > 0.65)
+ track_y = (np.minimum(bfy, 1 - bfy) * BLOCK_M < TRACK_HALF_M) & (hash01(bix, np.floor(bpy + 0.5), 11) > 0.65)
+ farmed = np.where((track_x | track_y)[..., None], col["dust"] * 0.85 + farmed * 0.15, farmed)
farm_w = fields * smoothstep(0.08, 0.22, patch * 0.6 + fields * 0.5)
# The wet unfarmed hills: patches of stony soil and grass (garrigue), terraces on the slopes, scrub.
@@ -201,15 +220,34 @@ def paint_samples(x: np.ndarray, y: np.ndarray, fields: np.ndarray, orchards: np
tf = np.mod(elev / TERRACE_STEP_M, 1.0)
steps_per_texel = grad * TEXEL_M / TERRACE_STEP_M
terrace = (smoothstep(0.05, 0.10, slope) * (1 - smoothstep(0.45, 0.65, slope)) * smoothstep(120.0, 320.0, elev)
- * smoothstep(0.55, 0.70, 1 - patch) * (1 - smoothstep(0.35, 0.8, steps_per_texel)))[..., None]
- terraced = hill * (0.78 + 0.24 * tf)[..., None]
- terraced = np.where((tf > 0.75)[..., None], terraced * 0.65 + col["stone"] * 0.35, terraced)
+ * smoothstep(0.40, 0.55, 1 - patch) * (1 - smoothstep(0.35, 0.8, steps_per_texel)))[..., None]
+ terraced = hill * (0.72 + 0.32 * tf)[..., None]
+ terraced = np.where((tf > 0.75)[..., None], terraced * 0.45 + col["stone"] * 0.55, terraced)
hill = hill * (1 - terrace) + terraced * terrace
- scrub = (0.14 + 0.2 * smoothstep(0.55, 0.85, patch)) * (1 - smoothstep(0.5, 0.8, slope))
- speck = (hash01(np.floor(x / 160.0), np.floor(y / 160.0), 8) < 0.30) * (1 - smoothstep(0.5, 0.8, slope)) * 0.7 # bushes
- hill = hill * (1 - np.maximum(scrub, speck))[..., None] + col["scrub"] * np.maximum(scrub, speck)[..., None]
+ flat_enough = 1 - smoothstep(0.5, 0.8, slope)
+ scrub = (0.14 + 0.2 * smoothstep(0.55, 0.85, patch)) * flat_enough
+ hill = hill * (1 - scrub)[..., None] + col["scrub"] * scrub[..., None]
+ # Bushes: round dots BUSH_R_M across, at most one per BUSH_CELL_M cell anywhere in it, in clumps (a 1.5 km noise sets
+ # the share of cells with one), each with a softer shadow offset away from the sun. A sample takes the nearest dot of
+ # the 2 x 2 cells round it, so a dot or shadow near a cell's edge is never cut.
+ clumps = 0.2 + 0.6 * smoothstep(0.3, 0.75, value_noise(x / 1500.0, y / 1500.0, 14))
+ bush = np.zeros(x.shape); shade = np.zeros(x.shape)
+ gx0, gy0 = np.floor(x / BUSH_CELL_M - 0.5), np.floor(y / BUSH_CELL_M - 0.5)
+ for ox in (0, 1):
+ for oy in (0, 1):
+ cx, cy = gx0 + ox, gy0 + oy
+ bx = (cx + 0.1 + 0.8 * hash01(cx, cy, 12)) * BUSH_CELL_M
+ by = (cy + 0.1 + 0.8 * hash01(cx, cy, 13)) * BUSH_CELL_M
+ present = hash01(cx, cy, 8) < clumps
+ bush = np.maximum(bush, present * (1 - smoothstep(0.7 * BUSH_R_M, BUSH_R_M, np.hypot(x - bx, y - by))))
+ sx_, sy_ = bx + BUSH_SHADOW[0] * 0.45 * BUSH_R_M, by + BUSH_SHADOW[1] * 0.45 * BUSH_R_M
+ shade = np.maximum(shade, present * (1 - smoothstep(0.6 * BUSH_R_M, 0.9 * BUSH_R_M, np.hypot(x - sx_, y - sy_))))
+ bush *= flat_enough
+ shade *= flat_enough * (1 - bush)
+ hill = hill * (1 - 0.45 * shade)[..., None]
+ hill = hill * (1 - 0.9 * bush)[..., None] + col["scrub"] * (0.9 * bush)[..., None]
# Not on the steep faces, where the shader draws rock (ScGroundBase: smoothstep(0.22, 0.45, slope), review M5).
- wild_w = wild * smoothstep(80.0, 250.0, elev) * 0.7 * (1 - smoothstep(0.22, 0.45, slope))
+ wild_w = wild * smoothstep(80.0, 250.0, elev) * 0.9 * (1 - smoothstep(0.22, 0.45, slope))
w = farm_w + wild_w
colour = (farmed * farm_w[..., None] + hill * wild_w[..., None]) / np.maximum(w, 1e-6)[..., None]
diff --git a/tools/tests/test_land_bake.py b/tools/tests/test_land_bake.py
index 51b2aea08..9405893e8 100644
--- a/tools/tests/test_land_bake.py
+++ b/tools/tests/test_land_bake.py
@@ -26,6 +26,28 @@ def test_the_painted_land_is_weighted_by_the_masks_and_holds_every_crop():
assert near.mean() > share, name
[email protected]("name, size_m, step_m", [("HEDGE_HALF_M", (8000, 2000), 5.0), ("TRACK_HALF_M", (36000, 4000), 14.0)])
+def test_field_lines_are_wide_enough_for_the_texture(name, size_m, step_m, monkeypatch):
+ # Land round 2: round 1's 18 m hedges and 30 m tracks were averaged away in the texture's 79 x 105 m texel. A line's
+ # own samples are those that change when its half width is 0; runs of them along east-west rows cross the lines at
+ # their angles (and the blocks' wobble stretches them by up to about 20% either way), so the median run measures the
+ # line across: at least 1.5 texels of the texel's 79 m (east-west) side; across its 105 m north-south side that is about
+ # 1.2 texels, as only east-west rows are sampled. (Tracks lie only on some 5.2 km block edges, so they need the larger
+ # ground.)
+ x, y = np.meshgrid(np.arange(0, size_m[0], step_m), np.arange(0, size_m[1], step_m))
+ zero, one = np.zeros_like(x), np.ones_like(x)
+ with_lines, _ = lb.paint_samples(x, y, one, zero, zero, zero + 50.0, zero)
+ monkeypatch.setattr(lb, name, 0.0)
+ without, _ = lb.paint_samples(x, y, one, zero, zero, zero + 50.0, zero)
+ line = np.abs(with_lines - without).max(axis=-1) > 1e-6
+ runs = []
+ for row in line:
+ edges = np.flatnonzero(np.diff(np.concatenate([[0], row.astype(np.int8), [0]])))
+ runs += [(b - a) * step_m for a, b in zip(edges[::2], edges[1::2]) if a > 0 and b < row.size]
+ assert line.mean() > 0.002 and len(runs) > 100
+ assert np.median(runs) >= 1.5 * 79.0, f"{name}: lines {np.median(runs):.0f} m across, under 1.5 texels"
+
+
def test_empty_texels_take_the_neighbouring_land_colour():
rgb = np.zeros((8, 8, 3)); filled = np.zeros((8, 8), dtype=bool)
rgb[:, :2] = (0.5, 0.4, 0.2); filled[:, :2] = True
diff --git a/unity/Assets/Scripts/Map/MapPalette.cs b/unity/Assets/Scripts/Map/MapPalette.cs
index 054959823..9832a71bc 100644
--- a/unity/Assets/Scripts/Map/MapPalette.cs
+++ b/unity/Assets/Scripts/Map/MapPalette.cs
@@ -5,10 +5,13 @@ using UnityEngine;
namespace Statecraft.Game.Map
{
/// <summary>The ground colours the terrain shader paints per biome (sRGB; MapBuilder bakes them, blended between hexes,
- /// into the biome texture). Warmer and more saturated than MapBuilder.BiomeColours, which the minimap keeps: olive on
- /// the coastal plain and the valleys (merge fix round 1: both promos' plain measures V about 0.54, R-B about 0.22, where
- /// the earlier dry-grass gold rendered 0.73 and 0.37), olive-ochre hills, sand-amber desert (research notes §1, promo 03). "sea" and "lake" are
- /// only seen where a lake or sea hex's blend reaches the shore; the water itself is shaded from the coast texture.</summary>
+ /// into the biome texture). Warmer and more saturated than MapBuilder.BiomeColours, which the minimap keeps. Land round 2
+ /// (#392): promo 03's warm dry ground on the coastal plain, the valleys and the lowland, at about the promo ground's hue
+ /// (28.6 degrees); an orange brown on the hills and mountains (22 degrees, saturation about 0.3; review of #392: a
+ /// red hue at low saturation read rose); and
+ /// sand-amber desert (research notes §1). Merge fix round 1's plain brightness (both promos' plain V about 0.54) is kept.
+ /// "sea" and "lake" are only seen where a lake or sea hex's blend reaches the shore; the water itself is shaded from the
+ /// coast texture.</summary>
public static class MapPalette
{
/// <summary>Every ground colour is brightened by this factor in sRGB (about 1.25 in linear light) and clamped to
@@ -18,9 +21,9 @@ namespace Statecraft.Game.Map
public static IReadOnlyDictionary<string, Color> Ground { get; } = new Dictionary<string, Color>
{
["sea"] = Lit(0.62f, 0.60f, 0.42f), ["lake"] = Lit(0.60f, 0.58f, 0.42f),
- ["coastal_plain"] = Lit(0.52f, 0.54f, 0.33f), ["hills"] = Lit(0.66f, 0.58f, 0.38f),
- ["mountains"] = Lit(0.62f, 0.53f, 0.40f), ["valley"] = Lit(0.50f, 0.53f, 0.33f),
- ["lowland"] = Lit(0.51f, 0.535f, 0.33f), ["desert"] = Lit(0.84f, 0.70f, 0.48f),
+ ["coastal_plain"] = Lit(0.603f, 0.508f, 0.43f), ["hills"] = Lit(0.66f, 0.526f, 0.449f),
+ ["mountains"] = Lit(0.639f, 0.518f, 0.447f), ["valley"] = Lit(0.58f, 0.505f, 0.425f),
+ ["lowland"] = Lit(0.595f, 0.51f, 0.43f), ["desert"] = Lit(0.84f, 0.70f, 0.48f),
};
static Color Lit(float r, float g, float b) =>
diff --git a/unity/Assets/Textures/Map/landuse.png b/unity/Assets/Textures/Map/landuse.png
index 5af88ed3c..7cf6b5f3e 100644
Binary files a/unity/Assets/Textures/Map/landuse.png and b/unity/Assets/Textures/Map/landuse.png differ