forked from rosebudai/OpenRCT2-Web
Add findings from scaling the reskin pipeline to 552 sprites across 36 FAL.ai batches. Key insight: palette quantization is the primary blocker for AI-generated reskins — mechanical palette remap is more reliable. Also fix stat flags in build-reskin-upload.sh for Linux compatibility (stat -c%s with -f%z fallback). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
129 lines
7.3 KiB
Plaintext
129 lines
7.3 KiB
Plaintext
# Progress Log — reskin-pipeline
|
|
# Generated from docs/plans/2026-02-25-reskin-pipeline.md
|
|
# Started: 2026-02-25
|
|
|
|
## Context
|
|
- Adapting /workspace/ottd-reskin-pipeline/ (AI sprite reskinning for OpenTTD) to OpenRCT2
|
|
- OpenRCT2 uses .parkobj files (zip with object.json + images.dat), not GRF/NFO
|
|
- Existing shell scripts handle extraction/repackaging: init-reskin-object-workspace.sh, rebuild-object.sh, build-reskin-upload.sh
|
|
- New Python pipeline slots between extraction and rebuild: batch -> generate (FAL.ai) -> parse
|
|
- Also adding Playwright screenshot and Gemini CLI visual judging capabilities
|
|
- All new files go under scripts/reskin/
|
|
- Python deps available: Pillow, numpy, fal-client
|
|
- Playwright installed with Chromium at /root/.cache/ms-playwright/chromium-1208
|
|
- Gemini CLI available at /usr/local/share/npm-global/bin/gemini
|
|
- Existing workspace example at tmp/reskin-workbench/support-structure-half/ with 4 sprites
|
|
--- Iteration 1 | story-1 | 2026-02-25 00:10:08 ---
|
|
Created scripts/reskin/categories.py with 6 category presets (scenery_small, scenery_large, scenery_wall, terrain, footpath, ride).
|
|
Each has tiling (bool), style_prompt (str), description_hint (str). No sprite ID ranges — OpenRCT2 discovers sprites from filesystem.
|
|
Verification passed: import + assert len(CATEGORIES) == 6.
|
|
Status: PASSED
|
|
Status: PASSED
|
|
|
|
--- Iteration 2 | story-2 | 2026-02-25 00:11:09 ---
|
|
Created scripts/reskin/batch_sprites.py adapted from ottd-reskin-pipeline/batch_env.py.
|
|
Key changes: removed NFO parsing, sprite ID extraction, subcategory batching.
|
|
Functions: load_sprites, create_batches, render_grid, render_grid_with_sprites, batch_sprites, main CLI.
|
|
Created scripts/reskin/test_batch_sprites.py with 6 tests — all pass.
|
|
Verification passed: pytest scripts/reskin/test_batch_sprites.py -v (6/6 passed).
|
|
Status: PASSED
|
|
Status: PASSED
|
|
|
|
--- Iteration 3 | story-3 | 2026-02-25 00:12:44 ---
|
|
Created scripts/reskin/generate_restyled.py adapted from ottd-reskin-pipeline/generate_restyled.py.
|
|
Key functions: load_descriptions, build_prompt, generate_with_fal, generate_all, main CLI.
|
|
Handles fal_client import gracefully (set to None if not installed).
|
|
Created scripts/reskin/test_generate_restyled.py with 4 tests — all pass.
|
|
Verification passed: pytest scripts/reskin/test_generate_restyled.py -v (4/4 passed).
|
|
Status: PASSED
|
|
Status: PASSED
|
|
|
|
--- Iteration 4 | story-4 | 2026-02-25 00:14:28 ---
|
|
Created scripts/reskin/parse_restyled.py adapted from ottd-reskin-pipeline/parse_and_replace.py.
|
|
Removed patch_sprite_sheets(), rebuild_grf(), save_png_small_idat(). Kept extract_sprites_from_grid(),
|
|
restore_alpha(), blend_tile_edges(), validate_sprite(). Added parse_restyled() main entry point.
|
|
Key change: returns (original_filename, ...) instead of (sprite_id, ...) since OpenRCT2 uses filenames.
|
|
Created scripts/reskin/test_parse_restyled.py with 7 tests — all pass.
|
|
Verification passed: pytest scripts/reskin/test_parse_restyled.py -v (7/7 passed).
|
|
Status: PASSED
|
|
Status: PASSED
|
|
|
|
--- Iteration 5 | story-5 | 2026-02-25 00:16:25 ---
|
|
Created scripts/reskin/reskin.py — orchestrator chaining batch -> generate -> parse.
|
|
Supports workspace mode (--workspace) and standalone mode (--sprites-dir).
|
|
Functions: resolve_dirs, resolve_style, resolve_tiling, resolve_description_hint, run_step, main CLI.
|
|
CLI args: --workspace|--sprites-dir, --style, --category, --tiling, --step, --through, --dry-run, --skip-existing, --list-categories.
|
|
Created scripts/reskin/test_reskin.py with 6 tests — all pass.
|
|
Verification passed: pytest scripts/reskin/test_reskin.py -v (6/6 passed) + --list-categories (6 categories).
|
|
Status: PASSED
|
|
Status: PASSED
|
|
|
|
--- Iteration 6 | story-6 | 2026-02-25 00:18:04 ---
|
|
Created scripts/reskin/screenshot_game.py — Playwright screenshot script for OpenRCT2 web.
|
|
Features: COOP/COEP server (reuses pattern from serve-emscripten.py), headless Chromium with
|
|
SharedArrayBuffer support, waits for canvas#canvas visible + #loadingWebassembly detached,
|
|
graceful error on missing serve dir.
|
|
CLI: --serve-dir, --output, --port, --wait-seconds.
|
|
Created scripts/reskin/test_screenshot_game.py with 2 tests:
|
|
- test_server_starts_and_stops: verifies COOP/COEP headers and content serving
|
|
- test_missing_serve_dir: verifies exit 1 with clear error message
|
|
Note: had to pip install playwright (browsers were pre-installed at /root/.cache/ms-playwright/).
|
|
Verification passed: pytest scripts/reskin/test_screenshot_game.py -v (2/2 passed).
|
|
Status: PASSED
|
|
Status: PASSED
|
|
|
|
--- Iteration 7 | story-7 | 2026-02-25 00:19:36 ---
|
|
Created scripts/reskin/judge_screenshot.py — Gemini CLI visual judge for game screenshots.
|
|
Features: build_prompt() for single/comparison modes with optional criteria,
|
|
parse_rating() extracts X/10 pattern, invoke_gemini() calls CLI with --include-directories,
|
|
judge() orchestrates prompt+invoke+parse, CLI with positional screenshot arg + --reference + --criteria.
|
|
Exits 0 if rating >= 5, exit 1 if < 5 or unparseable.
|
|
Created scripts/reskin/test_judge_screenshot.py with 8 tests:
|
|
- test_build_prompt_single_image, test_build_prompt_with_reference,
|
|
test_build_prompt_with_criteria, test_build_prompt_with_reference_and_criteria,
|
|
test_parse_rating_valid, test_parse_rating_missing,
|
|
test_parse_rating_ignores_out_of_range, test_parse_rating_picks_first_match
|
|
Verification passed: pytest scripts/reskin/test_judge_screenshot.py -v (8/8 passed).
|
|
Status: PASSED
|
|
Status: PASSED
|
|
|
|
--- Iteration 8 | story-8 | 2026-02-25 00:21:10 ---
|
|
Full test suite verification and CLI smoke test — all green.
|
|
- 35/35 tests passed across 7 test files (batch_sprites, generate_restyled, judge_screenshot, parse_restyled, reskin, screenshot_game)
|
|
- All 6 CLI scripts respond to --help without errors
|
|
- --list-categories shows 6 categories correctly
|
|
- No fixes needed — all prior stories left clean code.
|
|
Status: PASSED
|
|
Status: PASSED
|
|
|
|
|
|
--- FAL.ai Scale-Up Findings | 2026-02-25 ---
|
|
|
|
Scaled the reskin pipeline to process Electric Fields scenario walls (26 objects, 84 sprites)
|
|
and paths (8 objects, 468 sprites) through FAL.ai Gemini 3 Pro image edit API.
|
|
|
|
Pipeline execution:
|
|
- 36/36 FAL.ai batches succeeded (6 wall + 30 path)
|
|
- 552/552 sprites parsed and quantized to RCT2 palette
|
|
- 34 parkobj files rebuilt with correct sprite offsets
|
|
- End-to-end: batch → generate → parse → quantize → rebuild → deploy
|
|
|
|
Key findings:
|
|
1. Sprite offsets (x,y in sprites-full.json) are critical — defaulting to 0,0 causes
|
|
severe misalignment. Must export via `openrct2-cli sprite exportobject` and parse stdout.
|
|
2. Palette quantization is the primary blocker for AI-generated reskins. The ~176 usable
|
|
RCT2 palette colors cannot represent neon/cyberpunk effects (cyan, magenta, glow).
|
|
AI output gets crushed to dark muddy blocks during quantization.
|
|
3. g1.dat modification is risky: sprites >256px must be cropped, but cropping breaks the
|
|
sprite index alignment causing black/purple checkerboard artifacts in-game.
|
|
4. Mechanical palette remapping (index swap, no AI) works perfectly — proven with purple
|
|
grass tint across all 29294 g1.dat sprites.
|
|
5. Objects-only deployment (parkobjs without g1.dat changes) is safe and functional.
|
|
|
|
Recommended next steps:
|
|
- Option A: Palette-aware AI prompts ("use only these specific colors")
|
|
- Option B: Mechanical palette remap only (proven reliable, limited creative range)
|
|
- Option C: Hybrid — AI for shape/detail changes, then palette remap for color
|
|
|
|
--- COMPLETE: All stories processed ---
|