agent-manifesto-kit 1.7.0 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/README.md +37 -0
  2. package/collection/skills/art-direction-pass/SKILL.md +245 -0
  3. package/collection/skills/art-direction-pass/agents/openai.yaml +4 -0
  4. package/collection/skills/art-direction-pass/assets/presets.json +9 -0
  5. package/collection/skills/art-direction-pass/assets/visual_capture.gd +77 -0
  6. package/collection/skills/art-direction-pass/scripts/compare.py +86 -0
  7. package/collection/skills/art-direction-pass/scripts/metrics.py +56 -0
  8. package/collection/skills/art-direction-pass/scripts/test_tools.py +83 -0
  9. package/collection/skills/concept-scene-builder/SKILL.md +313 -0
  10. package/collection/skills/concept-scene-builder/agents/openai.yaml +4 -0
  11. package/collection/skills/concept-scene-builder/references/field-lessons.md +113 -0
  12. package/collection/skills/concept-scene-builder/scripts/blend.py +32 -0
  13. package/collection/skills/concept-scene-builder/scripts/crop.py +56 -0
  14. package/collection/skills/concept-scene-builder/scripts/grid_overlay.py +117 -0
  15. package/collection/skills/concept-scene-builder/scripts/test_tools.py +89 -0
  16. package/collection/skills/machine-builder/SKILL.md +222 -0
  17. package/collection/skills/machine-builder/agents/openai.yaml +4 -0
  18. package/collection/skills/machine-builder/assets/spec.example.yaml +47 -0
  19. package/collection/skills/machine-builder/scripts/validate.py +307 -0
  20. package/collection/skills/roadmap/SKILL.md +49 -0
  21. package/collection/skills/roadmap/agents/openai.yaml +4 -0
  22. package/collection/skills/roadmap/assets/post-commit.sh +33 -0
  23. package/collection/skills/roadmap/assets/template.html +470 -0
  24. package/collection/skills/roadmap/references/format.md +51 -0
  25. package/collection/skills/roadmap/scripts/roadmap.py +852 -0
  26. package/collection/skills/roadmap/scripts/test_roadmap.py +578 -0
  27. package/package.json +1 -1
package/README.md CHANGED
@@ -131,6 +131,43 @@ generation, key-pose error gates, frame sheets and residual easing, and Blender
131
131
  Mixamo-named rig's pose into a key pose and bake takes back onto the rig. kimodo.cpp, its models and
132
132
  Blender are installed separately; `KIMODO_ROOT` and `BLENDER` point at them.
133
133
 
134
+ Give any project a roadmap page from its TaskPilot items and git history:
135
+
136
+ ```bash
137
+ agentkit sync roadmap --provider claude,codex
138
+ ```
139
+
140
+ The [Roadmap skill](collection/skills/roadmap/SKILL.md) installs `scripts/roadmap.py` (`init`, `build`,
141
+ `check`, `path`), one shared template (English and Russian), a post-commit hook and the format
142
+ reference. The generated page is self-contained and carries its template id and data, so tools such as
143
+ Astro Preview can list it, and `check --template-from` reports a project whose template drifted.
144
+
145
+ Run an art direction pass on a game, bringing its look closer to the concept art:
146
+
147
+ ```bash
148
+ agentkit sync art-direction-pass --provider claude,codex
149
+ ```
150
+
151
+ The [Art Direction Pass skill](collection/skills/art-direction-pass/SKILL.md) audits the game against its
152
+ concepts, iterates on lighting, atmosphere and materials with deterministic captures and a blind A/B
153
+ reviewer, and codifies the result as per-category art guidelines, a graphics profile and material
154
+ presets. It ships a Godot 4 capture autoload, a camera preset template and Python tools for comparison
155
+ sheets, blind pairs and image metrics (Pillow and numpy).
156
+
157
+ Build a game environment from a concept image, and game-ready machines from a spec:
158
+
159
+ ```bash
160
+ agentkit sync concept-scene-builder machine-builder --provider claude,codex
161
+ ```
162
+
163
+ The [Concept Scene Builder skill](collection/skills/concept-scene-builder/SKILL.md) turns a concept into
164
+ a parametric asset kit, a layout JSON (hex, square or free-form in metres) and a data-built golden
165
+ scene, with grid-overlay, crop and blend tools (Pillow and numpy). The
166
+ [Machine Builder skill](collection/skills/machine-builder/SKILL.md) builds mechs and vehicles as rigid
167
+ parts on an armature from a spec and ships a Blender `validate.py` for collisions, support margin,
168
+ budgets and sockets. Both share the `docs/art/` format with Art Direction Pass; Blender and the game
169
+ engine are installed separately.
170
+
134
171
  Adopt a single skill for Codex:
135
172
 
