A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Map: furrows on the worked fields, along the land bake's parcels (Refs #2917) (#3070)
Beni Keyserman5ff2b8482630
diff --git a/ASSETS.yaml b/ASSETS.yamlindex 5cde77c82..fa75d8d93 100644--- a/ASSETS.yaml+++ b/ASSETS.yaml@@ -1687,6 +1687,18 @@ rules:source: "tools/land_bake.py (issue #33): the land-use colour and weight (procedural field parcels with farm tracks, garrigue, terraces and scrub) placed by: slope and water from the Copernicus DEM-derived heightmap (Copernicus-DEM); rainfall from CHELSA V2.1 bio12 (CC0-1.0) bias-corrected by the IMS station normals of content/map/precip_stations.json (data.gov.il dataset 481, IMS-data.gov.il, decision D6); content/map/hexes.json biomes (this project's own content, CC-BY-SA-4.0); and the town coordinates of content/map/settlements_1948.yaml (Wikipedia API, CC-BY-SA-4.0) for the citrus belt. Procedural, not AI-generated; attribution in NOTICE"status: verifiednote: "Decision D13 decided (owner, 2026-10-14, docs/oss/DECISIONS.md): CC BY-SA 4.0, the most restrictive input (the 1948 settlement coordinates from Wikipedia); the DEM, CHELSA and IMS findings accepted as recorded."+ - glob: "unity/Assets/Textures/Map/furrows.png"+ licence: CC-BY-SA-4.0+ source: "tools/land_bake.py (issue #2917): how strongly the ground detail pass draws furrows, by the same procedural field parcels and the same inputs as landuse.png (its row above: the Copernicus DEM-derived heightmap, Copernicus-DEM; CHELSA V2.1 bio12, CC0-1.0, with the IMS station normals, decision D6; content/map/hexes.json; content/map/settlements_1948.yaml, Wikipedia API, CC-BY-SA-4.0). Procedural: no image model; attribution in NOTICE"+ ai_generated: true+ status: verified+ note: "Licensed as landuse.png under decision D13 (owner, 2026-10-14, docs/oss/DECISIONS.md): baked in the same pass from the same inputs. ai_generated is true because Claude Code wrote the code that bakes it (#2917); no generative image model made any pixel."+ - glob: "unity/Assets/Textures/Map/fieldblocks.png"+ licence: CC-BY-SA-4.0+ source: "tools/land_bake.py (issue #2917): each procedural farm block's angle and strip offset, from the bake's seeded hash and the heightmap's extent (unity/Assets/StreamingAssets/map/heightmap.json, Copernicus-DEM), so the ground detail pass lays furrows along landuse.png's parcels. No geography or facts in it. Procedural: no image model"+ ai_generated: true+ status: verified+ note: "Licensed as landuse.png under decision D13, as a by-product of the same bake. ai_generated is true because Claude Code wrote the code that bakes it (#2917); no generative image model made any pixel."- glob: "unity/Assets/Resources/Map/BiomeColours.bytes"licence: CC-BY-SA-4.0source: "The biome ground colours (issue #321, #529), baked by Editor BiomeColourBake from the biomes and centres of content/map/hexes.json, the heightmap's bounds (unity/Assets/StreamingAssets/map/heightmap.json) and this project's MapPalette.Ground colours. The biomes are derived by tools/hexgrid.py from the Copernicus DEM GLO-30-derived heightmap (Copernicus-DEM), CHELSA V2.1 bio12 rainfall (CC0-1.0) and the IMS station normals of content/map/precip_stations.json (data.gov.il dataset 481, decision D6); no new facts; attribution in NOTICE"diff --git a/changelog.d/2917.md b/changelog.d/2917.mdnew file mode 100644index 000000000..db7fd69a0--- /dev/null+++ b/changelog.d/2917.md@@ -0,0 +1,2 @@+- The worked fields between the towns show furrows at the gameplay zooms: fine lines along each parcel's own rows, strongest on+ ploughland, fainter on green crops and stubble, none on fallow, grass or groves, so they lie in the land bake's parcels (#2917).diff --git a/docs/ai-disclosure.md b/docs/ai-disclosure.mdindex 4c459f34d..707814fa7 100644--- a/docs/ai-disclosure.md+++ b/docs/ai-disclosure.md@@ -135,6 +135,8 @@ This is not a licence clearance or a completed store content survey. owner-verif| unity/Assets/Art/Settlements/Prototype/Models/generated-1948-03-netanya-flat-roof-porch-house/*_basecolor.jpg | ASSETS.yaml | Tal Heuberger, Tripo Studio generated source, regenerated 24 October 2026 (#1379). Provider-original GLB and exact embedded 4096px colour-map bytes preserved; provenance.json records hashes. FBX is a local compatibility conversion with no decimation, repair or atlas; verified source triangle positions/connectivity, UVs and stored normals. This is not a provider-original FBX. | verified || unity/Assets/Art/Settlements/Prototype/Models/generated-1948-04-dark-basalt-house/*_basecolor.jpg | ASSETS.yaml | Tal Heuberger, Tripo Studio generated source, 22 October 2026. Provider-original GLB and exact embedded 4096px colour-map bytes preserved; provenance.json records hashes. FBX is a local compatibility conversion with no decimation, repair or atlas; verified source triangle positions/connectivity, UVs and stored normals. This is not a provider-original FBX. | verified || unity/Assets/Art/Settlements/Prototype/Models/generated-1948-05-plastered-courtyard-house-original/*_basecolor.jpg | ASSETS.yaml | Tal Heuberger, Tripo Studio generated source, regenerated 24 October 2026 (#1379). Provider-original GLB and exact embedded 4096px colour-map bytes preserved; provenance.json records hashes. FBX is a local compatibility conversion with no decimation, repair or atlas; verified source triangle positions/connectivity, UVs and stored normals. This is not a provider-original FBX. | verified |+| unity/Assets/Textures/Map/fieldblocks.png | ASSETS.yaml | tools/land_bake.py (issue #2917): each procedural farm block's angle and strip offset, from the bake's seeded hash and the heightmap's extent (unity/Assets/StreamingAssets/map/heightmap.json, Copernicus-DEM), so the ground detail pass lays furrows along landuse.png's parcels. No geography or facts in it. Procedural: no image model | verified |+| unity/Assets/Textures/Map/furrows.png | ASSETS.yaml | tools/land_bake.py (issue #2917): how strongly the ground detail pass draws furrows, by the same procedural field parcels and the same inputs as landuse.png (its row above: the Copernicus DEM-derived heightmap, Copernicus-DEM; CHELSA V2.1 bio12, CC0-1.0, with the IMS station normals, decision D6; content/map/hexes.json; content/map/settlements_1948.yaml, Wikipedia API, CC-BY-SA-4.0). Procedural: no image model; attribution in NOTICE | verified || unity/Assets/UI/StartScreen/declaration-hall.jpg | ASSETS.yaml | ElevenLabs Image API (Pro plan, decision D5), model GPT Image 2.5 Sunburst (gpt-image-2.5-sunburst), 2K, quality high, 2026-10-12 (#268); the start screen's painting, native 2048x1152, saved as JPEG (quality 90), no upscale. Take 1: prompt promo/start-screen/prompt-d.txt, with the previous painting (this file as merged in #255: Dreamina option C, resized to 1920x1080) as the composition reference and promo/final/03-gameplay-1936.png as the style reference. Take 2 (used): prompt promo/start-screen/prompt-d-edit.txt, an edit of take 1 that changes only the row of figures at the table. The previous painting (Dreamina, #255) showed sunbeams through the windows | verified || unity/Assets/WebGLTemplates/Statecraft/favicon.ico | ASSETS.yaml | Original geometric drawing for the WebGL page's tab icon (issue #47): a gold hexagon with a cream serif I on navy, in the loading page's colours; 16, 32 and 48 px; made 2026-10-11 for PR #169 | verified |diff --git a/docs/visual-v1.md b/docs/visual-v1.mdindex f628940bd..b30a88adf 100644--- a/docs/visual-v1.md+++ b/docs/visual-v1.md@@ -3697,3 +3697,63 @@ is not expected to change its balance (hypothesis).**Tests that now switch the layers off.** `BorderTests.Open` and `TerrainShaderTests.TheBakesCarveTheRelief` measure barestripes and bakes, so they switch both new toggles off, as they do the kits and trees. Their thresholds are unchanged.++## Issue #2917: furrows on the worked fields++**What draws them.** `land_bake.py` lays its parcels on a wobbled 5.2 km block grid, each block turned by a hashed angle,+with 1,000 m strips along its rows. It now writes two more textures. `furrows.png` (1024 x 2048, R8) holds the furrows'+strength: 1.0 on ploughland, 0.6 on green crops, 0.35 on stubble, none on fallow, grass or groves, and none on the rims,+hedges and tracks. `fieldblocks.png` (34 x 85, RGBA8, read texel by texel) holds each block's angle and strip offset as+16 bits. The bake's angle comes from a 64-bit hash that a shader cannot repeat, but the wobble and the row coordinate can+be repeated exactly. So `GroundDetail.shader` recomputes them from the world position and reads only the block's two+values, and the furrows run along each parcel's own rows. They stop exactly at strip and block edges. Where one parcel+ends and the next begins along a strip, the shader has no edge to stop at (the bake places those ends with its hash); the+furrows fade there through `furrows.png`'s 158 x 211 m texels, so they can reach about one texel into a fallow neighbour.+`test_the_block_table_rebuilds_the_bakes_rows` checks the Python mirror of that formula against the bake at 200,000+points, to within 0.5 m. `test_the_shader_holds_the_bakes_constants` reads the shader's own copies (the block and strip+size, the angle range, the pad, the wobble's numbers and the table's 16-bit decoding) and fails if they leave the bake's.+As the scrub does, the furrows give way to the keep-out mask (`_ScDetailKeepOutTex`: the towns, the routes and the units'+clearings), so no lines show through a unit token's clearing or along a route corridor.++**Why in the ground detail pass.** As with #2878, the terrain function sits at the frame-time cliff of issue #391. The+furrows are a variant of `GroundDetail.shader` (`SC_FURROWS`) behind the `furrows` visual toggle, so the profile prices+them alone. `GroundDetailTests.BothShadersCompileForWebGL2` compiles that variant for GLES3 too.++**Low tier.** `GroundDetail` is not one of `QualityFallback`'s steps, so the furrows have no fallback: they were priced on+the desktop headless build only. If a mobile profile shows them costly, the `furrows` toggle is the hook a fallback step+would turn off.++**Symbolic size.** At gameplay03 a pixel covers 35 to 46 m of ground, so real furrows (under 1 m apart) cannot show. The+lines are 240 m apart, with a finer set at 80 m weighted 0.6, gain 0.30, and both fade out once a line is under about 4+pixels apart. Each is an odd wave around zero, so the ground keeps its brightness and colour; GradeTests' warmth margin+(0.266 against a bar of 0.265) is unchanged.++**Measured (EditMode, `GroundDetailTests.TheFurrowsLineTheFieldsAndKeepTheirColour`, on against off, kits and trees+off).** Mean gradient +3.2% on the coastal plain at 12 km, +3.2% at 31 km, +1.45% at gameplay03 (the frame is mostly towns,+trees and hills); brightness and saturation within 0.0003; no change on the unfarmed Judean hills or at diorama02. Before+the keep-out mask (the PR's first round) the same frames gave +4.6%, +4.7% and +2.3%: the difference is the furrows that+lay inside town discs, clearings and route corridors, most of which the kits cover in play.++**Frame time** (headless WebGL `?vprofile`, 1920x1080, DPR 1, `machine_lock.py --exclusive --wait-unity`). The full+round of 10 November 2026: gameplay03 `all` 22.46 ms, `-furrows` 23.04 ms, so furrows cost -0.58 ms (spreads 0.59 and+0.94 ms); diorama02 `all` 23.33 ms, `-furrows` 23.20 ms, +0.13 ms (spreads 0.20 and 0.80 ms). An earlier round on+8 November gave +0.62 ms at gameplay03 (load average 7.1, spread 1.53 ms) and stopped partway through diorama02 on a+`res=1920x880` line. So the cost is within the noise, at most about 0.6 ms, under the 2.5 ms budget.+With the keep-out sample added (review of #3070, 10 November 2026, a new build): gameplay03 `all` 23.20 ms, `-furrows`+23.28 ms, -0.08 ms (spreads 1.68 and 0.74 ms, load average about 5); diorama02 24.07 and 24.02 ms, +0.05 ms (spreads 0.94+and 0.76 ms). A round just before it, which started at load average 42, gave +0.64 ms at gameplay03 with spreads of 4.6 and+5.6 ms (noise) and +0.12 ms at diorama02 (spreads 0.13 and 0.10 ms).++**Boot** (`?bootlog`, `screens ready`, three headless boots each, alternated, exclusive window, 10 November 2026): 4997,+5033 and 5067 ms against 5069, 5054 and 5103 ms for the v0.3.9 release (gunzipped to load as this build does), medians+5033 and 5069 ms. v0.3.9 is this branch's base plus 16 commits, so it is a near neighbour, not an exact A/B.++**Size.** `furrows.png` adds 2.8 MB to the data file uncompressed (R8 with mips), about 0.33 MB gzipped; `fieldblocks.png`+adds 11.6 KB. The build's data, wasm and framework files gzip to about 42.7 MB, so the nightly's 2% tolerance (about 0.85+MB) covers it without a budget line.++**Colour** (`tools/art_compare.py`, HUD masked, editor renders at 1920x1080 with `furrows` off and on, 10 November 2026).+gameplay03 against promo 03: saturation 0.4350 both, contrast 0.1585 both, warmth 0.0945 and 0.0944, palette distance+0.3775 and 0.3773. diorama02: identical to four places (0.4249, 0.2237, 0.1680, 0.5220); sand and sea warmth pass their+bands. The web build after: gameplay03 0.4220, 0.1765, 0.0884, 0.3050; diorama02 0.4203, 0.2341, 0.1707, 0.4923. The+furrows add lines, not colour.diff --git a/tools/README.md b/tools/README.mdindex f04cc5dbf..d8572ba6a 100644--- a/tools/README.md+++ b/tools/README.md@@ -81,8 +81,10 @@ Offline data tools (uv inline-script Python). Run from the repo root.reproducible only on the same toolchain.- `land_bake.py` writes `unity/Assets/Textures/Map/landuse.png` (the land-use colour and weight: field parcels withfarm tracks, garrigue, terraces and scrub, placed by slope, rainfall and towns) from the heightmap, the CHELSA rainfall,- the hex biomes and the 1948 settlements (no network); `StatecraftLand.hlsl` lays it over the biome ground. Re-run it- whenever one of those inputs changes.+ the hex biomes and the 1948 settlements (no network); `StatecraftLand.hlsl` lays it over the biome ground. It also+ writes `furrows.png` (each texel's furrow strength) and `fieldblocks.png` (each farm block's angle and strip offset),+ from which `GroundDetail.shader` draws fine furrows along the same parcels (#2917). Re-run it whenever one of those+ inputs changes.- `terrain_graph.py` writes `unity/Assets/Shaders/StatecraftTerrain.shadergraph` from Unity's "Terrain Simple" templatewith one Custom Function node (`StatecraftTerrain.hlsl`); re-run it only when that function's inputs or outputs change.- `art_compare.py` puts screenshots next to the promo image of their pose, writes deuteranopia and protanopia copies anddiff --git a/tools/land_bake.py b/tools/land_bake.pyindex cb6efda20..ecfaf6e2c 100644--- a/tools/land_bake.py+++ b/tools/land_bake.py@@ -19,6 +19,10 @@ groves in the citrus belt) with soft rims and hedges, some block edges as farm tstony soil and grass, terraces along the real contours, scrub. Writes, row 0 = north:unity/Assets/Textures/Map/landuse.png RGBA8, COLOUR_W x COLOUR_H (about 79 x 105 m): rgb the land's colour (sRGB,spread into the empty texels), a its weight over the biome ground (2 x 2 samples per texel)+ unity/Assets/Textures/Map/furrows.png L8, FURROW_W x FURROW_H (about 158 x 211 m): how strongly GroundDetail.shader+ draws its fine furrows (#2917): by the parcel's crop, off rims, hedges, tracks and groves, times the fields' weight+ unity/Assets/Textures/Map/fieldblocks.png RGBA8, one texel per farm block: its angle and strip offset (block_table),+ so the shader lays the furrows along these parcels without the 64-bit hashThe geography is real (slope, rain, towns); the parcels are procedural. Deterministic: the same PNG on every run."""import jsonimport math@@ -38,6 +42,8 @@ ROOT = Path(__file__).resolve().parents[1]MAP_DIR = ROOT / "unity" / "Assets" / "StreamingAssets" / "map"CONTENT = ROOT / "content" / "map"OUT = ROOT / "unity" / "Assets" / "Textures" / "Map" / "landuse.png"+FURROWS_OUT = OUT.with_name("furrows.png")+BLOCKS_OUT = OUT.with_name("fieldblocks.png")WIDTH, HEIGHT = 1024, 2048SLOPE_SMOOTH_M = 300.0 # the slope that decides "flat" is averaged over about this radiusFLAT_SLOPE = (0.035, 0.075) # rise/run: fully arable below the first, none above the second@@ -63,6 +69,10 @@ HEDGE_HALF_M = 75.0 # a hedge or tree line along a parcel edge: aboTRACK_HALF_M = 70.0 # a farm track along a block edge: about 140 mBUSH_CELL_M, BUSH_R_M = 300.0, 100.0 # at most one bush per cell, about 2.5 texels across, with a baked shadowBUSH_SHADOW = (0.966, -0.259) # east-south-east: away from the sun (MapLighting.SunAzimuth 285 degrees)+# The furrows (#2917): GroundDetail.shader draws them, fine lines along the bake's own rows, from two textures written here.+FURROW_W, FURROW_H = 1024, 2048 # furrows.png: each texel the mean furrow strength of 2 x 2 colour texels (about 158 x 211 m)+BLOCK_PAD = 1 # fieldblocks.png: block columns and rows beyond the map's on each side, for the wobble+ANGLE_MIN, ANGLE_SPAN = -0.35, 0.7 + math.pi / 2 # block_angle's range, which fieldblocks.png's 16 bits spanVERTICAL_EXAGGERATION = tb.VERTICAL_EXAGGERATIONPALETTE_BRIGHTNESS, PALETTE_MAX = 1.107, 0.95 # MapPalette.Brightness and MaxChannel: the land sits in the biome paletteSRGB = { # the land's colours (sRGB, before PALETTE_BRIGHTNESS), sampled from promo/final/03's ground and tuned on renders.@@ -165,20 +175,27 @@ def value_noise(x: np.ndarray, y: np.ndarray, seed: int) -> np.ndarray:return (a + (b - a) * ux) * (1 - uy) + (c + (d - c) * ux) * uy-def paint_samples(x: np.ndarray, y: np.ndarray, fields: np.ndarray, orchards: np.ndarray, wet: np.ndarray,- elev: np.ndarray, grad: np.ndarray) -> tuple[np.ndarray, np.ndarray]:- """Linear colour (..., 3) and weight (...) of the land at map points (x m east, y m north; elev real metres, grad its- rise per metre). Weight 0 leaves the biome's own ground."""- col = {k: linear(v) for k, v in SRGB.items()}- patch = value_noise(x / 2600.0 + 3.1, y / 2600.0 + 3.1, 1) # one patch noise for every patchy choice- # Farm blocks: a wobbled grid, each block turned by up to +-20 degrees (a few by 90) about its own centre.+def block_wobble(x: np.ndarray, y: np.ndarray) -> tuple[np.ndarray, np.ndarray]:+ """Map points (x m east, y m north) in farm-block units: a wobbled grid, so the blocks are not a lattice. The furrows'+ shader repeats this (GroundDetail.shader, ScFieldRows), so change both together."""wx = 0.275 * np.sin(y / 4100.0 + np.sin(x / 6700.0))wy = 0.275 * np.sin(x / 3900.0 + np.sin(y / 5300.0))- bpx, bpy = x / BLOCK_M + wx, y / BLOCK_M + wy+ return x / BLOCK_M + wx, y / BLOCK_M + wy+++def block_angle(bh: np.ndarray) -> np.ndarray:+ """A block's turn about its own centre (radians) from its hash: up to +-20 degrees, a few by 90."""+ return (bh - 0.5) * 0.7 + np.where(bh > 0.8, math.pi / 2, 0.0)+++def field_layout(x: np.ndarray, y: np.ndarray) -> dict[str, np.ndarray]:+ """The field parcels at map points (x m east, y m north): the block, its local frame (lx across the strips, ly along+ them, metres from the block's centre), the strip and parcel indices and hashes, and the distances to their edges."""+ bpx, bpy = block_wobble(x, y)bix, biy = np.floor(bpx), np.floor(bpy)bfx, bfy = bpx - bix, bpy - biybh = hash01(bix, biy, 2)- ang = (bh - 0.5) * 0.7 + np.where(bh > 0.8, math.pi / 2, 0.0)+ ang = block_angle(bh)qx, qy = (bfx - 0.5) * BLOCK_M, (bfy - 0.5) * BLOCK_Mlx, ly = np.cos(ang) * qx - np.sin(ang) * qy, np.sin(ang) * qx + np.cos(ang) * qy# Strips across the block, each cut into parcels of its own length (1.1-2.6 km).@@ -188,24 +205,42 @@ def paint_samples(x: np.ndarray, y: np.ndarray, fields: np.ndarray, orchards: nplen_m = 1100.0 + 1500.0 * chsy = ly / len_m + ch * 5.0pj = np.floor(sy)- ph, pv, po = hash01(ci, pj, bix, biy, 4), hash01(ci, pj, bix, biy, 5), hash01(ci, pj, bix, biy, 6)- edge_m = np.minimum(np.minimum(sx - ci, ci + 1 - sx) * STRIP_M, np.minimum(sy - pj, pj + 1 - sy) * len_m)- # The crop: 0.30 green, 0.20 ochre, 0.17 ploughed, 0.13 fallow, 0.20 grass; in the citrus belt up to 55% groves.- kinds = [(0.30, "green", 0.20), (0.50, "ochre", 0.08), (0.67, "plough", 0.24), (0.80, "fallow", 0.0), (1.01, "grass", 0.0)]- crop = np.zeros(x.shape + (3,)); gain = np.zeros(x.shape); done = np.zeros(x.shape, dtype=bool)- for upto, name, g in kinds:+ across_m = np.minimum(sx - ci, ci + 1 - sx) * STRIP_M+ along_m = np.minimum(sy - pj, pj + 1 - sy) * len_m+ return {"bpx": bpx, "bpy": bpy, "bix": bix, "biy": biy, "bfx": bfx, "bfy": bfy, "lx": lx, "sx": sx, "ci": ci,+ "sy": sy, "pj": pj, "across_m": across_m, "along_m": along_m,+ "ph": hash01(ci, pj, bix, biy, 4), "pv": hash01(ci, pj, bix, biy, 5), "po": hash01(ci, pj, bix, biy, 6)}+++def paint_samples(x: np.ndarray, y: np.ndarray, fields: np.ndarray, orchards: np.ndarray, wet: np.ndarray,+ elev: np.ndarray, grad: np.ndarray, furrows: bool = False):+ """Linear colour (..., 3) and weight (...) of the land at map points (x m east, y m north; elev real metres, grad its+ rise per metre). Weight 0 leaves the biome's own ground. With furrows, also each point's furrow strength (...), 0..1:+ how strongly GroundDetail.shader draws the fine furrows there (furrows.png)."""+ col = {k: linear(v) for k, v in SRGB.items()}+ patch = value_noise(x / 2600.0 + 3.1, y / 2600.0 + 3.1, 1) # one patch noise for every patchy choice+ # Farm blocks: a wobbled grid, each block turned by up to +-20 degrees (a few by 90) about its own centre.+ f = field_layout(x, y)+ bpx, bpy, bix, biy, bfx, bfy = f["bpx"], f["bpy"], f["bix"], f["biy"], f["bfx"], f["bfy"]+ lx, sx, ci, sy, pj = f["lx"], f["sx"], f["ci"], f["sy"], f["pj"]+ ph, pv, po, across_m, along_m = f["ph"], f["pv"], f["po"], f["across_m"], f["along_m"]+ edge_m = np.minimum(across_m, along_m)+ # The crop: 0.30 green, 0.20 ochre, 0.17 ploughed, 0.13 fallow, 0.20 grass; in the citrus belt up to 55% groves. The+ # last number is the crop's furrow strength: ploughland's furrows the most, a green crop's rows, faint stubble.+ kinds = [(0.30, "green", 0.20, 0.6), (0.50, "ochre", 0.08, 0.35), (0.67, "plough", 0.24, 1.0), (0.80, "fallow", 0.0, 0.0),+ (1.01, "grass", 0.0, 0.0)]+ crop = np.zeros(x.shape + (3,)); gain = np.zeros(x.shape); furrow = np.zeros(x.shape); done = np.zeros(x.shape, dtype=bool)+ for upto, name, g, fg in kinds:m = ~done & (ph < upto)- crop[m] = col[name]; gain[m] = g; done |= m+ crop[m] = col[name]; gain[m] = g; furrow[m] = fg; done |= mgrove = po < orchards * 0.55- crop[grove] = col["orchard"]; gain[grove] = 0.12+ crop[grove] = col["orchard"]; gain[grove] = 0.12; furrow[grove] = 0.0 # the groves' rows are their treesrows = 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(30.0, 100.0, edge_m)[..., None] # soft grassy rims (promo 03)farmed = col["grass"] * (1 - rim) + crop * rim# 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_mhedge = (((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)@@ -213,6 +248,7 @@ def paint_samples(x: np.ndarray, y: np.ndarray, fields: np.ndarray, orchards: nptrack_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)+ furrow = furrow * rim[..., 0] * ~hedge[..., 0] * ~(track_x | track_y)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.@@ -253,17 +289,22 @@ def paint_samples(x: np.ndarray, y: np.ndarray, fields: np.ndarray, orchards: npw = farm_w + wild_wcolour = (farmed * farm_w[..., None] + hill * wild_w[..., None]) / np.maximum(w, 1e-6)[..., None]+ if furrows:+ return colour, np.clip(w, 0.0, 1.0), np.clip(furrow * farm_w, 0.0, 1.0)return colour, np.clip(w, 0.0, 1.0)-def paint_land(fields: np.ndarray, orchards: np.ndarray, wet: np.ndarray, elev: np.ndarray, meta: dict) -> np.ndarray:+def paint_land(fields: np.ndarray, orchards: np.ndarray, wet: np.ndarray, elev: np.ndarray,+ meta: dict) -> tuple[np.ndarray, np.ndarray]:"""RGBA8 COLOUR_W x COLOUR_H (row 0 = north): rgb the land's linear colour, a its weight, from SUPERSAMPLE^2 samples per- texel. The masks are WIDTH x HEIGHT, the elevation the heightmap's (row 0 = north)."""+ texel; and the furrow strength, L8 FURROW_W x FURROW_H (row 0 = north), the mean of its texel's samples. The masks are+ WIDTH x HEIGHT, the elevation the heightmap's (row 0 = north)."""width_m, length_m = meta["width_km"] * 1000, meta["length_km"] * 1000dx, dy = tb.spacing_m(meta)gy, gx = np.gradient(elev.astype(np.float64), dy, dx)grad = np.hypot(gx, gy)out = np.zeros((COLOUR_H, COLOUR_W, 4))+ furrow = np.zeros((COLOUR_H, COLOUR_W))ss = SUPERSAMPLEoffs = (np.arange(ss) + 0.5) / sschunk = 256@@ -276,15 +317,41 @@ def paint_land(fields: np.ndarray, orchards: np.ndarray, wet: np.ndarray, elev:y = length_m - FR / COLOUR_H * length_mmy, mx = FR / COLOUR_H * HEIGHT - 0.5, FC / COLOUR_W * WIDTH - 0.5hy, hx = FR / COLOUR_H * (meta["height"] - 1), FC / COLOUR_W * (meta["width"] - 1)- c, w = paint_samples(x, y, bilinear(fields, my, mx), bilinear(orchards, my, mx), bilinear(wet, my, mx),- bilinear(elev.astype(np.float64), hy, hx), bilinear(grad, hy, hx))+ c, w, fs = paint_samples(x, y, bilinear(fields, my, mx), bilinear(orchards, my, mx), bilinear(wet, my, mx),+ bilinear(elev.astype(np.float64), hy, hx), bilinear(grad, hy, hx), furrows=True)rgbw = np.concatenate([c * w[..., None], w[..., None]], axis=-1) # premultiplied, so the box filter weighs colourn = len(rows)rgbw = rgbw.reshape(n, ss, COLOUR_W, ss, 4).mean(axis=(1, 3))out[rows] = np.concatenate([rgbw[..., :3] / np.maximum(rgbw[..., 3:], 1e-6), rgbw[..., 3:]], axis=-1)+ furrow[rows] = fs.reshape(n, ss, COLOUR_W, ss).mean(axis=(1, 3))out[..., :3] = dilate_colour(out[..., :3], out[..., 3] > 0.5 / 255)out[..., :3] = encode_srgb(out[..., :3])- return tb.to_u8(out)+ k = COLOUR_W // FURROW_W+ furrow = furrow.reshape(FURROW_H, k, FURROW_W, k).mean(axis=(1, 3))+ return tb.to_u8(out), tb.to_u8(furrow)+++def block_table(meta: dict) -> np.ndarray:+ """RGBA8 BLOCKS_W x BLOCKS_H (row 0 = north): one texel per farm block, the block (bix, biy) at column bix + BLOCK_PAD,+ row BLOCKS_H - 1 - (biy + BLOCK_PAD), so every block the wobble reaches on the map has one. rg its angle and ba its+ strips' offset (frac(bh * 7), what places the strips across it), each 16 bits, high byte first: the angle as+ (ang - ANGLE_MIN) / ANGLE_SPAN. The hash is 64-bit, which a shader cannot repeat; with this table GroundDetail.shader+ rebuilds each point's place in its block and strip exactly (block_wobble) and lays the furrows along the bake's+ parcels."""+ bw, bh_ = blocks_size(meta)+ biy, bix = np.mgrid[0:bh_, 0:bw] - BLOCK_PAD+ bh = hash01(bix, biy, 2)+ ang16 = np.round((block_angle(bh) - ANGLE_MIN) / ANGLE_SPAN * 65535).astype(np.int64)+ off16 = np.round(np.mod(bh * 7.0, 1.0) * 65536).astype(np.int64) % 65536+ rgba = np.stack([ang16 >> 8, ang16 & 255, off16 >> 8, off16 & 255], axis=-1).astype(np.uint8)+ return rgba[::-1] # row 0 = north: biy rises northwards+++def blocks_size(meta: dict) -> tuple[int, int]:+ """The block table's columns and rows: every block index the wobbled grid reaches over the map (block_wobble moves a+ point by at most 0.275 blocks), with BLOCK_PAD more on each side."""+ return (math.ceil(meta["width_km"] * 1000 / BLOCK_M) + 2 * BLOCK_PAD,+ math.ceil(meta["length_km"] * 1000 / BLOCK_M) + 2 * BLOCK_PAD)def encode_srgb(c: np.ndarray) -> np.ndarray:@@ -317,7 +384,7 @@ def dilate_colour(rgb: np.ndarray, filled: np.ndarray, passes: int = DILATE_PASSreturn rgb-def bake() -> np.ndarray:+def bake() -> tuple[np.ndarray, np.ndarray, np.ndarray]:elev, meta = tb.load_heightmap(MAP_DIR)hexes = json.loads((CONTENT / "hexes.json").read_text())xk, yk = texel_km(meta)@@ -355,15 +422,19 @@ def bake() -> np.ndarray:for _ in range(LAND_INTO_WATER):land = tb.shrink(land)land = ~land- rgba = paint_land(fields * land, orchards * land, wet * land, elev, meta)- return rgba+ rgba, furrows = paint_land(fields * land, orchards * land, wet * land, elev, meta)+ return rgba, furrows, block_table(meta)def main() -> None:- rgba = bake()+ rgba, furrows, blocks = bake()OUT.parent.mkdir(parents=True, exist_ok=True)Image.fromarray(rgba, "RGBA").save(OUT)+ Image.fromarray(furrows, "L").save(FURROWS_OUT)+ Image.fromarray(blocks, "RGBA").save(BLOCKS_OUT)print(f"wrote {OUT} ({COLOUR_W} x {COLOUR_H}): land weight mean {rgba[..., 3].mean() / 255:.3f}")+ print(f"wrote {FURROWS_OUT} ({FURROW_W} x {FURROW_H}): furrow strength mean {furrows.mean() / 255:.3f}")+ print(f"wrote {BLOCKS_OUT} ({blocks.shape[1]} x {blocks.shape[0]} blocks)")if __name__ == "__main__":diff --git a/tools/tests/test_land_bake.py b/tools/tests/test_land_bake.pyindex 9405893e8..1db7dd407 100644--- a/tools/tests/test_land_bake.py+++ b/tools/tests/test_land_bake.py@@ -1,3 +1,7 @@+import math+import re+from pathlib import Path+import numpy as npimport pytestfrom PIL import Image@@ -63,14 +67,103 @@ def test_the_land_reaches_into_the_water_and_avoids_the_rock():assert w_flat.mean() > 0.5 and w_cliff.max() < 0.01+def test_furrows_follow_the_crop_and_keep_off_the_rims_hedges_and_groves():+ x, y = np.meshgrid(np.arange(0, 20000, 50.0), np.arange(0, 20000, 50.0))+ zero, one = np.zeros_like(x), np.ones_like(x)+ _, _, none = lb.paint_samples(x, y, zero, zero, zero, zero + 50.0, zero, furrows=True)+ assert none.max() == 0.0, "no fields, no furrows"+ _, _, fs = lb.paint_samples(x, y, one, zero, zero, zero + 50.0, zero, furrows=True)+ f = lb.field_layout(x, y)+ inner = np.minimum(f["across_m"], f["along_m"]) > 150.0+ plough, fallow = (f["ph"] >= 0.50) & (f["ph"] < 0.67), f["ph"] >= 0.67+ assert np.median(fs[plough & inner]) > 0.9, "ploughland furrows fully inside the parcel"+ assert fs[fallow].max() == 0.0, "fallow and grass have none"+ assert fs[np.minimum(f["across_m"], f["along_m"]) < 30.0].max() == 0.0, "none on the parcels' rims"+ _, _, groves = lb.paint_samples(x, y, one, one, zero, zero + 50.0, zero, furrows=True)+ assert groves.mean() < 0.6 * fs.mean(), "the citrus belt's groves have none"+++def rows_from_table(x, y, table):+ """What GroundDetail.shader does with fieldblocks.png (ScFieldRows): the point's block from the wobbled grid, that+ block's angle and strip offset from its texel, then its across-the-strips coordinate lx and its strip phase."""+ bpx, bpy = lb.block_wobble(x, y)+ bix, biy = np.floor(bpx).astype(int), np.floor(bpy).astype(int)+ t = table[table.shape[0] - 1 - (biy + lb.BLOCK_PAD), bix + lb.BLOCK_PAD].astype(np.int64)+ ang = lb.ANGLE_MIN + (t[..., 0] * 256 + t[..., 1]) / 65535 * lb.ANGLE_SPAN+ off = (t[..., 2] * 256 + t[..., 3]) / 65536+ qx, qy = (bpx - bix - 0.5) * lb.BLOCK_M, (bpy - biy - 0.5) * lb.BLOCK_M+ lx = np.cos(ang) * qx - np.sin(ang) * qy+ return lx, np.mod(lx / lb.STRIP_M + off, 1.0)+++def test_the_block_table_rebuilds_the_bakes_rows():+ # #2917: the shader cannot repeat the 64-bit hash, so it reads each block's angle and strip offset from the table. With+ # them it must put every point where the bake does: the same distance across the strips (to well under a furrow) and+ # the same place in its strip, everywhere on the map, the wobbled edges included.+ meta = {"width_km": 161.53, "length_km": 431.22}+ table = lb.block_table(meta)+ assert table.shape == lb.blocks_size(meta)[::-1] + (4,)+ rng = np.random.default_rng(2917)+ x, y = rng.uniform(0, meta["width_km"] * 1000, 200000), rng.uniform(0, meta["length_km"] * 1000, 200000)+ lx, phase = rows_from_table(x, y, table)+ f = lb.field_layout(x, y)+ assert np.abs(lx - f["lx"]).max() < 0.5+ d = np.abs(phase - np.mod(f["sx"], 1.0))+ assert np.minimum(d, 1 - d).max() * lb.STRIP_M < 0.5+++SHADER = Path(__file__).resolve().parents[2] / "unity/Assets/Shaders/GroundDetail.shader"+NUMBER = r"(-?[\d.]+)"+++def test_the_shader_holds_the_bakes_constants():+ # #2917: GroundDetail.shader keeps its own copies of the farm blocks' constants and of block_wobble's formula (ScFieldRows),+ # and of the table's 16-bit encodings. If one side changes alone, the furrows leave the bake's parcels; this fails instead.+ src = SHADER.read_text()+ consts = re.search(rf"static const float ScBlockM = {NUMBER}, ScStripM = {NUMBER}, ScAngleMin = {NUMBER}, "+ rf"ScAngleSpan = {NUMBER} \+ {NUMBER};", src)+ assert consts, "ScFieldRows' constants line changed shape: update this test with it"+ block_m, strip_m, angle_min, span_a, span_b = map(float, consts.groups())+ assert (block_m, strip_m, angle_min) == (lb.BLOCK_M, lb.STRIP_M, lb.ANGLE_MIN)+ assert span_a + span_b == pytest.approx(lb.ANGLE_SPAN, abs=1e-6)+ assert lb.ANGLE_SPAN == 0.7 + math.pi / 2 # block_angle's range: 0.7 wide, a quarter turn on top+ pad = re.search(r"static const int ScBlockPad = (\d+);", src)+ assert pad and int(pad.group(1)) == lb.BLOCK_PAD+ wobble = re.search(rf"float2 bp = p / ScBlockM \+ {NUMBER} \* float2\(sin\(p\.y / {NUMBER} \+ sin\(p\.x / {NUMBER}\)\), "+ rf"sin\(p\.x / {NUMBER} \+ sin\(p\.y / {NUMBER}\)\)\);", src)+ assert wobble, "ScFieldRows' wobble line changed shape: update this test with it"+ a, py1, px1, px2, py2 = map(float, wobble.groups())+ rng = np.random.default_rng(2917)+ x, y = rng.uniform(0, 161530, 10000), rng.uniform(0, 431220, 10000)+ bpx, bpy = lb.block_wobble(x, y)+ assert np.abs(bpx - (x / block_m + a * np.sin(y / py1 + np.sin(x / px1)))).max() < 1e-9+ assert np.abs(bpy - (y / block_m + a * np.sin(x / px2 + np.sin(y / py2)))).max() < 1e-9+ # block_table's encodings, as the shader decodes them: the angle over 65535, the strip offset over 65536.+ assert "(b.r * 256.0 + b.g) / 65535.0 * ScAngleSpan" in src and "(b.b * 256.0 + b.a) / 65536.0" in src++@pytest.fixture(scope="module")def baked():return lb.bake()def test_the_committed_texture_is_the_bake(baked):- # Review M11: the committed PNG must be what tools/land_bake.py makes from today's inputs (about 20 s).- assert np.array_equal(np.asarray(Image.open(lb.OUT)), baked), "landuse.png is stale: run uv run tools/land_bake.py"+ # Review M11: the committed PNGs must be what tools/land_bake.py makes from today's inputs (about 30 s).+ land, furrows, blocks = baked+ assert np.array_equal(np.asarray(Image.open(lb.OUT)), land), "landuse.png is stale: run uv run tools/land_bake.py"+ assert np.array_equal(np.asarray(Image.open(lb.FURROWS_OUT)), furrows), "furrows.png is stale: run uv run tools/land_bake.py"+ assert np.array_equal(np.asarray(Image.open(lb.BLOCKS_OUT)), blocks), "fieldblocks.png is stale: run uv run tools/land_bake.py"+++def test_the_furrows_lie_on_the_farmed_plains():+ furrows = np.asarray(Image.open(lb.FURROWS_OUT))+ assert furrows.shape == (lb.FURROW_H, lb.FURROW_W)++ def strength(lon, lat):+ r, c = int((33.35 - lat) / 3.9 * furrows.shape[0]), int((lon - 34.2) / 1.7 * furrows.shape[1])+ return furrows[r - 6:r + 7, c - 6:c + 7].mean() / 255+ assert strength(34.84, 31.92) > 0.1 and strength(35.30, 32.62) > 0.1 # the coastal plain and the Jezreel valley+ assert strength(34.90, 30.60) == 0 and strength(35.50, 31.50) == 0 # the central Negev and the Dead Seadef test_the_committed_texture_has_its_size_and_follows_the_ground():diff --git a/unity/Assets/Editor/MapMaterials.cs b/unity/Assets/Editor/MapMaterials.csindex 0cd182a27..d430f1a9c 100644--- a/unity/Assets/Editor/MapMaterials.cs+++ b/unity/Assets/Editor/MapMaterials.cs@@ -28,6 +28,13 @@ namespace Statecraft.Game.EditorToolsterrain.SetTexture("_ScCoastTex", Tex(Statecraft.Game.Map.MapTexturePaths.Coast));terrain.SetTexture("_ScAoTex", Tex(Statecraft.Game.Map.MapTexturePaths.Ao));terrain.SetTexture("_ScLandTex", Tex(Statecraft.Game.Map.MapTexturePaths.Land)); // land use (tools/land_bake.py)+ // The ground detail pass's furrows (#2917): its material is in Resources, GroundDetail.Build copies it.+ var detailPath = "Assets/Resources/" + Statecraft.Game.Map.GroundDetail.MaterialResource + ".mat";+ var detail = AssetDatabase.LoadAssetAtPath<Material>(detailPath)+ ?? throw new System.IO.FileNotFoundException("ground detail material missing (GroundDetail.MaterialResource)", detailPath);+ detail.SetTexture("_FurrowTex", Tex(Statecraft.Game.Map.MapTexturePaths.Furrows));+ detail.SetTexture("_FieldBlockTex", Tex(Statecraft.Game.Map.MapTexturePaths.FieldBlocks));+ EditorUtility.SetDirty(detail);// Before the water drawn on it (issue #195: MapScene.TerrainWaterQueue), which precedes the other opaques.terrain.renderQueue = Statecraft.Game.Map.MapScene.TerrainWaterQueue - 1;EditorUtility.SetDirty(terrain);diff --git a/unity/Assets/Editor/MapTextures.cs b/unity/Assets/Editor/MapTextures.csindex bd24777f7..dcab075e1 100644--- a/unity/Assets/Editor/MapTextures.cs+++ b/unity/Assets/Editor/MapTextures.cs@@ -17,6 +17,16 @@ namespace Statecraft.Game.EditorToolsSet(MapTexturePaths.Coast, singleChannel: true);Set(MapTexturePaths.Ao, singleChannel: true);Set(MapTexturePaths.Land, singleChannel: false); // the land's colour and weight, block-compressed+ Set(MapTexturePaths.Furrows, singleChannel: true); // the furrows' strength (#2917), R8 as the coast and the AO+ // The farm blocks (#2917): GroundDetail.shader reads them texel by texel and decodes 16 bits from two bytes, so+ // every byte must arrive as written: no compression, filtering, mips or power-of-two resize, and linear.+ var blocks = AssetImporter.GetAtPath(MapTexturePaths.FieldBlocks) as TextureImporter+ ?? throw new System.IO.FileNotFoundException("run tools/land_bake.py", MapTexturePaths.FieldBlocks);+ blocks.textureType = TextureImporterType.Default; blocks.sRGBTexture = false; blocks.mipmapEnabled = false;+ blocks.isReadable = false; blocks.npotScale = TextureImporterNPOTScale.None; blocks.wrapMode = TextureWrapMode.Clamp;+ blocks.filterMode = FilterMode.Point; blocks.textureCompression = TextureImporterCompression.Uncompressed;+ blocks.alphaSource = TextureImporterAlphaSource.FromInput;+ blocks.SaveAndReimport();// The land: sRGB colour (the sampler decodes it; alpha, the weight, stays linear), 4096 rows on every platform// (the platforms' own 2048 caps would halve it: hedges and rims blur, -21% local detail at gameplay03), and an// automatic compressed format, so the WebGL build's texture subtarget picks it: DXT5 for the desktop build,diff --git a/unity/Assets/Resources/Map/GroundDetail.mat b/unity/Assets/Resources/Map/GroundDetail.matindex 1e473926d..afb8454e1 100644--- a/unity/Assets/Resources/Map/GroundDetail.mat+++ b/unity/Assets/Resources/Map/GroundDetail.mat@@ -22,7 +22,15 @@ Material:m_LockedProperties:m_SavedProperties:serializedVersion: 3- m_TexEnvs: []+ m_TexEnvs:+ - _FieldBlockTex:+ m_Texture: {fileID: 2800000, guid: a2cf406254fb41fa80b439a61f954d43, type: 3}+ m_Scale: {x: 1, y: 1}+ m_Offset: {x: 0, y: 0}+ - _FurrowTex:+ m_Texture: {fileID: 2800000, guid: e1c531cbe2e3467b8a5033b76e4705a7, type: 3}+ m_Scale: {x: 1, y: 1}+ m_Offset: {x: 0, y: 0}m_Ints: []m_Floats: []m_Colors: []diff --git a/unity/Assets/Scripts/Map/GroundDetail.cs b/unity/Assets/Scripts/Map/GroundDetail.csindex 720241dc7..35bb8330c 100644--- a/unity/Assets/Scripts/Map/GroundDetail.cs+++ b/unity/Assets/Scripts/Map/GroundDetail.cs@@ -16,7 +16,9 @@ namespace Statecraft.Game.Mappublic sealed class GroundDetail : MonoBehaviour{public const string Name = "GroundDetail", MaterialResource = "Map/GroundDetail", ScrubMaterialResource = "Map/GroundScrub",- Toggle = "grounddetail", ScrubToggle = "groundscrub";+ Toggle = "grounddetail", ScrubToggle = "groundscrub", FurrowToggle = "furrows";+ /// <summary>The pass's furrows (#2917, GroundDetail.shader): a shader variant, so the "furrows" toggle prices them.</summary>+ public const string FurrowKeyword = "SC_FURROWS";/// <summary>The queue right after the terrain (Terrain.mat 1998), over its lit colour and under everything else.</summary>public const int Queue = (int)RenderQueue.Geometry - 1;public const int TextureSize = 1024;@@ -79,6 +81,7 @@ namespace Statecraft.Game.Mapvar template = Resources.Load<Material>(MaterialResource); var scrubTemplate = Resources.Load<Material>(ScrubMaterialResource);if (template == null || scrubTemplate == null) { Debug.LogWarning($"{MaterialResource} or {ScrubMaterialResource} is missing: no ground detail"); return null; }var material = assets.Own(new Material(template) { name = Name, renderQueue = Queue });+ material.EnableKeyword(FurrowKeyword);var size = terrain.terrainData.size; var o = terrain.transform.position;Shader.SetGlobalTexture(DetailId, assets.Own(BuildTexture()));var classes = FillClasses(frame, hexes, out int nx, out int nz);@@ -107,6 +110,7 @@ namespace Statecraft.Game.Maplayer.mapRect = new Rect(o.x, o.z, size.x, size.z); layer.reliefM = size.y; layer.baseY = o.y;assets.OnTeardown(VisualToggles.Register(Toggle, set => layer.on = set));assets.OnTeardown(VisualToggles.Register(ScrubToggle, set => layer.scrubOn = set));+ assets.OnTeardown(VisualToggles.Register(FurrowToggle, set => { if (set) material.EnableKeyword(FurrowKeyword); else material.DisableKeyword(FurrowKeyword); }));return layer;}diff --git a/unity/Assets/Scripts/Map/MapShaderGlobals.cs b/unity/Assets/Scripts/Map/MapShaderGlobals.csindex 970e4e0d2..626171c64 100644--- a/unity/Assets/Scripts/Map/MapShaderGlobals.cs+++ b/unity/Assets/Scripts/Map/MapShaderGlobals.cs@@ -101,6 +101,11 @@ namespace Statecraft.Game.Mappublic const string Ao = "Assets/Textures/Map/ao.png";/// <summary>The land (tools/land_bake.py, issue #33): rgb its linear colour, a its weight over the biome ground.</summary>public const string Land = "Assets/Textures/Map/landuse.png";+ /// <summary>The furrows' strength (tools/land_bake.py, #2917): one uncompressed 8-bit channel, 1024 x 2048.</summary>+ public const string Furrows = "Assets/Textures/Map/furrows.png";+ /// <summary>One texel per farm block (tools/land_bake.py block_table, #2917): its angle and strip offset, 16 bits each,+ /// read texel by texel, so uncompressed, unfiltered, no mips and never resized to a power of two.</summary>+ public const string FieldBlocks = "Assets/Textures/Map/fieldblocks.png";/// <summary>The terrain water's mesh as heightmap samples (MapBuilder.WaterMeshBytes; Editor TerrainWaterBake), so a/// player does not derive it at boot (issue #195).</summary>public const string WaterMesh = "Assets/Textures/Map/terrain_water.bytes";diff --git a/unity/Assets/Shaders/GroundDetail.shader b/unity/Assets/Shaders/GroundDetail.shaderindex 7d28744ef..c43d3ad0e 100644--- a/unity/Assets/Shaders/GroundDetail.shader+++ b/unity/Assets/Shaders/GroundDetail.shader@@ -6,6 +6,9 @@// (GroundDetail.BuildTexture): r soil grain, g bushes as a height field (a lower threshold shows more of them), b their// shadows, a pale stones. Blend DstColor SrcColor doubles the source, so 0.5 leaves the ground as it is, and every term// fades to 0.5 by the pixel's footprint, before a tile could show or a dot could shimmer.+// Furrows (#2917, SC_FURROWS, the "furrows" toggle): fine lines along the land bake's own rows, so they lie in its parcels.+// The bake's parcels hang off a 64-bit hash no shader can repeat, so tools/land_bake.py writes each farm block's angle and+// strip offset (fieldblocks.png) and each texel's furrow strength (furrows.png); ScFieldRows rebuilds the rest exactly.Shader "Statecraft/GroundDetail"{Properties@@ -15,6 +18,10 @@ Shader "Statecraft/GroundDetail"_BushDark ("A bush's dark parts, times the ground", Color) = (0.56, 0.58, 0.47, 1)_ShadowDark ("Bush shadow, times the ground", Range(0, 1)) = 0.84_StoneGain ("Stones, brighter than the ground", Range(0, 1)) = 0.11+ _FurrowGain ("Furrows, darker and lighter than the ground", Range(0, 1)) = 0.30+ _FurrowM ("Furrow spacing (m)", Float) = 240+ _FurrowTex ("Furrow strength (land_bake.py)", 2D) = "black" {}+ _FieldBlockTex ("Farm blocks: angle, strip offset (land_bake.py)", 2D) = "black" {}}SubShader{@@ -30,13 +37,50 @@ Shader "Statecraft/GroundDetail"HLSLPROGRAM#pragma vertex Vert#pragma fragment Frag+ #pragma multi_compile_local_fragment _ SC_FURROWS // both variants ship: the toggle prices the furrows, not a zero gain#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"#include "Assets/Shaders/StatecraftMap.hlsl" // the map's globals, ScHexAxial and ScRegionAt; only what is called is compiled#include "Assets/Shaders/StatecraftGroundDetail.hlsl"CBUFFER_START(UnityPerMaterial)- float _GrainGain, _ShadowDark, _StoneGain;+ float _GrainGain, _ShadowDark, _StoneGain, _FurrowGain, _FurrowM;half4 _BushLight, _BushDark;+ float4 _FurrowTex_ST, _FieldBlockTex_ST, _FieldBlockTex_TexelSize;CBUFFER_END+ TEXTURE2D(_FurrowTex); SAMPLER(sampler_FurrowTex);+ TEXTURE2D(_FieldBlockTex);++ // tools/land_bake.py's farm blocks: BLOCK_M, STRIP_M, BLOCK_PAD and block_angle's range (ANGLE_MIN, ANGLE_SPAN).+ static const float ScBlockM = 5200.0, ScStripM = 1000.0, ScAngleMin = -0.35, ScAngleSpan = 0.7 + 1.5707963;+ static const int ScBlockPad = 1;+ // How far in from a strip's or a block's edge (m) the furrows start and are full: past the bake's grassy rims,+ // hedges and farm tracks (smoothstep(30, 100) and 70-75 m either side of an edge).+ static const float2 ScFurrowOffEdge = float2(90.0, 150.0);++ // A map point's place in the bake's parcels (land_bake.py field_layout): x its distance across the strips from+ // its block's centre (m: the bake's lx, along which its rows repeat), y its distance to the nearest strip or+ // block edge (m). The wobble is land_bake.py's block_wobble; the block's angle and strip offset are its texel.+ float2 ScFieldRows(float2 p)+ {+ float2 bp = p / ScBlockM + 0.275 * float2(sin(p.y / 4100.0 + sin(p.x / 6700.0)), sin(p.x / 3900.0 + sin(p.y / 5300.0)));+ float2 bi = floor(bp), bf = bp - bi;+ int2 texel = clamp(int2(bi) + ScBlockPad, int2(0, 0), int2(_FieldBlockTex_TexelSize.zw) - 1);+ float4 b = round(255.0 * LOAD_TEXTURE2D(_FieldBlockTex, texel));+ float ang = ScAngleMin + (b.r * 256.0 + b.g) / 65535.0 * ScAngleSpan;+ float2 q = (bf - 0.5) * ScBlockM;+ float lx = cos(ang) * q.x - sin(ang) * q.y;+ float s = frac(lx / ScStripM + (b.b * 256.0 + b.a) / 65536.0);+ float2 e = min(bf, 1.0 - bf);+ return float2(lx, min(min(s, 1.0 - s) * ScStripM, min(e.x, e.y) * ScBlockM));+ }++ // One set of furrows `spacing` apart: -1 in the furrow, +1 on the ridge, mean 0 (an odd curve of a triangle+ // wave), so the land keeps its brightness. Softer as the lines near the pixel, gone under 3 pixels apart.+ half ScFurrowLines(float lx, float spacing, float px)+ {+ float t = abs(frac(lx / spacing) - 0.5) * 4.0 - 1.0;+ float k = max(0.35, 4.0 * px / spacing);+ return (2.0 * smoothstep(-k, k, t) - 1.0) * (1.0 - smoothstep(spacing / 5.0, spacing / 3.0, px));+ }struct Attributes { float4 positionOS : POSITION; };struct Varyings@@ -62,6 +106,12 @@ Shader "Statecraft/GroundDetail"float coast = SAMPLE_TEXTURE2D(_ScDetailCoastTex, sampler_ScDetailCoastTex, uv).r;fade *= ScOffTheBeach(coast, i.mapM);fade *= ScClearOfBorder(i.mapM, footprint);+ #ifdef SC_FURROWS+ // Before the clip, which would leave fwidth undefined. px: metres a pixel across the furrows; it leaps where+ // a block edge cuts lx, and the furrows have faded out there already.+ float2 rows = ScFieldRows(i.mapM);+ float px = fwidth(rows.x);+ #endifclip(fade - 0.001); // not even a rounding step on the sand and the stripesfloat4 land = SAMPLE_TEXTURE2D(_ScDetailLandTex, sampler_ScDetailLandTex, uv);half4 cls = SAMPLE_TEXTURE2D(_ScDetailClassTex, sampler_ScDetailClassTex, uv);@@ -78,6 +128,13 @@ Shader "Statecraft/GroundDetail"half shade = smoothstep(threshold, threshold + 0.16, max(a.b, b.b) + ragged) * (1.0 - bush);half stone = smoothstep(0.72, 0.88, a.a) * cls.a;half3 c = 1.0 + _GrainGain * cls.b * ((a.r + b.r) - 1.0);+ #ifdef SC_FURROWS+ // Two sets: one 6 pixels apart at the gameplay pose, a finer at a third of that, which fades in closer; on the+ // crop's strength (the bake's), and, as the scrub, not on the towns, the routes or the units' clearings.+ half furrow = SAMPLE_TEXTURE2D(_FurrowTex, sampler_FurrowTex, uv).r * smoothstep(ScFurrowOffEdge.x, ScFurrowOffEdge.y, rows.y)+ * (1.0 - SAMPLE_TEXTURE2D_LOD(_ScDetailKeepOutTex, sampler_ScDetailKeepOutTex, uv, 0.0).r);+ c *= 1.0 + _FurrowGain * furrow * (ScFurrowLines(rows.x, _FurrowM, px) + 0.6 * ScFurrowLines(rows.x, _FurrowM / 3.0, px));+ #endifc *= 1.0 + _StoneGain * stone;c *= lerp(1.0, _ShadowDark, shade);c *= lerp(half3(1, 1, 1), lerp(_BushLight.rgb, _BushDark.rgb, tone), bush);diff --git a/unity/Assets/Tests/EditMode/FurrowShots.cs b/unity/Assets/Tests/EditMode/FurrowShots.csnew file mode 100644index 000000000..6e54f7a83--- /dev/null+++ b/unity/Assets/Tests/EditMode/FurrowShots.cs@@ -0,0 +1,109 @@+#nullable enable+using System;+using System.Collections;+using System.IO;+using System.Linq;+using NUnit.Framework;+using Statecraft.Game;+using Statecraft.Game.Map;+using Statecraft.Game.UI;+using UnityEditor;+using UnityEditor.SceneManagement;+using UnityEngine;+using UnityEngine.TestTools;+using UnityEngine.UIElements;+using Object = UnityEngine.Object;++/// <summary>Writes the before and after stills for issue #2917 (furrows on the fields between the towns) to+/// `.superpowers/shots-2917/<SHOTS_TAG>/` at the repository root (local, not committed; SHOTS_TAG from the environment,+/// "untagged" when unset), as GroundDetailShots does for #2878. Each pose is shot twice in one run, in the game's opening+/// state, with the "furrows" toggle on (`<pose>-after.png`) and off (`<pose>-before.png`), so a pair differs only by+/// the change. Shaders compile synchronously, so the furrows' variant is in place for the first frame. Explicit, so it does+/// not run with the checks.</summary>+[Explicit("writes stills for a pull request, not a check")]+public class FurrowShots+{+ static readonly (string name, double lon, double lat, float km, float yaw)[] Poses =+ {+ ("plain31", 34.84, 31.92, 31f, 0f), ("plain12", 34.84, 31.92, 12f, 0f), ("plain6", 34.84, 31.92, 6f, 0f),+ ("jezreel31", 35.30, 32.62, 31f, 0f), ("jezreel12", 35.30, 32.62, 12f, 0f),+ ("between31", 34.93, 32.02, 31f, 0f), ("hills12", 35.05, 31.76, 12f, 0f),+ ("gameplay03", PromoPose.Gameplay03.Lon, PromoPose.Gameplay03.Lat, PromoPose.Gameplay03.Distance / 1000f, PromoPose.Gameplay03.Yaw),+ ("diorama02", PromoPose.Diorama02.Lon, PromoPose.Diorama02.Lat, PromoPose.Diorama02.Distance / 1000f, PromoPose.Diorama02.Yaw),+ };++ string saveDir = "";+ RenderTexture? rt; PanelSettings? ps;+ bool async;++ [SetUp]+ public void Prepare()+ {+ saveDir = Path.Combine(Path.GetTempPath(), "statecraft-furrow-shots-" + Guid.NewGuid().ToString("N"));+ async = ShaderUtil.allowAsyncCompilation; ShaderUtil.allowAsyncCompilation = false;+ }++ [TearDown]+ public void DiscardScene()+ {+ ShaderUtil.allowAsyncCompilation = async;+ VisualToggles.SetAll(true);+ EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);+ if (ps != null) Object.DestroyImmediate(ps);+ if (rt != null) { rt.Release(); Object.DestroyImmediate(rt); }+ if (Directory.Exists(saveDir)) Directory.Delete(saveDir, true);+ }++ static IEnumerator Frames(int n) { for (int i = 0; i < n; i++) yield return null; }++ /// <summary>The map camera's frame at the game's 1920 x 1080, without the UI.</summary>+ static void Shot(string name, string dir)+ {+ var cam = Camera.main;+ var frame = new RenderTexture(1920, 1080, 24, RenderTextureFormat.ARGB32);+ var before = cam.targetTexture;+ cam.targetTexture = frame; cam.Render(); cam.targetTexture = before;+ var prev = RenderTexture.active; RenderTexture.active = frame;+ var tex = new Texture2D(1920, 1080, TextureFormat.RGB24, false);+ tex.ReadPixels(new Rect(0, 0, 1920, 1080), 0, 0); tex.Apply();+ RenderTexture.active = prev; frame.Release(); Object.DestroyImmediate(frame);+ File.WriteAllBytes(Path.Combine(dir, name + ".png"), tex.EncodeToPNG());+ Object.DestroyImmediate(tex);+ Debug.Log($"SHOT {name}");+ }++ [UnityTest]+ public IEnumerator WriteStills()+ {+ var tag = Environment.GetEnvironmentVariable("SHOTS_TAG");+ var dir = Path.GetFullPath(Path.Combine(Application.dataPath, "..", "..", ".superpowers", "shots-2917", string.IsNullOrEmpty(tag) ? "untagged" : tag));+ Directory.CreateDirectory(dir);+ yield return CivMovementShots.Boot(false, saveDir, (t, p, u, g) => { rt = t; ps = p; });+ yield return Frames(5);+ // CameraRig.Apply freezes the projection at the camera's own aspect, and a batch run's default is 4:3 (GroundDetailShots).+ Camera.main.aspect = 16f / 9f;+ var rig = Camera.main.GetComponent<CameraRig>();+ var map = Object.FindFirstObjectByType<MapScene>();+ rig.LookAt = CameraRig.OpeningLookAt(map.Frame, Camera.main.aspect, map.Settlements.First(s => s.Id == "tel_aviv"), map.Settlements.First(s => s.Id == "jaffa"));+ rig.Apply();+ yield return Frames(3);+ foreach (var on in new[] { true, false })+ {+ VisualToggles.Set(GroundDetail.FurrowToggle, on);+ Shot("opening31-" + (on ? "after" : "before"), dir);+ }+ foreach (var (name, lon, lat, km, yaw) in Poses)+ {+ var at = map.Frame.ToWorld(lon, lat, 0);+ at.y = map.Terrain.SampleHeight(at) + map.Terrain.transform.position.y;+ rig.LookAt = at; rig.Distance = km * 1000f; rig.Yaw = yaw; rig.Apply();+ yield return Frames(3);+ foreach (var on in new[] { true, false })+ {+ VisualToggles.Set(GroundDetail.FurrowToggle, on);+ yield return Frames(1);+ Shot(name + "-" + (on ? "after" : "before"), dir);+ }+ }+ }+}diff --git a/unity/Assets/Tests/EditMode/FurrowShots.cs.meta b/unity/Assets/Tests/EditMode/FurrowShots.cs.metanew file mode 100644index 000000000..7069ec3a2--- /dev/null+++ b/unity/Assets/Tests/EditMode/FurrowShots.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: 7aff97e0f70a248ce8cfb76a0e6136da\ No newline at end of filediff --git a/unity/Assets/Tests/EditMode/GroundDetailTests.cs b/unity/Assets/Tests/EditMode/GroundDetailTests.csindex a7c568dd2..ed426724e 100644--- a/unity/Assets/Tests/EditMode/GroundDetailTests.cs+++ b/unity/Assets/Tests/EditMode/GroundDetailTests.cs@@ -6,6 +6,7 @@ using NUnit.Framework;using Statecraft.Game;using Statecraft.Game.Map;using Statecraft.Game.Map.Units;+using UnityEditor;using UnityEditor.SceneManagement;using UnityEngine;using UnityEngine.TestTools;@@ -30,13 +31,13 @@ public class GroundDetailTestsreturn map;}- static RenderSample At(MapScene map, Camera cam, double lon, double lat, float distance)+ static RenderSample At(MapScene map, Camera cam, double lon, double lat, float distance, int width = 960, int height = 540){var rig = cam.GetComponent<CameraRig>();var at = map.Frame.ToWorld(lon, lat, 0);at.y = map.Terrain.SampleHeight(at) + map.Terrain.transform.position.y;rig.LookAt = at; rig.Distance = distance; rig.Apply();- return RenderSample.Render(cam, 960, 540);+ return RenderSample.Render(cam, width, height);}[Test]@@ -51,12 +52,19 @@ public class GroundDetailTestsAssert.AreEqual(UnityEngine.Rendering.ShadowCastingMode.Off, renderer.shadowCastingMode);Assert.Contains(GroundDetail.Toggle, VisualToggles.Names.ToList());Assert.Contains(GroundDetail.ScrubToggle, VisualToggles.Names.ToList());+ Assert.Contains(GroundDetail.FurrowToggle, VisualToggles.Names.ToList());+ Assert.IsTrue(renderer.sharedMaterial.IsKeywordEnabled(GroundDetail.FurrowKeyword), "furrows on by default");+ VisualToggles.Set(GroundDetail.FurrowToggle, false);+ Assert.IsFalse(renderer.sharedMaterial.IsKeywordEnabled(GroundDetail.FurrowKeyword), "the toggle drops the variant, so the profile prices it");}+ /// <summary>#2917: the furrows are a variant of their own (SC_FURROWS), which the default variants do not cover, so it+ /// is compiled too, on its own and with the main-light-shadow keyword the web tier draws with.</summary>[Test]public void BothShadersCompileForWebGL2(){- CollectionAssert.IsEmpty(ShaderChecks.Gles3Errors(Shader.Find("Statecraft/GroundDetail")));+ CollectionAssert.IsEmpty(ShaderChecks.Gles3Errors(Shader.Find("Statecraft/GroundDetail"),+ new[] { GroundDetail.FurrowKeyword }, new[] { GroundDetail.FurrowKeyword, "_MAIN_LIGHT_SHADOWS" }));CollectionAssert.IsEmpty(ShaderChecks.Gles3Errors(Shader.Find("Statecraft/GroundScrub")));}@@ -82,6 +90,71 @@ public class GroundDetailTestsAssert.AreEqual(bareOverview.MeanSaturation(), overview.MeanSaturation(), 0.002f, "gone by the overview");}+ /// <summary>#2917: the shader reads fieldblocks.png texel by texel and decodes 16 bits from two bytes, so the bytes must+ /// arrive as land_bake.py wrote them; furrows.png is one linear channel. The pass's material carries both.</summary>+ [Test]+ public void TheFurrowTexturesImportAsTheShaderReadsThem()+ {+ var blocks = AssetDatabase.LoadAssetAtPath<Texture2D>(MapTexturePaths.FieldBlocks);+ Assert.AreEqual((34, 85), (blocks.width, blocks.height), "every 5.2 km block the wobble reaches, one more each side, not resized to a power of two");+ Assert.AreEqual(TextureFormat.RGBA32, blocks.format, "uncompressed");+ Assert.AreEqual(1, blocks.mipmapCount); Assert.AreEqual(FilterMode.Point, blocks.filterMode); Assert.IsFalse(blocks.isDataSRGB);+ var furrows = AssetDatabase.LoadAssetAtPath<Texture2D>(MapTexturePaths.Furrows);+ Assert.AreEqual((1024, 2048), (furrows.width, furrows.height));+ Assert.AreEqual(TextureFormat.R8, furrows.format); Assert.IsFalse(furrows.isDataSRGB); Assert.Greater(furrows.mipmapCount, 1);+ Assert.AreEqual(TextureWrapMode.Clamp, furrows.wrapMode);+ var mat = Resources.Load<Material>(GroundDetail.MaterialResource);+ Assert.AreEqual(furrows, mat.GetTexture("_FurrowTex"));+ Assert.AreEqual(blocks, mat.GetTexture("_FieldBlockTex"));+ }++ /// <summary>#2917: the furrows add line detail to the farmed coastal plain at 12 km, at the opening zoom and at the+ /// gameplay pose (at 1920 x 1080: the lines are symbolic, sized for that frame), and leave its colour and brightness (they+ /// darken as much as they lighten, so GradeTests' thin warmth margin holds); the unfarmed Judean hills and the overview do+ /// not change. Measured at 240 m furrows and gain 0.30, off the keep-out mask (the town discs, the units' clearings and+ /// the kit routes' corridors, which the kits switched off here leave bare): +3.2% gradient at 12 km, +3.2% at 31 km, +1.45%+ /// at gameplay03 (the frame is mostly towns, trees and hills), brightness within 0.0003. Shaders compile synchronously: the furrows are a+ /// variant of their own, which the editor would otherwise draw only once compiled.</summary>+ [UnityTest]+ public IEnumerator TheFurrowsLineTheFieldsAndKeepTheirColour()+ {+ bool async = ShaderUtil.allowAsyncCompilation;+ ShaderUtil.allowAsyncCompilation = false;+ try+ {+ var map = OpenMap();+ RenderSample.TiltShift(false);+ yield return null;+ var cam = Camera.main;+ foreach (var n in new[] { "kits", "trees", GroundDetail.ScrubToggle }) if (VisualToggles.Names.Contains(n)) VisualToggles.Set(n, false);+ var g = PromoPose.Gameplay03; var d = PromoPose.Diorama02;+ RenderSample[] Shots() => new[]+ {+ At(map, cam, 34.84, 31.92, 12000f), At(map, cam, 34.84, 31.92, 31000f), At(map, cam, g.Lon, g.Lat, g.Distance, 1920, 1080),+ At(map, cam, 35.15, 31.78, 12000f), At(map, cam, d.Lon, d.Lat, d.Distance),+ };+ At(map, cam, 34.84, 31.92, 12000f); // warm-up: every variant in place+ var on = Shots();+ VisualToggles.Set(GroundDetail.FurrowToggle, false);+ var off = Shots();+ string[] names = { "plain 12 km", "plain 31 km", "gameplay03", "hills 12 km", "diorama02" };+ for (int k = 0; k < names.Length; k++)+ TestContext.WriteLine($"{names[k]}: gradient {off[k].GradientEnergy(0.25f, 0.75f):0.00000} -> {on[k].GradientEnergy(0.25f, 0.75f):0.00000}, " ++ $"luma {off[k].MeanLuma(0, 0, 1, 1):0.0000} -> {on[k].MeanLuma(0, 0, 1, 1):0.0000}, saturation {off[k].MeanSaturation():0.0000} -> {on[k].MeanSaturation():0.0000}");+ Assert.Greater(on[0].GradientEnergy(0.25f, 0.75f), 1.02f * off[0].GradientEnergy(0.25f, 0.75f), "furrows on the plain at 12 km");+ Assert.Greater(on[1].GradientEnergy(0.25f, 0.75f), 1.02f * off[1].GradientEnergy(0.25f, 0.75f), "at the opening zoom");+ Assert.Greater(on[2].GradientEnergy(0.25f, 0.75f), 1.01f * off[2].GradientEnergy(0.25f, 0.75f), "and still at the gameplay pose");+ for (int k = 0; k < 3; k++)+ {+ Assert.AreEqual(off[k].MeanLuma(0, 0, 1, 1), on[k].MeanLuma(0, 0, 1, 1), 0.004f, names[k] + ": as bright");+ Assert.AreEqual(off[k].MeanSaturation(), on[k].MeanSaturation(), 0.004f, names[k] + ": the same colour");+ }+ Assert.AreEqual(off[3].MeanLuma(0, 0, 1, 1), on[3].MeanLuma(0, 0, 1, 1), 0.002f, "not on the unfarmed hills");+ Assert.AreEqual(off[4].MeanSaturation(), on[4].MeanSaturation(), 0.001f, "gone by the overview");+ }+ finally { ShaderUtil.allowAsyncCompilation = async; }+ }+/// <summary>Scrub draws for the camera at the opening zoom, and not under the opt-in hex-tile board, past the gameplay/// zoom, or with the terrain off.</summary>[UnityTest]diff --git a/unity/Assets/Tests/EditMode/ShaderChecks.cs b/unity/Assets/Tests/EditMode/ShaderChecks.csindex c22291e75..a79c9d563 100644--- a/unity/Assets/Tests/EditMode/ShaderChecks.cs+++ b/unity/Assets/Tests/EditMode/ShaderChecks.cs@@ -58,9 +58,12 @@ public static class ShaderChecksreturn false;}- public static List<string> Gles3Errors(Shader shader)+ /// <summary>The GLES3 compile errors of every pass, for the default variants and for each of <paramref name="extra"/>+ /// keyword sets (a shader's own multi_compile keywords, which the defaults do not cover: GroundDetail's SC_FURROWS).</summary>+ public static List<string> Gles3Errors(Shader shader, params string[][] extra){if (shader == null) throw new ArgumentNullException(nameof(shader));+ var variants = Variants.Concat(extra).ToArray();var errors = new List<string>();int usable = 0;var data = ShaderUtil.GetShaderData(shader);@@ -75,7 +78,7 @@ public static class ShaderChecksvar pass = sub.GetPass(p);if (ExcludesGles3(pass.SourceCode)) continue;built++;- foreach (var keywords in Variants)+ foreach (var keywords in variants)foreach (var stage in new[] { ShaderType.Vertex, ShaderType.Fragment }){var info = pass.CompileVariant(stage, keywords, ShaderCompilerPlatform.GLES3x, BuildTarget.WebGL, true);diff --git a/unity/Assets/Textures/Map/fieldblocks.png b/unity/Assets/Textures/Map/fieldblocks.pngnew file mode 100644index 000000000..5a14d2ca3Binary files /dev/null and b/unity/Assets/Textures/Map/fieldblocks.png differdiff --git a/unity/Assets/Textures/Map/fieldblocks.png.meta b/unity/Assets/Textures/Map/fieldblocks.png.metanew file mode 100644index 000000000..0b1ba19ca--- /dev/null+++ b/unity/Assets/Textures/Map/fieldblocks.png.meta@@ -0,0 +1,130 @@+fileFormatVersion: 2+guid: a2cf406254fb41fa80b439a61f954d43+TextureImporter:+ internalIDToNameTable: []+ externalObjects: {}+ serializedVersion: 13+ mipmaps:+ mipMapMode: 0+ enableMipMap: 0+ sRGBTexture: 0+ linearTexture: 0+ fadeOut: 0+ borderMipMap: 0+ mipMapsPreserveCoverage: 0+ alphaTestReferenceValue: 0.5+ mipMapFadeDistanceStart: 1+ mipMapFadeDistanceEnd: 3+ bumpmap:+ convertToNormalMap: 0+ externalNormalMap: 0+ heightScale: 0.25+ normalMapFilter: 0+ flipGreenChannel: 0+ isReadable: 0+ streamingMipmaps: 0+ streamingMipmapsPriority: 0+ vTOnly: 0+ ignoreMipmapLimit: 0+ grayScaleToAlpha: 0+ generateCubemap: 6+ cubemapConvolution: 0+ seamlessCubemap: 0+ textureFormat: 1+ maxTextureSize: 2048+ textureSettings:+ serializedVersion: 2+ filterMode: 0+ aniso: 1+ mipBias: 0+ wrapU: 1+ wrapV: 1+ wrapW: 1+ nPOTScale: 0+ lightmap: 0+ compressionQuality: 50+ spriteMode: 0+ spriteExtrude: 1+ spriteMeshType: 1+ alignment: 0+ spritePivot: {x: 0.5, y: 0.5}+ spritePixelsToUnits: 100+ spriteBorder: {x: 0, y: 0, z: 0, w: 0}+ spriteGenerateFallbackPhysicsShape: 1+ alphaUsage: 1+ alphaIsTransparency: 0+ spriteTessellationDetail: -1+ textureType: 0+ textureShape: 1+ singleChannelComponent: 0+ flipbookRows: 1+ flipbookColumns: 1+ maxTextureSizeSet: 0+ compressionQualitySet: 0+ textureFormatSet: 0+ ignorePngGamma: 0+ applyGammaDecoding: 0+ swizzle: 50462976+ cookieLightType: 0+ platformSettings:+ - serializedVersion: 4+ buildTarget: DefaultTexturePlatform+ maxTextureSize: 2048+ resizeAlgorithm: 0+ textureFormat: -1+ textureCompression: 0+ compressionQuality: 50+ crunchedCompression: 0+ allowsAlphaSplitting: 0+ overridden: 0+ ignorePlatformSupport: 0+ androidETC2FallbackOverride: 0+ forceMaximumCompressionQuality_BC6H_BC7: 0+ - serializedVersion: 4+ buildTarget: Standalone+ maxTextureSize: 2048+ resizeAlgorithm: 0+ textureFormat: -1+ textureCompression: 0+ compressionQuality: 50+ crunchedCompression: 0+ allowsAlphaSplitting: 0+ overridden: 0+ ignorePlatformSupport: 0+ androidETC2FallbackOverride: 0+ forceMaximumCompressionQuality_BC6H_BC7: 0+ - serializedVersion: 4+ buildTarget: WebGL+ maxTextureSize: 2048+ resizeAlgorithm: 0+ textureFormat: -1+ textureCompression: 0+ compressionQuality: 50+ crunchedCompression: 0+ allowsAlphaSplitting: 0+ overridden: 0+ ignorePlatformSupport: 0+ androidETC2FallbackOverride: 0+ forceMaximumCompressionQuality_BC6H_BC7: 0+ spriteSheet:+ serializedVersion: 2+ sprites: []+ outline: []+ customData:+ physicsShape: []+ bones: []+ spriteID:+ internalID: 0+ vertices: []+ indices:+ edges: []+ weights: []+ secondaryTextures: []+ spriteCustomMetadata:+ entries: []+ nameFileIdTable: {}+ mipmapLimitGroupName:+ pSDRemoveMatte: 0+ userData:+ assetBundleName:+ assetBundleVariant:diff --git a/unity/Assets/Textures/Map/furrows.png b/unity/Assets/Textures/Map/furrows.pngnew file mode 100644index 000000000..7095e305eBinary files /dev/null and b/unity/Assets/Textures/Map/furrows.png differdiff --git a/unity/Assets/Textures/Map/furrows.png.meta b/unity/Assets/Textures/Map/furrows.png.metanew file mode 100644index 000000000..6cea4c6fa--- /dev/null+++ b/unity/Assets/Textures/Map/furrows.png.meta@@ -0,0 +1,130 @@+fileFormatVersion: 2+guid: e1c531cbe2e3467b8a5033b76e4705a7+TextureImporter:+ internalIDToNameTable: []+ externalObjects: {}+ serializedVersion: 13+ mipmaps:+ mipMapMode: 0+ enableMipMap: 1+ sRGBTexture: 0+ linearTexture: 0+ fadeOut: 0+ borderMipMap: 0+ mipMapsPreserveCoverage: 0+ alphaTestReferenceValue: 0.5+ mipMapFadeDistanceStart: 1+ mipMapFadeDistanceEnd: 3+ bumpmap:+ convertToNormalMap: 0+ externalNormalMap: 0+ heightScale: 0.25+ normalMapFilter: 0+ flipGreenChannel: 0+ isReadable: 0+ streamingMipmaps: 0+ streamingMipmapsPriority: 0+ vTOnly: 0+ ignoreMipmapLimit: 0+ grayScaleToAlpha: 0+ generateCubemap: 6+ cubemapConvolution: 0+ seamlessCubemap: 0+ textureFormat: 1+ maxTextureSize: 2048+ textureSettings:+ serializedVersion: 2+ filterMode: 2+ aniso: 1+ mipBias: 0+ wrapU: 1+ wrapV: 1+ wrapW: 1+ nPOTScale: 1+ lightmap: 0+ compressionQuality: 50+ spriteMode: 0+ spriteExtrude: 1+ spriteMeshType: 1+ alignment: 0+ spritePivot: {x: 0.5, y: 0.5}+ spritePixelsToUnits: 100+ spriteBorder: {x: 0, y: 0, z: 0, w: 0}+ spriteGenerateFallbackPhysicsShape: 1+ alphaUsage: 1+ alphaIsTransparency: 0+ spriteTessellationDetail: -1+ textureType: 10+ textureShape: 1+ singleChannelComponent: 1+ flipbookRows: 1+ flipbookColumns: 1+ maxTextureSizeSet: 0+ compressionQualitySet: 0+ textureFormatSet: 0+ ignorePngGamma: 0+ applyGammaDecoding: 0+ swizzle: 50462976+ cookieLightType: 0+ platformSettings:+ - serializedVersion: 4+ buildTarget: DefaultTexturePlatform+ maxTextureSize: 2048+ resizeAlgorithm: 0+ textureFormat: -1+ textureCompression: 0+ compressionQuality: 50+ crunchedCompression: 0+ allowsAlphaSplitting: 0+ overridden: 0+ ignorePlatformSupport: 0+ androidETC2FallbackOverride: 0+ forceMaximumCompressionQuality_BC6H_BC7: 0+ - serializedVersion: 4+ buildTarget: Standalone+ maxTextureSize: 2048+ resizeAlgorithm: 0+ textureFormat: -1+ textureCompression: 1+ compressionQuality: 50+ crunchedCompression: 0+ allowsAlphaSplitting: 0+ overridden: 0+ ignorePlatformSupport: 0+ androidETC2FallbackOverride: 0+ forceMaximumCompressionQuality_BC6H_BC7: 0+ - serializedVersion: 4+ buildTarget: WebGL+ maxTextureSize: 2048+ resizeAlgorithm: 0+ textureFormat: -1+ textureCompression: 1+ compressionQuality: 50+ crunchedCompression: 0+ allowsAlphaSplitting: 0+ overridden: 0+ ignorePlatformSupport: 0+ androidETC2FallbackOverride: 0+ forceMaximumCompressionQuality_BC6H_BC7: 0+ spriteSheet:+ serializedVersion: 2+ sprites: []+ outline: []+ customData:+ physicsShape: []+ bones: []+ spriteID:+ internalID: 0+ vertices: []+ indices:+ edges: []+ weights: []+ secondaryTextures: []+ spriteCustomMetadata:+ entries: []+ nameFileIdTable: {}+ mipmapLimitGroupName:+ pSDRemoveMatte: 0+ userData:+ assetBundleName:+ assetBundleVariant: