pixelkiln 0.97.0 → 0.99.0
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.
- package/README.md +1 -1
- package/dist/cli.js +312 -19
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +281 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1094 -50
- package/dist/index.d.ts +1094 -50
- package/dist/index.js +277 -11
- package/dist/index.js.map +1 -1
- package/docs/CLI.md +27 -4
- package/docs/ENDPOINTS.md +82 -3
- package/docs/GENERATORS.md +2 -2
- package/docs/MANIFEST.md +7 -0
- package/docs/PIXELLAB.md +2 -2
- package/docs/REVISIONS.md +9 -1
- package/docs/TILES.md +29 -0
- package/package.json +1 -1
- package/schema/manifest.schema.json +119 -0
- package/schema/recipe.schema.json +29 -0
- package/skills/pixelkiln/references/pixellab.md +1 -1
package/README.md
CHANGED
|
@@ -55,7 +55,7 @@ provenance and no long-lived npm token.
|
|
|
55
55
|
| Hand edits | Touch-ups in your own editor or a pinned in-browser Pixelorama, kept beside the generated art with the generation still the record; frame and tile sets member by member. |
|
|
56
56
|
| Controlled inputs | Hashed revision lineage (image-to-image and inpaint; on PixelLab also palette reduction, pixel cleanup, animation, skeleton posing, interpolation, and animation edits), fail-closed parent approval, source-versus-candidate review, and content-addressed per-asset ComfyUI bindings. |
|
|
57
57
|
| Characters | A base in 4 or 8 directions from a prompt or your own sprite (four PixelLab engines), poses, loops, portraits, and outfit transfers as dependent assets generated in waves, free mirrored directions (one `directions` list declares a loop and mirrors the rest), account adoption and salvage, and SpriteFrames export. |
|
|
58
|
-
| PixelLab utilities | `unzoom` returns upscaled reference art to its native grid, `pixelate` turns a photo or render into pixel art (Image to Pixel Art Pro Flash, 6 generations, or `--pro` for 20), `normal-map` makes a sprite's or a loop strip's normal map for lighting (0.5
|
|
58
|
+
| PixelLab utilities | `unzoom` returns upscaled reference art to its native grid, `pixelate` turns a photo or render into pixel art (Image to Pixel Art Pro Flash, 6 generations, or `--pro` for 20), `normal-map` makes a sprite's or a loop strip's normal map for lighting (0.1 generation, or 0.5 on pro), `vfx` builds animated effects such as explosions and auras with PixelLab's free VFX workbench, `font` generates a `.ttf` and glyph atlas, `music` makes a song (two MP3 takes, with optional seamless loops and loop points) and `sfx` a sound effect (WAV), `ui` splits a generated UI panel into elements, draws their hover and pressed states, sets 9-slice insets, and pulls every piece with a record, `asset` imports your own sprite as an object, expands it to 8 directions, resizes its canvas, and exports it as a spritesheet, `.aseprite` file or GIF, `estimate-skeleton` starts a keypoints file for skeleton animation, and `skeleton-preview` draws its poses over the sprite for free. |
|
|
59
59
|
| Existing-art onboarding | Manifest scaffolding, exact-hash account adoption, and prompt recovery. |
|
|
60
60
|
| Recovery | Safe stale-output replacement, validated caches, durable references, resumable paid jobs, and per-asset generation history with free restores. |
|
|
61
61
|
| Shared-account safety | Cross-project claim files or a registered workspace catalog, sibling-style exclusion, reviewed salvage, keep/discard tags, separate confirmed purge. |
|
package/dist/cli.js
CHANGED
|
@@ -135,6 +135,12 @@ var VALUE_FLAGS = [
|
|
|
135
135
|
"--size",
|
|
136
136
|
"--animation",
|
|
137
137
|
"--direction",
|
|
138
|
+
"--outline-rounding",
|
|
139
|
+
"--part-shapes",
|
|
140
|
+
"--surface-detail",
|
|
141
|
+
"--detail-softness",
|
|
142
|
+
"--mode",
|
|
143
|
+
"--strength",
|
|
138
144
|
"--bpm",
|
|
139
145
|
"--seconds",
|
|
140
146
|
"--lyrics",
|
|
@@ -538,6 +544,12 @@ function parseArgs(argv) {
|
|
|
538
544
|
sprite: get("--sprite"),
|
|
539
545
|
fps: numberOption("--fps", { min: 1, max: 60, integer: true }),
|
|
540
546
|
gamePack: rest.includes("--game-pack"),
|
|
547
|
+
mode: get("--mode"),
|
|
548
|
+
strength: numberOption("--strength", { min: 0, max: 2 }),
|
|
549
|
+
outlineRounding: numberOption("--outline-rounding", { min: 0, max: 3 }),
|
|
550
|
+
partShapes: numberOption("--part-shapes", { min: 0, max: 2 }),
|
|
551
|
+
surfaceDetail: numberOption("--surface-detail", { min: 0, max: 2 }),
|
|
552
|
+
detailSoftness: numberOption("--detail-softness", { min: 0.6, max: 3 }),
|
|
541
553
|
kind: get("--kind"),
|
|
542
554
|
size: get("--size"),
|
|
543
555
|
animation: get("--animation"),
|
|
@@ -638,8 +650,10 @@ Commands
|
|
|
638
650
|
generations; asks first.
|
|
639
651
|
normal-map PixelLab: make the normal map of a PNG sprite (--from), or of a
|
|
640
652
|
horizontal strip of --frames equal frames, so an engine can light
|
|
641
|
-
it. --convention opengl (default) or directx. 0.
|
|
642
|
-
|
|
653
|
+
it. --convention opengl (default) or directx. 0.1 generation on
|
|
654
|
+
lite (default), 0.5 with --mode pro; shape it with --strength,
|
|
655
|
+
--outline-rounding, --part-shapes, --surface-detail and
|
|
656
|
+
--detail-softness. Asks first.
|
|
643
657
|
vfx PixelLab: build an animated pixel-art effect with the VFX
|
|
644
658
|
workbench (free) from a --preset, a --recipe file, a saved
|
|
645
659
|
--effect, and/or --part; writes <out>.png/.gif/.json and a
|
|
@@ -694,7 +708,14 @@ Options
|
|
|
694
708
|
--artist <a> vfx --description: lite (default) or pro
|
|
695
709
|
--weight <w> font: Bold or Regular (default)
|
|
696
710
|
--id <id> ui/asset: the PixelLab asset to work on
|
|
697
|
-
--kind <kind> asset: object (default) or character
|
|
711
|
+
--kind <kind> asset: object (default) or character; normal-map: what the
|
|
712
|
+
picture is (character, object, topdown, side, iso, ui)
|
|
713
|
+
--mode <mode> normal-map: lite (default, 0.1 generation) or pro (0.5)
|
|
714
|
+
--strength <n> normal-map: how far pixels tilt from the viewer, 0-2
|
|
715
|
+
--outline-rounding <n> normal-map: how much the outline rounds off, 0-3
|
|
716
|
+
--part-shapes <n> normal-map: how much the sprite's 3D parts add, 0-2
|
|
717
|
+
--surface-detail <n> normal-map: the art's light and dark as bumps, 0-2
|
|
718
|
+
--detail-softness <n> normal-map: blur of that detail in px, 0.6-3
|
|
698
719
|
--size <WxH> asset canvas: the new canvas, in multiples of 4
|
|
699
720
|
--animation <id> asset mirror/export: an animation group id
|
|
700
721
|
--direction <dir> asset mirror: the direction to flip; asset expand: the
|
|
@@ -1330,6 +1351,21 @@ function specHash(spec, styleImageHashes, providerOptionIdentity = spec.provider
|
|
|
1330
1351
|
terrainBoundarySeed: spec.terrainBoundarySeed,
|
|
1331
1352
|
terrainStepSlope: spec.terrainStepSlope,
|
|
1332
1353
|
terrainConnectDiagonals: spec.terrainConnectDiagonals,
|
|
1354
|
+
// Added after the fields above, each only when set, so no terrain entry
|
|
1355
|
+
// written before them changes hash. The walkable flags change no pixel
|
|
1356
|
+
// and are deliberately not here.
|
|
1357
|
+
terrainShapeSeed: spec.terrainShapeSeed,
|
|
1358
|
+
terrainSideWallThickness: spec.terrainSideWallThickness,
|
|
1359
|
+
terrainSideWallPlacement: spec.terrainSideWallPlacement,
|
|
1360
|
+
terrainEnhance: spec.terrainEnhance,
|
|
1361
|
+
terrainPlatformThickness: spec.terrainPlatformThickness,
|
|
1362
|
+
// Reference images enter as their bytes' hashes, never their paths.
|
|
1363
|
+
terrainReferences: spec.terrainReferences && Object.keys(spec.terrainReferences).length ? Object.fromEntries(
|
|
1364
|
+
["lower", "upper", "transition"].flatMap((side) => {
|
|
1365
|
+
const reference = spec.terrainReferences[side];
|
|
1366
|
+
return reference ? [[side, reference.sha256]] : [];
|
|
1367
|
+
})
|
|
1368
|
+
) : void 0,
|
|
1333
1369
|
// "top-down" is the default and draws the same set as leaving it out.
|
|
1334
1370
|
terrainOrientation: spec.terrainOrientation === "sidescroller" ? spec.terrainOrientation : void 0,
|
|
1335
1371
|
// Which set and which of its terrains, not that terrain's id: the id
|
|
@@ -1462,6 +1498,14 @@ function specHash(spec, styleImageHashes, providerOptionIdentity = spec.provider
|
|
|
1462
1498
|
description: spec.revision.description,
|
|
1463
1499
|
removalTask: spec.revision.removalTask,
|
|
1464
1500
|
convention: spec.revision.convention,
|
|
1501
|
+
// Each only when set, so normal-map revisions made before them keep their hash.
|
|
1502
|
+
normalMapMode: spec.revision.normalMapMode,
|
|
1503
|
+
normalMapKind: spec.revision.normalMapKind,
|
|
1504
|
+
normalMapStrength: spec.revision.normalMapStrength,
|
|
1505
|
+
outlineRounding: spec.revision.outlineRounding,
|
|
1506
|
+
partShapes: spec.revision.partShapes,
|
|
1507
|
+
surfaceDetail: spec.revision.surfaceDetail,
|
|
1508
|
+
detailSoftness: spec.revision.detailSoftness,
|
|
1465
1509
|
driftThreshold: spec.revision.driftThreshold,
|
|
1466
1510
|
subjectDescription: spec.revision.subjectDescription,
|
|
1467
1511
|
initialPose: spec.revision.initialPose,
|
|
@@ -1596,7 +1640,7 @@ function terrainTileCount(transitionSize, mode2, orientation) {
|
|
|
1596
1640
|
return transitionSize === 1 ? 25 : 16;
|
|
1597
1641
|
}
|
|
1598
1642
|
function terrainCost(mode2, tileSize, orientation) {
|
|
1599
|
-
if (orientation === "sidescroller") return
|
|
1643
|
+
if (orientation === "sidescroller") return mode2 === "pro" ? 15 : 1;
|
|
1600
1644
|
if (mode2 === "pro") return tileSize <= 32 ? 15 : 25;
|
|
1601
1645
|
return 4;
|
|
1602
1646
|
}
|
|
@@ -2022,6 +2066,24 @@ var RevisionSchema = z.object({
|
|
|
2022
2066
|
removalTask: z.enum(["simple", "complex"]).optional(),
|
|
2023
2067
|
/** `normal-map` only: `opengl` (green up; PixelLab's default) or `directx` (green down, for Unreal). */
|
|
2024
2068
|
convention: NormalMapConventionSchema.optional(),
|
|
2069
|
+
/**
|
|
2070
|
+
* `normal-map` only: `lite` (PixelLab's default, 0.1 generation) makes the
|
|
2071
|
+
* map from the art alone; `pro` (0.5) plans each part's shape, what is in
|
|
2072
|
+
* front and what is sunk.
|
|
2073
|
+
*/
|
|
2074
|
+
normalMapMode: z.enum(["lite", "pro"]).optional(),
|
|
2075
|
+
/** `normal-map` only: what the picture is. Left out, PixelLab reads it from the picture; set it for sidescroller, isometric and UI art. */
|
|
2076
|
+
normalMapKind: z.enum(["character", "object", "topdown", "side", "iso", "ui"]).optional(),
|
|
2077
|
+
/** `normal-map` only: how far every pixel tilts away from facing the viewer, 0 to 2 (the API refuses more). */
|
|
2078
|
+
normalMapStrength: z.number().min(0).max(2).optional(),
|
|
2079
|
+
/** `normal-map` only: how much the outline rounds off, 0 to 3; 0 keeps it flat to the edge. */
|
|
2080
|
+
outlineRounding: z.number().min(0).max(3).optional(),
|
|
2081
|
+
/** `normal-map` only: how much the sprite's 3D parts (a round head, an arm) add, 0 to 2. */
|
|
2082
|
+
partShapes: z.number().min(0).max(2).optional(),
|
|
2083
|
+
/** `normal-map` only: the art's own light and dark as bumps, 0 to 2; 0 for a smooth surface. */
|
|
2084
|
+
surfaceDetail: z.number().min(0).max(2).optional(),
|
|
2085
|
+
/** `normal-map` only: how far that detail is blurred, 0.6 to 3 px. */
|
|
2086
|
+
detailSoftness: z.number().min(0.6).max(3).optional(),
|
|
2025
2087
|
/**
|
|
2026
2088
|
* `animate-skeleton`: what the character *looks like*, a noun
|
|
2027
2089
|
* phrase (colours, clothing, held items) — distinct from the asset's
|
|
@@ -2182,6 +2244,15 @@ var RevisionSchema = z.object({
|
|
|
2182
2244
|
path: ["convention"]
|
|
2183
2245
|
});
|
|
2184
2246
|
}
|
|
2247
|
+
for (const field of ["normalMapMode", "normalMapKind", "normalMapStrength", "outlineRounding", "partShapes", "surfaceDetail", "detailSoftness"]) {
|
|
2248
|
+
if (revision[field] !== void 0 && revision.mode !== "normal-map") {
|
|
2249
|
+
context.addIssue({
|
|
2250
|
+
code: z.ZodIssueCode.custom,
|
|
2251
|
+
message: `${field} applies to normal-map revisions only`,
|
|
2252
|
+
path: [field]
|
|
2253
|
+
});
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2185
2256
|
if (revision.description !== void 0 && revision.mode !== "animate-skeleton" && revision.mode !== "remove-background") {
|
|
2186
2257
|
context.addIssue({
|
|
2187
2258
|
code: z.ZodIssueCode.custom,
|
|
@@ -2384,6 +2455,48 @@ var StyleObjectSchema = z.object({
|
|
|
2384
2455
|
* lower terrain between them.
|
|
2385
2456
|
*/
|
|
2386
2457
|
terrainConnectDiagonals: z.boolean().optional(),
|
|
2458
|
+
/**
|
|
2459
|
+
* `terrain` generator only, standard mode, top-down. Which ragged border
|
|
2460
|
+
* `terrainRaggedness` draws, 0 to 99 (the website's Reshuffle): another
|
|
2461
|
+
* number gives a different boundary at the same raggedness. API default 0.
|
|
2462
|
+
*/
|
|
2463
|
+
terrainShapeSeed: z.number().int().min(0).max(99).optional(),
|
|
2464
|
+
/**
|
|
2465
|
+
* `terrain` generator only, standard mode, top-down, with
|
|
2466
|
+
* `terrainTransitionSize` above 0. How thick the wall reads on the top
|
|
2467
|
+
* rim and down both sides of the front face, 0 to 1. The website starts
|
|
2468
|
+
* at 0.1.
|
|
2469
|
+
*/
|
|
2470
|
+
terrainSideWallThickness: z.number().min(0).max(1).optional(),
|
|
2471
|
+
/**
|
|
2472
|
+
* `terrain` generator only, standard mode, top-down, with
|
|
2473
|
+
* `terrainTransitionSize` above 0. Which side of the border the wall sits
|
|
2474
|
+
* on: 0 sticks out past the terrain (the API default), 1 is carved into
|
|
2475
|
+
* it so the shape stays put. The website starts at 0.5.
|
|
2476
|
+
*/
|
|
2477
|
+
terrainSideWallPlacement: z.number().min(0).max(1).optional(),
|
|
2478
|
+
/**
|
|
2479
|
+
* `terrain` generator only, standard mode. PixelLab rewrites the terrain
|
|
2480
|
+
* descriptions and picks base colors before drawing unless this is
|
|
2481
|
+
* false. On by default upstream; set false to have your wording used as
|
|
2482
|
+
* written.
|
|
2483
|
+
*/
|
|
2484
|
+
terrainEnhance: z.boolean().optional(),
|
|
2485
|
+
/**
|
|
2486
|
+
* `terrain` generator only, a standard sidescroller set. How thick the
|
|
2487
|
+
* platform body is, 0 thin to 1 thick. Left out, PixelLab fits it to
|
|
2488
|
+
* `terrainTransitionSize`.
|
|
2489
|
+
*/
|
|
2490
|
+
terrainPlatformThickness: z.number().min(0).max(1).optional(),
|
|
2491
|
+
/**
|
|
2492
|
+
* `terrain` generator only, top-down. Whether each terrain can be walked
|
|
2493
|
+
* on, stored with the set for PixelLab's maps and engine exports (left
|
|
2494
|
+
* out, those guess from the terrain's name). They change no pixel, so
|
|
2495
|
+
* they are sent when the set is generated and are not part of its
|
|
2496
|
+
* identity: changing one later does not make the set stale.
|
|
2497
|
+
*/
|
|
2498
|
+
terrainLowerWalkable: z.boolean().optional(),
|
|
2499
|
+
terrainUpperWalkable: z.boolean().optional(),
|
|
2387
2500
|
/**
|
|
2388
2501
|
* `terrain` generator only. Visual height of the step between lower and
|
|
2389
2502
|
* upper terrain. Without `terrainShapeStyle`, only 0, 0.25, 0.5, or 1 are
|
|
@@ -2776,6 +2889,18 @@ var AssetSchema = z.object({
|
|
|
2776
2889
|
* (a sword hand, a parted fringe) comes out the other way round.
|
|
2777
2890
|
*/
|
|
2778
2891
|
mirror: z.string().min(1).optional(),
|
|
2892
|
+
/**
|
|
2893
|
+
* `terrain` styles only: a PNG per terrain for PixelLab to take that
|
|
2894
|
+
* terrain's look from, paths relative to the manifest. Top-down sets
|
|
2895
|
+
* take `lower`, `upper` and `transition`. A sidescroller set takes
|
|
2896
|
+
* `lower` (the platform body, pro mode) or `transition` (the surface
|
|
2897
|
+
* layer, standard mode), each a square PNG of the tile size.
|
|
2898
|
+
*/
|
|
2899
|
+
terrainReferences: z.object({
|
|
2900
|
+
lower: z.string().min(1).optional(),
|
|
2901
|
+
upper: z.string().min(1).optional(),
|
|
2902
|
+
transition: z.string().min(1).optional()
|
|
2903
|
+
}).strict().optional(),
|
|
2779
2904
|
/** Made from existing pixels by a local transform; see AssetDeriveSchema. Free; the provider is never called. */
|
|
2780
2905
|
derive: AssetDeriveSchema.optional(),
|
|
2781
2906
|
/** Built by a tool outside pixelkiln; see AssetExternalSchema. Never generated. */
|
|
@@ -7401,7 +7526,12 @@ function refusalReason(status, body) {
|
|
|
7401
7526
|
if (status < 400 || status >= 500 || !body.startsWith("{")) return "";
|
|
7402
7527
|
try {
|
|
7403
7528
|
const detail = JSON.parse(body).detail;
|
|
7404
|
-
|
|
7529
|
+
if (typeof detail === "string" && detail) return `: ${detail.slice(0, 400)}`;
|
|
7530
|
+
if (Array.isArray(detail)) {
|
|
7531
|
+
const messages = detail.map((item) => item && typeof item === "object" && typeof item.msg === "string" ? item.msg : "").filter(Boolean).map((msg) => msg.replace(/^Value error, /, ""));
|
|
7532
|
+
if (messages.length) return `: ${messages.join("; ").slice(0, 400)}`;
|
|
7533
|
+
}
|
|
7534
|
+
return "";
|
|
7405
7535
|
} catch {
|
|
7406
7536
|
return "";
|
|
7407
7537
|
}
|
|
@@ -7435,6 +7565,8 @@ function targetPaletteBody(palette) {
|
|
|
7435
7565
|
}
|
|
7436
7566
|
};
|
|
7437
7567
|
}
|
|
7568
|
+
var NORMAL_MAP_MODES = ["lite", "pro"];
|
|
7569
|
+
var NORMAL_MAP_KINDS = ["character", "object", "topdown", "side", "iso", "ui"];
|
|
7438
7570
|
var PixelLabClient = class {
|
|
7439
7571
|
constructor(apiKey, timeoutMs = 12e4) {
|
|
7440
7572
|
this.apiKey = apiKey;
|
|
@@ -7603,6 +7735,16 @@ var PixelLabClient = class {
|
|
|
7603
7735
|
lower_description: args.lowerDescription,
|
|
7604
7736
|
upper_description: args.upperDescription
|
|
7605
7737
|
};
|
|
7738
|
+
const image = (value) => ({ type: "base64", base64: value.base64, format: value.format });
|
|
7739
|
+
if (args.shapeSeed != null) body.shape_seed = args.shapeSeed;
|
|
7740
|
+
if (args.sideWallThickness != null) body.side_wall_thickness = args.sideWallThickness;
|
|
7741
|
+
if (args.sideWallPlacement != null) body.side_wall_placement = args.sideWallPlacement;
|
|
7742
|
+
if (args.enhance != null) body.enhance = args.enhance;
|
|
7743
|
+
if (args.lowerWalkable != null) body.lower_walkable = args.lowerWalkable;
|
|
7744
|
+
if (args.upperWalkable != null) body.upper_walkable = args.upperWalkable;
|
|
7745
|
+
if (args.lowerReferenceImage) body.lower_reference_image = image(args.lowerReferenceImage);
|
|
7746
|
+
if (args.upperReferenceImage) body.upper_reference_image = image(args.upperReferenceImage);
|
|
7747
|
+
if (args.transitionReferenceImage) body.transition_reference_image = image(args.transitionReferenceImage);
|
|
7606
7748
|
if (args.transitionDescription) body.transition_description = args.transitionDescription;
|
|
7607
7749
|
if (args.lowerBaseTileId) body.lower_base_tile_id = args.lowerBaseTileId;
|
|
7608
7750
|
if (args.upperBaseTileId) body.upper_base_tile_id = args.upperBaseTileId;
|
|
@@ -7640,6 +7782,12 @@ var PixelLabClient = class {
|
|
|
7640
7782
|
*/
|
|
7641
7783
|
async createTilesetSidescroller(args) {
|
|
7642
7784
|
const body = { lower_description: args.lowerDescription };
|
|
7785
|
+
const image = (value) => ({ type: "base64", base64: value.base64, format: value.format });
|
|
7786
|
+
if (args.mode) body.mode = args.mode;
|
|
7787
|
+
if (args.enhance != null) body.enhance = args.enhance;
|
|
7788
|
+
if (args.platformThickness != null) body.platform_thickness = args.platformThickness;
|
|
7789
|
+
if (args.transitionReferenceImage) body.transition_reference_image = image(args.transitionReferenceImage);
|
|
7790
|
+
if (args.lowerReferenceImage) body.lower_reference_image = image(args.lowerReferenceImage);
|
|
7643
7791
|
if (args.transitionDescription) body.transition_description = args.transitionDescription;
|
|
7644
7792
|
if (args.lowerBaseTileId) body.lower_base_tile_id = args.lowerBaseTileId;
|
|
7645
7793
|
if (args.tileSize != null) body.tile_size = { width: args.tileSize, height: args.tileSize };
|
|
@@ -8497,8 +8645,15 @@ var PixelLabClient = class {
|
|
|
8497
8645
|
*/
|
|
8498
8646
|
async normalMap(args) {
|
|
8499
8647
|
const body = { image: args.image };
|
|
8648
|
+
if (args.mode) body.mode = args.mode;
|
|
8649
|
+
if (args.kind) body.kind = args.kind;
|
|
8650
|
+
if (args.shape?.strength != null) body.strength = args.shape.strength;
|
|
8500
8651
|
if (args.frames != null && args.frames !== 1) body.frames = args.frames;
|
|
8501
8652
|
if (args.convention) body.convention = args.convention;
|
|
8653
|
+
if (args.shape?.outlineRounding != null) body.outline_rounding = args.shape.outlineRounding;
|
|
8654
|
+
if (args.shape?.partShapes != null) body.part_shapes = args.shape.partShapes;
|
|
8655
|
+
if (args.shape?.surfaceDetail != null) body.surface_detail = args.shape.surfaceDetail;
|
|
8656
|
+
if (args.shape?.detailSoftness != null) body.detail_softness = args.shape.detailSoftness;
|
|
8502
8657
|
return validateResponse(
|
|
8503
8658
|
RevisionJobSubmitSchema,
|
|
8504
8659
|
await this.request("/normal-map", { method: "POST", body: JSON.stringify(body) }),
|
|
@@ -9708,7 +9863,9 @@ async function pixelateFile(client2, input, opts = {}) {
|
|
|
9708
9863
|
await sleep3(interval);
|
|
9709
9864
|
}
|
|
9710
9865
|
}
|
|
9711
|
-
|
|
9866
|
+
function normalMapCost(mode2) {
|
|
9867
|
+
return mode2 === "pro" ? 0.5 : 0.1;
|
|
9868
|
+
}
|
|
9712
9869
|
var NORMAL_MAP_MIN_SIDE = 8;
|
|
9713
9870
|
var NORMAL_MAP_MAX_SIDE = 512;
|
|
9714
9871
|
var NORMAL_MAP_MAX_FRAMES = 32;
|
|
@@ -9752,7 +9909,10 @@ async function normalMapFile(client2, input, opts = {}) {
|
|
|
9752
9909
|
const submitted = await client2.normalMap({
|
|
9753
9910
|
image: { base64: bytes.toString("base64"), format: "png" },
|
|
9754
9911
|
frames,
|
|
9755
|
-
convention: opts.convention
|
|
9912
|
+
convention: opts.convention,
|
|
9913
|
+
shape: opts.shape,
|
|
9914
|
+
mode: opts.mode,
|
|
9915
|
+
kind: opts.kind
|
|
9756
9916
|
});
|
|
9757
9917
|
const jobId = submitted.background_job_id;
|
|
9758
9918
|
const started = Date.now();
|
|
@@ -10076,7 +10236,7 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
10076
10236
|
return { unit: "generations", amount: 1, candidates: 1 };
|
|
10077
10237
|
}
|
|
10078
10238
|
if (spec.revision?.mode === "normal-map") {
|
|
10079
|
-
return { unit: "generations", amount:
|
|
10239
|
+
return { unit: "generations", amount: normalMapCost(spec.revision.normalMapMode), candidates: 1 };
|
|
10080
10240
|
}
|
|
10081
10241
|
if (spec.revision?.mode === "reduce-colors" || spec.revision?.mode === "correct-pixelart") {
|
|
10082
10242
|
return { unit: "generations", amount: 0.1, candidates: 1 };
|
|
@@ -10444,6 +10604,23 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
10444
10604
|
if (spec.terrainTileSize === 64 && spec.terrainMode !== "pro") {
|
|
10445
10605
|
throw new Error('PixelLab terrain: a 64px tile needs terrainMode: "pro"');
|
|
10446
10606
|
}
|
|
10607
|
+
const standardOnly = {
|
|
10608
|
+
terrainShapeSeed: spec.terrainShapeSeed,
|
|
10609
|
+
terrainSideWallThickness: spec.terrainSideWallThickness,
|
|
10610
|
+
terrainSideWallPlacement: spec.terrainSideWallPlacement,
|
|
10611
|
+
terrainEnhance: spec.terrainEnhance
|
|
10612
|
+
};
|
|
10613
|
+
const proSet = Object.entries(standardOnly).filter(([, value]) => value != null).map(([field]) => field);
|
|
10614
|
+
if (pro && proSet.length) {
|
|
10615
|
+
throw new Error(`PixelLab terrain: ${proSet.join(", ")} shape a standard set; terrainMode: "pro" ignores them`);
|
|
10616
|
+
}
|
|
10617
|
+
if ((spec.terrainSideWallThickness != null || spec.terrainSideWallPlacement != null) && !(spec.terrainTransitionSize != null && spec.terrainTransitionSize > 0)) {
|
|
10618
|
+
throw new Error("PixelLab terrain: terrainSideWallThickness and terrainSideWallPlacement shape the wall, which needs a terrainTransitionSize above 0");
|
|
10619
|
+
}
|
|
10620
|
+
if (spec.terrainPlatformThickness != null) {
|
|
10621
|
+
throw new Error("PixelLab terrain: terrainPlatformThickness is a sidescroller control");
|
|
10622
|
+
}
|
|
10623
|
+
this.requireTerrainReferences(spec);
|
|
10447
10624
|
if (spec.terrainShapeStyle && spec.terrainTransitionSize != null && spec.terrainTransitionSize > 0.5) {
|
|
10448
10625
|
throw new Error(
|
|
10449
10626
|
"PixelLab terrain: terrainShapeStyle with terrainTransitionSize above 0.5 uses an extended 32-tile layout pixelkiln does not model; use 0, 0.25, or 0.5"
|
|
@@ -10462,7 +10639,6 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
10462
10639
|
*/
|
|
10463
10640
|
validateSidescrollerTerrain(spec) {
|
|
10464
10641
|
const topDownOnly = {
|
|
10465
|
-
terrainMode: spec.terrainMode,
|
|
10466
10642
|
terrainShapeStyle: spec.terrainShapeStyle,
|
|
10467
10643
|
terrainView: spec.terrainView,
|
|
10468
10644
|
terrainSpreadX: spec.terrainSpreadX,
|
|
@@ -10472,7 +10648,12 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
10472
10648
|
terrainBoundaryAmplitude: spec.terrainBoundaryAmplitude,
|
|
10473
10649
|
terrainBoundarySeed: spec.terrainBoundarySeed,
|
|
10474
10650
|
terrainStepSlope: spec.terrainStepSlope,
|
|
10475
|
-
terrainConnectDiagonals: spec.terrainConnectDiagonals
|
|
10651
|
+
terrainConnectDiagonals: spec.terrainConnectDiagonals,
|
|
10652
|
+
terrainShapeSeed: spec.terrainShapeSeed,
|
|
10653
|
+
terrainSideWallThickness: spec.terrainSideWallThickness,
|
|
10654
|
+
terrainSideWallPlacement: spec.terrainSideWallPlacement,
|
|
10655
|
+
terrainLowerWalkable: spec.terrainLowerWalkable,
|
|
10656
|
+
terrainUpperWalkable: spec.terrainUpperWalkable
|
|
10476
10657
|
};
|
|
10477
10658
|
const set = Object.entries(topDownOnly).filter(([, value]) => value != null).map(([field]) => field);
|
|
10478
10659
|
if (set.length) {
|
|
@@ -10481,9 +10662,26 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
10481
10662
|
if (spec.terrainTileSize !== 16 && spec.terrainTileSize !== 32) {
|
|
10482
10663
|
throw new Error(`PixelLab terrain: a sidescroller set's tiles are 16 or 32px, got ${spec.terrainTileSize}`);
|
|
10483
10664
|
}
|
|
10484
|
-
if (spec.terrainTransitionSize != null && ![0, 0.25, 0.5
|
|
10485
|
-
throw new Error("PixelLab terrain: a sidescroller set's terrainTransitionSize must be 0, 0.25, 0.5
|
|
10665
|
+
if (spec.terrainTransitionSize != null && ![0, 0.25, 0.5].includes(spec.terrainTransitionSize)) {
|
|
10666
|
+
throw new Error("PixelLab terrain: a sidescroller set's terrainTransitionSize must be 0, 0.25, or 0.5 (the top layer stops at half a tile)");
|
|
10667
|
+
}
|
|
10668
|
+
const pro = spec.terrainMode === "pro";
|
|
10669
|
+
if (pro && (spec.terrainEnhance != null || spec.terrainPlatformThickness != null)) {
|
|
10670
|
+
throw new Error('PixelLab terrain: terrainEnhance and terrainPlatformThickness shape a standard sidescroller set; terrainMode: "pro" ignores them');
|
|
10671
|
+
}
|
|
10672
|
+
if (spec.terrainConnect?.lower && !pro) {
|
|
10673
|
+
throw new Error(`PixelLab terrain: a sidescroller set connects to another set's platform only with terrainMode: "pro"`);
|
|
10674
|
+
}
|
|
10675
|
+
if (spec.terrainReferences?.upper) {
|
|
10676
|
+
throw new Error("PixelLab terrain: a sidescroller set's upper terrain is empty air; it takes no upper reference");
|
|
10677
|
+
}
|
|
10678
|
+
if (spec.terrainReferences?.lower && !pro) {
|
|
10679
|
+
throw new Error('PixelLab terrain: a sidescroller set keeps a lower (platform body) reference only with terrainMode: "pro"');
|
|
10486
10680
|
}
|
|
10681
|
+
if (spec.terrainReferences?.transition && pro) {
|
|
10682
|
+
throw new Error('PixelLab terrain: a sidescroller set textures its top layer from a transition reference only on standard mode; drop it or terrainMode: "pro"');
|
|
10683
|
+
}
|
|
10684
|
+
this.requireTerrainReferences(spec, spec.terrainTileSize);
|
|
10487
10685
|
if (spec.terrainConnect?.upper) {
|
|
10488
10686
|
throw new Error(
|
|
10489
10687
|
"PixelLab terrain: a sidescroller set's upper terrain is empty air; only its lower (platform) terrain can connect"
|
|
@@ -10496,6 +10694,19 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
10496
10694
|
);
|
|
10497
10695
|
}
|
|
10498
10696
|
}
|
|
10697
|
+
/** Reference files must exist; a sidescroller's must be a square PNG of the tile size. */
|
|
10698
|
+
requireTerrainReferences(spec, tileSize) {
|
|
10699
|
+
for (const [side, reference] of Object.entries(spec.terrainReferences ?? {})) {
|
|
10700
|
+
if (!reference?.sha256) {
|
|
10701
|
+
throw new Error(`PixelLab terrain: the ${side} reference is missing or not a PNG: ${reference?.file}`);
|
|
10702
|
+
}
|
|
10703
|
+
if (tileSize != null && (reference.width !== tileSize || reference.height !== tileSize)) {
|
|
10704
|
+
throw new Error(
|
|
10705
|
+
`PixelLab terrain: a sidescroller set's ${side} reference must be a ${tileSize}x${tileSize} PNG; ${reference.file} is ${reference.width}x${reference.height}`
|
|
10706
|
+
);
|
|
10707
|
+
}
|
|
10708
|
+
}
|
|
10709
|
+
}
|
|
10499
10710
|
validateCharacter(spec, styleImages = []) {
|
|
10500
10711
|
const character = spec.character;
|
|
10501
10712
|
if (!character) throw new Error(`${spec.styleId}/${spec.assetId} has no character shape`);
|
|
@@ -11273,7 +11484,12 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
11273
11484
|
outline: spec.outline,
|
|
11274
11485
|
shading: spec.shading,
|
|
11275
11486
|
detail: spec.detail,
|
|
11276
|
-
seed: spec.seed
|
|
11487
|
+
seed: spec.seed,
|
|
11488
|
+
mode: spec.terrainMode,
|
|
11489
|
+
enhance: spec.terrainEnhance,
|
|
11490
|
+
platformThickness: spec.terrainPlatformThickness,
|
|
11491
|
+
lowerReferenceImage: await terrainReferenceImage(spec, "lower"),
|
|
11492
|
+
transitionReferenceImage: await terrainReferenceImage(spec, "transition")
|
|
11277
11493
|
});
|
|
11278
11494
|
return {
|
|
11279
11495
|
jobId: res2.tileset_id,
|
|
@@ -11308,7 +11524,16 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
11308
11524
|
shading: spec.shading,
|
|
11309
11525
|
detail: spec.detail,
|
|
11310
11526
|
seed: spec.seed,
|
|
11311
|
-
targetPalette: targetPaletteFor(spec)
|
|
11527
|
+
targetPalette: targetPaletteFor(spec),
|
|
11528
|
+
shapeSeed: spec.terrainShapeSeed,
|
|
11529
|
+
sideWallThickness: spec.terrainSideWallThickness,
|
|
11530
|
+
sideWallPlacement: spec.terrainSideWallPlacement,
|
|
11531
|
+
enhance: spec.terrainEnhance,
|
|
11532
|
+
lowerWalkable: spec.terrainLowerWalkable,
|
|
11533
|
+
upperWalkable: spec.terrainUpperWalkable,
|
|
11534
|
+
lowerReferenceImage: await terrainReferenceImage(spec, "lower"),
|
|
11535
|
+
upperReferenceImage: await terrainReferenceImage(spec, "upper"),
|
|
11536
|
+
transitionReferenceImage: await terrainReferenceImage(spec, "transition")
|
|
11312
11537
|
});
|
|
11313
11538
|
return {
|
|
11314
11539
|
jobId: res2.tileset_id,
|
|
@@ -11485,7 +11710,20 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
11485
11710
|
}
|
|
11486
11711
|
if (revision.mode === "normal-map") {
|
|
11487
11712
|
const strip = roles ? { base64: joinStripPng(images.map((member) => Buffer.from(member.base64, "base64"))).toString("base64"), format: "png" } : image;
|
|
11488
|
-
const res2 = await this.client.normalMap({
|
|
11713
|
+
const res2 = await this.client.normalMap({
|
|
11714
|
+
image: strip,
|
|
11715
|
+
frames: roles?.length ?? 1,
|
|
11716
|
+
convention: revision.convention,
|
|
11717
|
+
mode: revision.normalMapMode,
|
|
11718
|
+
kind: revision.normalMapKind,
|
|
11719
|
+
shape: {
|
|
11720
|
+
strength: revision.normalMapStrength,
|
|
11721
|
+
outlineRounding: revision.outlineRounding,
|
|
11722
|
+
partShapes: revision.partShapes,
|
|
11723
|
+
surfaceDetail: revision.surfaceDetail,
|
|
11724
|
+
detailSoftness: revision.detailSoftness
|
|
11725
|
+
}
|
|
11726
|
+
});
|
|
11489
11727
|
return {
|
|
11490
11728
|
jobId: res2.background_job_id,
|
|
11491
11729
|
metadata: roles ? { revisionMembers: roles, ...revision.sourceFps != null ? { revisionFps: revision.sourceFps } : {} } : {}
|
|
@@ -12487,6 +12725,16 @@ function sendsTargetPalette(spec) {
|
|
|
12487
12725
|
return false;
|
|
12488
12726
|
}
|
|
12489
12727
|
}
|
|
12728
|
+
async function terrainReferenceImage(spec, side) {
|
|
12729
|
+
const reference = spec.terrainReferences?.[side];
|
|
12730
|
+
if (!reference) return void 0;
|
|
12731
|
+
if (!existsSync11(reference.file)) throw new Error(`terrain ${side} reference is missing: ${reference.file}`);
|
|
12732
|
+
const bytes = readFileSync2(reference.file);
|
|
12733
|
+
if (sha256(bytes) !== reference.sha256) {
|
|
12734
|
+
throw new Error(`terrain ${side} reference changed after the manifest was resolved: ${reference.file}; run the command again`);
|
|
12735
|
+
}
|
|
12736
|
+
return { base64: bytes.toString("base64"), format: "png" };
|
|
12737
|
+
}
|
|
12490
12738
|
function targetPaletteFor(spec) {
|
|
12491
12739
|
if (!sendsTargetPalette(spec)) return void 0;
|
|
12492
12740
|
if (!spec.palette.length && spec.maxColors == null) return void 0;
|
|
@@ -14351,6 +14599,13 @@ async function resolveSpecs(loaded, filter) {
|
|
|
14351
14599
|
terrainBoundarySeed: generator === "terrain" ? style.terrainBoundarySeed : void 0,
|
|
14352
14600
|
terrainStepSlope: generator === "terrain" ? style.terrainStepSlope : void 0,
|
|
14353
14601
|
terrainConnectDiagonals: generator === "terrain" ? style.terrainConnectDiagonals : void 0,
|
|
14602
|
+
terrainShapeSeed: generator === "terrain" ? style.terrainShapeSeed : void 0,
|
|
14603
|
+
terrainSideWallThickness: generator === "terrain" ? style.terrainSideWallThickness : void 0,
|
|
14604
|
+
terrainSideWallPlacement: generator === "terrain" ? style.terrainSideWallPlacement : void 0,
|
|
14605
|
+
terrainEnhance: generator === "terrain" ? style.terrainEnhance : void 0,
|
|
14606
|
+
terrainPlatformThickness: generator === "terrain" ? style.terrainPlatformThickness : void 0,
|
|
14607
|
+
terrainLowerWalkable: generator === "terrain" ? style.terrainLowerWalkable : void 0,
|
|
14608
|
+
terrainUpperWalkable: generator === "terrain" ? style.terrainUpperWalkable : void 0,
|
|
14354
14609
|
terrainTransitionSize: generator === "terrain" ? style.terrainTransitionSize : void 0,
|
|
14355
14610
|
terrainView: generator === "terrain" ? style.terrainView : void 0,
|
|
14356
14611
|
terrainOrientation: generator === "terrain" ? style.terrainOrientation : void 0,
|
|
@@ -14709,6 +14964,13 @@ async function resolveSpecs(loaded, filter) {
|
|
|
14709
14964
|
...asset.revision.description ? { description: asset.revision.description } : {},
|
|
14710
14965
|
...asset.revision.removalTask ? { removalTask: asset.revision.removalTask } : {},
|
|
14711
14966
|
...asset.revision.convention ? { convention: asset.revision.convention } : {},
|
|
14967
|
+
...asset.revision.normalMapMode ? { normalMapMode: asset.revision.normalMapMode } : {},
|
|
14968
|
+
...asset.revision.normalMapKind ? { normalMapKind: asset.revision.normalMapKind } : {},
|
|
14969
|
+
...asset.revision.normalMapStrength == null ? {} : { normalMapStrength: asset.revision.normalMapStrength },
|
|
14970
|
+
...asset.revision.outlineRounding == null ? {} : { outlineRounding: asset.revision.outlineRounding },
|
|
14971
|
+
...asset.revision.partShapes == null ? {} : { partShapes: asset.revision.partShapes },
|
|
14972
|
+
...asset.revision.surfaceDetail == null ? {} : { surfaceDetail: asset.revision.surfaceDetail },
|
|
14973
|
+
...asset.revision.detailSoftness == null ? {} : { detailSoftness: asset.revision.detailSoftness },
|
|
14712
14974
|
...asset.revision.driftThreshold == null ? {} : { driftThreshold: asset.revision.driftThreshold },
|
|
14713
14975
|
...asset.revision.subjectDescription ? { subjectDescription: asset.revision.subjectDescription } : {},
|
|
14714
14976
|
...asset.revision.initialPose ? { initialPose: asset.revision.initialPose } : {},
|
|
@@ -14783,6 +15045,20 @@ async function resolveSpecs(loaded, filter) {
|
|
|
14783
15045
|
}
|
|
14784
15046
|
resolved.terrainConnect = links;
|
|
14785
15047
|
}
|
|
15048
|
+
if (asset.terrainReferences) {
|
|
15049
|
+
if (resolved.generator !== "terrain") {
|
|
15050
|
+
throw new Error(`assets.${assetId}.terrainReferences: only a terrain set takes terrain references; style "${styleId}" uses "${resolved.generator}"`);
|
|
15051
|
+
}
|
|
15052
|
+
const references = {};
|
|
15053
|
+
for (const side of ["lower", "upper", "transition"]) {
|
|
15054
|
+
const relative = asset.terrainReferences[side];
|
|
15055
|
+
if (!relative) continue;
|
|
15056
|
+
const file = path18.resolve(root, relative);
|
|
15057
|
+
const image = await optionalRevisionImage(file, `terrain ${side} reference`, "png");
|
|
15058
|
+
references[side] = { file, sha256: image?.hash ?? null, width: image?.width ?? null, height: image?.height ?? null };
|
|
15059
|
+
}
|
|
15060
|
+
if (Object.keys(references).length) resolved.terrainReferences = references;
|
|
15061
|
+
}
|
|
14786
15062
|
if (asset.scene) resolved.scene = await resolveMapScene(root, styleId, assetId, resolved.generator, asset.scene, activeProvider);
|
|
14787
15063
|
resolved.specHash = specHash(
|
|
14788
15064
|
resolved,
|
|
@@ -24397,21 +24673,38 @@ async function runNormalMap(args) {
|
|
|
24397
24673
|
log(
|
|
24398
24674
|
` normal-map ${args.from}${frames > 1 ? ` (a strip of ${frames} frames)` : ""} \u2192 ${out}, ${convention} (green ${convention === "opengl" ? "up" : "down"})`
|
|
24399
24675
|
);
|
|
24400
|
-
|
|
24401
|
-
|
|
24402
|
-
|
|
24676
|
+
if (args.mode !== void 0 && !NORMAL_MAP_MODES.includes(args.mode)) {
|
|
24677
|
+
throw new UsageError(`--mode must be ${NORMAL_MAP_MODES.join(" or ")}, got "${args.mode}"`);
|
|
24678
|
+
}
|
|
24679
|
+
if (args.kind !== void 0 && !NORMAL_MAP_KINDS.includes(args.kind)) {
|
|
24680
|
+
throw new UsageError(`--kind must be one of ${NORMAL_MAP_KINDS.join(", ")}, got "${args.kind}"`);
|
|
24681
|
+
}
|
|
24682
|
+
const mode2 = args.mode;
|
|
24683
|
+
const cost = normalMapCost(mode2);
|
|
24684
|
+
log(` cost: ${cost} generation (${mode2 === "pro" ? "pro" : "lite, PixelLab's default; --mode pro is 0.5"}, charged on delivery)`);
|
|
24685
|
+
if (args.budget !== void 0 && args.budget < cost) {
|
|
24686
|
+
throw new Error(`--budget ${args.budget} is below this normal map's ${cost}-generation cost`);
|
|
24403
24687
|
}
|
|
24404
24688
|
if (args.dryRun) {
|
|
24405
24689
|
log(" dry run: nothing sent");
|
|
24406
24690
|
return;
|
|
24407
24691
|
}
|
|
24408
|
-
if (!await confirm(` Spend ${
|
|
24692
|
+
if (!await confirm(` Spend ${cost} generation on this normal map?`, args.yes)) return;
|
|
24409
24693
|
loadKeys(args);
|
|
24410
24694
|
let last = "";
|
|
24411
24695
|
const res = await normalMapFile(clientFromEnv(), args.from, {
|
|
24412
24696
|
out,
|
|
24413
24697
|
frames,
|
|
24414
24698
|
convention: args.convention ? convention : void 0,
|
|
24699
|
+
mode: mode2,
|
|
24700
|
+
kind: args.kind,
|
|
24701
|
+
shape: {
|
|
24702
|
+
strength: args.strength,
|
|
24703
|
+
outlineRounding: args.outlineRounding,
|
|
24704
|
+
partShapes: args.partShapes,
|
|
24705
|
+
surfaceDetail: args.surfaceDetail,
|
|
24706
|
+
detailSoftness: args.detailSoftness
|
|
24707
|
+
},
|
|
24415
24708
|
force: args.force,
|
|
24416
24709
|
onProgress: (status) => {
|
|
24417
24710
|
if (status !== last) log(` ${status}\u2026`);
|