pixelkiln 0.144.2 → 0.145.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/docs/CLI.md CHANGED
@@ -1306,7 +1306,8 @@ See [derived artifacts](./ARTIFACTS.md) and [tiles](./TILES.md).
1306
1306
 
1307
1307
  Preview or export a set from the manifest's `parallax` section: layers far to
1308
1308
  near, each a generated asset, a finished file, sky bands, or a run of
1309
- silhouettes laid by seed, with an optional loop, dithered foot and tint. Offline;
1309
+ silhouettes laid by seed, with an optional loop, dithered foot and tint, and
1310
+ other times of day by palette swap. Offline;
1310
1311
  spends nothing.
1311
1312
 
1312
1313
  ```bash
@@ -1319,7 +1320,9 @@ pixelkiln parallax export dusk --format godot --out game/bg
1319
1320
  Without a set id the command runs every set, and `--out` then needs one. Output goes to
1320
1321
  `parallax/<set>/` beside the manifest, or `--out`; each export format gets its
1321
1322
  own folder with the layer pictures it uses and a `.pixelkiln.json` provenance
1322
- record, which `--force` overwrites. The command prints each layer's size,
1323
+ record, which `--force` overwrites. A set with `times` gets a preview strip per
1324
+ time, a Godot shader that switches between them, and a Tiled map and LDtk
1325
+ project per time. The command prints each layer's size,
1323
1326
  position, speeds and seam ratio, and warns about a looping layer whose join is
1324
1327
  more than twice as rough as its inside, a backdrop that does not reach the
1325
1328
  camera's far end or the top of the climb, and (on export) LDtk tiles past the
package/docs/MANIFEST.md CHANGED
@@ -756,7 +756,8 @@ letters, digits, `-` and `_`, since it names folders and a Godot node. The
756
756
  | `view` | yes | The game's view in pixels, `[width, height]`. |
757
757
  | `travel` | no | How far the camera moves sideways across the level. Defaults to twice the view's width. |
758
758
  | `climb` | no | How far the camera climbs. Defaults to 0. |
759
- | `palette` | no | What a layer's `tint` snaps to: a style id, for that style's `palette`, or a list of colours. Without it, a tint snaps to the colours already in the picture. |
759
+ | `palette` | no | What a layer's `tint` snaps to: a style id, for that style's `palette`, or a list of colours. Without it, a tint snaps to the colours already in the picture. It is also what `times` swap from. |
760
+ | `times` | no | Other times of day, by name (letters, digits, `-` and `_`, up to 15): `{ "night": { "palette": "night", "cool": true } }`. Each swaps the set's `palette` for its own by luminance rank. `palette` is a style id or a list of colours; `cool` maps only onto colours whose blue is at least their red. Needs the set's `palette`. Godot exports carry the times in a shader; Tiled and LDtk get a map per time. |
760
761
  | `layers` | yes | 1 to 32 layers, far first. |
761
762
 
762
763
  | Layer field | Required | Meaning |
@@ -801,7 +802,8 @@ The manifest refuses an `asset` it does not declare, in a layer or a run, a
801
802
  `style` the asset is not generated under, a layer name used twice, the run
802
803
  fields on a layer that is not a run, `foot` or `tint` on a `sky` layer, `foot`
803
804
  with `extend`, `loop` on a `sky` layer, a run or a layer that does not repeat,
804
- and a `palette` style that does not exist or has no palette.
805
+ `times` on a set without a `palette`, and a set or time `palette` style that
806
+ does not exist or has no palette.
805
807
 
806
808
  ## Validation and editor setup
807
809
 
package/docs/PARALLAX.md CHANGED
@@ -300,7 +300,7 @@ the layer pictures it uses and a provenance record:
300
300
  | Format | What it writes |
301
301
  |---|---|
302
302
  | Tiled | A map (`.tmj`) with one image layer per parallax layer, `parallaxx` and `parallaxy` set to the speeds, `repeatx` on looping layers. Each layer's offset allows for where the camera starts, and the map's parallax origin stays at (0, 0). |
303
- | Godot 4.3+ | A scene (`.tscn`) with one `Parallax2D` per layer holding a `Sprite2D`, `scroll_scale` set to the speeds and `repeat_size` to the picture. Instance it next to a `Camera2D` whose top-left starts at `(0, climb)`. |
303
+ | Godot 4.3+ | A scene (`.tscn`) with one `Parallax2D` per layer holding a `Sprite2D`, `scroll_scale` set to the speeds and `repeat_size` to the picture. Instance it next to a `Camera2D` whose top-left starts at `(0, climb)`. A set with `times` adds a shader for them (step 9). |
304
304
  | LDtk | A project (`.ldtk`) with one level the size of the view plus the camera's travel. LDtk has no image layer, so each layer is a Tiles layer over a picture of everything the camera can see of it, repeats included, with `parallaxFactorX` = 1 − speed and scaling off. |
305
305
 
306
306
  We checked the exports against the preview, pixel for pixel, at camera
@@ -458,35 +458,70 @@ of the [research note](./RESEARCH_PARALLAX.md) has the numbers.
458
458
 
459
459
  ## 9. A second time of day
460
460
 
461
- To show the same place at another time, recolour the finished set instead of
461
+ To show the same place at another time, swap the set's palette instead of
462
462
  generating it again. A palette swap keeps every shape, so the two times line up
463
463
  when the game fades from one to the other, and it costs nothing.
464
464
 
465
- ![Alpine at night, the dusk set above recoloured by script](../website/public/research/parallax/night/recoloured.webp)
465
+ ![Alpine at night, the dusk set above with its palette swapped](../website/public/research/parallax/night/recoloured.webp)
466
466
 
467
467
  1. Take a palette for the new time the way you took the first one. The night
468
468
  palette here is the 42 colours of PixelLab's mountain valley, sent again
469
469
  with the same prompt and seed and "at night" in place of "at dusk".
470
- 2. Swap each finished piece onto it by luminance rank, the far range, layers,
471
- landforms and tier copies alike:
472
-
473
- ```bash
474
- $P recolour far.png far.night.png dusk.manifest.json night.manifest.json cool
470
+ 2. Name the time on the set. The set's `palette` is what it swaps from:
471
+
472
+ ```jsonc
473
+ "alpine-dusk": {
474
+ "palette": "parallax-a",
475
+ "times": {
476
+ "night": { "palette": "night", "cool": true } // a style id, or a list of colours
477
+ },
478
+ "layers": [ ... ]
479
+ }
475
480
  ```
