Commit Graph

9 Commits

Author SHA1 Message Date
Axel Meyer
50a0a3508f feat(scan-sprite): walk dir, normalise aliases, detect collisions 2026-06-16 21:02:06 +02:00
Axel Meyer
775ad58308 feat(alias): filename -> snake_case alias converter 2026-06-16 20:57:07 +02:00
calic
765e4bf964 docs: CR-6 — README um echte v0.2-Flags ergaenzt (--pad-px/--schema/--verbose/--tile-size auto)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 15:02:13 +00:00
calic
7555d5a1e0 atlas-baker v0.2.0 — padding + blob-14 validation + opaque flag
Implements the §13 contract from the autotile-blob-styles design
paper (Rev 4):

  - **Edge-replicated padding** (Rev 4 §13.3, mandatory): each tile
    in the packed atlas gets a `--pad-px` ring (default 2) of edge-
    replicated pixels. Inner content + UV coords unchanged; pack-
    rects inflated by 2 * padPx before MaxRects. write.js's new
    placeTileWithPadding helper handles both the inner-copy and
    the edge-replicate sweep. Prevents bilinear-sampler bleed from
    adjacent tiles in the atlas — was the green-flicker bug we
    caught during 0.5.0c integration with vagrant-skeleton.

  - **E1 — Schema slot validation**: new `--schema blob-14` flag
    runs validateBlob14Sources against the source dir. Errors out
    with clear "missing slot 7 (tee_full)" message if the 14 PNGs
    don't match the canonical enumeration. New src/schema.js
    module holds REQUIRED_SLOTS_BLOB14 + validateBlob14Sources +
    validateBlob14Collision.

  - **E2 — Collision sidecar**: bake.js looks for collision.json
    in the source dir. If present + --schema blob-14: validate
    14 slot entries exist via validateBlob14Collision. Copy
    through to atlas output as tiles.collision.json (read by
    consumer engines via the existing atlas-path resolver).

  - **Opaque-flag alpha analysis** (powers lib-core.maps' opaque-
    ceiling-cache in v0.5.0e): write.js's placeTileWithPadding
    scans each tile's inner content for alpha === 255. If all
    inner pixels are opaque, the tile entry in tiles.atlas.json
    gets `"opaque": true`. Replaces lib-core.maps' slot-13-only
    heuristic with real data.

Backwards-compat: pre-Rev-4 callers (test fixtures) use tile.w/h
without innerW/innerH. write.js falls back to w/h when innerW is
absent and padPx defaults to 0 — old code paths unchanged.

atlas_version bumped 1 -> 2 in tiles.atlas.json output. Consumers
key on atlas_id, not version, so this is a behavioural signal only.

Test surface: all 20 existing node:test cases still pass (pack +
scan + lock + 5 bake-* + write tests).

End-to-end verification: prototype-blob-geom re-baked through new
pipeline (8 atlases: 4 base styles + 3 tinted singles + testbench),
SPOREL_CI=1 vagrant-skeleton rc=0 with 60 render_frame_ok, no
magenta-placeholders or render-hook errors.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-28 22:54:39 +02:00
Axel Meyer
dea2d8fb88 Wire bake orchestrator and CLI
Connects scan + lock + pack + write into the full pipeline. CLI entry
parses args, dispatches to bake(), prints summary or error. Five
integration tests cover fresh bake, lock-aware ID preservation,
deleted-tile tracking, oversize hard-fail, and bit-identical
determinism across re-bakes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 22:48:08 +02:00
Axel Meyer
589bdaef10 Add atlas composers and output writers
composeAtlas blits placed tile pixels into bounds-sized RGBA + L8 PNGs,
synthesizing L8=0 planes for unpaired diffuse tiles. buildAtlasJson
emits the metadata with deterministic ID-sorted tile arrays and applies
the optional blocks_sight regex.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 22:45:54 +02:00
Axel Meyer
52689e9a9c Add MaxRects Best-Area-Fit packer
Deterministic placement heuristic (Best-Area-Fit with tiebreak on
shorter remaining short side). Power-of-2-rounded output bounds for
GPU friendliness. Oversize hard-fails with packed-area diagnostic.

Test bounds corrected: guillotine split fills tiles left-to-right,
so 3x 32x32 tiles produce boundsW=128 (not 64 as the plan draft had).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 22:44:00 +02:00
Axel Meyer
83499850fb Add lock-file load and stable ID assignment
Lock-file determinism guarantees re-bakes do not renumber existing
tiles. Atlas_id mismatch is a hard-fail to prevent silent corruption.
Deleted tile IDs move to deleted[] and are not recycled.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 22:40:50 +02:00
Axel Meyer
b64e3e87a9 Init atlas-baker tool with source-dir scan and pair-detection
Creates the sporel-tool-atlas-baker Node CLI scaffold and the first
phase of the bake pipeline: scan a source directory for *_diffuse.png
files, pair them with optional *_height.png companions, and return
alphabetically-sorted sources for deterministic re-bakes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 22:38:42 +02:00