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 kits: one shared atlas for every town kit: plaster, stone, tile roofs, windows and balconies (Refs #2428) (#2883)

Eyal Golan92ab384ce137
diff --git a/ASSETS.yaml b/ASSETS.yaml
index f53d95a65..afa812157 100644
--- a/ASSETS.yaml
+++ b/ASSETS.yaml
@@ -1675,6 +1675,13 @@ rules:
status: verified
note: "Provenance of this project's own compilation; not human historical or Hebrew sign-off. 61 fields are supplied: 59 are native-review-pending and 2 carry the owner's approved wording (27 October 2026). Eleven compound geographic captions remain NEEDS-RESEARCH with per-field English fallback, following the ruling not to invent unsourced historical forms. Geometry, dates and simulation inputs are unchanged."
# --- Baked map textures (derived from the heightmap) ---
+ # #2428: the town kits' one shared atlas.
+ - glob: "unity/Assets/Art/Kits/kit_atlas.png"
+ licence: CC-BY-4.0
+ ai_generated: true
+ status: verified
+ source: "Painted entirely by code: uv run asset-sources/kit-atlas/make_kit_atlas.py (numpy, Pillow; fixed seeds, no input files, no photographs and no image model). Regenerating gives the same bytes."
+ note: "ai_generated is true because Claude Code wrote the generator; no generative image model or paid service made any pixel. Albedo only, no lighting painted in (KitAtlasTests)."
- glob: "unity/Assets/Textures/Map/landuse.png"
licence: CC-BY-SA-4.0
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"
diff --git a/LICENSING.md b/LICENSING.md
index be85de20b..8d2f5a582 100644
--- a/LICENSING.md
+++ b/LICENSING.md
@@ -8,7 +8,7 @@ Different parts of this repository are under different licences. Where a file is
| Game content (text and data) | `content/` (events, people, offices, model, rules, map YAML/JSON and their baked runtime forms `map/*.tsv`), except the third-party map data below | [CC BY-SA 4.0](LICENSES/CC-BY-SA-4.0.txt), credit "Statecraft: Israel contributors". The text paraphrases its cited sources, many from Wikipedia (CC BY-SA), so share-alike applies; each entry lists its sources |
| Translations | `translations/` (the game content and UI strings in languages other than English and Hebrew, written with `tools/translate.py`) | [CC BY-SA 4.0](LICENSES/CC-BY-SA-4.0.txt), credit "Statecraft: Israel contributors". A translation of `content/` text is an adaptation of it, so share-alike applies (owner, 24 October 2026, #1604) |
| Historian pilot packets quoting game content | `docs/reviews/historian/pilot-2026-10-20/` | [CC BY-SA 4.0](LICENSES/CC-BY-SA-4.0.txt), credit "Statecraft: Israel contributors". Draft reproductions of the pinned `content/` text/comments, not a human review record; any future reviewer text still needs their separate CC BY 4.0 consent. |
-| Original docs, art and UI assets | `docs/`, the root `*.md` files (except `LICENSE`), `ASSETS.yaml`, `ASSETS.portraits.yaml`, `asset-sources/**/*.json` (provenance and validation receipts), `promo/shots.json`, `promo/CREDITS.md`, `tools/README.md`, `reports/` (our own text), `research_notes/` (our own text), `unity/Assets/UI/*.uxml`, `*.uss`, `strings.en.yaml`, `unity/Assets/Materials/`, `unity/Assets/Resources/Units/` (materials), `unity/Assets/Shaders/`, `unity/Assets/UI/*.asset`, `unity/Assets/WebGLTemplates/Statecraft/favicon.ico`, `unity/Assets/Resources/EventImageCatalog.asset` (the event-photo catalog: alt texts, credits and flags; the pictures it points to are under their own licences below), `promo/ref/geo-reference.png` | [CC BY 4.0](LICENSES/CC-BY-4.0.txt), credit "Statecraft: Israel contributors" |
+| Original docs, art and UI assets | `docs/`, the root `*.md` files (except `LICENSE`), `ASSETS.yaml`, `ASSETS.portraits.yaml`, `asset-sources/**/*.json` (provenance and validation receipts), `promo/shots.json`, `promo/CREDITS.md`, `tools/README.md`, `reports/` (our own text), `research_notes/` (our own text), `unity/Assets/UI/*.uxml`, `*.uss`, `strings.en.yaml`, `unity/Assets/Materials/`, `unity/Assets/Art/Kits/` (the town kits' atlas), `unity/Assets/Resources/Units/` (materials), `unity/Assets/Shaders/`, `unity/Assets/UI/*.asset`, `unity/Assets/WebGLTemplates/Statecraft/favicon.ico`, `unity/Assets/Resources/EventImageCatalog.asset` (the event-photo catalog: alt texts, credits and flags; the pictures it points to are under their own licences below), `promo/ref/geo-reference.png` | [CC BY 4.0](LICENSES/CC-BY-4.0.txt), credit "Statecraft: Israel contributors" |
| Unity template-derived files | `unity/Assets/Settings/` (URP assets, renderers, volume profiles), `spikes/m0/unity/Assets/Settings/`, `spikes/m0/unity/Assets/UI Toolkit/UnityThemes/`, and any Shader Graph generated from a Unity template (for example `unity/Assets/Shaders/StatecraftTerrain.shadergraph`, from "Terrain Simple") | Created from Unity's project or graph templates and edited; under the [Unity Companion License](https://unity.com/legal/licenses/unity-companion-license) (use with Unity), not the code licence |
| AI-generated images | `promo/final/01`–`08`, `promo/ref/*-src.jpg`, `docs/images/hero-concept-1936.jpg`, `promo/start-screen/*.png`, `unity/Assets/UI/StartScreen/declaration-hall.jpg` | Marked [CC0 1.0](LICENSES/CC0-1.0.txt). No rights are claimed. Purely AI-generated output may not be copyrightable. Made with the ElevenLabs Image API (see `promo/CREDITS.md`), except the start screen's option images, made with Dreamina; the start screen's painting was made on ElevenLabs from a Dreamina option (`ASSETS.yaml`). |
| AI-generated sound effects | `unity/Assets/Resources/Audio/turn-ended.ogg`, `event-card.ogg`, `refused.ogg` (only these three cues) | owner holds written permission from ElevenLabs for publishing these files in this repo; owner, 20 Oct 2026. Made with ElevenLabs Sound Effects through the project's paid subscription; source and processing records are in `ASSETS.yaml`. This records the owner-attested publication basis, not a CC0 grant or an independently inspected permission document. The manifest uses `LicenseRef-ElevenLabs-Owner-Permission`. The owner instructed us to ship the Codex pick after considering all twelve candidates; no listening gate was requested. Codex has not listened and no human listening verification is claimed. |
diff --git a/asset-sources/kit-atlas/make_kit_atlas.py b/asset-sources/kit-atlas/make_kit_atlas.py
new file mode 100644
index 000000000..e87947ec7
--- /dev/null
+++ b/asset-sources/kit-atlas/make_kit_atlas.py
@@ -0,0 +1,479 @@
+#!/usr/bin/env python3
+# /// script
+# requires-python = ">=3.11"
+# dependencies = ["numpy>=2", "pillow>=11"]
+# ///
+"""Paints the town kits' one shared atlas (#2428) from code: no photographs, no AI images, no input files.
+
+ uv run asset-sources/kit-atlas/make_kit_atlas.py
+
+writes unity/Assets/Art/Kits/kit_atlas.png: a 4 x 4 grid of 512 px cells, which Unity imports as one Texture2DArray of 16
+layers (kit_atlas.png.meta), so each cell tiles and has its own mipmaps with no bleeding from its neighbours. The same
+code gives the same bytes.
+
+Rules for a cell:
+- Albedo only. No lighting is painted in: no cast shadow, no sun side, no ambient occlusion. Glass and doors are dark
+ because they are dark, not because they are shaded; the sun, shadows and grade come from Kit.shader.
+- Plaster and stone are near white and neutral. The building's own vertex colour tints them, so each town keeps the palette
+ it had, and a block's jitter still reads.
+- Every cell tiles in both directions. A facade cell (the first five) is one ground storey (the bottom quarter) under three
+ upper storeys, and Kit.shader repeats the upper three. So a facade cell's wall is 12 m wide and 13.2 m high, a storey being
+ 3.3 m as everywhere in the kits. KitMesh.Scale must match the sizes in CELLS.
+"""
+from __future__ import annotations
+
+import hashlib
+import sys
+from pathlib import Path
+
+import numpy as np
+from PIL import Image
+
+N = 512 # cell side, px
+STOREY = N // 4 # px: a storey is a quarter of a facade cell's height
+OUT = Path(__file__).resolve().parents[2] / "unity/Assets/Art/Kits/kit_atlas.png"
+
+# Layer order: KitMesh's Facade enum (layer + 1 = its value / 17). (name, metres across, metres high).
+CELLS = [
+ ("white_city", 12.0, 13.2), ("stone_facade", 12.0, 13.2), ("village_facade", 12.0, 13.2), ("mud_facade", 12.0, 13.2),
+ ("moshava_facade", 12.0, 13.2), ("plaster", 12.0, 12.0), ("ashlar", 6.0, 6.0), ("rubble", 4.0, 4.0),
+ ("roof_tile", 4.0, 4.0), ("flat_roof", 16.0, 16.0), ("ribbon_glass", 6.0, 1.2), ("balcony_rail", 12.0, 1.25),
+ ("corrugated", 4.0, 4.0), ("planks", 4.0, 4.0), ("spare_a", 4.0, 4.0), ("spare_b", 4.0, 4.0),
+]
+
+
+# ---- periodic noise ----------------------------------------------------------------------------------------------------
+
+def noise(seed: int, beta: float = 1.6, stretch: tuple[float, float] = (1.0, 1.0)) -> np.ndarray:
+ """Tiling spectral noise in about [-1, 1]: beta sets how smooth; a large stretch on an axis elongates the noise along it."""
+ rng = np.random.default_rng(seed)
+ white = rng.standard_normal((N, N))
+ fy, fx = np.fft.fftfreq(N)[:, None] * stretch[1], np.fft.fftfreq(N)[None, :] * stretch[0]
+ r = np.sqrt(fx * fx + fy * fy)
+ r[0, 0] = 1.0
+ spec = np.fft.fft2(white) / r ** beta
+ spec[0, 0] = 0.0
+ out = np.fft.ifft2(spec).real
+ return np.clip(out / (2.6 * out.std()), -1.0, 1.0)
+
+
+def rgb(r: float, g: float, b: float) -> np.ndarray:
+ return np.array([r, g, b], dtype=np.float64)
+
+
+def fill(colour: np.ndarray) -> np.ndarray:
+ return np.ones((N, N, 3)) * colour
+
+
+def rect(a: np.ndarray, x0: float, y0: float, x1: float, y1: float, colour, wrap: bool = True) -> None:
+ """Fills a rectangle (px, y up from the cell's bottom), wrapping across the cell's sides."""
+ ys = np.arange(int(round(y0)), int(round(y1)))
+ for x in range(int(round(x0)), int(round(x1))):
+ a[ys, x % N if wrap else x] = colour
+
+
+def tint(a: np.ndarray, x0: float, y0: float, x1: float, y1: float, k) -> None:
+ ys = np.arange(int(round(y0)), int(round(y1)))
+ for x in range(int(round(x0)), int(round(x1))):
+ a[ys, x % N] *= k
+
+
+def grain(a: np.ndarray, seed: int, big: float, fine: float, streak: float = 0.0) -> np.ndarray:
+ """Weathering: broad patches, fine grain and, with streak, rain runs (long up and down). Multiplies the albedo."""
+ k = 1.0 + big * noise(seed, 1.9) + fine * noise(seed + 1, 0.7)
+ if streak:
+ k += streak * np.minimum(noise(seed + 2, 1.3, (0.7, 9.0)), 0.0)
+ return a * k[..., None]
+
+
+def drips(a: np.ndarray, seed: int, x0: float, x1: float, y: float, length: float, k: float = 0.10) -> None:
+ """Rain stains running down the wall from a sill or a ledge at y: albedo, a dirtier wall, not a shadow."""
+ rng = np.random.default_rng(seed)
+ for x in range(int(x0), int(x1)):
+ run = int(length * rng.uniform(0.3, 1.0))
+ strength = k * rng.uniform(0.3, 1.0)
+ for j in range(run):
+ yy = int(y) - j
+ if 0 <= yy < N:
+ a[yy, x % N] *= 1.0 - strength * (1.0 - j / run)
+
+
+def street_dirt(a: np.ndarray, k: float = 0.12) -> None:
+ """The dust a wall takes up from the street, fading out over the ground storey."""
+ t = np.clip(1.0 - np.arange(N) / STOREY, 0.0, 1.0)[:, None, None]
+ a *= 1.0 - k * t ** 2
+
+
+def normalise(a: np.ndarray, mean: float) -> np.ndarray:
+ """Scales a tintable surface so it dims the vertex colour by a known amount, not by whatever the noise summed to."""
+ return np.clip(a * (mean / a.mean()), 0.0, 1.0)
+
+
+# ---- window and door pieces (px, y up) ---------------------------------------------------------------------------------
+
+GLASS = rgb(0.13, 0.15, 0.17)
+FRAME = rgb(0.62, 0.61, 0.58)
+OLIVE = rgb(0.40, 0.47, 0.40) # painted shutter
+BROWN = rgb(0.36, 0.28, 0.21) # old wood
+TEAL = rgb(0.32, 0.45, 0.47) # painted wood
+
+
+def casement(a, x0, y0, w, h, panes=2, frame=FRAME, glass=GLASS):
+ rect(a, x0, y0, x0 + w, y0 + h, frame)
+ t = max(2, round(w * 0.06))
+ pw = (w - t * (panes + 1)) / panes
+ rows = 2
+ ph = (h - t * (rows + 1)) / rows
+ for i in range(panes):
+ for j in range(rows):
+ px = x0 + t + i * (pw + t)
+ py = y0 + t + j * (ph + t)
+ rect(a, px, py, px + pw, py + ph, glass * (1.0 + 0.12 * ((i * 3 + j * 5) % 3)))
+
+
+def slats(a, x0, y0, w, h, colour, step=4):
+ rect(a, x0, y0, x0 + w, y0 + h, colour)
+ for y in range(int(y0), int(y0 + h), step):
+ tint(a, x0, y, x0 + w, y + 1, 0.74)
+
+
+def shuttered(a, x0, y0, w, h, colour, seed):
+ """A window with its two leaves folded back on the wall."""
+ casement(a, x0, y0, w, h)
+ leaf = w * 0.48
+ slats(a, x0 - leaf, y0, leaf, h, colour)
+ slats(a, x0 + w, y0, leaf, h, colour)
+
+
+def arched(a, x0, y0, w, h, colour, surround=None, pad=7):
+ """An arched opening of width w and full height h (the arch's crown), in colour, with a pale dressed-stone surround."""
+ yy, xx = np.mgrid[0:N, 0:N]
+ cx = x0 + 0.5 * w
+ def mask(pw, ph_extra):
+ spring = y0 + h - 0.5 * w
+ dx = np.minimum(np.abs(xx - cx), N - np.abs(xx - cx))
+ low = (dx < 0.5 * pw) & (yy >= y0 - ph_extra) & (yy < spring)
+ top = (dx ** 2 + (yy - spring) ** 2 < (0.5 * pw) ** 2) & (yy >= spring)
+ return low | top
+ if surround is not None:
+ a[mask(w + 2 * pad, pad)] *= surround
+ a[mask(w, 0)] = colour
+
+
+def door(a, x0, y0, w, h, colour, panels=2):
+ rect(a, x0, y0, x0 + w, y0 + h, colour)
+ t = max(3, round(w * 0.1))
+ pw = (w - t * 3) / 2
+ ph = (h - t * (panels + 1)) / panels
+ for i in range(2):
+ for j in range(panels):
+ px = x0 + t + i * (pw + t)
+ py = y0 + t + j * (ph + t)
+ tint(a, px, py, px + pw, py + ph, 0.82)
+
+
+def plinth(a, colour, px=14, courses=0):
+ """The wall's foot, below the ground storey's openings: a darker base, with joints when it is built of stone. Kit.shader
+ clamps a wall's buried part to this band."""
+ a[:px, :] = a[:px, :] * colour
+ if courses:
+ h = px // courses
+ for c in range(courses):
+ a[c * h:c * h + 2, :] *= 0.8
+ shift = (c * 37) % 41
+ for x in range(shift, N, 41):
+ a[c * h:(c + 1) * h, x:x + 2] *= 0.82
+
+
+def voronoi_stones(seed: int, count: int, squash: float = 1.0):
+ """Rough stones: per pixel, the tiling distance to the mortar joint (px) and the stone's id."""
+ rng = np.random.default_rng(seed)
+ pts = rng.random((count, 2)) * N
+ yy, xx = np.mgrid[0:N, 0:N].astype(np.float64)
+ best = np.full((N, N), 1e12)
+ second = np.full((N, N), 1e12)
+ ids = np.zeros((N, N), dtype=np.int64)
+ for i, (px, py) in enumerate(pts):
+ dx = np.minimum(np.abs(xx - px), N - np.abs(xx - px))
+ dy = np.minimum(np.abs(yy - py), N - np.abs(yy - py)) * squash
+ d = np.sqrt(dx * dx + dy * dy)
+ closer = d < best
+ second = np.where(closer, best, np.minimum(second, d))
+ ids = np.where(closer, i, ids)
+ best = np.where(closer, d, best)
+ return second - best, ids, rng.random(count)
+
+
+def coursed_stone(seed: int, course_px: int, base: float = 0.92, joint: float = 0.70) -> np.ndarray:
+ """Coursed dressed stone: courses a whole fraction of the cell, blocks of random length, each its own tone."""
+ rng = np.random.default_rng(seed)
+ a = np.ones((N, N))
+ rows = N // course_px
+ h = N / rows
+ for r in range(rows):
+ y0, y1 = round(r * h), round((r + 1) * h)
+ cuts = [0.0]
+ while cuts[-1] < N:
+ cuts.append(cuts[-1] + rng.uniform(1.3, 2.9) * h)
+ scale = N / cuts[-1]
+ shift = int(rng.integers(0, N))
+ for c0, c1 in zip(cuts, cuts[1:]):
+ x0, x1 = round(c0 * scale), round(c1 * scale)
+ xs = (np.arange(x0, x1) + shift) % N
+ a[np.ix_(np.arange(y0, y1), xs)] = base * rng.uniform(0.91, 1.07)
+ a[np.ix_(np.arange(y0, y1), xs[:2])] = joint
+ a[y0:y0 + 2, :] = joint
+ return a
+
+
+# ---- the cells ----------------------------------------------------------------------------------------------------------
+
+def white_city() -> np.ndarray:
+ """Plastered International Style wall, 4 bays of 3 m: windows above, doors and a shop in the ground storey."""
+ a = fill(rgb(0.97, 0.97, 0.96))
+ bay = N / 4
+ # Upper storeys: casements, one with its blind half down, one with the slatted shutter drawn.
+ for s in range(1, 4):
+ for b in range(4):
+ # 1.4 to 2.6 m above the floor, as the ribbon windows (Ribbons), which stand in front of them on a long side.
+ x, y = (b + 0.15) * bay, s * STOREY + 0.424 * STOREY
+ w, h = 0.7 * bay, 0.364 * STOREY
+ k = (b * 2 + s * 3) % 5
+ casement(a, x, y, w, h, panes=3)
+ if k == 1: slats(a, x, y + 0.45 * h, w, 0.55 * h, rgb(0.72, 0.70, 0.64))
+ if k == 3: slats(a, x, y, w, h, rgb(0.55, 0.60, 0.56))
+ drips(a, 1000 + 10 * s + b, x, x + w, y - 1, 0.42 * STOREY)
+ # A thin string course at each floor line: a paler render band, no shadow.
+ tint(a, 0, s * STOREY - 3, N, s * STOREY + 3, 0.93)
+ # Ground storey: window, door, window, shopfront.
+ casement(a, 0.15 * bay, 0.424 * STOREY, 0.7 * bay, 0.364 * STOREY, panes=3)
+ door(a, 1.26 * bay, 0.08 * STOREY, 0.48 * bay, 0.72 * STOREY, TEAL)
+ rect(a, 1.26 * bay, 0.8 * STOREY, 1.74 * bay, 0.9 * STOREY, GLASS)
+ casement(a, 2.15 * bay, 0.424 * STOREY, 0.7 * bay, 0.364 * STOREY, panes=3)
+ slats(a, 3.1 * bay, 0.08 * STOREY, 0.8 * bay, 0.72 * STOREY, rgb(0.48, 0.47, 0.44), step=5)
+ street_dirt(a, 0.18)
+ plinth(a, rgb(0.74, 0.72, 0.68), 26, courses=2)
+ return np.clip(grain(a, 11, 0.03, 0.014, 0.10), 0, 1)
+
+
+def stone_facade() -> np.ndarray:
+ """Dressed stone in courses, 3 bays of 4 m: tall arched windows, shop arches below."""
+ s = coursed_stone(21, 13)
+ a = np.repeat(s[..., None], 3, axis=2) * rgb(1.0, 0.985, 0.95)
+ bay = N / 3
+ for st in range(1, 4):
+ for b in range(3):
+ w, h = 0.3 * bay, 0.66 * STOREY
+ x, y = (b + 0.35) * bay, st * STOREY + 0.18 * STOREY
+ arched(a, x, y, w, h, GLASS, surround=1.1)
+ k = (b + st * 2) % 4
+ if k != 2:
+ rect(a, x + 0.47 * w, y, x + 0.53 * w, y + 0.8 * h, FRAME * 0.8)
+ rect(a, x, y + 0.42 * h, x + w, y + 0.46 * h, FRAME * 0.8)
+ else:
+ arched(a, x, y, w, h, BROWN)
+ # sill
+ tint(a, x - 7, y - 5, x + w + 7, y, 1.09)
+ drips(a, 2000 + 10 * st + b, x - 4, x + w + 4, y - 6, 0.34 * STOREY, 0.13)
+ for b in range(3):
+ x, w, h = (b + 0.3) * bay, 0.4 * bay, 0.76 * STOREY
+ if b == 1:
+ arched(a, x, 0.06 * STOREY, w, h, BROWN, surround=1.1)
+ else:
+ arched(a, x, 0.06 * STOREY, w, h, GLASS * 1.3, surround=1.1)
+ rect(a, x, 0.06 * STOREY, x + w, 0.4 * STOREY, rgb(0.42, 0.34, 0.27))
+ street_dirt(a, 0.18)
+ plinth(a, rgb(0.80, 0.77, 0.72), 22, courses=2)
+ return np.clip(grain(a, 22, 0.05, 0.026, 0.10), 0, 1)
+
+
+def rubble_field(seed: int) -> np.ndarray:
+ d, ids, tone = voronoi_stones(seed, 190, 1.7)
+ stone = 0.86 + 0.13 * tone[ids]
+ joint = np.clip(d / 5.0, 0.0, 1.0)
+ return 0.74 + (stone - 0.74) * joint
+
+
+def small_opening(a, x, y, w, h, colour):
+ tint(a, x - 5, y - 5, x + w + 5, y + h + 5, 1.1)
+ rect(a, x, y, x + w, y + h, colour)
+
+
+def village_facade() -> np.ndarray:
+ """A hill village's rough limestone, 2 bays of 6 m: small deep windows, one plank door."""
+ a = np.repeat(rubble_field(31)[..., None], 3, axis=2) * rgb(1.0, 0.98, 0.94)
+ bay = N / 2
+ for st in range(1, 4):
+ for b in range(2):
+ small_opening(a, (b + 0.22 + 0.34 * ((st + b) % 2)) * bay, st * STOREY + 0.4 * STOREY, 0.2 * bay, 0.4 * STOREY,
+ BROWN if (st * 2 + b) % 3 == 0 else GLASS)
+ small_opening(a, 0.26 * bay, 0.05 * STOREY, 0.24 * bay, 0.72 * STOREY, TEAL * 0.9)
+ small_opening(a, 1.56 * bay, 0.42 * STOREY, 0.2 * bay, 0.36 * STOREY, GLASS)
+ street_dirt(a, 0.18)
+ plinth(a, rgb(0.78, 0.75, 0.70), 24)
+ return np.clip(grain(a, 32, 0.05, 0.022, 0.08), 0, 1)
+
+
+def mud_facade() -> np.ndarray:
+ """The plain's mud plaster, 2 bays of 6 m: hand-smoothed, patched, with small openings."""
+ a = fill(rgb(0.95, 0.94, 0.92))
+ a = a * (1.0 + 0.05 * noise(41, 1.4, (1.0, 2.0)) + 0.04 * noise(42, 2.1))[..., None]
+ bay = N / 2
+ for st in range(1, 4):
+ for b in range(2):
+ x, y = (b + 0.3 + 0.2 * ((st + b) % 2)) * bay, st * STOREY + 0.42 * STOREY
+ rect(a, x, y, x + 0.16 * bay, y + 0.36 * STOREY, BROWN * 0.7 if (b + st) % 3 == 1 else GLASS)
+ rect(a, 0.3 * bay, 0.04 * STOREY, 0.52 * bay, 0.74 * STOREY, BROWN)
+ rect(a, 1.5 * bay, 0.42 * STOREY, 1.66 * bay, 0.76 * STOREY, GLASS)
+ street_dirt(a, 0.16)
+ plinth(a, rgb(0.76, 0.72, 0.66), 28)
+ return np.clip(grain(a, 43, 0.035, 0.02, 0.10), 0, 1)
+
+
+def moshava_facade() -> np.ndarray:
+ """Whitewash, 3 bays of 4 m: windows with green shutters folded back, a panelled door."""
+ a = fill(rgb(0.96, 0.955, 0.94))
+ bay = N / 3
+ for st in range(1, 4):
+ for b in range(3):
+ w, h = 0.27 * bay, 0.54 * STOREY
+ shuttered(a, (b + 0.365) * bay, st * STOREY + 0.28 * STOREY, w, h, OLIVE, b)
+ drips(a, 5000 + 10 * st + b, (b + 0.365) * bay, (b + 0.365) * bay + w, st * STOREY + 0.28 * STOREY - 1, 0.3 * STOREY)
+ shuttered(a, 0.365 * bay, 0.28 * STOREY, 0.27 * bay, 0.54 * STOREY, OLIVE, 0)
+ door(a, 1.31 * bay, 0.05 * STOREY, 0.38 * bay, 0.78 * STOREY, TEAL)
+ shuttered(a, 2.365 * bay, 0.28 * STOREY, 0.27 * bay, 0.54 * STOREY, OLIVE, 0)
+ street_dirt(a, 0.18)
+ plinth(a, rgb(0.72, 0.70, 0.66), 26, courses=2)
+ return np.clip(grain(a, 51, 0.03, 0.016, 0.10), 0, 1)
+
+
+def plaster() -> np.ndarray:
+ a = grain(fill(rgb(0.96, 0.96, 0.95)), 61, 0.03, 0.016, 0.10)
+ return normalise(a, 0.93)
+
+
+def ashlar() -> np.ndarray:
+ # Rolled half a course, so the cell's edges fall inside a course: its seam is no joint.
+ a = np.roll(np.repeat(coursed_stone(71, 34)[..., None], 3, axis=2), 17, axis=0) * rgb(1.0, 0.985, 0.95)
+ return normalise(grain(a, 72, 0.03, 0.024), 0.90)
+
+
+def rubble() -> np.ndarray:
+ a = np.repeat(rubble_field(81)[..., None], 3, axis=2) * rgb(1.0, 0.98, 0.94)
+ return normalise(grain(a, 82, 0.04, 0.02), 0.88)
+
+
+def roof_tile() -> np.ndarray:
+ """Pantile rows (32 rows over 4 m, ridge up the cell), neutral so the vertex colour keeps the roof's own red; each tile its own
+ tone, a dark gap between rows. The gaps are the tile's colour there, not a shadow worked out for a sun."""
+ rows, cols = 32, 24
+ rng = np.random.default_rng(91)
+ tone = rng.uniform(0.82, 1.14, (rows, cols))
+ yy, xx = np.mgrid[0:N, 0:N].astype(np.float64)
+ ry, cx = yy / N * rows, xx / N * cols
+ r = np.floor(ry).astype(int) % rows
+ # Odd rows are half a tile along (the bond).
+ cx = (cx + 0.5 * (r % 2)) % cols
+ c = np.floor(cx).astype(int) % cols
+ fy, fx = ry - np.floor(ry), cx - np.floor(cx)
+ k = tone[r, c] * (0.86 + 0.14 * np.sin(np.pi * fx) ** 0.6) # the tile's crown a little paler than its side
+ k *= np.where(fy < 0.12, 0.62, 1.0)
+ a = np.roll(np.repeat(k[..., None], 3, axis=2), N // (2 * rows), axis=0) # the seam inside a row, not on a gap
+ return normalise(grain(a, 92, 0.05, 0.03), 0.84)
+
+
+def flat_roof() -> np.ndarray:
+ """A limed terrace: gravelled, patched where it was repaired, dark along the joints where the rain sits."""
+ a = fill(rgb(0.96, 0.95, 0.93))
+ a = grain(a, 101, 0.05, 0.035)
+ a *= (1.0 - 0.09 * np.clip((noise(102, 2.2) + 0.1) * 1.4, 0.0, 1.0))[..., None]
+ rng = np.random.default_rng(103)
+ for _ in range(9): # repairs: squares of newer lime, lighter or darker, soft enough to stay off the eye far away
+ x, y = rng.integers(0, N, 2)
+ w, h = rng.integers(36, 110, 2)
+ tint(a, x, min(y, N - h), x + w, min(y, N - h) + h, rng.uniform(0.97, 1.02))
+ for x in range(N // 4, N, N // 2):
+ a[:, x:x + 3] *= 0.90
+ a[x:x + 3, :] *= 0.90
+ return normalise(a, 0.90)
+
+
+def ribbon_glass() -> np.ndarray:
+ """A ribbon window's strip: steel casements, 8 bays over 6 m, some with a slatted wooden blind down. Dark, so it reads as
+ a band far off; the frames only show close up."""
+ a = fill(GLASS)
+ rng = np.random.default_rng(111)
+ bay = N // 8
+ for b in range(8):
+ x = b * bay
+ a[:, x:x + bay] *= rng.uniform(0.86, 1.2)
+ kind = rng.integers(0, 5)
+ if kind == 0:
+ slats(a, x, N * 0.5, bay, N * 0.5, rgb(0.46, 0.43, 0.38), step=24)
+ if kind == 1:
+ slats(a, x, 0, bay, N, rgb(0.40, 0.42, 0.40), step=24)
+ a[:, x:x + 5] = FRAME * 0.72
+ a[:, x + bay // 2 - 1:x + bay // 2 + 2] = FRAME * 0.55
+ a[:16, :] = FRAME * 0.72
+ a[-16:, :] = FRAME * 0.72
+ return np.clip(a, 0, 1)
+
+
+def balcony_rail() -> np.ndarray:
+ """A balcony's solid plastered parapet: a pale cap on top, a band of render, rain runs; the slab's drip edge at its foot."""
+ a = grain(fill(rgb(0.96, 0.96, 0.95)), 121, 0.025, 0.014, 0.14)
+ a[-44:, :] *= 1.03
+ a[:64, :] *= 0.88
+ return normalise(a, 0.93)
+
+
+def corrugated() -> np.ndarray:
+ """Corrugated iron, 24 ribs over 4 m, grey to rust. The ribs differ in tone only faintly."""
+ xx = np.arange(N)[None, :]
+ k = 0.93 + 0.07 * np.sin(2 * np.pi * xx * 24 / N)
+ a = np.repeat(np.repeat(k, N, axis=0)[..., None], 3, axis=2)
+ rust = 0.45 * np.clip((noise(131, 1.5, (0.6, 4.0)) + 0.1) * 1.6, 0, 1) # soft, and run down the sheets
+ rust = 0.5 * (rust + np.roll(rust, N // 2, axis=1))[..., None] # the same weight on both halves of the cell
+ a = a * (1 - rust) + a * rgb(0.92, 0.72, 0.58) * rust
+ return normalise(grain(a, 132, 0.04, 0.02), 0.88)
+
+
+def planks() -> np.ndarray:
+ """Upright boards, 16 over 4 m."""
+ rng = np.random.default_rng(141)
+ a = np.ones((N, N))
+ w = N // 16
+ tones = rng.uniform(0.84, 1.08, 16)
+ tones[8:] += tones[:8].mean() - tones[8:].mean() # the cell's two halves weigh the same: no drift across it
+ for i in range(16):
+ a[:, i * w:(i + 1) * w] = tones[i]
+ a[:, i * w:i * w + 2] = 0.58
+ a = np.roll(a, w // 2, axis=1) * (1.0 + 0.05 * noise(142, 1.2, (0.6, 6.0)))
+ return normalise(np.repeat(a[..., None], 3, axis=2), 0.88)
+
+
+def spare() -> np.ndarray:
+ return fill(rgb(1.0, 1.0, 1.0))
+
+
+PAINT = [white_city, stone_facade, village_facade, mud_facade, moshava_facade, plaster, ashlar, rubble, roof_tile, flat_roof,
+ ribbon_glass, balcony_rail, corrugated, planks, spare, spare]
+
+
+def main() -> int:
+ assert len(PAINT) == len(CELLS) == 16
+ sheet = np.zeros((4 * N, 4 * N, 3))
+ for i, paint in enumerate(PAINT):
+ cell = paint()
+ assert cell.shape == (N, N, 3)
+ # Painted y up; an image's first row is its top, and the atlas's layer 0 is its top left cell.
+ sheet[(i // 4) * N:(i // 4 + 1) * N, (i % 4) * N:(i % 4 + 1) * N] = cell[::-1]
+ px = (np.clip(sheet, 0.0, 1.0) * 255.0 + 0.5).astype(np.uint8)
+ OUT.parent.mkdir(parents=True, exist_ok=True)
+ Image.fromarray(px, "RGB").save(OUT, optimize=True)
+ print(f"{OUT.name} {OUT.stat().st_size} bytes sha256 {hashlib.sha256(OUT.read_bytes()).hexdigest()}")
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/changelog.d/2428-kit-atlas.md b/changelog.d/2428-kit-atlas.md
new file mode 100644
index 000000000..892c67e4e
--- /dev/null
+++ b/changelog.d/2428-kit-atlas.md
@@ -0,0 +1,6 @@
+### Changed
+- Map: every code-built town kit now has real surface detail from one shared atlas, painted by code: plastered White City
+ blocks with casements, blinds, doors and shopfronts; coursed stone with arched windows for Jerusalem, Jaffa and the old
+ towns; rough stone and mud plaster in the Arab villages; whitewash with green shutters and red tiled roofs in the moshavot and
+ kibbutzim; gravelled flat roofs, weathered walls and stone plinths. Same meshes and one material, so no town gains a draw
+ call (#2428).
diff --git a/docs/ai-disclosure.md b/docs/ai-disclosure.md
index e06e91586..b96d0ea46 100644
--- a/docs/ai-disclosure.md
+++ b/docs/ai-disclosure.md
@@ -105,6 +105,7 @@ This is not a licence clearance or a completed store content survey. owner-verif
| unity/Assets/Art/HexTiles/Props/arava_oasis_tamarisk/normal.jpg | ASSETS.yaml | Tal Heuberger, Tripo H3.1 through Higgsfield, 19 October 2026, text-generated concept; byte-identical copy of asset-sources/recovered-vegetation-20261031/hf_tamarisk/normal.jpg (route and task id: its provenance.json). SHA-256 1488db247a20ea6a18af5a4f2cda01fc25b3f85ce2a5818c026bcaa9b9c06235. | verified |
| unity/Assets/Art/HexTiles/Props/hula_swamp_papyrus/albedo.jpg | ASSETS.yaml | Tal Heuberger, Tripo H3.1 through Higgsfield, 19 October 2026, text-generated concept; byte-identical copy of asset-sources/recovered-vegetation-20261031/g25_papyrus/albedo.jpg (route and task id: its provenance.json). SHA-256 97307421442321d3a8e1fa2fd479fa49c755a775e485fffff9f67a1004dfcfd8. | verified |
| unity/Assets/Art/HexTiles/Props/hula_swamp_papyrus/normal.jpg | ASSETS.yaml | Tal Heuberger, Tripo H3.1 through Higgsfield, 19 October 2026, text-generated concept; byte-identical copy of asset-sources/recovered-vegetation-20261031/g25_papyrus/normal.jpg (route and task id: its provenance.json). SHA-256 641d6f6d0ea6eee7ff3eb2cb19f7ccbadfba044b68c5a2be261e51ffe56746a3. | verified |
+| unity/Assets/Art/Kits/kit_atlas.png | ASSETS.yaml | Painted entirely by code: uv run asset-sources/kit-atlas/make_kit_atlas.py (numpy, Pillow; fixed seeds, no input files, no photographs and no image model). Regenerating gives the same bytes. | verified |
| unity/Assets/Art/Settlements/Prototype/Models/*/*-far.png | ASSETS.yaml | Baked from Tal Heuberger's delivered colour maps (the <id>_basecolor.jpg files beside them, in the ASSETS.yaml rows above) by unity/Assets/Editor/FarModelLevels.cs: each far triangle's 8x8 texel cell of a 256 texel wide map samples the colour of the nearest point of the original surface. The <id>-far.json beside it records the source colour map's path and SHA-256. | verified |
| unity/Assets/Art/Settlements/Prototype/Models/b01-white-city-v2/b01-white-city-v2_basecolor.jpg | ASSETS.yaml | Tal Heuberger original offered in PR #507 at 3ef0a7a5a36887aee7a24fd11ddf722507695f3c, unity/Assets/Art/Settlements/Prototype/Models/b01-white-city-v2/b01-white-city-v2_basecolor.jpg. Raw and shipped SHA-256 in docs/original-models.json. Copied source byte for byte, including original geometry/clips or JPEG bytes. | verified |
| unity/Assets/Art/Settlements/Prototype/Models/b02a-tel-aviv-corner-block-v2/b02a-tel-aviv-corner-block-v2_basecolor.jpg | ASSETS.yaml | Tal Heuberger original offered in PR #507 at 3ef0a7a5a36887aee7a24fd11ddf722507695f3c, unity/Assets/Art/Settlements/Prototype/Models/b02a-tel-aviv-corner-block-v2/b02a-tel-aviv-corner-block-v2_basecolor.jpg. Raw and shipped SHA-256 in docs/original-models.json. Copied source byte for byte, including original geometry/clips or JPEG bytes. | verified |
diff --git a/docs/visual-v1.md b/docs/visual-v1.md
index 7259f58ac..1b9969a47 100644
--- a/docs/visual-v1.md
+++ b/docs/visual-v1.md
@@ -3597,3 +3597,25 @@ WebGL `?shot`, 1920x1080, main `5f8fa9fcd` against this grade on `14fcb0c3b` plu
- **HUD.** The top bar and date plate are pixel-identical between the two WebGL shots at gameplay03 (mean difference 0.00-0.01/255); the translucent help bar and legend move by 0.3 and 0.85/255 on average, and the minimap's frame by about 0.8/255 where map shows through. English and Hebrew composited frames were looked at, before and after. Label pills were looked at, not measured.
- **Cost: NOT MEASURED.** `?vprofile` needs `machine_lock.py --exclusive` and the lanes may not take it. By construction only LUT inputs changed (as in #38), but that is an argument, not a number; the sun and ambient are uniforms. Boot: NOT MEASURED. The web build, uncompressed, is 555 MB on both sides by `du`; `wasm` 65,092 KB and `data` 36,072 KB on this branch.
- **Seen, not changed.** Close views (hero06negev) show contour bands on the terrain before and after; not caused by this pass.
+
+## Issue #2428: one shared atlas for the town kits
+The kits drew vertex colours and a procedural window pattern. They now also sample one shared atlas,
+`unity/Assets/Art/Kits/kit_atlas.png`, painted by `asset-sources/kit-atlas/make_kit_atlas.py` (`uv run`; no input files, no
+image model, same bytes every run). It is a 4 x 4 sheet of 512 px cells imported as one `Texture2DArray` (16 layers), so a cell
+tiles and has its own mipmaps with no bleeding. The cells: five facades (White City, stone, hill village, mud plaster, moshava),
+plaster, ashlar, rubble, roof tile, flat roof, ribbon glass, balcony rail, corrugated iron, planks, and two spare white ones.
+- **Mesh:** the vertex layout, the meshes and the one material are as before, so no town gains a draw (`KITS ... draws=65` before
+ and after). The colour's alpha is now the surface, `KitMesh.Facade`: the layer + 1, times 17. uv0 is in cells; on a facade v
+ counts storeys, and `Kit.shader` lays out one ground storey under three repeating ones. A facade wall counts whole bays, so a
+ corner never cuts a window, and starts at a phase hashed from its position, so no random stream moves. Plain (trees, boats,
+ tents, the ma'abara's patched sheet) has no cell.
+- **Light:** the atlas is albedo only. Stains and street dust are dirt in the colour, not shadow; `KitAtlasTests` checks that a
+ solid cell has no brighter side. The shader's old contact darkening at a wall's foot stays.
+- **Far off:** mipmaps replace the window pattern's box filter; a wall fades to its mean with no moire. The atlas is
+ sampled with explicit gradients taken outside the branch, because `fwidth` inside it is undefined on WebGL 2.
+- **Ribbon windows** start one storey up, so the ground storey shows the facade's doors and shop.
+- **Size:** the build's `.data` gzips (level 6, the player built with `-compression disabled`) 1,316,744 bytes larger, about 3.2%
+ of the download, so the PR carries a nightly size budget line.
+- **Frame time, not measured to this document's standard:** `?vprofile` needs the exclusive lock, which this lane did not take. A
+ run under the shared lock at load 11-16, main against the branch, read gameplay03 23.53 -> 22.12 ms (spreads 2.93, 3.93) and
+ diorama02 25.78 -> 28.03 ms (spreads 1.56, 2.98): a noisy reading, not a cost.
diff --git a/unity/Assets/Art/Kits.meta b/unity/Assets/Art/Kits.meta
new file mode 100644
index 000000000..806ae9ec6
--- /dev/null
+++ b/unity/Assets/Art/Kits.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 0df7c15995a040e4bc94358c6f8f5127
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Art/Kits/kit_atlas.png b/unity/Assets/Art/Kits/kit_atlas.png
new file mode 100644
index 000000000..05c004348
Binary files /dev/null and b/unity/Assets/Art/Kits/kit_atlas.png differ
diff --git a/unity/Assets/Art/Kits/kit_atlas.png.meta b/unity/Assets/Art/Kits/kit_atlas.png.meta
new file mode 100644
index 000000000..6864addbc
--- /dev/null
+++ b/unity/Assets/Art/Kits/kit_atlas.png.meta
@@ -0,0 +1,130 @@
+fileFormatVersion: 2
+guid: 9094acea2187414c8667b0ab50412374
+TextureImporter:
+ internalIDToNameTable: []
+ externalObjects: {}
+ serializedVersion: 13
+ mipmaps:
+ mipMapMode: 0
+ enableMipMap: 1
+ sRGBTexture: 1
+ 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: 4
+ mipBias: 0
+ wrapU: 0
+ wrapV: 0
+ wrapW: 0
+ 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: 0
+ alphaIsTransparency: 0
+ spriteTessellationDetail: -1
+ textureType: 0
+ textureShape: 4
+ singleChannelComponent: 0
+ flipbookRows: 4
+ flipbookColumns: 4
+ 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: 1
+ compressionQuality: 100
+ 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: 100
+ crunchedCompression: 0
+ allowsAlphaSplitting: 0
+ overridden: 1
+ ignorePlatformSupport: 0
+ androidETC2FallbackOverride: 0
+ forceMaximumCompressionQuality_BC6H_BC7: 0
+ - serializedVersion: 4
+ buildTarget: WebGL
+ maxTextureSize: 2048
+ resizeAlgorithm: 0
+ textureFormat: -1
+ textureCompression: 1
+ compressionQuality: 100
+ crunchedCompression: 0
+ allowsAlphaSplitting: 0
+ overridden: 1
+ 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/Editor/MapMaterials.cs b/unity/Assets/Editor/MapMaterials.cs
index f4d0ee2ae..0cd182a27 100644
--- a/unity/Assets/Editor/MapMaterials.cs
+++ b/unity/Assets/Editor/MapMaterials.cs
@@ -16,6 +16,7 @@ namespace Statecraft.Game.EditorTools
public const string FramePath = Folder + "/MapFrame.mat";
public const string KitPath = Folder + "/Kit.mat";
public const string TreePath = Folder + "/Tree.mat";
+ public const string KitAtlasPath = "Assets/Art/Kits/kit_atlas.png"; // a Texture2DArray (#2428, make_kit_atlas.py)
public static void Create()
{
@@ -44,12 +45,15 @@ namespace Statecraft.Game.EditorTools
// mesh's vertex colours (MapBuilder.BuildFrame).
Make(FramePath, "Statecraft/MapFrame", null);
// Settlement kits and trees (art spike): Assets/Shaders/Kit.shader. Buildings are merged static meshes (no tint
- // jitter: each building's colour is in its vertices); trees are GPU-instanced and get a per-instance tint.
+ // jitter: each building's colour is in its vertices); trees are GPU-instanced and get a per-instance tint. Both carry
+ // the one shared town atlas (#2428); a material made here from scratch would otherwise have none.
+ var atlas = AssetDatabase.LoadAssetAtPath<Texture2DArray>(KitAtlasPath)
+ ?? throw new System.IO.FileNotFoundException("kit atlas missing (asset-sources/kit-atlas/make_kit_atlas.py)", KitAtlasPath);
var kit = Make(KitPath, "Statecraft/Kit", Color.white);
- kit.SetFloat("_Jitter", 0f);
+ kit.SetFloat("_Jitter", 0f); kit.SetTexture("_KitAtlas", atlas);
EditorUtility.SetDirty(kit);
var tree = Make(TreePath, "Statecraft/Kit", Color.white);
- tree.SetFloat("_Jitter", 0.16f); tree.SetFloat("_WindowDark", 0f);
+ tree.SetFloat("_Jitter", 0.16f); tree.SetTexture("_KitAtlas", atlas);
EditorUtility.SetDirty(tree);
AssetDatabase.SaveAssets();
}
diff --git a/unity/Assets/Materials/Kit.mat b/unity/Assets/Materials/Kit.mat
index 91d323b95..fd8062111 100644
--- a/unity/Assets/Materials/Kit.mat
+++ b/unity/Assets/Materials/Kit.mat
@@ -22,12 +22,14 @@ Material:
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
- m_TexEnvs: []
+ m_TexEnvs:
+ - _KitAtlas:
+ m_Texture: {fileID: 18700000, guid: 9094acea2187414c8667b0ab50412374, type: 3}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- - _CityWindowDark: 0.95
- _Jitter: 0
- - _WindowDark: 0.55
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
m_BuildTextureStacks: []
diff --git a/unity/Assets/Materials/Tree.mat b/unity/Assets/Materials/Tree.mat
index 7ba4376cf..361214fec 100644
--- a/unity/Assets/Materials/Tree.mat
+++ b/unity/Assets/Materials/Tree.mat
@@ -22,11 +22,14 @@ Material:
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
- m_TexEnvs: []
+ m_TexEnvs:
+ - _KitAtlas:
+ m_Texture: {fileID: 18700000, guid: 9094acea2187414c8667b0ab50412374, type: 3}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _Jitter: 0.16
- - _WindowDark: 0
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
m_BuildTextureStacks: []
diff --git a/unity/Assets/Scripts/Map/Kits/KitMesh.cs b/unity/Assets/Scripts/Map/Kits/KitMesh.cs
index ffb823f39..6ffa6a45e 100644
--- a/unity/Assets/Scripts/Map/Kits/KitMesh.cs
+++ b/unity/Assets/Scripts/Map/Kits/KitMesh.cs
@@ -5,13 +5,20 @@ using UnityEngine.Rendering;
namespace Statecraft.Game.Map.Kits
{
- /// <summary>Facade styles, carried in the vertex colour's alpha and read by Statecraft/Kit (Kit.shader): which window
- /// pattern a wall gets. Roofs, domes and trees are Plain.</summary>
- public enum Facade : byte { Plain = 0, Stone = 64, Village = 128, WhiteCity = 255 }
+ /// <summary>A surface, carried in the vertex colour's alpha and read by Statecraft/Kit (Kit.shader): which cell of the one
+ /// shared atlas (#2428, Art/Kits/kit_atlas.png, asset-sources/kit-atlas/make_kit_atlas.py) a face shows. The alpha is the
+ /// atlas layer + 1, times 17, so it survives the vertex's 8 bits. The first five cells are facades: windows and doors over
+ /// a ground storey. Plain (trees, boats, tents, the ma'abara's patched sheet) has no cell and draws its vertex colour.</summary>
+ public enum Facade : byte
+ {
+ Plain = 0, WhiteCity = 17, Stone = 34, Village = 51, Mud = 68, Moshava = 85, Plaster = 102, Ashlar = 119, Rubble = 136,
+ RoofTile = 153, FlatRoof = 170, RibbonGlass = 187, BalconyRail = 204, Corrugated = 221, Planks = 238,
+ }
/// <summary>Grows one mesh from procedural parts (boxes, roofs, domes, towers, crowns). Vertex layout: position, normal,
- /// colour (sRGB albedo, alpha = <see cref="Facade"/>), uv0 = a wall's (along, up) position in real metres before the
- /// symbolic scale, so the shader draws storeys and windows at their real proportions on symbolic-size buildings.</summary>
+ /// colour (sRGB albedo, alpha = <see cref="Facade"/>), uv0 = where on that surface's atlas cell the vertex lies, from its
+ /// real size before the symbolic scale (<see cref="Tile"/>), so storeys, tiles and courses keep their real proportions on
+ /// symbolic-size buildings. u counts cells; v counts cells, or on a facade storeys above the wall's ground level.</summary>
public sealed class KitMesh
{
readonly List<Vector3> pos = new List<Vector3>();
@@ -21,6 +28,48 @@ namespace Statecraft.Game.Map.Kits
readonly List<int> tri = new List<int>();
public int VertexCount => pos.Count;
+ /// <summary>The vertex colours and uvs so far (test aids: ToMesh's upload drops the CPU copy).</summary>
+ internal IReadOnlyList<Color32> Colours => col;
+ internal IReadOnlyList<Vector2> Uvs => uv;
+
+ /// <summary>A storey (real m), as everywhere in the kits.</summary>
+ public const float StoreyM = 3.3f;
+ /// <summary>A facade cell's width (real m); it holds a whole number of the facade's <see cref="BayM"/>.</summary>
+ public const float FacadeCellM = 12f;
+
+ /// <summary>The real metres one atlas cell covers on this surface, across and up (make_kit_atlas.py's CELLS). On a facade
+ /// the height is one storey, since Kit.shader lays out a facade's storeys itself.</summary>
+ public static Vector2 Tile(Facade f)
+ {
+ switch (f)
+ {
+ case Facade.WhiteCity: case Facade.Stone: case Facade.Village: case Facade.Mud: case Facade.Moshava:
+ return new Vector2(FacadeCellM, StoreyM);
+ case Facade.Plaster: return new Vector2(12f, 12f);
+ case Facade.Ashlar: return new Vector2(6f, 6f);
+ case Facade.FlatRoof: return new Vector2(16f, 16f);
+ case Facade.RibbonGlass: return new Vector2(6f, 1.2f);
+ case Facade.BalconyRail: return new Vector2(12f, 1.25f);
+ default: return new Vector2(4f, 4f);
+ }
+ }
+
+ /// <summary>A facade's window bay (real m), or 0 on a surface with no bays: a wall counts whole bays, so a corner never
+ /// cuts a window.</summary>
+ public static float BayM(Facade f) => f == Facade.WhiteCity ? 3f : f == Facade.Stone || f == Facade.Moshava ? 4f : f == Facade.Village || f == Facade.Mud ? 6f : 0f;
+
+ /// <summary>The plain surface that goes with a facade: its parapets, gable ends and the like, where no window belongs.</summary>
+ public static Facade Solid(Facade f) => f == Facade.Stone ? Facade.Ashlar : f == Facade.Village ? Facade.Rubble
+ : f == Facade.WhiteCity || f == Facade.Moshava || f == Facade.Mud ? Facade.Plaster : f;
+
+ /// <summary>A building's own start along its surface, in whole bays (whole cells without bays), so walls of one size do not
+ /// all show the same stain and the same shutters. From the position alone: no random stream moves.</summary>
+ static float Phase(float x, float z, int salt, float cells)
+ {
+ uint h = (uint)Mathf.RoundToInt(x) * 73856093u ^ (uint)Mathf.RoundToInt(z) * 19349663u ^ (uint)salt * 83492791u;
+ h ^= h >> 13; h *= 1274126177u; h ^= h >> 16;
+ return (h % 64u) * cells;
+ }
// ---- Issue #659: the close mesh (owner ruling on #700: "Models up close only") --------------------------------
// Up close the towns' buildings are Tal Heuberger's models (TownModelLayer); far off they are this mesh's kit buildings, as
// before. The close mesh is this mesh without its buildings (their vertex and index spans, CutStart/CutEnd), plus
@@ -258,6 +307,14 @@ namespace Statecraft.Game.Map.Kits
tri.Add(i); tri.Add(i + 1); tri.Add(i + 2);
}
+ /// <summary>A flat-shaded triangle with a uv per corner, clockwise seen from its front.</summary>
+ public void Triangle(Vector3 a, Vector3 b, Vector3 c, Color32 colour, Vector2 ta, Vector2 tb, Vector2 tc)
+ {
+ var n = Vector3.Cross(b - a, c - a).normalized;
+ int i = V(a, n, colour, ta); V(b, n, colour, tb); V(c, n, colour, tc);
+ tri.Add(i); tri.Add(i + 1); tri.Add(i + 2);
+ }
+
/// <summary>The walls (and, unless <paramref name="roofed"/>, the flat roof) of a box: footprint centred on
/// (<paramref name="x"/>, <paramref name="z"/>), <paramref name="w"/> wide along its own x after a yaw of
/// <paramref name="yawDeg"/>, <paramref name="d"/> deep; walls from <paramref name="bottom"/> (sunk into the slope) to
@@ -265,25 +322,35 @@ namespace Statecraft.Game.Map.Kits
/// metres for the facade uv (the symbolic scale). With <paramref name="parapet"/> above 0 and a flat roof, a plastered
/// rim stands round the roof's edge (Parapet).</summary>
public void Box(float x, float z, float yawDeg, float w, float d, float bottom, float ground, float h, Color32 wall, Color32 roof,
- Facade facade, float metresPerReal, bool roofed = false, float parapet = 0f, float parapetThickness = 0f)
+ Facade facade, float metresPerReal, bool roofed = false, float parapet = 0f, float parapetThickness = 0f, Facade? roofSurface = null)
{
var c = Corners(x, z, yawDeg, w, d);
float top = ground + h;
var wallC = wall; wallC.a = (byte)facade;
- float vb = (bottom - ground) / metresPerReal, vt = h / metresPerReal;
+ var tile = Tile(facade);
+ float vb = (bottom - ground) / metresPerReal / tile.y, vt = h / metresPerReal / tile.y;
+ float bay = BayM(facade), step = bay > 0f ? bay / tile.x : 1f;
for (int i = 0; i < 4; i++)
{
var a = c[i]; var b = c[(i + 1) % 4];
- float len = (b - a).magnitude / metresPerReal;
+ // A facade's wall counts whole bays (at least one), stretched a little to fit; anything else runs in real metres.
+ float len = (b - a).magnitude / metresPerReal / tile.x;
+ if (bay > 0f) len = Mathf.Max(1f, Mathf.Round(len / step)) * step;
+ float u0 = Phase(x, z, i, step);
Face(new Vector3(a.x, bottom, a.y), new Vector3(a.x, top, a.y), new Vector3(b.x, top, b.y), new Vector3(b.x, bottom, b.y), wallC,
- new Vector2(0, vb), new Vector2(0, vt), new Vector2(len, vt), new Vector2(len, vb));
+ new Vector2(u0, vb), new Vector2(u0, vt), new Vector2(u0 + len, vt), new Vector2(u0 + len, vb));
}
if (!roofed)
{
- var r = roof; r.a = 0;
+ // A flat roof is limed, unless the part is Plain (a boat's deck) or says otherwise (a hut's tin).
+ var top2 = roofSurface ?? (facade == Facade.Plain ? Facade.Plain : Facade.FlatRoof);
+ var r = roof; r.a = (byte)top2;
+ var cell = Tile(top2);
+ float ru = w / metresPerReal / cell.x, rv = d / metresPerReal / cell.y, r0 = Phase(x, z, 4, 1f);
Face(new Vector3(c[0].x, top, c[0].y), new Vector3(c[3].x, top, c[3].y), new Vector3(c[2].x, top, c[2].y), new Vector3(c[1].x, top, c[1].y), r,
- Vector2.zero, Vector2.zero, Vector2.zero, Vector2.zero);
- if (parapet > 0f && 2f * parapetThickness < Mathf.Min(w, d)) Parapet(c, Corners(x, z, yawDeg, w - 2f * parapetThickness, d - 2f * parapetThickness), top, parapet, wall);
+ new Vector2(r0, r0), new Vector2(r0, r0 + rv), new Vector2(r0 + ru, r0 + rv), new Vector2(r0 + ru, r0));
+ if (parapet > 0f && 2f * parapetThickness < Mathf.Min(w, d))
+ Parapet(c, Corners(x, z, yawDeg, w - 2f * parapetThickness, d - 2f * parapetThickness), top, parapet, wall, Solid(facade), metresPerReal);
}
}
@@ -292,17 +359,20 @@ namespace Statecraft.Game.Map.Kits
/// <paramref name="inner"/> (both as Corners gives them). Its outer face continues the wall upwards but is Plain (no
/// window rows), so it reads as a light band at the roof's edge; its inner face looks onto the roof; its top is one
/// ring of 8 vertices. 40 vertices in all.</summary>
- void Parapet(Vector2[] outer, Vector2[] inner, float roofY, float height, Color32 colour)
+ void Parapet(Vector2[] outer, Vector2[] inner, float roofY, float height, Color32 colour, Facade surface, float metresPerReal)
{
- colour.a = (byte)Facade.Plain;
+ colour.a = (byte)surface;
float y = roofY + height;
+ var tile = Tile(surface);
+ float tv = height / metresPerReal / tile.y;
Vector3 P(Vector2 q, float h) => new Vector3(q.x, h, q.y);
for (int i = 0; i < 4; i++)
{
int j = (i + 1) % 4;
// Outside (as Box's walls), then inside: the same edge reversed, so it faces the roof.
- Face(P(outer[i], roofY), P(outer[i], y), P(outer[j], y), P(outer[j], roofY), colour, Vector2.zero, Vector2.zero, Vector2.zero, Vector2.zero);
- Face(P(inner[j], roofY), P(inner[j], y), P(inner[i], y), P(inner[i], roofY), colour, Vector2.zero, Vector2.zero, Vector2.zero, Vector2.zero);
+ float to = (outer[j] - outer[i]).magnitude / metresPerReal / tile.x, ti = (inner[j] - inner[i]).magnitude / metresPerReal / tile.x;
+ Face(P(outer[i], roofY), P(outer[i], y), P(outer[j], y), P(outer[j], roofY), colour, Vector2.zero, new Vector2(0f, tv), new Vector2(to, tv), new Vector2(to, 0f));
+ Face(P(inner[j], roofY), P(inner[j], y), P(inner[i], y), P(inner[i], roofY), colour, Vector2.zero, new Vector2(0f, tv), new Vector2(ti, tv), new Vector2(ti, 0f));
}
int o = pos.Count;
for (int i = 0; i < 4; i++) V(P(outer[i], y), Vector3.up, colour, Vector2.zero);
@@ -313,37 +383,52 @@ namespace Statecraft.Game.Map.Kits
/// <summary>A gable roof on a w x d box whose walls end at <paramref name="eaves"/>: the ridge runs along the longer
/// side, <paramref name="rise"/> above the eaves, with a small overhang.</summary>
- public void Gable(float x, float z, float yawDeg, float w, float d, float eaves, float rise, Color32 roof, Color32 gableWall)
+ public void Gable(float x, float z, float yawDeg, float w, float d, float eaves, float rise, Color32 roof, Color32 gableWall,
+ float metresPerReal = 1f, Facade surface = Facade.RoofTile, Facade gableSurface = Facade.Plaster)
{
if (d > w) { yawDeg += 90f; (w, d) = (d, w); }
float ow = w * 1.06f, od = d * 1.12f;
var c = Corners(x, z, yawDeg, ow, od); // 0 (-w,-d), 1 (+w,-d), 2 (+w,+d), 3 (-w,+d) in local axes
var r0 = (c[0] + c[3]) * 0.5f; var r1 = (c[1] + c[2]) * 0.5f; // ridge ends
- var g = gableWall; g.a = 0; var rf = roof; rf.a = 0;
+ var g = gableWall; g.a = (byte)gableSurface; var rf = roof; rf.a = (byte)surface;
Vector3 P(Vector2 p, float y) => new Vector3(p.x, y, p.y);
- Face(P(c[0], eaves), P(r0, eaves + rise), P(r1, eaves + rise), P(c[1], eaves), rf, Vector2.zero, Vector2.zero, Vector2.zero, Vector2.zero);
- Face(P(c[2], eaves), P(r1, eaves + rise), P(r0, eaves + rise), P(c[3], eaves), rf, Vector2.zero, Vector2.zero, Vector2.zero, Vector2.zero);
- Triangle(P(c[1], eaves), P(r1, eaves + rise), P(c[2], eaves), g);
- Triangle(P(c[3], eaves), P(r0, eaves + rise), P(c[0], eaves), g);
+ // A slope's uv: along the ridge and up the slope, so the tile rows run with the eaves.
+ var tile = Tile(surface);
+ float us = ow / metresPerReal / tile.x, vs = Mathf.Sqrt(rise * rise + 0.25f * od * od) / metresPerReal / tile.y, p0 = Phase(x, z, 5, 1f);
+ Face(P(c[0], eaves), P(r0, eaves + rise), P(r1, eaves + rise), P(c[1], eaves), rf,
+ new Vector2(p0, 0f), new Vector2(p0, vs), new Vector2(p0 + us, vs), new Vector2(p0 + us, 0f));
+ Face(P(c[2], eaves), P(r1, eaves + rise), P(r0, eaves + rise), P(c[3], eaves), rf,
+ new Vector2(p0, 0f), new Vector2(p0, vs), new Vector2(p0 + us, vs), new Vector2(p0 + us, 0f));
+ var gt = Tile(gableSurface);
+ float gu = od / metresPerReal / gt.x, gv = rise / metresPerReal / gt.y;
+ var ga = Vector2.zero; var gb = new Vector2(0.5f * gu, gv); var gc = new Vector2(gu, 0f);
+ Triangle(P(c[1], eaves), P(r1, eaves + rise), P(c[2], eaves), g, ga, gb, gc);
+ Triangle(P(c[3], eaves), P(r0, eaves + rise), P(c[0], eaves), g, ga, gb, gc);
}
/// <summary>A four-sided pyramid cap (a clock tower's or a tiled hip roof).</summary>
- public void Pyramid(float x, float z, float yawDeg, float w, float d, float y, float rise, Color32 colour)
+ public void Pyramid(float x, float z, float yawDeg, float w, float d, float y, float rise, Color32 colour, float metresPerReal = 1f,
+ Facade surface = Facade.RoofTile)
{
- var c = Corners(x, z, yawDeg, w, d); var apex = new Vector3(x, y + rise, z); colour.a = 0;
+ var c = Corners(x, z, yawDeg, w, d); var apex = new Vector3(x, y + rise, z); colour.a = (byte)surface;
+ var tile = Tile(surface);
for (int i = 0; i < 4; i++)
{
var a = c[i]; var b = c[(i + 1) % 4];
- Triangle(new Vector3(a.x, y, a.y), apex, new Vector3(b.x, y, b.y), colour);
+ float len = (b - a).magnitude / metresPerReal / tile.x;
+ float slope = Vector3.Distance(new Vector3(0.5f * (a.x + b.x), y, 0.5f * (a.y + b.y)), apex) / metresPerReal / tile.y;
+ Triangle(new Vector3(a.x, y, a.y), apex, new Vector3(b.x, y, b.y), colour, Vector2.zero, new Vector2(0.5f * len, slope), new Vector2(len, 0f));
}
}
/// <summary>A smooth dome (a mosque's or a house's) of radius r standing on y: a hemisphere, or, with
/// <paramref name="rise"/> under 1, a lower cap rising rise x r (a village house's shallow vault).</summary>
- public void Dome(float x, float z, float y, float r, Color32 colour, int segments = 10, int rings = 4, float rise = 1f)
+ public void Dome(float x, float z, float y, float r, Color32 colour, int segments = 10, int rings = 4, float rise = 1f, float metresPerReal = 1f,
+ Facade surface = Facade.FlatRoof)
{
- colour.a = 0;
+ colour.a = (byte)surface;
int first = pos.Count;
+ var tile = Tile(surface);
for (int j = 0; j <= rings; j++)
{
float phi = Mathf.PI * 0.5f * j / rings;
@@ -353,7 +438,8 @@ namespace Statecraft.Game.Map.Kits
var n = new Vector3(Mathf.Cos(phi) * Mathf.Cos(th), Mathf.Sin(phi), Mathf.Cos(phi) * Mathf.Sin(th));
// An ellipsoid's normal: the sphere's with its height scaled by 1 / rise (unchanged for a hemisphere).
var nn = rise == 1f ? n : new Vector3(n.x * rise, n.y, n.z * rise).normalized;
- V(new Vector3(x, y, z) + new Vector3(n.x * r, n.y * r * rise, n.z * r), nn, colour, Vector2.zero);
+ V(new Vector3(x, y, z) + new Vector3(n.x * r, n.y * r * rise, n.z * r), nn, colour,
+ new Vector2(th * r / metresPerReal / tile.x, phi * r / metresPerReal / tile.y));
}
}
for (int j = 0; j < rings; j++)
@@ -370,13 +456,14 @@ namespace Statecraft.Game.Map.Kits
{
colour.a = (byte)facade;
int first = pos.Count;
+ var tile = Tile(facade);
for (int i = 0; i <= sides; i++)
{
float th = 2f * Mathf.PI * i / sides;
var n = new Vector3(Mathf.Cos(th), 0f, Mathf.Sin(th));
- float u = th * r0 / metresPerReal;
+ float u = th * r0 / metresPerReal / tile.x;
V(b0 + n * r0, n, colour, new Vector2(u, 0f));
- V(b1 + n * r1, n, colour, new Vector2(u, (b1.y - b0.y) / metresPerReal));
+ V(b1 + n * r1, n, colour, new Vector2(u, (b1.y - b0.y) / metresPerReal / tile.y));
}
for (int i = 0; i < sides; i++)
{
diff --git a/unity/Assets/Scripts/Map/Kits/SettlementKits.Camp.cs b/unity/Assets/Scripts/Map/Kits/SettlementKits.Camp.cs
index 7fda1091e..48fafa0a3 100644
--- a/unity/Assets/Scripts/Map/Kits/SettlementKits.Camp.cs
+++ b/unity/Assets/Scripts/Map/Kits/SettlementKits.Camp.cs
@@ -39,7 +39,7 @@ namespace Statecraft.Game.Map.Kits
{
var p = At(u, v);
var (bottom, top) = GroundSpan(p, yaw, w * m, d * m, ground, m);
- km.Box(p.x, p.y, yaw, w * m, d * m, bottom, top, CampFenceH * m, fence, fence, Facade.Plain, m);
+ km.Box(p.x, p.y, yaw, w * m, d * m, bottom, top, CampFenceH * m, fence, fence, Facade.Planks, m, roofSurface: Facade.Planks);
}
Record(s.Id, "camp_yard", c, yaw, 2f * half, 2f * half, CampFenceH * m, fence);
// The barracks: 10 x 3.6 m, timber walls under tin roofs, in two columns (u = -7, 7) of three rows (v = -10, -4,
@@ -50,7 +50,7 @@ namespace Statecraft.Game.Map.Kits
{
var p = At(u, v); float w = 10f * m, d = 3.6f * m, bh = 3f * m;
var (bottom, top) = GroundSpan(p, yaw, w, d, ground, m);
- km.Box(p.x, p.y, yaw, w, d, bottom, top, bh, timber, tin, Facade.Plain, m);
+ km.Box(p.x, p.y, yaw, w, d, bottom, top, bh, timber, tin, Facade.Planks, m, roofSurface: Facade.Corrugated);
Record(s.Id, "barracks", p, yaw, w, d, bh, timber);
n++;
}
diff --git a/unity/Assets/Scripts/Map/Kits/SettlementKits.Kibbutz.cs b/unity/Assets/Scripts/Map/Kits/SettlementKits.Kibbutz.cs
index e7bb7fbbc..ccc2c6623 100644
--- a/unity/Assets/Scripts/Map/Kits/SettlementKits.Kibbutz.cs
+++ b/unity/Assets/Scripts/Map/Kits/SettlementKits.Kibbutz.cs
@@ -79,8 +79,8 @@ namespace Statecraft.Game.Map.Kits
// Issue #659: up close the hall is Tal Heuberger's b07 dining hall, the clerestory's height included; far off, the kit's.
AddModel(owner, TownModel.B07DiningHall, p, yaw, w, d, h + 1.2f * m, bottom, top, km, m, exactHeight: false, flip: false);
var cut = km.CutStart();
- km.Box(p.x, p.y, yaw, w, d, bottom, top, h, wall, roof, Facade.Plain, m);
- km.Box(p.x, p.y, yaw, w * 0.8f, d * 0.4f, top + h - 0.3f * m, top + h, 1.2f * m, wall, roof, Facade.Plain, m);
+ km.Box(p.x, p.y, yaw, w, d, bottom, top, h, wall, roof, Facade.Plaster, m);
+ km.Box(p.x, p.y, yaw, w * 0.8f, d * 0.4f, top + h - 0.3f * m, top + h, 1.2f * m, wall, roof, Facade.Plaster, m);
km.CutEnd(cut);
Record(owner, "dining_hall", p, yaw, w, d, h, wall);
kibbutzHalls++;
@@ -98,8 +98,8 @@ namespace Statecraft.Game.Map.Kits
{
var wall = Jitter(C(0.80f, 0.76f, 0.68f), ref rnd, 0.04f);
var roof = Jitter(C(0.47f, 0.48f, 0.49f), ref rnd, 0.05f);
- km.Box(p.x, p.y, yaw, b.w, b.d, bottom, top, b.h, wall, roof, Facade.Plain, m, roofed: true);
- km.Gable(p.x, p.y, yaw, b.w, b.d, top + b.h, Mathf.Min(b.w, b.d) * 0.3f, roof, wall);
+ km.Box(p.x, p.y, yaw, b.w, b.d, bottom, top, b.h, wall, roof, Facade.Plaster, m, roofed: true);
+ km.Gable(p.x, p.y, yaw, b.w, b.d, top + b.h, Mathf.Min(b.w, b.d) * 0.3f, roof, wall, m, Facade.Corrugated);
farmSheds++;
return wall;
}
@@ -107,8 +107,8 @@ namespace Statecraft.Game.Map.Kits
{
var wall = Jitter(C(0.93f, 0.92f, 0.87f), ref rnd, 0.03f);
var roof = Jitter(C(0.74f, 0.31f, 0.20f), ref rnd, 0.08f);
- km.Box(p.x, p.y, yaw, b.w, b.d, bottom, top, b.h, wall, roof, Facade.Village, m, roofed: true);
- km.Gable(p.x, p.y, yaw, b.w, b.d, top + b.h, Mathf.Min(b.w, b.d) * 0.42f, roof, wall);
+ km.Box(p.x, p.y, yaw, b.w, b.d, bottom, top, b.h, wall, roof, Facade.Moshava, m, roofed: true);
+ km.Gable(p.x, p.y, yaw, b.w, b.d, top + b.h, Mathf.Min(b.w, b.d) * 0.42f, roof, wall, m);
return wall;
}
}
diff --git a/unity/Assets/Scripts/Map/Kits/SettlementKits.Landmarks.cs b/unity/Assets/Scripts/Map/Kits/SettlementKits.Landmarks.cs
index 31dca0c13..ddd57f8c2 100644
--- a/unity/Assets/Scripts/Map/Kits/SettlementKits.Landmarks.cs
+++ b/unity/Assets/Scripts/Map/Kits/SettlementKits.Landmarks.cs
@@ -116,8 +116,8 @@ namespace Statecraft.Game.Map.Kits
float y = ground.Y(p.x, p.y);
var start = km.CutStart();
km.Box(p.x, p.y, 15f, 5f * m, 5f * m, y - 2f * m, y, 24f * m, stone, stone, Facade.Stone, m, roofed: true);
- km.Box(p.x, p.y, 15f, 4f * m, 4f * m, y + 24f * m, y + 24f * m, 4f * m, C(0.90f, 0.82f, 0.64f), stone, Facade.Plain, m, roofed: true);
- km.Pyramid(p.x, p.y, 15f, 4.4f * m, 4.4f * m, y + 28f * m, 3.5f * m, C(0.55f, 0.47f, 0.40f));
+ km.Box(p.x, p.y, 15f, 4f * m, 4f * m, y + 24f * m, y + 24f * m, 4f * m, C(0.90f, 0.82f, 0.64f), stone, Facade.Ashlar, m, roofed: true);
+ km.Pyramid(p.x, p.y, 15f, 4.4f * m, 4.4f * m, y + 28f * m, 3.5f * m, C(0.55f, 0.47f, 0.40f), m);
AtWorldScale(s.Id, "clock_tower", km, start, start, "clock_tower", 15f, p, y, m);
Record(s.Id, "clock_tower", p, 15f, 5f * m, 5f * m, 31.5f * m, stone);
n++;
@@ -166,7 +166,7 @@ namespace Statecraft.Game.Map.Kits
var cur = c + new Vector2(Mathf.Cos(a), Mathf.Sin(a)) * r;
var mid = (prev + cur) * 0.5f; var dir = cur - prev;
float yaw = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
- km.Box(mid.x, mid.y, yaw, dir.magnitude * 1.08f, 5f * m, sea - 2f * m, sea, 2.2f * m, stone, stone, Facade.Plain, m);
+ km.Box(mid.x, mid.y, yaw, dir.magnitude * 1.08f, 5f * m, sea - 2f * m, sea, 2.2f * m, stone, stone, Facade.Ashlar, m);
Record("jaffa", "breakwater", mid, yaw, dir.magnitude * 1.08f, 5f * m, 2.2f * m, stone); // SeaCraft keeps its boats off it
prev = cur;
}
@@ -229,7 +229,7 @@ namespace Statecraft.Game.Map.Kits
if (lots.Free(pc, 0.5f * Mathf.Sqrt(pw * pw + pl * pl))) // first in the Old City
{
var (pb, pg) = GroundSpan(pc, 0f, pw, pl, ground, 1f);
- km.Box(pc.x, pc.y, 0f, pw, pl, pb, pg, 80f, C(0.80f, 0.72f, 0.58f), paving, Facade.Plain, 10f);
+ km.Box(pc.x, pc.y, 0f, pw, pl, pb, pg, 80f, C(0.80f, 0.72f, 0.58f), paving, Facade.Ashlar, 10f);
// Its lots: discs over the platform, each clear of the routes.
for (float u = -pw * 0.5f + 150f; u < pw * 0.5f; u += 260f)
for (float v = -pl * 0.5f + 150f; v < pl * 0.5f; v += 260f)
@@ -252,7 +252,7 @@ namespace Statecraft.Game.Map.Kits
km.Shaft(new Vector3(dc.x, deck + 5f * kv, dc.y), new Vector3(dc.x, deck + 11f * kv, dc.y), rOct, rOct, tiles, 8);
km.Cone(new Vector3(dc.x, deck + 11f * kv, dc.y), rOct, 2.5f * k, C(0.62f, 0.62f, 0.60f), 8);
km.Shaft(new Vector3(dc.x, deck + 11f * kv, dc.y), new Vector3(dc.x, deck + 19f * kv, dc.y), 11f * k, 11f * k, tiles, 16);
- km.Dome(dc.x, dc.y, deck + 19f * kv, 11f * k, lead, 16, 6);
+ km.Dome(dc.x, dc.y, deck + 19f * kv, 11f * k, lead, 16, 6, surface: Facade.Plain);
AtWorldScale(s.Id, "dome_of_the_rock", km, start, dc, deck, kv);
Record(s.Id, "dome_of_the_rock", dc, 0f, 2f * rOct, 2f * rOct, 19f * kv + 11f * k, tiles);
n++;
@@ -263,7 +263,7 @@ namespace Statecraft.Game.Map.Kits
var ac = pc + new Vector2(0f, -0.5f * pl + 0.5f * al + 40f);
start = km.CutStart();
km.Box(ac.x, ac.y, 0f, aw, al, deck - 60f, deck, 300f, C(0.84f, 0.77f, 0.62f), C(0.70f, 0.70f, 0.68f), Facade.Stone, 16f);
- km.Dome(ac.x, ac.y + 0.3f * al, deck + 280f, 0.45f * aw, C(0.55f, 0.56f, 0.57f), 12, 5);
+ km.Dome(ac.x, ac.y + 0.3f * al, deck + 280f, 0.45f * aw, C(0.55f, 0.56f, 0.57f), 12, 5, surface: Facade.Plain);
AtWorldScale(s.Id, "al_aqsa", km, start, ac, deck, 16f);
Record(s.Id, "al_aqsa", ac, 0f, aw, al, 300f, C(0.84f, 0.77f, 0.62f));
n++;
@@ -302,8 +302,8 @@ namespace Statecraft.Game.Map.Kits
if (gap[i]) continue;
var (bottom, gy) = GroundSpan(mid, yaw, len, wallT, ground, 1f);
var start = km.CutStart();
- km.Box(mid.x, mid.y, yaw, len * 1.01f, wallT, bottom, gy, wallH, stone, top, Facade.Plain, KitScale.Houses);
- km.Box(mid.x, mid.y, yaw, len * 1.01f, wallT * 0.35f, gy + wallH, gy + wallH, 90f, top, top, Facade.Plain, KitScale.Houses); // the parapet
+ km.Box(mid.x, mid.y, yaw, len * 1.01f, wallT, bottom, gy, wallH, stone, top, Facade.Ashlar, KitScale.Houses);
+ km.Box(mid.x, mid.y, yaw, len * 1.01f, wallT * 0.35f, gy + wallH, gy + wallH, 90f, top, top, Facade.Ashlar, KitScale.Houses); // the parapet
AtWorldScale(s.Id, "walls", km, start, mid, gy, KitScale.Houses, yaw, keepLength: true);
lots.Add(new Lot { c = mid, r = pieceR, id = s.Id });
built++;
@@ -319,7 +319,7 @@ namespace Statecraft.Game.Map.Kits
if (ground.OnRoute(t, 0.5f * tw + 10f)) continue; // the tower itself stays off the road
var (tb, ty) = GroundSpan(t, yaw, tw, tw, ground, 1f);
var tower = km.CutStart();
- km.Box(t.x, t.y, yaw, tw, tw, tb, ty, th, stone, top, byRoad ? Facade.Stone : Facade.Plain, KitScale.Houses);
+ km.Box(t.x, t.y, yaw, tw, tw, tb, ty, th, stone, top, byRoad ? Facade.Stone : Facade.Ashlar, KitScale.Houses);
AtWorldScale(s.Id, "wall_tower", km, tower, t, ty, KitScale.Houses);
}
}
@@ -358,7 +358,7 @@ namespace Statecraft.Game.Map.Kits
var start = km.CutStart();
km.Box(cp.x, cp.y, 0f, 18f * m, 16f * m, y - 2f * m, y, 12f * m, stone, top, Facade.Stone, m);
km.Box(cp.x - 5f * m, cp.y + 4f * m, 0f, 7f * m, 7f * m, y + 12f * m - 1f, y + 12f * m, 6f * m, stone, top, Facade.Stone, m);
- km.Shaft(new Vector3(cp.x + 6f * m, y, cp.y - 5f * m), new Vector3(cp.x + 6f * m, y + 30f * m, cp.y - 5f * m), 1.7f * m, 1.4f * m, stone, 8);
+ km.Shaft(new Vector3(cp.x + 6f * m, y, cp.y - 5f * m), new Vector3(cp.x + 6f * m, y + 30f * m, cp.y - 5f * m), 1.7f * m, 1.4f * m, stone, 8, Facade.Ashlar, m);
km.Cone(new Vector3(cp.x + 6f * m, y + 30f * m, cp.y - 5f * m), 1.6f * m, 3.5f * m, C(0.62f, 0.62f, 0.58f), 8);
AtWorldScale(s.Id, "citadel", km, start, cp, y, m);
Record(s.Id, "citadel", cp, 0f, 18f * m, 16f * m, 33.5f * m, stone);
@@ -391,7 +391,7 @@ namespace Statecraft.Game.Map.Kits
{
var mid = from + d * ((i + 0.5f) / k);
if (!ground.Water(mid.x, mid.y)) continue;
- km.Box(mid.x, mid.y, yaw, d.magnitude / k * 1.04f, 5f * m, sea - 2f * m, sea, 2.4f * m, stone, stone, Facade.Plain, m);
+ km.Box(mid.x, mid.y, yaw, d.magnitude / k * 1.04f, 5f * m, sea - 2f * m, sea, 2.4f * m, stone, stone, Facade.Ashlar, m);
Record(s.Id, "breakwater", mid, yaw, d.magnitude / k * 1.04f, 5f * m, 2.4f * m, stone); // SeaCraft keeps its boats off it
pieces++;
}
@@ -412,8 +412,8 @@ namespace Statecraft.Game.Map.Kits
var (b, y) = GroundSpan(q, 0f, 15f * m, 6f * m, ground, m);
AddModel(s.Id, TownModel.B32CargoShed, q, 0f, 15f * m, 6f * m, 5.1f * m, b, y, km, m, exactHeight: false, flip: false); // #659
var cut = km.CutStart();
- km.Box(q.x, q.y, 0f, 15f * m, 6f * m, b, y, 3.5f * m, shed, C(0.62f, 0.58f, 0.54f), Facade.Plain, m, roofed: true);
- km.Gable(q.x, q.y, 0f, 15f * m, 6f * m, y + 3.5f * m, 1.6f * m, C(0.58f, 0.55f, 0.52f), shed);
+ km.Box(q.x, q.y, 0f, 15f * m, 6f * m, b, y, 3.5f * m, shed, C(0.62f, 0.58f, 0.54f), Facade.Plaster, m, roofed: true);
+ km.Gable(q.x, q.y, 0f, 15f * m, 6f * m, y + 3.5f * m, 1.6f * m, C(0.58f, 0.55f, 0.52f), shed, m, Facade.Corrugated);
km.CutEnd(cut);
Record(s.Id, "warehouse", q, 0f, 15f * m, 6f * m, 5.1f * m, shed);
n++;
@@ -463,7 +463,7 @@ namespace Statecraft.Game.Map.Kits
{
var mid = a + d * ((i + 0.5f) / k);
if (!ground.Water(mid.x, mid.y)) continue;
- km.Box(mid.x, mid.y, yaw, d.magnitude / k * 1.04f, 4.5f * m, y - 2f * m, y, 2.2f * m, stone, stone, Facade.Plain, m);
+ km.Box(mid.x, mid.y, yaw, d.magnitude / k * 1.04f, 4.5f * m, y - 2f * m, y, 2.2f * m, stone, stone, Facade.Ashlar, m);
Record(s.Id, "breakwater", mid, yaw, d.magnitude / k * 1.04f, 4.5f * m, 2.2f * m, stone); // SeaCraft keeps its boats off it
pieces++;
}
@@ -485,8 +485,8 @@ namespace Statecraft.Game.Map.Kits
var (bt, gy) = GroundSpan(q, 90f, shedL * m, shedW * m, ground, m);
AddModel(s.Id, TownModel.B32CargoShed, q, 90f, shedL * m, shedW * m, 5f * m, bt, gy, km, m, exactHeight: false, flip: false); // #659
var cut = km.CutStart();
- km.Box(q.x, q.y, 90f, shedL * m, shedW * m, bt, gy, 3.2f * m, shed, C(0.62f, 0.58f, 0.54f), Facade.Plain, m, roofed: true);
- km.Gable(q.x, q.y, 90f, shedL * m, shedW * m, gy + 3.2f * m, 1.8f * m, C(0.60f, 0.58f, 0.55f), shed);
+ km.Box(q.x, q.y, 90f, shedL * m, shedW * m, bt, gy, 3.2f * m, shed, C(0.62f, 0.58f, 0.54f), Facade.Plaster, m, roofed: true);
+ km.Gable(q.x, q.y, 90f, shedL * m, shedW * m, gy + 3.2f * m, 1.8f * m, C(0.60f, 0.58f, 0.55f), shed, m, Facade.Corrugated);
km.CutEnd(cut);
Record(s.Id, "warehouse", q, 90f, shedL * m, shedW * m, 5f * m, shed);
n++;
@@ -510,8 +510,8 @@ namespace Statecraft.Game.Map.Kits
float w = Mathf.Lerp(7f, 5.6f, i / 4f) * m;
km.Box(p.x, p.y, 0f, w, w, i == 0 ? y - 2f * m : y + i * storey - 1f, y + i * storey, storey, stone, stone, Facade.Stone, m);
}
- km.Box(p.x, p.y, 0f, 3.2f * m, 3.2f * m, y + 27f * m - 1f, y + 27f * m, 2.6f * m, stone, stone, Facade.Plain, m, roofed: true);
- km.Dome(p.x, p.y, y + 29.6f * m, 1.6f * m, C(0.80f, 0.78f, 0.72f));
+ km.Box(p.x, p.y, 0f, 3.2f * m, 3.2f * m, y + 27f * m - 1f, y + 27f * m, 2.6f * m, stone, stone, Facade.Ashlar, m, roofed: true);
+ km.Dome(p.x, p.y, y + 29.6f * m, 1.6f * m, C(0.80f, 0.78f, 0.72f), metresPerReal: m);
AtWorldScale(owner, "white_tower", km, start, p, y, m);
Record(owner, "white_tower", p, 0f, 7f * m, 7f * m, 31f * m, stone);
return 1;
@@ -525,12 +525,12 @@ namespace Statecraft.Game.Map.Kits
var stone = Jitter(C(0.87f, 0.80f, 0.66f), ref rnd, 0.03f);
var start = km.CutStart();
km.Box(p.x, p.y, 0f, 14f * m, 14f * m, y - 2f * m, y, 7f * m, stone, stone, Facade.Stone, KitScale.Landmarks);
- km.Dome(p.x, p.y, y + 7f * m - 0.5f * m, 5.5f * m, C(0.80f, 0.80f, 0.76f));
+ km.Dome(p.x, p.y, y + 7f * m - 0.5f * m, 5.5f * m, C(0.80f, 0.80f, 0.76f), metresPerReal: m);
float mx = p.x + 8.5f * m, mz = p.y - 6f * m;
float my = ground.Y(mx, mz);
var minaret = km.CutStart();
- km.Shaft(new Vector3(mx, my - 2f * m, mz), new Vector3(mx, my + 26f * m, mz), 1.6f * m, 1.35f * m, stone, 8);
- km.Shaft(new Vector3(mx, my + 20f * m, mz), new Vector3(mx, my + 21f * m, mz), 2.1f * m, 2.1f * m, stone, 8); // the balcony
+ km.Shaft(new Vector3(mx, my - 2f * m, mz), new Vector3(mx, my + 26f * m, mz), 1.6f * m, 1.35f * m, stone, 8, Facade.Ashlar, m);
+ km.Shaft(new Vector3(mx, my + 20f * m, mz), new Vector3(mx, my + 21f * m, mz), 2.1f * m, 2.1f * m, stone, 8, Facade.Ashlar, m); // the balcony
km.Cone(new Vector3(mx, my + 26f * m, mz), 1.5f * m, 4.5f * m, C(0.62f, 0.62f, 0.58f), 8);
AtWorldScale(owner, "mosque", km, start, minaret, "minaret", 0f, p, y, m);
Record(owner, "mosque", p, 0f, 14f * m, 14f * m, 30.5f * m, stone);
@@ -556,8 +556,8 @@ namespace Statecraft.Game.Map.Kits
float a = yaw * Mathf.Deg2Rad, u = 0.5f * w - 1.4f * m, v = -(0.5f * d - 1.4f * m);
float mx = p.x + u * Mathf.Cos(a) - v * Mathf.Sin(a), mz = p.y + u * Mathf.Sin(a) + v * Mathf.Cos(a);
var minaret = km.CutStart();
- km.Box(mx, mz, yaw, 2.8f * m, 2.8f * m, top + 5.5f * m - 0.3f * m, top + 5.5f * m, 7.9f * m, stone, roof, Facade.Plain, m);
- km.Box(mx, mz, yaw, 3.3f * m, 3.3f * m, top + 13.4f * m - 0.2f * m, top + 13.4f * m, 0.6f * m, stone, roof, Facade.Plain, m); // the balcony's parapet
+ km.Box(mx, mz, yaw, 2.8f * m, 2.8f * m, top + 5.5f * m - 0.3f * m, top + 5.5f * m, 7.9f * m, stone, roof, Facade.Ashlar, m);
+ km.Box(mx, mz, yaw, 3.3f * m, 3.3f * m, top + 13.4f * m - 0.2f * m, top + 13.4f * m, 0.6f * m, stone, roof, Facade.Ashlar, m); // the balcony's parapet
AtWorldScale(owner, "village_mosque", km, start, minaret, "minaret", yaw, p, top, m);
Record(owner, "village_mosque", p, yaw, w, d, 14f * m, stone);
return 1;
@@ -573,10 +573,10 @@ namespace Statecraft.Game.Map.Kits
float yq = ground.Y(q.x, q.y);
var start = km.CutStart();
km.Box(q.x, q.y, 0f, 9f * m, 18f * m, yq - 2f * m, yq, 12f * m, stone, stone, Facade.Stone, m, roofed: true);
- km.Gable(q.x, q.y, 0f, 9f * m, 18f * m, yq + 12f * m, 4f * m, C(0.66f, 0.34f, 0.24f), stone);
+ km.Gable(q.x, q.y, 0f, 9f * m, 18f * m, yq + 12f * m, 4f * m, C(0.66f, 0.34f, 0.24f), stone, m, gableSurface: Facade.Ashlar);
var belfry = km.CutStart(); // the belfry last, so it can be replaced (#2266)
km.Box(q.x, q.y + 7f * m, 0f, 4.5f * m, 4.5f * m, yq + 12f * m, yq + 12f * m, 14f * m, stone, stone, Facade.Stone, m, roofed: true);
- km.Pyramid(q.x, q.y + 7f * m, 0f, 4.8f * m, 4.8f * m, yq + 26f * m, 6f * m, C(0.60f, 0.52f, 0.44f));
+ km.Pyramid(q.x, q.y + 7f * m, 0f, 4.8f * m, 4.8f * m, yq + 26f * m, 6f * m, C(0.60f, 0.52f, 0.44f), m);
AtWorldScale(owner, "church", km, start, belfry, "belfry", 0f, q, yq, m);
Record(owner, "church", q, 0f, 9f * m, 18f * m, 32f * m, stone);
return true;
@@ -599,7 +599,7 @@ namespace Statecraft.Game.Map.Kits
var b = new Vector3(p.x + Mathf.Cos(a) * 2.6f * m, y - 2f * m, p.y + Mathf.Sin(a) * 2.6f * m);
km.Shaft(b, new Vector3(p.x + Mathf.Cos(a) * 1.8f * m, y + 9f * m, p.y + Mathf.Sin(a) * 1.8f * m), 0.35f * m, 0.3f * m, concrete, 4);
}
- km.Shaft(new Vector3(p.x, y + 9f * m, p.y), new Vector3(p.x, y + 13.5f * m, p.y), 3f * m, 3f * m, concrete, 10);
+ km.Shaft(new Vector3(p.x, y + 9f * m, p.y), new Vector3(p.x, y + 13.5f * m, p.y), 3f * m, 3f * m, concrete, 10, Facade.Plaster, m);
km.Cone(new Vector3(p.x, y + 13.5f * m, p.y), 3.1f * m, 1.2f * m, C(0.66f, 0.64f, 0.60f), 10);
if (model) km.CutEnd(cut); // up close the model stands here instead
return 1;
diff --git a/unity/Assets/Scripts/Map/Kits/SettlementKits.Models.cs b/unity/Assets/Scripts/Map/Kits/SettlementKits.Models.cs
index fb7fcc73e..f862b8fe9 100644
--- a/unity/Assets/Scripts/Map/Kits/SettlementKits.Models.cs
+++ b/unity/Assets/Scripts/Map/Kits/SettlementKits.Models.cs
@@ -173,7 +173,7 @@ namespace Statecraft.Game.Map.Kits
}
if (top - bottom > PlinthRiseM * m)
km.Plinths.Box(p.x, p.y, yaw, Mathf.Max(w, nu * pu - gap), Mathf.Max(d, nv * pv - gap), bottom, top, // #1032: models may stand out to the plot edge
- 0f, TerraceStone, TerraceStone, Facade.Plain, m, roofed: true);
+ 0f, TerraceStone, TerraceStone, Facade.Rubble, m, roofed: true);
}
static void AddModel(string id, TownModel model, Vector2 p, float yaw, float w, float d, float h, float bottom, float top, KitMesh km,
@@ -183,7 +183,7 @@ namespace Statecraft.Game.Map.Kits
var mi = Fit(id, model, p, yaw, w, d, h, top, exactHeight, flip, m);
models.Add(mi);
// The plinth under the model itself, not the whole plot.
- if (top - bottom > PlinthRiseM * m) km.Plinths.Box(p.x, p.y, yaw, mi.W, mi.D, bottom, top, 0f, TerraceStone, TerraceStone, Facade.Plain, m, roofed: true);
+ if (top - bottom > PlinthRiseM * m) km.Plinths.Box(p.x, p.y, yaw, mi.W, mi.D, bottom, top, 0f, TerraceStone, TerraceStone, Facade.Rubble, m, roofed: true);
}
/// <summary>A town plot's models by its style and its place (issue #659's table).</summary>
diff --git a/unity/Assets/Scripts/Map/Kits/SettlementKits.Moshav.cs b/unity/Assets/Scripts/Map/Kits/SettlementKits.Moshav.cs
index 8bc8e909d..f49bb86d9 100644
--- a/unity/Assets/Scripts/Map/Kits/SettlementKits.Moshav.cs
+++ b/unity/Assets/Scripts/Map/Kits/SettlementKits.Moshav.cs
@@ -39,8 +39,8 @@ namespace Statecraft.Game.Map.Kits
// building, its gable included; far off, the kit's.
AddModel(owner, TownModel.B09aCommunal, p, yaw, w, d, h + d * 0.42f, bottom, top, km, m, exactHeight: false, flip: false);
var cut = km.CutStart();
- km.Box(p.x, p.y, yaw, w, d, bottom, top, h, wall, roof, Facade.Village, m, roofed: true);
- km.Gable(p.x, p.y, yaw, w, d, top + h, d * 0.42f, roof, wall);
+ km.Box(p.x, p.y, yaw, w, d, bottom, top, h, wall, roof, Facade.Moshava, m, roofed: true);
+ km.Gable(p.x, p.y, yaw, w, d, top + h, d * 0.42f, roof, wall, m);
km.CutEnd(cut);
Record(owner, "public_building", p, yaw, w, d, h, wall);
return 1;
diff --git a/unity/Assets/Scripts/Map/Kits/SettlementKits.Outpost.cs b/unity/Assets/Scripts/Map/Kits/SettlementKits.Outpost.cs
index 6beadf1f9..ecf0c2b4f 100644
--- a/unity/Assets/Scripts/Map/Kits/SettlementKits.Outpost.cs
+++ b/unity/Assets/Scripts/Map/Kits/SettlementKits.Outpost.cs
@@ -45,7 +45,7 @@ namespace Statecraft.Game.Map.Kits
{
var p = At(u, v);
var (bottom, top) = GroundSpan(p, yaw, w * m, d * m, ground, m);
- km.Box(p.x, p.y, yaw, w * m, d * m, bottom, top, OutpostWallH * m, stone, stone, Facade.Plain, m);
+ km.Box(p.x, p.y, yaw, w * m, d * m, bottom, top, OutpostWallH * m, stone, stone, Facade.Rubble, m);
}
Record(s.Id, "outpost_yard", c, yaw, side, side, OutpostWallH * m, stone);
// The lookout tower in the yard's (+u, +v) corner: three storeys under a slightly wider cap.
@@ -53,7 +53,7 @@ namespace Statecraft.Game.Map.Kits
var p = At(h - 2f, h - 2f); float w = 4f * m, th = 9.5f * m;
var (bottom, top) = GroundSpan(p, yaw, w, w, ground, m);
km.Box(p.x, p.y, yaw, w, w, bottom, top, th, stone, roof, Facade.Stone, m);
- km.Box(p.x, p.y, yaw, w * 1.08f, w * 1.08f, top + th, top + th, 1f * m, stone, roof, Facade.Plain, m);
+ km.Box(p.x, p.y, yaw, w * 1.08f, w * 1.08f, top + th, top + th, 1f * m, stone, roof, Facade.Ashlar, m);
Record(s.Id, "lookout_tower", p, yaw, w, w, th + 1f * m, stone);
}
AtWorldScale(s.Id, "outpost_yard", km, start, c, ground.Y(c.x, c.y), m); // #1032: the wall and the tower, as one landmark
@@ -79,7 +79,7 @@ namespace Statecraft.Game.Map.Kits
AddModel(s.Id, i == 0 ? TownModel.B07DiningHall : TownModel.B09aCommunal, q, yaw, w * m, d * m, bh, qBottom, qTop, km, m,
exactHeight: false, flip: false);
var cut = km.CutStart();
- km.Box(p.x, p.y, yaw, w * m, d * m, bottom, top, bh, concrete, roof, living ? Facade.Village : Facade.Plain, m);
+ km.Box(p.x, p.y, yaw, w * m, d * m, bottom, top, bh, concrete, roof, living ? Facade.Moshava : Facade.Plaster, m);
km.CutEnd(cut);
// The first, larger living building holds the fortress's "חדר אוכל" (the source above): Revivim's one dining hall.
Record(s.Id, i == 0 ? "dining_hall" : "building", p, yaw, w * m, d * m, bh, concrete);
diff --git a/unity/Assets/Scripts/Map/Kits/SettlementKits.TelAviv.cs b/unity/Assets/Scripts/Map/Kits/SettlementKits.TelAviv.cs
index b521b6016..b8990e538 100644
--- a/unity/Assets/Scripts/Map/Kits/SettlementKits.TelAviv.cs
+++ b/unity/Assets/Scripts/Map/Kits/SettlementKits.TelAviv.cs
@@ -82,7 +82,7 @@ namespace Statecraft.Game.Map.Kits
var shade = C(wall.r / 255f * 0.62f, wall.g / 255f * 0.62f, wall.b / 255f * 0.64f);
km.Box(c.x, c.y, yaw, w * 0.72f, b.d * 0.6f, bottom, top, storey, shade, shade, Facade.Plain, m, roofed: true);
km.Box(c.x, c.y, yaw, w, b.d, top + storey - 0.3f * m, top + storey, body - storey, wall, terrace, Facade.WhiteCity, m);
- Ribbons(km, c, yaw, w, b.d, top + storey, body - storey, m);
+ Ribbons(km, c, yaw, w, b.d, top + storey, body - storey, m, 0); // the first storey up: the pilotis are the ground storey
}
else
{
@@ -105,10 +105,10 @@ namespace Statecraft.Game.Map.Kits
{
var pc = At(du + pu, pv);
km.Box(pc.x, pc.y, yaw, pw, pd, top + body - 0.3f * m, top + body, storey, wall, terrace, Facade.WhiteCity, m);
- Ribbons(km, pc, yaw, pw, pd, top + body, storey, m);
+ Ribbons(km, pc, yaw, pw, pd, top + body, storey, m, 0);
}
var r1 = At(du + su, sv);
- km.Box(r1.x, r1.y, yaw, rw, rd, top + h - 2f, top + h, 2.8f * m, wall, terrace, Facade.Plain, m);
+ km.Box(r1.x, r1.y, yaw, rw, rd, top + h - 2f, top + h, 2.8f * m, wall, terrace, Facade.Plaster, m);
if (RoofDetail && detail.Chance(RoofTankShare)) RoofTank(km, r1, yaw, rw, rd, top + h + 2.8f * m, m);
if (rnd.Chance(0.4f))
{
@@ -116,7 +116,7 @@ namespace Statecraft.Game.Map.Kits
// Keep the old 0.1 lw clearance, but measure it from the parapet's inner edge rather than the outer wall.
var r2 = At(du + (rnd.Chance(0.5f) ? 1f : -1f) * (0.5f * w - WhiteParapetThicknessM * m - 0.6f * lw),
rnd.Range(-0.2f, 0.2f) * b.d);
- if (!setback) km.Box(r2.x, r2.y, yaw, lw, ld, top + h - 2f, top + h, 2.4f * m, wall, terrace, Facade.Plain, m);
+ if (!setback) km.Box(r2.x, r2.y, yaw, lw, ld, top + h - 2f, top + h, 2.4f * m, wall, terrace, Facade.Plaster, m);
}
Record(id, "building", p, yaw, b.w, b.d, b.h, wall);
}
@@ -148,28 +148,32 @@ namespace Statecraft.Game.Map.Kits
return (pw, pd, pu, pv, pu + fu * pw, pv + fv * pd);
}
- /// <summary>Glass of the ribbon windows: near black, as promo 03's deep-set windows read.</summary>
- static readonly Color32 RibbonGlass = new Color32(38, 42, 48, 0);
+ /// <summary>The ribbon windows' surface: its atlas cell paints the dark glass, the steel frames and the blinds, so far off
+ /// it still reads as promo 03's deep-set, near-black strip, and this tint leaves the cell as painted.</summary>
+ static readonly Color32 RibbonGlass = new Color32(255, 255, 255, (byte)Facade.RibbonGlass);
/// <summary>Tel Aviv's ribbon windows (the International Style's horizontal strip window): one unbroken dark strip per
/// storey along each long side of a w x d block whose walls rise <paramref name="h"/> from <paramref name="y0"/>, set
/// a hair proud of the wall (no z-fight), 1.4-2.6 m above each floor, so it shows above the balcony's parapet. Geometry,
/// not the facade shader (Kit.shader is left alone): at the gameplay zoom a 2 m window bay is under a pixel and the
- /// shader's discrete windows fade to their mean, while a strip stays a band. Two triangles per storey and side.</summary>
- static void Ribbons(KitMesh km, Vector2 c, float yaw, float w, float d, float y0, float h, float m)
+ /// shader's discrete windows fade to their mean, while a strip stays a band. Two triangles per storey and side, from storey
+ /// <paramref name="first"/> up: the ground storey (0) keeps its doors and shop (the facade's own cell, #2428).</summary>
+ static void Ribbons(KitMesh km, Vector2 c, float yaw, float w, float d, float y0, float h, float m, int first = 1)
{
float storey = 3.3f * m, a = yaw * Mathf.Deg2Rad, ca = Mathf.Cos(a), sa = Mathf.Sin(a);
float hu = 0.5f * w - 0.6f * m, off = 0.06f * m;
if (hu <= 0f) return;
Vector3 P(float u, float v, float y) => new Vector3(c.x + u * ca - v * sa, y, c.y + u * sa + v * ca);
int storeys = Mathf.RoundToInt(h / storey);
- for (int k = 0; k < storeys; k++)
+ float tu = 2f * hu / m / KitMesh.Tile(Facade.RibbonGlass).x;
+ for (int k = first; k < storeys; k++)
{
float y1 = y0 + k * storey + 1.4f * m, y2 = y0 + k * storey + 2.6f * m;
for (int side = -1; side <= 1; side += 2)
{
float v = side * (0.5f * d + off), u0 = side * hu, u1 = -side * hu; // clockwise seen from outside, as Box's walls
- km.Face(P(u0, v, y1), P(u0, v, y2), P(u1, v, y2), P(u1, v, y1), RibbonGlass, Vector2.zero, Vector2.zero, Vector2.zero, Vector2.zero);
+ km.Face(P(u0, v, y1), P(u0, v, y2), P(u1, v, y2), P(u1, v, y1), RibbonGlass,
+ new Vector2(k * 0.37f, 0f), new Vector2(k * 0.37f, 1f), new Vector2(k * 0.37f + tu, 1f), new Vector2(k * 0.37f + tu, 0f));
}
}
}
@@ -181,8 +185,8 @@ namespace Statecraft.Game.Map.Kits
for (int side = -1; side <= 1; side += 2)
{
float v = side * 0.5f * (d - t), u = side * 0.5f * (w - t);
- km.Box(c.x - v * sa, c.y + v * ca, yaw, w, t, roofY - 0.1f * m, roofY, hgt, wall, wall, Facade.Plain, m);
- km.Box(c.x + u * ca, c.y + u * sa, yaw, t, d - 2f * t, roofY - 0.1f * m, roofY, hgt, wall, wall, Facade.Plain, m);
+ km.Box(c.x - v * sa, c.y + v * ca, yaw, w, t, roofY - 0.1f * m, roofY, hgt, wall, wall, Facade.Plaster, m);
+ km.Box(c.x + u * ca, c.y + u * sa, yaw, t, d - 2f * t, roofY - 0.1f * m, roofY, hgt, wall, wall, Facade.Plaster, m);
}
}
diff --git a/unity/Assets/Scripts/Map/Kits/SettlementKits.cs b/unity/Assets/Scripts/Map/Kits/SettlementKits.cs
index c948abfd4..ecebb918a 100644
--- a/unity/Assets/Scripts/Map/Kits/SettlementKits.cs
+++ b/unity/Assets/Scripts/Map/Kits/SettlementKits.cs
@@ -955,7 +955,7 @@ namespace Statecraft.Game.Map.Kits
float rw = roofW * rnd.Range(0.22f, 0.36f), rd = b.d * rnd.Range(0.3f, 0.45f);
float su = roofW * rnd.Range(-0.15f, 0.15f), sv = b.d * rnd.Range(-0.12f, 0.12f), ya = yaw * Mathf.Deg2Rad;
var s = roofC + new Vector2(su * Mathf.Cos(ya) - sv * Mathf.Sin(ya), su * Mathf.Sin(ya) + sv * Mathf.Cos(ya));
- km.Box(s.x, s.y, yaw, rw, rd, top + b.h - 2f, top + b.h, 2.8f * m, wall, roof, Facade.Plain, m);
+ km.Box(s.x, s.y, yaw, rw, rd, top + b.h - 2f, top + b.h, 2.8f * m, wall, roof, Facade.Plaster, m);
if (white && RoofDetail && detail.Chance(RoofTankShare)) RoofTank(km, s, yaw, rw, rd, top + b.h + 2.8f * m, m);
}
// Many White City roofs carry a second room (the shared laundry room beside the stair head), at the
@@ -967,7 +967,7 @@ namespace Statecraft.Game.Map.Kits
float inset = parapet > 0f ? parapetT : 0f;
float u = (rnd.Chance(0.5f) ? 1f : -1f) * (0.5f * b.w - inset - 0.6f * rw), v = rnd.Range(-0.2f, 0.2f) * b.d;
km.Box(p.x + u * Mathf.Cos(a) - v * Mathf.Sin(a), p.y + u * Mathf.Sin(a) + v * Mathf.Cos(a), yaw, rw, rd, top + b.h - 2f, top + b.h,
- 2.4f * m, wall, roof, Facade.Plain, m);
+ 2.4f * m, wall, roof, Facade.Plaster, m);
}
break;
}
@@ -980,9 +980,9 @@ namespace Statecraft.Game.Map.Kits
float parapet = RoofDetail ? DetailAt(p, 43).Range(StoneParapetMinM, StoneParapetMaxM) * m : 0f;
km.Box(p.x, p.y, yaw, b.w, b.d, bottom, top, b.h, wall, roof, Facade.Stone, m, roofed: tiled, parapet: parapet,
parapetThickness: StoneParapetThicknessM * m);
- if (tiled) km.Pyramid(p.x, p.y, yaw, b.w * 1.04f, b.d * 1.04f, top + b.h, 2.6f * m, Jitter(C(0.70f, 0.33f, 0.22f), ref rnd, 0.06f));
+ if (tiled) km.Pyramid(p.x, p.y, yaw, b.w * 1.04f, b.d * 1.04f, top + b.h, 2.6f * m, Jitter(C(0.70f, 0.33f, 0.22f), ref rnd, 0.06f), m);
else if (rnd.Chance(0.35f))
- km.Box(p.x, p.y, yaw, b.w * 0.3f, b.d * 0.35f, top + b.h - 2f, top + b.h, 2.6f * m, wall, roof, Facade.Plain, m);
+ km.Box(p.x, p.y, yaw, b.w * 0.3f, b.d * 0.35f, top + b.h - 2f, top + b.h, 2.6f * m, wall, roof, Facade.Ashlar, m);
Record(id, "building", p, yaw, b.w, b.d, b.h, wall);
break;
}
@@ -995,7 +995,7 @@ namespace Statecraft.Game.Map.Kits
if (tiled)
{
km.Box(p.x, p.y, yaw, b.w, b.d, bottom, top, b.h, wall, roof, Facade.Stone, m, roofed: true);
- km.Pyramid(p.x, p.y, yaw, b.w * 1.04f, b.d * 1.04f, top + b.h, 2.2f * m, Jitter(C(0.70f, 0.33f, 0.22f), ref rnd, 0.06f));
+ km.Pyramid(p.x, p.y, yaw, b.w * 1.04f, b.d * 1.04f, top + b.h, 2.2f * m, Jitter(C(0.70f, 0.33f, 0.22f), ref rnd, 0.06f), m);
}
else StoneHouse(km, p, yaw, b, bottom, top, wall, roof, Facade.Stone, m, rnd.Chance(OldHouseDome), ref rnd);
Record(id, "building", p, yaw, b.w, b.d, b.h, wall);
@@ -1011,8 +1011,8 @@ namespace Statecraft.Game.Map.Kits
// uphill ground with a flat yard round the house, so a village on a hillside steps down in terraces.
if (hill && top - bottom > TerraceRiseM * m)
km.Box(p.x, p.y, yaw, b.w + 2f * TerraceMarginM * m, b.d + 2f * TerraceMarginM * m, bottom, top, 0.15f * m,
- Jitter(TerraceStone, ref rnd, 0.05f), Jitter(TerraceYard, ref rnd, 0.04f), Facade.Plain, m);
- StoneHouse(km, p, yaw, b, bottom, top, wall, roof, Facade.Village, m, dome, ref rnd);
+ Jitter(TerraceStone, ref rnd, 0.05f), Jitter(TerraceYard, ref rnd, 0.04f), Facade.Rubble, m);
+ StoneHouse(km, p, yaw, b, bottom, top, wall, roof, hill ? Facade.Village : Facade.Mud, m, dome, ref rnd);
Record(id, "building", p, yaw, b.w, b.d, b.h, wall);
break;
}
@@ -1027,7 +1027,7 @@ namespace Statecraft.Game.Map.Kits
var wall = Jitter(C(0.86f, 0.79f, 0.66f), ref rnd, 0.04f);
var roof = Jitter(C(0.72f, 0.31f, 0.20f), ref rnd, 0.06f);
km.Box(p.x, p.y, yaw, b.w, b.d, bottom, top, b.h, wall, roof, Facade.Stone, m, roofed: true);
- km.Gable(p.x, p.y, yaw, b.w, b.d, top + b.h, Mathf.Min(b.w, b.d) * 0.55f, roof, wall);
+ km.Gable(p.x, p.y, yaw, b.w, b.d, top + b.h, Mathf.Min(b.w, b.d) * 0.55f, roof, wall, m, gableSurface: Facade.Ashlar);
Record(id, "building", p, yaw, b.w, b.d, b.h, wall);
break;
}
@@ -1035,8 +1035,8 @@ namespace Statecraft.Game.Map.Kits
{
var wall = Jitter(C(0.92f, 0.89f, 0.82f), ref rnd, 0.04f);
var roof = Jitter(C(0.74f, 0.31f, 0.20f), ref rnd, 0.08f);
- km.Box(p.x, p.y, yaw, b.w, b.d, bottom, top, b.h, wall, roof, Facade.Village, m, roofed: true);
- km.Gable(p.x, p.y, yaw, b.w, b.d, top + b.h, Mathf.Min(b.w, b.d) * 0.42f, roof, wall);
+ km.Box(p.x, p.y, yaw, b.w, b.d, bottom, top, b.h, wall, roof, Facade.Moshava, m, roofed: true);
+ km.Gable(p.x, p.y, yaw, b.w, b.d, top + b.h, Mathf.Min(b.w, b.d) * 0.42f, roof, wall, m);
Record(id, "building", p, yaw, b.w, b.d, b.h, wall);
break;
}
@@ -1125,7 +1125,7 @@ namespace Statecraft.Game.Map.Kits
// The topmost flat roof's parapet (none under a dome): every town house's, half the village houses'; its height
// the house's own, from its own stream (DetailAt), so rnd draws what it always has.
var detail = DetailAt(p, 41);
- bool village = facade == Facade.Village;
+ bool village = facade == Facade.Village || facade == Facade.Mud;
float parapet = RoofDetail && !dome && (!village || detail.Chance(VillageParapetShare))
? (village ? detail.Range(VillageParapetMinM, VillageParapetMaxM) : detail.Range(StoneParapetMinM, StoneParapetMaxM)) * m : 0f;
float parapetT = (village ? VillageParapetThicknessM : StoneParapetThicknessM) * m;
@@ -1134,14 +1134,14 @@ namespace Statecraft.Game.Map.Kits
float low = b.h - storey;
km.Box(p.x, p.y, yaw, b.w, b.d, bottom, top, low, wall, roof, facade, m);
km.Box(uc.x, uc.y, yaw, uw, ud, top + low - 0.3f * m, top + low, storey, wall, roof, facade, m, parapet: parapet, parapetThickness: parapetT);
- if (dome) km.Dome(uc.x, uc.y, top + b.h - 0.2f * m, Mathf.Min(uw, ud) * 0.4f, roof, rise: 0.6f);
+ if (dome) km.Dome(uc.x, uc.y, top + b.h - 0.2f * m, Mathf.Min(uw, ud) * 0.4f, roof, rise: 0.6f, metresPerReal: m);
return;
}
// A roof room (none under a dome) is the topmost roof, so the parapet goes on it: on the main roof the room's walls
// would stand through the rim. The same roll as ever (only without a dome), drawn before the main block, which draws none.
bool room = !dome && rnd.Chance(0.35f);
km.Box(p.x, p.y, yaw, b.w, b.d, bottom, top, b.h, wall, roof, facade, m, parapet: room ? 0f : parapet, parapetThickness: parapetT);
- if (dome) km.Dome(p.x, p.y, top + b.h - 0.2f * m, Mathf.Min(b.w, b.d) * 0.33f, roof, rise: 0.6f);
+ if (dome) km.Dome(p.x, p.y, top + b.h - 0.2f * m, Mathf.Min(b.w, b.d) * 0.33f, roof, rise: 0.6f, metresPerReal: m);
else if (room)
km.Box(uc.x, uc.y, yaw, uw * 0.8f, ud * 0.8f, top + b.h - 0.3f * m, top + b.h, storey * 0.85f, wall, roof, facade, m,
parapet: parapet, parapetThickness: parapetT);
@@ -1180,7 +1180,7 @@ namespace Statecraft.Game.Map.Kits
for (int k = 1; k < storeys; k++)
{
float floor = ground + k * storey;
- km.Box(x, z, yaw, bw, proj, floor - slab, floor - slab, slab + parapet, rail, roof, Facade.Plain, m);
+ km.Box(x, z, yaw, bw, proj, floor - slab, floor - slab, slab + parapet, rail, roof, Facade.BalconyRail, m);
}
}
}
@@ -1455,7 +1455,7 @@ namespace Statecraft.Game.Map.Kits
float rw = b.w * rnd.Range(0.25f, 0.4f), rd = b.d * rnd.Range(0.3f, 0.45f), a = yaw * Mathf.Deg2Rad;
float su = b.w * rnd.Range(-0.2f, 0.2f), sv = b.d * rnd.Range(-0.15f, 0.15f);
km.Box(p.x + su * Mathf.Cos(a) - sv * Mathf.Sin(a), p.y + su * Mathf.Sin(a) + sv * Mathf.Cos(a), yaw, rw, rd, top + b.h - 2f, top + b.h,
- 2.8f * m, wall, roof, Facade.Plain, m);
+ 2.8f * m, wall, roof, Facade.Plaster, m);
}
return wall;
}
@@ -1467,7 +1467,7 @@ namespace Statecraft.Game.Map.Kits
if (rnd.Chance(0.03f))
{
km.Box(p.x, p.y, yaw, b.w, b.d, bottom, top, b.h, wall, roof, Facade.Stone, m, roofed: true);
- km.Pyramid(p.x, p.y, yaw, b.w * 1.04f, b.d * 1.04f, top + b.h, 2.2f * m, Jitter(C(0.70f, 0.33f, 0.22f), ref rnd, 0.06f));
+ km.Pyramid(p.x, p.y, yaw, b.w * 1.04f, b.d * 1.04f, top + b.h, 2.2f * m, Jitter(C(0.70f, 0.33f, 0.22f), ref rnd, 0.06f), m);
}
else StoneHouse(km, p, yaw, b, bottom, top, wall, roof, Facade.Stone, m, rnd.Chance(OldHouseDome), ref rnd);
return wall;
@@ -1482,7 +1482,7 @@ namespace Statecraft.Game.Map.Kits
var wall = hill ? StoneWall(ref rnd) : Jitter(MudBrick, ref rnd, 0.06f);
var roof = Jitter(LimeRoof, ref rnd, 0.05f);
bool dome = rnd.Value() < VillageDome && hill;
- StoneHouse(km, p, yaw, b, bottom, top, wall, roof, Facade.Village, m, dome, ref detail);
+ StoneHouse(km, p, yaw, b, bottom, top, wall, roof, hill ? Facade.Village : Facade.Mud, m, dome, ref detail);
return wall;
}
default:
@@ -1490,8 +1490,8 @@ namespace Statecraft.Game.Map.Kits
if (b.part != KibbutzPart.None) return KibbutzBuilding(km, p, yaw, b, bottom, top, m, ref rnd);
var wall = Jitter(C(0.92f, 0.89f, 0.82f), ref rnd, 0.04f);
var roof = Jitter(C(0.74f, 0.31f, 0.20f), ref rnd, 0.08f);
- km.Box(p.x, p.y, yaw, b.w, b.d, bottom, top, b.h, wall, roof, Facade.Village, m, roofed: true);
- km.Gable(p.x, p.y, yaw, b.w, b.d, top + b.h, Mathf.Min(b.w, b.d) * 0.42f, roof, wall);
+ km.Box(p.x, p.y, yaw, b.w, b.d, bottom, top, b.h, wall, roof, Facade.Moshava, m, roofed: true);
+ km.Gable(p.x, p.y, yaw, b.w, b.d, top + b.h, Mathf.Min(b.w, b.d) * 0.42f, roof, wall, m);
return wall;
}
}
@@ -1547,7 +1547,7 @@ namespace Statecraft.Game.Map.Kits
// Low side walls under a peaked roof, so it reads as a tent rather than a shed.
var cloth = Jitter(C(0.33f, 0.27f, 0.21f), ref rnd, 0.08f);
km.Box(p.x, p.y, tyaw, tw, td, bottom, top, 1.1f * m, Jitter(C(0.42f, 0.35f, 0.27f), ref rnd, 0.06f), cloth, Facade.Plain, m, roofed: true);
- km.Gable(p.x, p.y, tyaw, tw, td, top + 1.1f * m, 1.4f * m, cloth, cloth);
+ km.Gable(p.x, p.y, tyaw, tw, td, top + 1.1f * m, 1.4f * m, cloth, cloth, surface: Facade.Plain, gableSurface: Facade.Plain);
pitched++;
}
if (pitched == 0) continue;
diff --git a/unity/Assets/Shaders/Kit.shader b/unity/Assets/Shaders/Kit.shader
index 15d621933..cbad01e5b 100644
--- a/unity/Assets/Shaders/Kit.shader
+++ b/unity/Assets/Shaders/Kit.shader
@@ -1,7 +1,8 @@
-// Settlement kits and trees (art spike, issues #31 #32 #34 #37). Vertex colour is the sRGB albedo; its alpha picks a
-// facade's window pattern (KitMesh.Facade), drawn from uv0 = the wall's (along, up) position in real metres, so storeys and
-// windows keep real proportions on symbolic-size buildings, box-filtered so they fade to their mean instead of shimmering
-// when a storey is a pixel or two. Lit like the terrain (the sun with its shadows, the trilight ambient through SH; in shade
+// Settlement kits and trees (art spike, issues #31 #32 #34 #37; atlas, #2428). Vertex colour is the sRGB albedo; its alpha
+// picks the surface (KitMesh.Facade): a layer of the one shared atlas (_KitAtlas, Art/Kits/kit_atlas.png as a 2D array), which
+// multiplies the vertex colour, at uv0 (cells; a facade's v is storeys). So storeys, tile rows and courses keep real
+// proportions on symbolic-size buildings, and the atlas's mipmaps fade them to their mean instead of shimmering when a
+// storey is a pixel or two. The atlas is albedo only: this shader does all the light. Lit like the terrain (the sun with its shadows, the trilight ambient through SH; in shade
// the ambient also takes a sun-warm bounce, KitBounce, so a face keeps its own colour) and
// hazed with the terrain's own ScHazeAmount, so kits sit in the same air as the ground. GPU instancing for the trees, with a
// per-instance tint hashed from the instance's origin (no per-instance buffer: WebGL 2 has instanced arrays only).
@@ -13,8 +14,7 @@ Shader "Statecraft/Kit"
{
_BaseColor ("Tint", Color) = (1, 1, 1, 1)
_Jitter ("Per-instance tint jitter", Range(0, 0.5)) = 0
- _WindowDark ("Window darkness", Range(0, 1)) = 0.55
- _CityWindowDark ("White City window darkness", Range(0, 1)) = 0.95
+ [NoScaleOffset] _KitAtlas ("Town kit atlas (one Texture2DArray)", 2DArray) = "white" {}
}
SubShader
{
@@ -23,7 +23,7 @@ Shader "Statecraft/Kit"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
CBUFFER_START(UnityPerMaterial)
half4 _BaseColor;
- half _Jitter, _WindowDark, _CityWindowDark;
+ half _Jitter;
CBUFFER_END
ENDHLSL
@@ -67,30 +67,10 @@ Shader "Statecraft/Kit"
// How much of the ambient in full shade is the sun's bounce (kit shadow colour, refs #32).
static const half KitBounce = 0.6;
- // A 1D band [a, b] of a period-1 pattern, box-filtered over the pixel's footprint w (in periods).
- float Band(float x, float a, float b, float w)
- {
- float lo = saturate((frac(x) - a) / max(w, 1e-4) + 0.5), hi = saturate((frac(x) - b) / max(w, 1e-4) + 0.5);
- return lo - hi;
- }
+ TEXTURE2D_ARRAY(_KitAtlas); SAMPLER(sampler_KitAtlas);
- // Window mask (1 = glass) and its mean over a whole storey, for each facade style.
- float Windows(float style, float2 uv, float2 fw, out float mean)
- {
- float storey = 3.3, bay = style > 0.75 ? 2.0 : (style > 0.4 ? 4.2 : 3.0);
- float wv = fw.y / storey, wu = fw.x / bay;
- float a0, a1, b0, b1;
- if (style > 0.75) { a0 = 0.36; a1 = 0.86; b0 = 0.12; b1 = 0.84; } // white city: tall wide windows, plaster piers between
- else if (style > 0.4) { a0 = 0.40; a1 = 0.72; b0 = 0.38; b1 = 0.62; } // village / moshava: a few small windows
- else { a0 = 0.36; a1 = 0.74; b0 = 0.34; b1 = 0.64; } // stone: arched-height windows
- mean = (a1 - a0) * (b1 - b0);
- float m = Band(uv.y / storey, a0, a1, wv) * Band(uv.x / bay, b0, b1, wu);
- // Fade to the mean once a storey is under about three pixels: no moire at the gameplay zoom. The White City's
- // storeys hold until about two pixels (the box filter keeps them clean there), so its 30 km look keeps its
- // window rows (settlements quick wins, #31).
- float hold = style > 0.75 ? saturate(2.2 - wv * 4.4) : saturate(1.5 - wv * 3.0);
- return lerp(mean, m, hold) * step(0.0, uv.y);
- }
+ // The surfaces up to this one are facades: one ground storey under three that repeat (make_kit_atlas.py).
+ static const float KitFacades = 5.0, KitFacadeRows = 4.0;
half4 Frag(Varyings i) : SV_Target
{
@@ -100,25 +80,24 @@ Shader "Statecraft/Kit"
float t = i.tint - 0.5;
albedo *= 1.0 + _Jitter * t * 2.0;
albedo.r *= 1.0 + _Jitter * (frac(i.tint * 7.31) - 0.5);
- float style = i.color.a;
- float2 fw = fwidth(i.uv); // outside the branch: derivatives need uniform control flow
- if (style > 0.1)
+ float surface = round(i.color.a * 15.0); // KitMesh.Facade: the atlas layer + 1, or 0 for no cell
+ // Outside the branch: derivatives need uniform control flow.
+ float2 dx = ddx(i.uv), dy = ddy(i.uv);
+ if (surface > 0.5)
{
- float mean;
- float glass = Windows(style, i.uv, fw, mean);
- // White-city balconies: a lighter slab line and its shadow under it, every storey.
- if (style > 0.75)
+ float2 uv = i.uv;
+ if (surface < KitFacades + 0.5)
{
- float fv = fw.y / 3.3;
- float slab = Band(i.uv.y / 3.3, 0.28, 0.36, fv), under = Band(i.uv.y / 3.3, 0.36, 0.42, fv);
- float fade = saturate(2.2 - fv * 4.4);
- albedo *= 1.0 + 0.10 * lerp(0.08, slab, fade) - 0.45 * lerp(0.06, under, fade);
+ // Storeys up the wall to rows of the cell: the ground storey once, then the upper three over and over; a
+ // wall's buried part stays on the plinth band at the cell's foot.
+ float storeys = uv.y;
+ float row = storeys < 0.0 ? 0.01 : storeys < 1.0 ? storeys : 1.0 + fmod(storeys - 1.0, KitFacadeRows - 1.0);
+ uv.y = row / KitFacadeRows;
+ dx.y /= KitFacadeRows; dy.y /= KitFacadeRows;
+ // Contact darkening in the bottom real 3 m of a wall.
+ albedo *= lerp(0.72, 1.0, saturate(storeys * 3.3 / 3.0));
}
- // The White City's ribbon windows sit deep under the balcony slabs and read near black in promo 03
- // (settlements quick wins, #31); the stone and village windows keep the shared darkness.
- albedo *= 1.0 - (style > 0.75 ? _CityWindowDark : _WindowDark) * glass;
- // Contact darkening in the bottom real 3 m of a wall.
- albedo *= lerp(0.72, 1.0, saturate(i.uv.y / 3.0));
+ albedo *= SAMPLE_TEXTURE2D_ARRAY_GRAD(_KitAtlas, sampler_KitAtlas, uv, surface - 1.0, dx, dy).rgb;
}
Light sun = GetMainLight(TransformWorldToShadowCoord(i.positionWS));
float ndl = saturate(dot(n, sun.direction));
diff --git a/unity/Assets/Tests/EditMode/KitAtlasShots.cs b/unity/Assets/Tests/EditMode/KitAtlasShots.cs
new file mode 100644
index 000000000..bc3a472ea
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/KitAtlasShots.cs
@@ -0,0 +1,155 @@
+#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.Map.Kits;
+using Statecraft.Game.UI;
+using UnityEditor.SceneManagement;
+using UnityEngine;
+using UnityEngine.TestTools;
+using UnityEngine.UIElements;
+using Object = UnityEngine.Object;
+
+/// <summary>Writes the before and after stills for #2428 (the town kits' shared atlas) to `.superpowers/shots-2428/&lt;SHOTS_TAG&gt;/`
+/// at the repository root (local, not committed), as MajorCityShots writes its own: the map camera's frame with the UI over it,
+/// English. <see cref="Close"/> is the game as it draws: the kit-drawn places at zooms where the kit draws. <see cref="KitsOnly"/>
+/// switches the town models off (TownModelLayer.Draw) to judge a kit that the models hide up close, and says so in each file's
+/// name (`kit-...`). Explicit, so it does not run with the checks.</summary>
+[Explicit("writes stills for a pull request, not a check")]
+public class KitAtlasShots
+{
+ string shotDir = "", saveDir = "";
+ RenderTexture? rt; PanelSettings? ps;
+
+ [SetUp]
+ public void Prepare()
+ {
+ var tag = Environment.GetEnvironmentVariable("SHOTS_TAG");
+ shotDir = Path.GetFullPath(Path.Combine(Application.dataPath, "..", "..", ".superpowers", "shots-2428", string.IsNullOrEmpty(tag) ? "untagged" : tag));
+ Directory.CreateDirectory(shotDir);
+ saveDir = Path.Combine(Path.GetTempPath(), "statecraft-kit-atlas-shots-" + Guid.NewGuid().ToString("N"));
+ }
+
+ [TearDown]
+ public void Discard()
+ {
+ 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 MapScene Scene => Object.FindFirstObjectByType<MapScene>();
+
+ static Vector3 Ground(Vector3 at)
+ {
+ at.y = Scene.Terrain.SampleHeight(at) + Scene.Terrain.transform.position.y;
+ return at;
+ }
+
+ static Vector3 CentreOf(string id, Vector2 offsetM = default)
+ {
+ var map = Scene;
+ var f = map.KitFootprints.FirstOrDefault(x => x.id == id);
+ var at = f.id != null ? new Vector3(f.centre.x, 0f, f.centre.y) : map.Frame.ToWorld(map.Settlements.First(x => x.Id == id).Lon, map.Settlements.First(x => x.Id == id).Lat, 0);
+ return Ground(at + new Vector3(offsetM.x, 0f, offsetM.y));
+ }
+
+ static void Aim(Vector3 at, float viewM, float yaw = 0f)
+ {
+ var rig = Camera.main.GetComponent<CameraRig>();
+ rig.LookAt = at; rig.Yaw = yaw; rig.Distance = viewM; rig.Apply();
+ float down = -Camera.main.transform.forward.y;
+ if (down > 1e-4f) { rig.Distance = Mathf.Max(1000f, viewM - at.y / down); rig.Apply(); }
+ }
+
+ static Color[] Read(RenderTexture from)
+ {
+ var prev = RenderTexture.active;
+ RenderTexture.active = from;
+ var tex = new Texture2D(from.width, from.height, TextureFormat.RGBA32, false);
+ tex.ReadPixels(new Rect(0, 0, from.width, from.height), 0, 0);
+ tex.Apply();
+ RenderTexture.active = prev;
+ var px = tex.GetPixels();
+ Object.DestroyImmediate(tex);
+ return px;
+ }
+
+ void Shot(string name)
+ {
+ int w = CivMovementShots.Width, h = CivMovementShots.Height;
+ var cam = Camera.main;
+ var frame = new RenderTexture(w, h, 24, RenderTextureFormat.ARGB32);
+ var before = cam.targetTexture;
+ cam.targetTexture = frame; cam.Render(); cam.targetTexture = before;
+ var map = Read(frame); var over = Read(rt!);
+ frame.Release(); Object.DestroyImmediate(frame);
+ var outPx = new Color[map.Length];
+ for (int i = 0; i < map.Length; i++)
+ {
+ var u = over[i]; var m = map[i];
+ outPx[i] = new Color(u.r + m.r * (1f - u.a), u.g + m.g * (1f - u.a), u.b + m.b * (1f - u.a), 1f);
+ }
+ var tex = new Texture2D(w, h, TextureFormat.RGB24, false);
+ tex.SetPixels(outPx); tex.Apply();
+ File.WriteAllBytes(Path.Combine(shotDir, name + ".png"), tex.EncodeToPNG());
+ Object.DestroyImmediate(tex);
+ Debug.Log(FormattableString.Invariant($"SHOT {name}: view {TownModelLayer.ViewDistance(cam):F0} m, aspect {cam.aspect:F3}, m11/m00 {cam.projectionMatrix[1, 1] / cam.projectionMatrix[0, 0]:F3}"));
+ }
+
+ IEnumerator Take(string name, Vector3 at, float viewM, float yaw = 0f)
+ {
+ Aim(at, viewM, yaw);
+ for (int i = 0; i < 6; i++) { Camera.main.Render(); yield return null; }
+ Shot(name);
+ }
+
+ /// <summary>CameraRig.Apply freezes the projection at the camera's own aspect, and a batch run's default is 4:3, which would
+ /// draw every still 1.33 times too wide: so the camera takes the still's aspect first, and each SHOT line states it.</summary>
+ IEnumerator Boot()
+ {
+ yield return CivMovementShots.Boot(false, saveDir, (t, p, u, g) => { rt = t; ps = p; });
+ Camera.main.aspect = (float)CivMovementShots.Width / CivMovementShots.Height;
+ }
+
+ [UnityTest]
+ public IEnumerator Close()
+ {
+ yield return Boot();
+ Debug.Log("KITATLAS " + Scene.KitStats);
+ // The pose the promo is measured at, the start view, then close: the four cities' blocks.
+ var pose = PromoPose.Gameplay03;
+ var rig = Camera.main.GetComponent<CameraRig>();
+ rig.LookAt = Scene.Frame.ToWorld(pose.Lon, pose.Lat, 0); rig.Yaw = pose.Yaw; rig.Distance = pose.Distance; rig.Apply();
+ for (int i = 0; i < 6; i++) { Camera.main.Render(); yield return null; }
+ Shot("gameplay03");
+ foreach (var (city, yaw) in new[] { ("tel_aviv", 0f), ("jerusalem", 0f), ("haifa", 0f), ("jaffa", 0f) })
+ foreach (var km in new[] { 31f, 16f, 8f })
+ yield return Take(FormattableString.Invariant($"{city}-{km:0}km"), CentreOf(city), km * 1000f, yaw);
+ yield return Take("tel_aviv-low-6km", CentreOf("tel_aviv", new Vector2(2500f, 1500f)), 6000f, 30f);
+ // Tal Heuberger's clock tower and minaret in Jaffa beside Tel Aviv's first blocks.
+ yield return Take("tel_aviv-tal-8km", CentreOf("tel_aviv", new Vector2(-300f, -1300f)), 8000f, 30f);
+ yield return Take("jerusalem-west-8km", CentreOf("jerusalem", new Vector2(-2600f, -300f)), 8000f, 20f);
+ yield return Take("jerusalem-old-8km", CentreOf("jerusalem", new Vector2(2300f, -2200f)), 8000f, 20f);
+ // Tel Aviv's edge towards its neighbours, where the kit's blocks meet Tal Heuberger's models.
+ yield return Take("tel_aviv-edge-12km", CentreOf("tel_aviv", new Vector2(4200f, -1800f)), 12000f);
+ }
+
+ [UnityTest]
+ public IEnumerator KitsOnly()
+ {
+ yield return Boot();
+ var towns = Scene.GetComponentInChildren<TownModelLayer>(true);
+ towns.Draw = false;
+ foreach (var (id, km) in new[] { ("nazareth", 14f), ("gaza", 14f), ("acre", 14f), ("petah_tikva", 14f), ("nahalal", 14f), ("degania_alef", 14f), ("rishon_lezion", 14f), ("qalqilya", 14f), ("beersheba", 14f) })
+ {
+ if (!Scene.KitFootprints.Any(f => f.id == id)) { Debug.LogWarning("SHOT kit-" + id + ": no footprint"); continue; }
+ yield return Take(FormattableString.Invariant($"kit-{id}-{km:0}km"), CentreOf(id), km * 1000f);
+ }
+ }
+}
diff --git a/unity/Assets/Tests/EditMode/KitAtlasShots.cs.meta b/unity/Assets/Tests/EditMode/KitAtlasShots.cs.meta
new file mode 100644
index 000000000..ba7a94436
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/KitAtlasShots.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: cf56bb9030454f67a77bc021f2cce8dc
diff --git a/unity/Assets/Tests/EditMode/KitAtlasTests.cs b/unity/Assets/Tests/EditMode/KitAtlasTests.cs
new file mode 100644
index 000000000..b2711370d
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/KitAtlasTests.cs
@@ -0,0 +1,150 @@
+#nullable enable
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using NUnit.Framework;
+using Statecraft.Game.Map.Kits;
+using UnityEditor;
+using UnityEngine;
+
+/// <summary>#2428: the town kits' one shared atlas. The kits stay one mesh per town with one material, so the atlas adds no draw;
+/// these tests pin what makes it work: the material carries it, each face names its cell, a wall counts whole bays, and the cells
+/// tile and carry no painted light. Surfaces are written as their alpha bytes (KitMesh.Facade).</summary>
+public class KitAtlasTests
+{
+ const byte WhiteCity = 17, Stone = 34, Plaster = 102, RoofTile = 153, FlatRoof = 170;
+ const string AtlasPath = "Assets/Art/Kits/kit_atlas.png";
+ const int Cell = 512;
+ static readonly Color32 Grey = new Color32(200, 200, 200, 255);
+
+ /// <summary>The cells that are one tiling surface all over: no windows, so any drift across one would be painted light.</summary>
+ static readonly int[] SolidCells = { 5, 6, 7, 8, 9, 12, 13 };
+
+ static (Vector2 min, Vector2 max) Span(KitMesh km, int from, int to)
+ {
+ Vector2 lo = km.Uvs[from], hi = km.Uvs[from];
+ for (int i = from; i < to; i++) { lo = Vector2.Min(lo, km.Uvs[i]); hi = Vector2.Max(hi, km.Uvs[i]); }
+ return (lo, hi);
+ }
+
+ [Test]
+ public void BothKitMaterialsCarryTheOneSharedAtlas()
+ {
+ var kit = AssetDatabase.LoadAssetAtPath<Material>("Assets/Materials/Kit.mat");
+ var tree = AssetDatabase.LoadAssetAtPath<Material>("Assets/Materials/Tree.mat");
+ Assert.IsTrue(kit.HasProperty("_KitAtlas"), "Statecraft/Kit has an atlas slot");
+ var atlas = kit.GetTexture("_KitAtlas") as Texture2DArray;
+ Assert.IsNotNull(atlas, "Kit.mat holds a Texture2DArray");
+ Assert.AreEqual(16, atlas!.depth, "the 4 x 4 sheet's cells");
+ Assert.AreEqual(Cell, atlas.width);
+ Assert.AreEqual(TextureWrapMode.Repeat, atlas.wrapMode, "every cell tiles");
+ Assert.Greater(atlas.mipmapCount, 5, "the mipmaps fade the windows to their mean far off");
+ Assert.AreSame(atlas, tree.GetTexture("_KitAtlas"), "one texture for both materials");
+ }
+
+ [Test]
+ public void AWallCountsWholeBaysSoACornerNeverCutsAWindow()
+ {
+ foreach (var (surface, bay) in new[] { ((Facade)WhiteCity, 3f), ((Facade)Stone, 4f) })
+ foreach (float wide in new[] { 13f, 21.7f, 24f })
+ {
+ var km = new KitMesh();
+ km.Box(0f, 0f, 20f, wide * 60f, 10f * 60f, -60f, 0f, 3.3f * 60f * 4f, Grey, Grey, surface, 60f, roofed: true);
+ var (min, max) = Span(km, 0, 4); // the first wall: wide across
+ float bays = (max.x - min.x) * 12f / bay;
+ Assert.AreEqual(Mathf.Round(bays), bays, 1e-3f, $"{surface} {wide} m: {bays} bays");
+ Assert.AreEqual(Mathf.Round(wide / bay), bays, 1e-3f, "the nearest whole count, not a stretch by a bay or more");
+ Assert.AreEqual(4f, max.y, 1e-3f, "v counts storeys");
+ }
+ }
+
+ [Test]
+ public void ARoofFaceNamesItsCellAndRunsInRealMetres()
+ {
+ var box = new KitMesh();
+ box.Box(0f, 0f, 0f, 3200f, 1600f, 0f, 0f, 400f, Grey, Grey, (Facade)Stone, 100f);
+ var (lo, hi) = Span(box, 16, 20);
+ Assert.AreEqual(FlatRoof, box.Colours[16].a, "a flat roof is the limed terrace's cell");
+ Assert.AreEqual(2f, hi.x - lo.x, 1e-3f, "32 real m at 16 m a cell");
+ Assert.AreEqual(1f, hi.y - lo.y, 1e-3f);
+
+ var gable = new KitMesh();
+ gable.Gable(0f, 0f, 0f, 800f, 400f, 300f, 170f, Grey, Grey, 100f);
+ Assert.AreEqual(RoofTile, gable.Colours[0].a, "a gable slope is tiled");
+ Assert.AreEqual(8f * 1.06f / 4f, gable.Uvs[2].x - gable.Uvs[0].x, 1e-3f, "along the ridge, at 4 real m a cell");
+ Assert.Greater(gable.Uvs[1].y - gable.Uvs[0].y, 0.5f, "up the slope, so the rows run with the eaves");
+ Assert.AreEqual(Plaster, gable.Colours[8].a, "the gable end is a plain wall");
+ }
+
+ /// <summary>The ground storey's doors: a Tel Aviv block's ribbon windows start one storey up, and a parapet is its wall's
+ /// plain surface, with no window rows through it.</summary>
+ [Test]
+ public void AWhiteCityParapetIsPlasterWithNoWindowRows()
+ {
+ var km = new KitMesh();
+ km.Box(0f, 0f, 0f, 1200f, 900f, 0f, 0f, 400f, Grey, Grey, (Facade)WhiteCity, 60f, parapet: 60f, parapetThickness: 20f);
+ Assert.AreEqual(Plaster, km.Colours[km.VertexCount - 1].a);
+ }
+
+ static Color32[] Sheet()
+ {
+ var tex = new Texture2D(2, 2, TextureFormat.RGBA32, false, false);
+ Assert.IsTrue(tex.LoadImage(File.ReadAllBytes(AtlasPath)), "the atlas decodes");
+ Assert.AreEqual(4 * Cell, tex.width); Assert.AreEqual(4 * Cell, tex.height);
+ var px = tex.GetPixels32();
+ Object.DestroyImmediate(tex);
+ return px;
+ }
+
+ /// <summary>Layer i of the sheet, as rows bottom up (LoadImage's GetPixels32 runs bottom up; layer 0 is the top left).</summary>
+ static float[,] Luminance(Color32[] sheet, int layer)
+ {
+ int cx = layer % 4, cy = 3 - layer / 4;
+ var l = new float[Cell, Cell];
+ for (int y = 0; y < Cell; y++)
+ for (int x = 0; x < Cell; x++)
+ {
+ var c = sheet[(cy * Cell + y) * 4 * Cell + cx * Cell + x];
+ l[y, x] = (0.2126f * c.r + 0.7152f * c.g + 0.0722f * c.b) / 255f;
+ }
+ return l;
+ }
+
+ /// <summary>No lighting painted in: a sun side would show as one half of a plain cell brighter than the other, either way.</summary>
+ [Test]
+ public void ASolidCellHasNoPaintedLight()
+ {
+ var sheet = Sheet();
+ foreach (int layer in SolidCells)
+ {
+ var l = Luminance(sheet, layer);
+ float left = 0f, right = 0f, low = 0f, high = 0f;
+ for (int y = 0; y < Cell; y++)
+ for (int x = 0; x < Cell; x++)
+ {
+ if (x < Cell / 2) left += l[y, x]; else right += l[y, x];
+ if (y < Cell / 2) low += l[y, x]; else high += l[y, x];
+ }
+ Assert.AreEqual(1f, left / right, 0.03f, $"layer {layer}: left against right");
+ Assert.AreEqual(1f, low / high, 0.06f, $"layer {layer}: bottom against top");
+ }
+ }
+
+ /// <summary>A solid cell's opposite edges match about as well as any two neighbouring rows inside it: the seams do not show.</summary>
+ [Test]
+ public void ASolidCellTilesWithNoSeam()
+ {
+ var sheet = Sheet();
+ foreach (int layer in SolidCells)
+ {
+ var l = Luminance(sheet, layer);
+ float seam = 0f, inside = 0f;
+ for (int x = 0; x < Cell; x++)
+ {
+ seam += Mathf.Abs(l[0, x] - l[Cell - 1, x]) + Mathf.Abs(l[x, 0] - l[x, Cell - 1]);
+ inside += Mathf.Abs(l[200, x] - l[201, x]) + Mathf.Abs(l[x, 200] - l[x, 201]);
+ }
+ Assert.LessOrEqual(seam, 2.5f * inside + 0.02f * 2 * Cell, $"layer {layer}: seam {seam}, inside {inside}");
+ }
+ }
+}
diff --git a/unity/Assets/Tests/EditMode/KitAtlasTests.cs.meta b/unity/Assets/Tests/EditMode/KitAtlasTests.cs.meta
new file mode 100644
index 000000000..479763d92
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/KitAtlasTests.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: cedac669dd8c4d7ba5a8515cc3901b62