136
173
  ```bash
@@ -0,0 +1,245 @@
1
+ ---
2
+ name: art-direction-pass
3
+ description: Iteratively bring an existing game's visuals closer to its concept art and codify the result as per-category art guidelines, presets and capture/compare scripts. Use for 'match the concept', 'improve the look/vibe', art direction passes.
4
+ ---
5
+
6
+ # Art Direction Pass
7
+
8
+ You act as a senior art director + technical artist + lighting artist + rendering engineer on an EXISTING playable game. The concept art is the visual source of truth; the game is the implementation to improve.
9
+
10
+ The goal is not more graphics. The goal is a coherent, art-directed image that matches the concept's mood, palette, lighting and shape language, plus durable guidelines and tools so every future asset follows the same rules.
11
+
12
+ Do not redesign gameplay, change balance, remove systems, or break collisions. Keep the game playable.
13
+
14
+ ## Prerequisites
15
+
16
+ - A runnable game with a real display/GPU for captures. Godot 4 and Three.js have notes and templates below; other engines need an equivalent capture tool. Verify with the engine itself (for example `godot --version`).
17
+ - Python 3 with Pillow and numpy: `python3 -m pip install Pillow numpy`; verify with `python3 -c "import PIL, numpy"`.
18
+ - A way to spawn a fresh reviewer that sees only images: a subagent, or a separate session when the tool has no subagents.
19
+ - The skill's resources, installed with it under `.claude/skills/art-direction-pass/` (other tools use their own skills directory): `assets/presets.json`, `assets/visual_capture.gd`, `scripts/compare.py`, `scripts/metrics.py`. See Templates for usage.
20
+
21
+ ## Arguments
22
+
23
+ Read them from the invocation text. Defaults in brackets.
24
+
25
+ - `scope` [global,environment] — any of: `global`, `terrain`, `architecture`, `props`, `vegetation`, `characters`, `vfx`, `all`. `environment` = terrain + architecture + props + vegetation. Categories outside scope are frozen: do not modify their assets; only keep them readable through global lighting/post.
26
+ - `mode` [full] — `audit` (Phases 0–2 only, then stop), `full` (all phases), `codify` (Phase 4 only: extract guidelines/presets from the current state; requires an existing `docs/art/direction/`, otherwise run Phases 0–2 first, including Phase 1 when captures are possible).
27
+ - `concepts` [docs/art/reference/] — folder with concept images, optionally in subfolders per category.
28
+ - `max_iterations` [12], `min_iterations` [5].
29
+
30
+ If the scope or concept location is ambiguous and the user is present, ask once. Otherwise state the reading you took at the top of the iteration log and continue. Missing concepts are a stop condition, not an ambiguity.
31
+
32
+ ## Git
33
+
34
+ The pass relies on a baseline, one recorded state per kept iteration and reverts of rejected ones. Follow the project's own Git rules: if its instructions require approval for commits, tags or branches, ask once before Phase 3 (`audit` needs no Git permission) for permission to commit iterations on the current (or a dedicated) branch. Never push, and never commit changes this pass did not make.
35
+
36
+ Without that permission, or when the working tree already has the user's own changes, use snapshots instead of commits. A snapshot is a tree object written through a temporary index; it creates no commit, ref or tag and leaves the project's index alone. `docs/art/` is excluded so reverts never touch the log, patches or captures:
37
+
38
+ ```sh
39
+ snap() { idx=$(mktemp); GIT_INDEX_FILE=$idx git read-tree HEAD && GIT_INDEX_FILE=$idx git add -A -- . ':!docs/art' && GIT_INDEX_FILE=$idx git write-tree; rm -f "$idx"; }
40
+ ```
41
+
42
+ - Baseline: `snap` before any change; record its id and `git rev-parse HEAD` in `docs/art/iterations/log.md`. The user's uncommitted and untracked files are part of it and never appear in iteration patches.
43
+ - Kept iteration: `snap` again, save `git diff --binary <last kept> <new>` as `docs/art/iterations/<NN>/change.patch`, record the new id as the last kept state.
44
+ - Rejected iteration: `snap` the current state as `<cur>`, run `git diff --binary <cur> <last kept> | git apply --binary` (this also deletes files the iteration added), then check that a fresh `snap` equals `<last kept>`.
45
+
46
+ Never build on a degraded result either way.
47
+
48
+ ## Stop conditions
49
+
50
+ - Captures cannot be produced (no display/GPU, for example in a sandbox or CI) or stay nondeterministic after a reasonable fix attempt: deliver the `audit` outputs, report the blocker, and do not start Phase 3.
51
+ - No fresh blind reviewer can be spawned: same as above. Never review your own changes in place of the blind reviewer.
52
+ - No concept images at `concepts`: ask if the user is present; otherwise stop after Phase 0 notes and report it. Never derive the target from the game itself.
53
+ - The game no longer runs or existing tests fail after a change: revert that change before anything else.
54
+
55
+ ## Phase 0 — Discover
56
+
57
+ 1. Read the project's agent instructions (`AGENTS.md` or the tool's own instruction file), README and any existing `docs/art/`. If `docs/art/` exists, this is a follow-up pass: update the existing documents, never rewrite them from scratch, and append to `docs/art/CHANGELOG.md`.
58
+ 2. Identify: engine and version, renderer, color space, target platform and FPS, gameplay camera (projection, pitch, distance, FOV), resolution, how to run the game, existing tests.
59
+ 3. List the categories that actually exist in this game. Only create guideline files for those.
60
+ 4. Record the baseline (see Git). With commit permission and a clean tree, tag the current commit `visual-baseline-<date>` (or the next free tag); otherwise take the baseline snapshot and create no tag.
61
+
62
+ ## Phase 1 — Capture Harness
63
+
64
+ Subject to the stop conditions. Visual work without reproducible screenshots is guessing. Build or reuse a capture tool before any visual change.
65
+
66
+ Requirements:
67
+ - Named camera presets in `tools/visual/presets.json`: at least `gameplay_wide` (the real gameplay camera), one `gameplay_<area>` per distinct biome/area, and one close-up per in-scope category. Close-ups never replace gameplay-distance checks.
68
+ - Deterministic: fixed RNG seed applied before level generation, paused animations/particles, fixed time of day/weather.
69
+ - Settle frames before capture (shadows, TAA, GI, auto-exposure).
70
+ - Output to `docs/art/iterations/<NN>/<preset>.png` (`00` is the baseline) plus `perf.json` (average GPU and CPU render time per preset, measured with vsync off).
71
+ - Verify: two consecutive runs of the same build produce identical (or near-identical, mean abs diff < 1/255) images. Fix nondeterminism before Phase 3.
72
+
73
+ Prefer a capture method already described in the project's instructions; otherwise use the templates.
74
+
75
+ ## Phase 2 — Forensics and Direction
76
+
77
+ Analyse the concepts and the current game separately, then compare.
78
+
79
+ ### Direction documents
80
+
81
+ ```
82
+ docs/art/
83
+ direction/
84
+ 00-global.md # applies to everything
85
+ 10-terrain.md
86
+ 20-architecture.md # buildings, structures, walls, bridges
87
+ 30-props.md
88
+ 40-vegetation.md
89
+ 50-characters.md # heroes, NPCs, enemies, mechs, vehicles, units
90
+ 60-vfx.md
91
+ gap-report.md
92
+ iterations/
93
+ CHANGELOG.md
94
+ reference/ # concepts, per category if available
95
+ ```
96
+
97
+ Every statement must be an actionable constraint with numbers where possible. Bad: "richer, more polished". Good: "roofs overhang walls by 0.4–0.6 m; recessed openings are 2–3 value steps darker than the wall".
98
+
99
+ If a trait cannot be read confidently from the concept, write it under `Uncertain` instead of inventing it. The concepts may be AI-generated: they define mood, palette, lighting, value structure, shape language and detail density — not every individual detail. Never copy non-functional or physically implausible details.
100
+
101
+ **00-global.md** sections:
102
+ - Mood in one sentence, then the 5 traits that create it
103
+ - Palette: dominant / secondary / accent as hex, with value (0–100) and approximate share of screen
104
+ - Value structure: where the darkest and lightest values live; foreground/midground/background separation
105
+ - Lighting: key direction (azimuth/elevation), key color and intensity, fill/ambient color, shadow color, shadow softness, warm/cool relationship
106
+ - Atmosphere: fog color, density, height falloff, aerial perspective, sky
107
+ - Post: tone mapper, exposure, contrast, saturation, grading, bloom (only with purpose), AA, AO
108
+ - Camera and composition: projection, angle, framing, focal hierarchy
109
+ - Global material rules: roughness ranges, metallic usage, texel density (px/m), bevel width scale, weathering level
110
+ - Readability rules: what must always stand out at gameplay distance
111
+ - Uncertain
112
+
113
+ **Each category file** (10–60) uses the same template:
114
+ - Role in the scene (focal / supporting / background) and screen share
115
+ - Shape language: dominant forms, angular vs soft, exaggeration, bevel/chamfer width
116
+ - Proportions and scale with numbers (relative to player/character height)
117
+ - Detail hierarchy: macro / medium / micro — what goes where, density, quiet areas
118
+ - Materials: preset table — name, albedo hex, roughness, metallic, normal strength, texture scale
119
+ - Palette slice: which global colors this category may use
120
+ - Readability: value/hue separation from neighbours at gameplay distance
121
+ - Asset spec for NEW assets: triangle budget, texel density, pivot and scale conventions, naming, which material presets to use, LOD rules. Write it so an asset-generation pipeline (e.g. Blender scripts) can follow it mechanically.
122
+ - Do / Don't (short, concrete)
123
+ - Uncertain
124
+
125
+ Category-specific emphasis:
126
+ - terrain: macro value variation, tiling breakup at gameplay distance, blend transitions, contact with objects
127
+ - architecture: silhouette variety, roof/overhang thickness, recess depth, grounding, construction logic
128
+ - props: clustering, scale consistency, they support rather than compete
129
+ - vegetation: cluster shapes, color variation range, wind motion, density at gameplay camera
130
+ - characters: silhouette and value separation from environment, team/faction color rules, rigid vs skinned parts, emissive usage
131
+ - vfx: color and value budget relative to the scene, bloom budget, duration, readability of gameplay information
132
+
133
+ ### Gap report
134
+
135
+ `docs/art/gap-report.md` — a prioritized table: Category | Target | Current | Root cause (geometry / material / texture / lighting / camera / color management / environment design / missing context / inconsistency) | Fix | Impact | Effort | Verification | Status.
136
+
137
+ Do not start with textures when lighting, values or composition are the real problem.
138
+
139
+ ### Checkpoint
140
+
141
+ If the user is present: stop, show `00-global.md` and the top 10 gaps, wait for approval. A wrong reading of the concept poisons every iteration. If unattended, continue and note it in the log. In `audit` mode, stop here.
142
+
143
+ ## Phase 3 — Iterate
144
+
145
+ Subject to the stop conditions.
146
+
147
+ ### Priority order
148
+
149
+ Work top-down. Global, scene-wide fixes before per-asset fixes.
150
+
151
+ 1. Color management, tone mapping, exposure
152
+ 2. Key light, fill/ambient, shadows
153
+ 3. Atmosphere and depth: fog, aerial perspective, sky, grading
154
+ 4. Global palette and value structure
155
+ 5. Shared material presets per category
156
+ 6. Composition and environment design (set dressing, clustering, negative space)
157
+ 7. Geometry: silhouettes and proportions, only where they clearly contradict the concept
158
+ 8. Secondary detail and polish
159
+
160
+ ### Loop
161
+
162
+ Each iteration:
163
+ 1. Capture all presets.
164
+ 2. Build comparison sheets with `compare.py sheet` and metrics with `metrics.py`.
165
+ 3. Diagnose the 3–5 biggest remaining discrepancies; separate root causes from symptoms.
166
+ 4. Change ONE group (lighting, or materials, or atmosphere…). For uncertain parameters, try 2–3 clearly different variants instead of tiny nudges.
167
+ 5. Capture again and run the blind reviewer on every preset.
168
+ 6. Keep or revert based on the evidence. Never build on a degraded result.
169
+ 7. Record a kept iteration as `art(<NN>): <what changed> — reviewer <old>→<new>` (commit message, or the saved diff's heading). Append to `docs/art/iterations/log.md`: discrepancies addressed, changes, parameters, reviewer scores, remaining issues, frame time delta.
170
+
171
+ An iteration's gain is mean(after) − mean(before) over all criteria and presets, scored in the same review; a reverted iteration counts as 0. Stop after at least `min_iterations` when two consecutive iterations each gain < 0.5, or at `max_iterations`.
172
+
173
+ Never claim an improvement without an updated render. If capture fails, say so; do not pretend to verify.
174
+
175
+ ### Blind reviewer
176
+
177
+ Every iteration, spawn a FRESH reviewer (subagent or separate session). For each preset, run `compare.py blind` into a temporary directory outside the project (`-o <tmp>/<NN>/<preset>`) with the mapping kept in the project (`--mapping docs/art/iterations/<NN>/blind/<preset>.mapping.json`). Each preset is shuffled separately, so A and B mean different things per preset. Copy the concept images for the in-scope categories (and the global ones) into `<tmp>/<NN>/concepts/`. Give the reviewer only absolute paths inside `<tmp>/<NN>/`, tell it to open only the listed files and never list directories or read anything else, and run it without project access where the tool allows. It never sees code, diffs, the log, the mappings or the project's capture folders.
178
+
179
+ To compare 2–3 variants of one change, review each variant against the last kept state and keep the one with the best gain among those the reviewer prefers.
180
+
181
+ For each preset it must:
182
+ 1. Choose which of A/B is closer to the concept in overall mood and style, and why.
183
+ 2. Score both 1–5 on: mood, lighting, palette, value/contrast, atmosphere/depth, materials, cohesion, focal readability. Add category-specific criteria for in-scope categories.
184
+ 3. List the top 3 remaining discrepancies.
185
+
186
+ Keep a change only if the reviewer prefers it on `gameplay_wide` and on a majority of all presets. Metrics are supporting evidence; the reviewer and gameplay readability decide.
187
+
188
+ ### Rules for effects
189
+
190
+ Every new effect needs: the discrepancy it addresses, why this technique, its parameters, its cost, how it was verified. No universal bloom, saturation boosts, vignette or fog used to hide weak models or materials. No uncontrolled procedural noise, random decoration, arbitrary lights or excessive particles. Do not raise polygon counts without a visible benefit.
191
+
192
+ ## Phase 4 — Codify
193
+
194
+ The result must survive the next asset. Turn what worked into data and rules.
195
+
196
+ - **Graphics profile**: one central place for all look parameters (Godot: a `GraphicsProfile` Resource `.tres` applied by a script to WorldEnvironment, lights and post; Three.js: a single `graphics-profile.json/ts`). No magic numbers scattered through the code.
197
+ - **Material presets library**: one file per preset, grouped by category (Godot: `res://art/materials/<category>/<preset>.tres`). Assets reference presets instead of ad-hoc materials.
198
+ - **Direction docs**: update every category file with the final numbers that actually shipped (light angles, hex values, roughness ranges, budgets). Mark what was verified vs still uncertain.
199
+ - **Asset checklist**: a short checklist per category at the end of each file, for whoever (human or agent) makes the next asset.
200
+ - Optional **asset lint** script: flags meshes using non-preset materials, wrong scale, triangle budget overruns, texel density outliers.
201
+
202
+ Codify refactors must not change the image: capture every preset before and after with the Phase 1 harness and require a mean abs diff < 1/255. If captures are impossible, say the refactor is visually unverified.
203
+
204
+ In `codify` mode, do only this phase from the current state.
205
+
206
+ ## Phase 5 — Final review
207
+
208
+ Write `docs/art/iterations/final.md`: before/after sheets for every preset, top improvements, remaining discrepancies and why they were not resolved, next highest-impact steps, frame time before/after, confirmation that the game still runs and existing tests pass. Do not declare the target achieved unless the screenshots support it.
209
+
210
+ ## Constraints
211
+
212
+ - Work in the existing stack; no new frameworks or heavy dependencies (Pillow and numpy for tools are fine).
213
+ - Respect performance: measure frame time per preset every iteration; document any trade-off over 10%.
214
+ - Do not distort the gameplay camera to win a pixel-level match.
215
+ - Prefer one global fix over many local patches, but keep meaningful variation where the concept has it.
216
+
217
+ ## Engine notes
218
+
219
+ **Godot 4**
220
+ - `--headless` does not render. Capture with a real display/GPU.
221
+ - Look levers: WorldEnvironment (tonemap: Filmic/ACES/AgX where available, exposure, white; SSAO, SSIL, SDFGI or baked lightmaps/VoxelGI; volumetric fog, depth/height fog; glow; adjustments + color correction LUT), DirectionalLight3D (angle, color, energy, shadow blur, PSSM splits, bias), ReflectionProbe, decals, StandardMaterial3D roughness/metallic/normal.
222
+ - Check the renderer (Forward+/Mobile/Compatibility): many effects only exist in Forward+.
223
+
224
+ **Three.js**
225
+ - Capture via Playwright in headed mode; renderer with `preserveDrawingBuffer: true`, then `canvas.toDataURL()`.
226
+ - Look levers: `outputColorSpace`, `toneMapping` (ACES/AgX/Neutral) + `toneMappingExposure`, PMREM environment, shadow map type and radius, postprocessing (SSAO/GTAO, bloom, color grading), fog/FogExp2.
227
+
228
+ ## Templates
229
+
230
+ Copy `assets/` templates into `tools/visual/` and adapt them to the project. Invoke the `scripts/` tools by path from the project root, so relative outputs land in the project.
231
+
232
+ - `assets/presets.json` — scene, seed, settle frames and camera presets (`name`, `pos`, `target`, `fov`; `ortho: true` with `size` for orthographic cameras).
233
+ - `assets/visual_capture.gd` — Godot 4 autoload `VisualCapture`. Run:
234
+ `godot --path . --resolution 1920x1080 -- --visual-capture=res://tools/visual/presets.json --visual-out=/abs/path/docs/art/iterations/01`.
235
+ If the game's camera controller fights `make_current()`, disable it for capture. If particles keep moving while paused, set their `speed_scale` to 0 during capture.
236
+ - `scripts/compare.py` — `compare.py sheet REF BEFORE [AFTER] -o sheet.png`; `compare.py blind BEFORE AFTER -o <tmp>/<NN>/<preset> --mapping docs/art/iterations/<NN>/blind/<preset>.mapping.json` writes `A.png`/`B.png` and refuses a mapping inside the reviewer folder.
237
+ - `scripts/metrics.py` — `metrics.py IMG [IMG...] -o metrics.json`: luminance percentiles (p5/p50/p95), mean saturation and a 6-color palette with screen shares. Compare reference vs current: large gaps point to tone mapping/exposure (luminance), grading (saturation) or materials/lighting color (palette).
238
+
239
+ Tests of the tools themselves: `python3 -B -m unittest discover -s .claude/skills/art-direction-pass/scripts` (skipped without Pillow and numpy).
240
+
241
+ ## Output
242
+
243
+ - `audit`: `tools/visual/` with the capture harness (and its autoload registration), `docs/art/iterations/00/` (baseline captures, `perf.json`), `docs/art/iterations/log.md`, `docs/art/direction/00-global.md`, category files for in-scope categories, `docs/art/gap-report.md`; report the top 10 gaps and any stop condition hit. Without captures, mark the gap report's Current column as read from code, unverified.
244
+ - `full`: the above plus `docs/art/iterations/<NN>/`, the codified profile and presets, and `final.md`; report the reviewer score trajectory, frame time before/after and the remaining discrepancies.
245
+ - `codify`: the graphics profile, material presets and updated direction docs, plus whatever Phases 0–2 created when `direction/` was missing; report the files changed and whether the image was verified unchanged.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Art Direction Pass"
3
+ short_description: "Bring a game's visuals closer to its concept art and codify the look"
4
+ default_prompt: "Use $art-direction-pass to audit this game against its concept art, iterate on the look with blind reviews and codify the result as art guidelines and presets."
@@ -0,0 +1,9 @@
1
+ {
2
+ "scene": "res://levels/test_level.tscn",
3
+ "seed": 1337,
4
+ "settle_frames": 90,
5
+ "presets": [
6
+ {"name": "gameplay_wide", "pos": [0, 30, 25], "target": [0, 0, 0], "fov": 45},
7
+ {"name": "architecture_close", "pos": [8, 6, 10], "target": [5, 2, 2], "fov": 40}
8
+ ]
9
+ }
@@ -0,0 +1,77 @@
1
+ # Deterministic preset capture for Godot 4. Copy to the project (e.g. tools/visual/visual_capture.gd),
2
+ # register it as the autoload `VisualCapture`, and run with a real display/GPU (--headless does not render):
3
+ # godot --path . --resolution 1920x1080 -- --visual-capture=res://tools/visual/presets.json --visual-out=/abs/path/docs/art/iterations/01
4
+ # Without --visual-capture the autoload does nothing, so it is safe to keep registered.
5
+
6
+ extends Node
7
+
8
+ var _cfg: Dictionary
9
+
10
+ func _ready() -> void:
11
+ var cfg_path := _arg("--visual-capture")
12
+ if cfg_path.is_empty():
13
+ return
14
+ process_mode = Node.PROCESS_MODE_ALWAYS
15
+ var parsed = JSON.parse_string(FileAccess.get_file_as_string(cfg_path))
16
+ if typeof(parsed) != TYPE_DICTIONARY:
17
+ push_error("visual capture: cannot read presets from %s" % cfg_path)
18
+ get_tree().quit(1)
19
+ return
20
+ _cfg = parsed
21
+ seed(int(_cfg.get("seed", 1))) # before the level generates anything
22
+ _run.call_deferred(_arg("--visual-out", "user://visual_capture"))
23
+
24
+ func _arg(key: String, fallback := "") -> String:
25
+ for a in OS.get_cmdline_user_args():
26
+ if a.begins_with(key + "="):
27
+ return a.substr(key.length() + 1)
28
+ return fallback
29
+
30
+ func _run(out: String) -> void:
31
+ var tree := get_tree()
32
+ if _cfg.has("scene"):
33
+ tree.change_scene_to_file(_cfg.scene)
34
+ await tree.process_frame
35
+ await tree.process_frame
36
+ tree.paused = true # freezes gameplay/animation; rendering continues
37
+ # Measure real render cost (GPU and render-thread CPU), not the paused process callbacks.
38
+ DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)
39
+ var vp_rid := tree.root.get_viewport_rid()
40
+ RenderingServer.viewport_set_measure_render_time(vp_rid, true)
41
+ DirAccess.make_dir_recursive_absolute(out)
42
+ var cam := Camera3D.new()
43
+ cam.process_mode = Node.PROCESS_MODE_ALWAYS
44
+ tree.root.add_child(cam)
45
+ var perf := {}
46
+ for p in _cfg.presets:
47
+ cam.fov = float(p.get("fov", 50.0))
48
+ if p.get("ortho", false):
49
+ cam.projection = Camera3D.PROJECTION_ORTHOGONAL
50
+ cam.size = float(p.size)
51
+ else:
52
+ cam.projection = Camera3D.PROJECTION_PERSPECTIVE
53
+ cam.global_position = Vector3(p.pos[0], p.pos[1], p.pos[2])
54
+ var target := Vector3(p.target[0], p.target[1], p.target[2])
55
+ var dir := (target - cam.global_position).normalized()
56
+ cam.look_at(target, Vector3.FORWARD if absf(dir.dot(Vector3.UP)) > 0.999 else Vector3.UP)
57
+ cam.make_current()
58
+ var n := int(_cfg.get("settle_frames", 60))
59
+ var measured := 0
60
+ var gpu := 0.0
61
+ var cpu := 0.0
62
+ for i in n:
63
+ await RenderingServer.frame_post_draw
64
+ if i >= n >> 1: # average the settled half only
65
+ gpu += RenderingServer.viewport_get_measured_render_time_gpu(vp_rid)
66
+ cpu += RenderingServer.viewport_get_measured_render_time_cpu(vp_rid)
67
+ measured += 1
68
+ tree.root.get_texture().get_image().save_png("%s/%s.png" % [out, p.name])
69
+ perf[p.name] = {
70
+ "avg_gpu_render_ms": gpu / max(measured, 1),
71
+ "avg_cpu_render_ms": cpu / max(measured, 1),
72
+ "fps": Engine.get_frames_per_second(),
73
+ }
74
+ var f := FileAccess.open("%s/perf.json" % out, FileAccess.WRITE)
75
+ f.store_string(JSON.stringify(perf, " "))
76
+ f.close()
77
+ tree.quit()
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env python3
2
+ """Side-by-side comparison sheets and blind A/B pairs for art direction passes.
3
+
4
+ sheet: compare.py sheet REF BEFORE [AFTER] -o out.png
5
+ blind: compare.py blind BEFORE AFTER -o dir/ [--mapping mapping.json]
6
+
7
+ `blind` writes dir/A.png and dir/B.png in random order. The mapping is written to --mapping, or
8
+ next to the folder (dir.mapping.json), never inside it. Put dir in a temporary directory outside
9
+ the project and keep the mapping in the project, away from the reviewer's files.
10
+ Requires Pillow.
11
+ """
12
+ import argparse
13
+ import json
14
+ import pathlib
15
+ import random
16
+
17
+ from PIL import Image, ImageDraw
18
+
19
+ HEIGHT = 720
20
+ GAP = 10
21
+ LABEL_BAR = 30
22
+
23
+
24
+ def fit(path, height=HEIGHT):
25
+ im = Image.open(path).convert("RGB")
26
+ return im.resize((max(1, round(im.width * height / im.height)), height), Image.LANCZOS)
27
+
28
+
29
+ def sheet(paths, labels, out):
30
+ ims = [fit(p) for p in paths]
31
+ width = sum(i.width for i in ims) + GAP * (len(ims) - 1)
32
+ canvas = Image.new("RGB", (width, HEIGHT + LABEL_BAR), (20, 20, 20))
33
+ draw, x = ImageDraw.Draw(canvas), 0
34
+ for im, label in zip(ims, labels):
35
+ canvas.paste(im, (x, LABEL_BAR))
36
+ draw.text((x + 8, 8), label, fill=(230, 230, 230))
37
+ x += im.width + GAP
38
+ canvas.save(out)
39
+ return out
40
+
41
+
42
+ def mapping_path(out_dir):
43
+ out_dir = pathlib.Path(out_dir).resolve()
44
+ return out_dir.parent / f"{out_dir.name}.mapping.json"
45
+
46
+
47
+ def blind(before, after, out_dir, rng=random, mapping=None):
48
+ out = pathlib.Path(out_dir).resolve()
49
+ target = pathlib.Path(mapping).resolve() if mapping else mapping_path(out)
50
+ if out == target.parent or out in target.parents:
51
+ raise ValueError("the mapping must not be written inside the reviewer folder")
52
+ images = [Image.open(p).convert("RGB") for p in (before, after)] # fail before writing anything
53
+ out.mkdir(parents=True, exist_ok=True)
54
+ pair = [("before", images[0]), ("after", images[1])]
55
+ rng.shuffle(pair)
56
+ for slot, (_, image) in zip("AB", pair):
57
+ image.save(out / f"{slot}.png")
58
+ result = {slot: label for slot, (label, _) in zip("AB", pair)}
59
+ target.parent.mkdir(parents=True, exist_ok=True)
60
+ target.write_text(json.dumps(result) + "\n")
61
+ return result
62
+
63
+
64
+ def main(argv=None):
65
+ ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
66
+ ap.add_argument("mode", choices=["sheet", "blind"])
67
+ ap.add_argument("images", nargs="+")
68
+ ap.add_argument("-o", required=True, help="output PNG (sheet) or output folder (blind)")
69
+ ap.add_argument("--mapping", help="blind: where to write the A/B mapping (default: beside the folder)")
70
+ a = ap.parse_args(argv)
71
+ if a.mode == "sheet":
72
+ if not 2 <= len(a.images) <= 3:
73
+ ap.error("sheet takes REF BEFORE [AFTER]")
74
+ sheet(a.images, ["reference", "before", "after"][: len(a.images)], a.o)
75
+ else:
76
+ if len(a.images) != 2:
77
+ ap.error("blind takes exactly BEFORE AFTER")
78
+ try:
79
+ blind(a.images[0], a.images[1], a.o, mapping=a.mapping)
80
+ except ValueError as e:
81
+ ap.error(str(e))
82
+ return 0
83
+
84
+
85
+ if __name__ == "__main__":
86
+ raise SystemExit(main())
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env python3
2
+ """Luminance and saturation statistics plus a 6-color palette per image.
3
+
4
+ metrics.py IMG [IMG...] -o metrics.json
5
+
6
+ Deterministic (fixed k-means seed). Requires Pillow and numpy.
7
+ """
8
+ import argparse
9
+ import json
10
+
11
+ import numpy as np
12
+ from PIL import Image
13
+
14
+ LUMA = np.array([0.2126, 0.7152, 0.0722])
15
+
16
+
17
+ def stats(path, k=6, iters=12):
18
+ im = Image.open(path).convert("RGB")
19
+ im.thumbnail((256, 256))
20
+ px = np.asarray(im, dtype=np.float32).reshape(-1, 3) / 255.0
21
+ lum = px @ LUMA
22
+ mx, mn = px.max(1), px.min(1)
23
+ sat = np.where(mx > 0, (mx - mn) / np.maximum(mx, 1e-6), 0)
24
+ k = min(k, len(px))
25
+ rng = np.random.default_rng(0)
26
+ centers = px[rng.choice(len(px), k, replace=False)]
27
+ for _ in range(iters):
28
+ labels = ((px[:, None] - centers[None]) ** 2).sum(-1).argmin(1)
29
+ centers = np.array([px[labels == i].mean(0) if (labels == i).any() else centers[i] for i in range(k)])
30
+ labels = ((px[:, None] - centers[None]) ** 2).sum(-1).argmin(1)
31
+ share = np.bincount(labels, minlength=k) / len(px)
32
+ order = share.argsort()[::-1]
33
+ return {
34
+ "lum_p5_p50_p95": [round(float(v), 3) for v in np.percentile(lum, [5, 50, 95])],
35
+ "sat_mean": round(float(sat.mean()), 3),
36
+ "palette": [
37
+ {"hex": "#%02x%02x%02x" % tuple(np.clip(np.rint(centers[i] * 255), 0, 255).astype(int)),
38
+ "share": round(float(share[i]), 3)}
39
+ for i in order
40
+ ],
41
+ }
42
+
43
+
44
+ def main(argv=None):
45
+ ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
46
+ ap.add_argument("images", nargs="+")
47
+ ap.add_argument("-o", required=True)
48
+ a = ap.parse_args(argv)
49
+ with open(a.o, "w") as f:
50
+ json.dump({p: stats(p) for p in a.images}, f, indent=2)
51
+ f.write("\n")
52
+ return 0
53
+
54
+
55
+ if __name__ == "__main__":
56
+ raise SystemExit(main())
@@ -0,0 +1,83 @@
1
+ """Model-free tests for compare.py and metrics.py. Skipped when Pillow or numpy is missing."""
2
+ import json
3
+ import pathlib
4
+ import random
5
+ import sys
6
+ import tempfile
7
+ import unittest
8
+
9
+ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
10
+
11
+ try:
12
+ import numpy # noqa: F401
13
+ from PIL import Image
14
+ HAVE_DEPS = True
15
+ except ImportError:
16
+ HAVE_DEPS = False
17
+
18
+
19
+ @unittest.skipUnless(HAVE_DEPS, "Pillow and numpy are required")
20
+ class ToolsTest(unittest.TestCase):
21
+ def setUp(self):
22
+ self.tmp = tempfile.TemporaryDirectory()
23
+ self.dir = pathlib.Path(self.tmp.name)
24
+ self.red = self.dir / "red.png"
25
+ self.blue = self.dir / "blue.png"
26
+ Image.new("RGB", (64, 32), (255, 0, 0)).save(self.red)
27
+ Image.new("RGB", (32, 32), (0, 0, 255)).save(self.blue)
28
+
29
+ def tearDown(self):
30
+ self.tmp.cleanup()
31
+
32
+ def test_sheet_scales_to_common_height(self):
33
+ import compare
34
+ out = self.dir / "sheet.png"
35
+ compare.main(["sheet", str(self.red), str(self.blue), str(self.red), "-o", str(out)])
36
+ im = Image.open(out)
37
+ self.assertEqual(im.height, compare.HEIGHT + compare.LABEL_BAR)
38
+ self.assertEqual(im.width, 1440 + 720 + 1440 + 2 * compare.GAP)
39
+
40
+ def test_blind_keeps_mapping_outside_the_reviewer_folder(self):
41
+ import compare
42
+ out = self.dir / "blind"
43
+ mapping = compare.blind(str(self.red), str(self.blue), out, rng=random.Random(1))
44
+ self.assertEqual(sorted(p.name for p in out.iterdir()), ["A.png", "B.png"])
45
+ saved = json.loads((self.dir / "blind.mapping.json").read_text())
46
+ self.assertEqual(saved, mapping)
47
+ self.assertEqual(sorted(saved.values()), ["after", "before"])
48
+ before_slot = next(s for s, label in saved.items() if label == "before")
49
+ self.assertEqual(Image.open(out / f"{before_slot}.png").getpixel((0, 0)), (255, 0, 0))
50
+
51
+ def test_blind_writes_an_explicit_mapping_and_refuses_one_inside_the_folder(self):
52
+ import compare
53
+ out = self.dir / "tmp" / "gameplay_wide"
54
+ target = self.dir / "project" / "gameplay_wide.mapping.json"
55
+ mapping = compare.blind(str(self.red), str(self.blue), out, mapping=target)
56
+ self.assertEqual(json.loads(target.read_text()), mapping)
57
+ self.assertFalse((out.parent / "gameplay_wide.mapping.json").exists())
58
+ refused = self.dir / "tmp" / "refused"
59
+ with self.assertRaises(ValueError):
60
+ compare.blind(str(self.red), str(self.blue), refused, mapping=refused / "m.json")
61
+ self.assertFalse(refused.exists())
62
+
63
+ def test_metrics_are_deterministic_and_find_the_palette(self):
64
+ import metrics
65
+ half = self.dir / "half.png"
66
+ im = Image.new("RGB", (40, 20), (0, 0, 0))
67
+ im.paste((255, 255, 255), (20, 0, 40, 20))
68
+ im.save(half)
69
+ out = self.dir / "m.json"
70
+ metrics.main([str(half), "-o", str(out)])
71
+ first = out.read_text()
72
+ metrics.main([str(half), "-o", str(out)])
73
+ self.assertEqual(first, out.read_text())
74
+ data = json.loads(first)[str(half)]
75
+ self.assertEqual(data["lum_p5_p50_p95"][0], 0.0)
76
+ self.assertEqual(data["lum_p5_p50_p95"][2], 1.0)
77
+ self.assertEqual(data["sat_mean"], 0.0)
78
+ top = {c["hex"]: c["share"] for c in data["palette"] if c["share"] > 0}
79
+ self.assertEqual(top, {"#000000": 0.5, "#ffffff": 0.5})
80
+
81
+
82
+ if __name__ == "__main__":
83
+ unittest.main()