476
481
 
477
- `cool` leaves out the new palette's light colours, those whose red is above
478
- their blue: lit windows, lamplight and the moon. Without it, pink-lit snow
479
- turns orange.
480
- 3. Draw the sky from the new palette.
482
+ Both palettes are sorted dark to light, and a colour a given share of the
483
+ way up the first becomes the colour the same share up the second. Every
484
+ layer goes through the same table, sky bands included. `cool` leaves out the
485
+ new palette's light colours, those whose red is above their blue: lit
486
+ windows, lamplight and the moon. Without it, pink-lit snow turns orange.
487
+ 3. Preview it. `pixelkiln parallax preview` writes a strip for each time
488
+ (`alpine-dusk.preview.night.png`), and the page has a menu to switch time.
489
+
490
+ The exports carry every time:
491
+
492
+ - **Godot** gets one scene with a shader on every layer (`<set>.gdshader`)
493
+ and a lookup picture (`<set>.colours.png`): row 0 is every colour the set
494
+ uses, and row n what each becomes at the n-th time. The layers share one
495
+ material, so one line recolours the whole set, and `blend` fades to another
496
+ time:
497
+
498
+ ```gdscript
499
+ var m = $Background/far/Sprite2D.material # any layer: they share it
500
+ m.set_shader_parameter("time", 1) # 0 as drawn; n is metadata/times[n - 1]
501
+ m.set_shader_parameter("blend_to", 0) # fade back toward dusk...
502
+ m.set_shader_parameter("blend", 0.5) # ...halfway
503
+ ```
504
+
505
+ The shader matches exact colours, so keep the pictures' import lossless
506
+ (Godot's default for 2D), the filter nearest (the export sets it) and
507
+ `modulate` white.
508
+ - **Tiled and LDtk** have no shaders, so each time is a map of its own over
509
+ recoloured pictures: `alpine-dusk.night.tmj` and `alpine-dusk.night.ldtk`.
510
+
511
+ Godot 4.7, Tiled's renderer and the LDtk drawing code each drew the alpine set
512
+ at night the same as the night preview at seven camera positions, with no pixel
513
+ different, and the swap matches the research script's `recolour` pixel for
514
+ pixel.
481
515
 
482
516
  Generating the set again on the new palette also gives layers that agree, but
483
517
  in a different place. Every peak moves. "At night" in a prompt also brought a
484
518
  moon or stars into 7 of 9 pictures, two of them despite "no moon, no stars" in
485
- the prompt. Generate only
486
- what the new time adds, such as a moon, as its own sprite. A swap keeps the
487
- light where the first time put it, which suits dusk to night; light from
488
- another side needs new pictures. The manifests and build script are in
489
- [`benchmarks/parallax-night`](../benchmarks/parallax-night).
519
+ the prompt. Generate only what the new time adds, such as a moon, as its own
520
+ sprite. A swap keeps the light where the first time put it, which suits dusk to
521
+ night; light from another side needs new pictures. The manifests and build
522
+ script are in [`benchmarks/parallax-night`](../benchmarks/parallax-night), and
523
+ [`benchmarks/parallax-refined/alpine`](../benchmarks/parallax-refined/alpine)
524
+ has the dusk set with its night time.
490
525
 
491
526
  ## What this guide does not cover
492
527
 
@@ -500,7 +500,7 @@ The silhouette route behaves the same way. Step 18's runs recoloured keep their
500
500
 
501
501
  ## The `pixelkiln parallax` command
502
502
 
503
- Steps 1 to 22 led to a command. It is narrower than the proposal this note used to carry. Step 2's loop is in the command as `loop`, and step 18's finishing as `foot` and `tint`, snapped to a set's `palette`.
503
+ Steps 1 to 22 led to a command. It is narrower than the proposal this note used to carry. Step 2's loop is in the command as `loop`, step 18's finishing as `foot` and `tint`, snapped to a set's `palette`, and step 20's palette swap as a set's `times`.
504
504
 
505
505
  A manifest's `parallax` section names sets. A set has the `view`, how far the camera moves (`travel`, `climb`) and its layers, far to near. A layer is a generated `asset`, read from the lockfile, a finished `file`, `sky` bands drawn by PixelKiln, or a `run` of silhouettes laid by seed as step 12 lays them, with `speed` and optional `speedY`, `x`, `bottom`, `extend`, `repeat`, `repeatY`, `foot` and `tint`. The [manifest reference](./MANIFEST.md#parallax-sets) lists them.
506
506
 
@@ -515,6 +515,8 @@ The runs now name the landforms as generated, with `"foot": 0.3` and each tier's
515
515
 
516
516
  The whole layers of both refined sets now name the pictures as generated, with `"loop": "cut"`, and the far ranges with a `tint` of amount 1. The command's loop makes the same choices as the script, the same first-found pair for the cut and the same rounding and palette snap for the crossfade. On seven generated layers with each of the three methods, all 21 results matched the script's pixel for pixel. Both sets' preview frames and LDtk files were unchanged. Their Tiled and Godot pictures differ only in the colour stored under fully transparent pixels, which the script's tint recolours and the command leaves alone. On those seven layers the cut left every join at a seam ratio of 0.4 or less, and the crossfade left five of the seven rougher than before, so the guide recommends the cut.
517
517
 
518
+ Step 20's palette swap is a set's `times`: each names a palette and, optionally, `cool`. The command builds the script's table, both palettes sorted by luminance with the same tie order and the same rounding of halves to even. On step 18's 18 finished alpine pieces, swapped onto the night palette with `cool` and without, all 36 results matched the script's pixel for pixel on every opaque pixel, and the `cool` ones matched step 20's committed files. A Godot export carries every time in one scene: a `canvas_item` shader on every layer looks each pixel's colour up in row 0 of a small picture of the set's colours (32 for the alpine set) and draws the same column of the row for the time asked for. Tiled and LDtk have no shaders, so they get a map per time over recoloured pictures. The refined alpine set has a night time. Godot 4.7.2 with snapping, rendering through the shader, Tiled's renderer drawing the night map and the LDtk drawing code drawing the night level each matched the night preview at seven camera positions (0, 2, 50, 137, 240, 333 and 480), with no pixel different. With the shader at time 0, Godot still matched the dusk preview. The shader's `blend`, a fade between two times, mixes colours off the palette and was not checked against the preview.
519
+
518
520
  ## What other people are doing
519
521
 
520
522
  - **Layered generation models.** [LayerDiffuse](https://arxiv.org/abs/2402.17113) (Apache-2.0) adds transparency to latent diffusion models and can generate several layers of one scene together. [Qwen-Image-Layered](https://github.com/QwenLM/Qwen-Image-Layered) (Apache-2.0, December 2025) breaks a picture into a chosen number of RGBA layers, at 640 or 1024 px buckets. ComfyUI ships it with an fp8 variant because the default needs a lot of VRAM ([ComfyUI docs](https://docs.comfy.org/tutorials/image/qwen/qwen-image-layered)). Neither was trained on pixel art. Step 17 ran Qwen-Image-Layered on a 12 GB card. It works, slowly, and splits sky from scene rather than by distance. LayerDiffuse is untried.
@@ -545,7 +547,6 @@ The whole layers of both refined sets now name the pictures as generated, with `
545
547
  ## What is next
546
548
 
547
549
  - **Open the LDtk export in the LDtk editor.** Step 22 checked LDtk by its source, not by running it.
548
- - **A palette swap in the engine.** Step 20's table could run as a lookup in a shader, so one set covers a day cycle with no extra pictures.
549
550
  - **A time of day lit from another side**, such as midday. A palette swap cannot move the light, so this is where generating again might earn its cost.
550
551
  - **A full sideways Retro Diffusion set** from `rd_plus__default`, keyed by script and scrolled, with retries for candidates that come on a gradient.
551
552
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixelkiln",
3
- "version": "0.144.2",
3
+ "version": "0.145.0",
4
4
  "description": "Manifest-driven pixel-art generation, review, recovery, and packaging with deterministic provenance.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -2548,6 +2548,41 @@
2548
2548
  }
2549
2549
  ]
2550
2550
  },
2551
+ "times": {
2552
+ "type": "object",
2553
+ "additionalProperties": {
2554
+ "type": "object",
2555
+ "properties": {
2556
+ "palette": {
2557
+ "anyOf": [
2558
+ {
2559
+ "type": "string",
2560
+ "minLength": 1
2561
+ },
2562
+ {
2563
+ "type": "array",
2564
+ "items": {
2565
+ "type": "string",
2566
+ "pattern": "^#?[0-9a-f]{6}$"
2567
+ },
2568
+ "minItems": 2,
2569
+ "maxItems": 256
2570
+ }
2571
+ ]
2572
+ },
2573
+ "cool": {
2574
+ "type": "boolean"
2575
+ }
2576
+ },
2577
+ "required": [
2578
+ "palette"
2579
+ ],
2580
+ "additionalProperties": false
2581
+ },
2582
+ "propertyNames": {
2583
+ "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,31}$"
2584
+ }
2585
+ },
2551
2586
  "layers": {
2552
2587
  "type": "array",
2553
2588
  "items": {
@@ -97,9 +97,13 @@ this; its numbers are in step 12 of the research note.
97
97
 
98
98
  ## A second time of day
99
99
 
100
- - Recolour the finished set onto the new time's palette by luminance rank
101
- (`parallax.py recolour ... cool`) instead of generating it again. It is free,
102
- and every shape stays where it was, so the two times line up.
100
+ - Swap the set's palette instead of generating again: `"times": { "night":
101
+ { "palette": "<style or colours>", "cool": true } }` on the set, which needs
102
+ its own `palette` to swap from. It is free, and every shape stays where it
103
+ was, so the two times line up. The preview writes a strip per time; Godot
104
+ gets one scene with a shader (`time` 0 as drawn, n the n-th of
105
+ `metadata/times`, `blend`/`blend_to` to fade); Tiled and LDtk get a map per
106
+ time. Matches `parallax.py recolour` pixel for pixel.
103
107
  - Take the new palette from the same prompt and seed as the first one, with the
104
108
  time of day changed. For night, leave its warm light colours (windows, lamps,
105
109
  the moon) out of the swap, or pink-lit snow turns orange.