pixelkiln 0.136.0 → 0.138.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/PROVIDERS.md +2 -1
- package/docs/CHARACTERS_3D.md +17 -4
- package/docs/README.md +1 -0
- package/docs/RESEARCH_3D.md +49 -1
- package/docs/RESEARCH_PARALLAX.md +448 -0
- package/package.json +1 -1
- package/skills/pixelkiln/SKILL.md +3 -0
- package/skills/pixelkiln/references/parallax.md +81 -0
package/PROVIDERS.md
CHANGED
|
@@ -143,7 +143,8 @@ For a production environment, build a kit: seamless terrain, separate
|
|
|
143
143
|
landmarks and buildings, foreground occluders, and a distant backdrop. You can
|
|
144
144
|
rerun one weak piece, set collision per object, and move layers independently
|
|
145
145
|
for parallax. Generate each piece at its native pixel resolution, then use
|
|
146
|
-
integer nearest-neighbor scaling.
|
|
146
|
+
integer nearest-neighbor scaling. The [parallax research note](./docs/RESEARCH_PARALLAX.md) covers
|
|
147
|
+
looping, splitting a flat picture by depth, and engine settings.
|
|
147
148
|
|
|
148
149
|
A visual benchmark should use the same briefs for an isolated building, a
|
|
149
150
|
top-down landmark, and a full scenic background. Use the same intended native
|
package/docs/CHARACTERS_3D.md
CHANGED
|
@@ -248,8 +248,21 @@ unlike a held thing, its file has to keep that frame, which `texture.py`
|
|
|
248
248
|
gives it. Its back goes to the back of the forearm, its top towards the
|
|
249
249
|
elbow, so it stands upright when the arm hangs, and it is made
|
|
250
250
|
`STRAPPED_LENGTH` of the body's height tall (default 0.36). `STRAPPED_TURN=90`
|
|
251
|
-
lays it across the arm. It follows the forearm
|
|
252
|
-
bones.
|
|
251
|
+
lays it across the arm, which the shield motions need. It follows the forearm
|
|
252
|
+
alone and needs no hand bones.
|
|
253
|
+
|
|
254
|
+
A shield strapped across the left arm gets motions of its own:
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
python3 research/scripts/shield.py <animated.glb> <with-shield-motions.glb>
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
That adds `Shield_Idle`, `Shield_Walk`, `Shield_Jog`, `Shield_Attack`,
|
|
261
|
+
`Shield_Block`, `Shield_Hold` (the block held) and `Shield_Bash`. Each takes
|
|
262
|
+
the body from a stock motion and writes the shield arm: where the elbow
|
|
263
|
+
lies, which way the shield faces and which way its top points. Run it before
|
|
264
|
+
`sway.py`. In the stock motions the shield lies on its side on a hanging
|
|
265
|
+
arm, so play these in their place.
|
|
253
266
|
|
|
254
267
|
Two hands on one grip takes the `two-handed` kind and one more script:
|
|
255
268
|
|
|
@@ -362,8 +375,8 @@ swing. See step 31 of the research note.
|
|
|
362
375
|
untried, the grip is not sized to the hand, there are four motions made for two hands
|
|
363
376
|
and the rest are stock one-handed ones bent to fit, which can bend a wrist
|
|
364
377
|
too far,
|
|
365
|
-
and
|
|
366
|
-
|
|
378
|
+
and there are no left-handed sword motions. The shield's straps are paint:
|
|
379
|
+
the hand does not hold one. A fist cannot open, so it cannot let go or change its hold.
|
|
367
380
|
- **Many bodies.** The items have been worn by two: the one they were cut on
|
|
368
381
|
and one much heavier man, after `refit.py` reshaped them for him. Other
|
|
369
382
|
heights and builds are untried.
|
package/docs/README.md
CHANGED
|
@@ -29,6 +29,7 @@ provider you are using. These Markdown files also render at
|
|
|
29
29
|
| [Environment provider benchmark](./PROVIDER_BENCHMARK.md) | Compare PixelLab, Retro Diffusion, and ComfyUI on buildings, backgrounds, cleanup, and native-grid recovery. |
|
|
30
30
|
| [3D characters from sprites](./CHARACTERS_3D.md) | An experimental pipeline from directional sprites to a rigged, animated 3D character with separate items: a pixel path and a painted path, the steps, and what each costs. Scripts, not a command. |
|
|
31
31
|
| [Research: 3D models from sprites](./RESEARCH_3D.md) | Every attempt to turn eight directional sprites into a 3D model, with pictures. Research, not a feature. |
|
|
32
|
+
| [Research: parallax backgrounds](./RESEARCH_PARALLAX.md) | Ways to build a scrolling background in depth and to get its layers out of a generator, tested on the benchmark backgrounds. Research, not a feature. |
|
|
32
33
|
| [Controlled asset revisions](./REVISIONS.md) | Image-to-image and inpaint edits, PixelLab palette cleanup, animation, skeleton posing, and interpolation from a parent asset; masks, approval gates, side-by-side review, and ComfyUI bindings. |
|
|
33
34
|
| [Derived artifacts](./ARTIFACTS.md) | Refine, pack, mount, and export; provenance, approval gates, ownership, and crash recovery. |
|
|
34
35
|
| [Recovery and account safety](./RECOVERY.md) | Restore, caches, adopt, salvage, cross-project claims, tagging, and confirmed purge. |
|
package/docs/RESEARCH_3D.md
CHANGED
|
@@ -66,6 +66,7 @@ Last updated 17 November 2026.
|
|
|
66
66
|
| 56 | A spear advance | Our scripts | A forward step written as footwork: the leading foot steps, the other follows, neither passes the other, the hips stay turned 45 degrees | Keep. Both bodies advance in the stance with the stance's wrists and both feet reaching. Made in place; not seen in a game. |
|
|
67
67
|
| 57 | Root motion | Our scripts | A `Root` bone under the hips, keyed forward at the pace the planted foot goes back, for every walk, run and the advance | Keep for walks and the advance: Godot moves the character by the measured distance to the millimetre. The jog's and sprint's speeds are rough. |
|
|
68
68
|
| 58 | An attack and a thrust that carry forward | Our scripts | `Great_Attack_Fwd` and `Spear_Thrust_Fwd`: the stepping foot stays where it lands and the other follows, with the travel written as root motion | Keep. The measured travel is within 5 mm of what was written and a planted foot moves 8 mm at most. |
|
|
69
|
+
| 59 | Shield motions | Our scripts | `shield.py`: the shield arm written as three directions (elbow, face, top), for a guard, a walk, a jog, the sword attack, a block, a held block and a bash | Keep. Seven motions on both bodies; nothing gets more than 1.7 cm inside the shield. Not seen in a game. |
|
|
69
70
|
|
|
70
71
|
**How the percentages are measured.** The model is projected back to each of the eight camera positions and its outline is compared with the sprite's outline. The score is the area the two share divided by the area either covers, averaged over the views. 100% means the model casts exactly the sprite's shadow from every side. It measures shape only, not colour. It also favours carving, which is built from those same outlines.
|
|
71
72
|
|
|
@@ -1639,6 +1640,50 @@ Not checked: the rebuilt model's picture in the site viewer, any moment but the
|
|
|
1639
1640
|
|
|
1640
1641
|
**Verdict.** Keep. An attack can now move the character, and the file says by how much.
|
|
1641
1642
|
|
|
1643
|
+
## 59. Shield motions
|
|
1644
|
+
|
|
1645
|
+
**Question.** Step 49 strapped a shield to the left forearm, and it has been carried, not used: the library has no shield motions, so the arm does what it does empty. Can motions be written for it, as step 51 wrote them for the greatsword?
|
|
1646
|
+
|
|
1647
|
+
**Setup.** A new script, [`scripts/shield.py`](../research/scripts/shield.py).
|
|
1648
|
+
|
|
1649
|
+
- *What is written down.* A shield strapped to a forearm leaves the arm little to decide: which way the elbow lies from the shoulder, which way the shield's face points, and which way its top points. A motion gives those three directions at a few moments. Being directions and not places, they give the same pose on a body with other proportions and cannot fall short. A first version gave the shield's place instead and solved the arm to it; the same numbers then asked the second body, whose upper arm is two thirds of his arm, for a 60 degree roll and still missed by 13 cm.
|
|
1650
|
+
- *The frame they are in.* It leans with the spine. It faces the way the character does while the chest is within 45 degrees of that, and turns with the chest beyond it. The sword idle stands with the chest turned 45 degrees and the jog swings it 55 degrees each way, so a frame fixed to the chest pointed the shield off to one side, and a frame fixed to the ground put the shield through the trunk whenever the trunk leaned or turned. A motion may ask for less slack: the jog and the sword attack let the shield ride the chest (10 and 20 degrees), because the arm cannot keep a shield facing ahead while the chest turns 134 degrees behind it.
|
|
1651
|
+
- *Strapped across the arm.* Step 49 put the shield's top towards the elbow, which is upright only while the arm hangs. A guard needs the forearm level behind an upright shield, so both bodies were rigged again with `STRAPPED_TURN=90`, and `rig.py` now leaves the shield's face and top on the forearm bone for `shield.py` to read.
|
|
1652
|
+
- *The sword arm.* In the stock walk the right arm swings, and on the first body the sword went 10 cm into the shield. The walk and the jog hold the sword arm as the sword idle has it.
|
|
1653
|
+
- *The motions.* `Shield_Idle`, `Shield_Walk` and `Shield_Jog`; `Shield_Attack`, the stock sword attack with the shield held out of the sword's way; `Shield_Block`, one second, the shield up over the face while the knees give; `Shield_Hold`, the block held; and `Shield_Bash`, one second, drawn in and driven out with a step of the left foot and the hips turning behind it. The block and the bash reuse `wield.py`'s footwork.
|
|
1654
|
+
- *The measure.* The shield is rigid, so everything else was taken into its own space at every thirtieth of a second and tested against a depth map of its front and back: how deep the deepest point of the body, the armour, the cape or the sword gets inside it. The left forearm and hand are left out, since the shield sits on them.
|
|
1655
|
+
|
|
1656
|
+
**Result.**
|
|
1657
|
+
|
|
1658
|
+

|
|
1659
|
+
|
|
1660
|
+
On guard, walking, jogging, the sword attack, the block held, and the bash, on the first body (top) and the second.
|
|
1661
|
+
|
|
1662
|
+
| Motion | Seconds | Elbow bend | Deepest inside the shield, first body | Second body |
|
|
1663
|
+
|---|---|---|---|---|
|
|
1664
|
+
| `Shield_Idle` | 1.67 | 90 | 0.6 cm (cuirass) | nothing |
|
|
1665
|
+
| `Shield_Walk` | 1.33 | 93 | under 0.1 cm | 1.7 cm (cuirass) |
|
|
1666
|
+
| `Shield_Jog` | 0.93 | 88 | 0.2 cm | nothing |
|
|
1667
|
+
| `Shield_Attack` | 1.53 | 88 to 92 | 0.6 cm | nothing |
|
|
1668
|
+
| `Shield_Block` | 1.00 | 90 to 102 | 0.6 cm | nothing |
|
|
1669
|
+
| `Shield_Hold` | 1.67 | 102 | nothing | nothing |
|
|
1670
|
+
| `Shield_Bash` | 1.00 | 90 to 107 | 0.6 cm | 1.7 cm (cuirass) |
|
|
1671
|
+
|
|
1672
|
+
- **Before the poses were tuned** the same measure found the helm 6.7 cm into the shield in the attack and the lifted thigh right through it in the jog. The jog's and the attack's pose, elbow out from the side and the shield turned out, was the third of ten tried.
|
|
1673
|
+
- **The block lifts the middle of the shield** from 23 cm below the shoulder to 4 cm below it on the first body, and puts it 44 cm ahead; the bash carries it from 18 cm ahead of the shoulder to 44 cm.
|
|
1674
|
+
- **Both files validate** with no errors or warnings, at 3.1 and 2.9 MB with 19 animations, and Godot 4.7.2 imports them with no errors and lists all seven.
|
|
1675
|
+
- **Godot renames animations ending in `_Loop`.** The held block was first `Shield_Block_Loop`; Godot drops that ending on import and the name collided with `Shield_Block`. It is `Shield_Hold`.
|
|
1676
|
+
|
|
1677
|
+
**What is not done.**
|
|
1678
|
+
|
|
1679
|
+
- **The shield lies across the arm now,** so in every motion that is not one of these seven (the plain idle, the roll, the death) it sits on its side on a hanging arm.
|
|
1680
|
+
- **The left hand does not grip anything.** The straps are still paint.
|
|
1681
|
+
- **In the attack the shield swings behind** with the chest and shows its back. A fighter would keep it nearer the front.
|
|
1682
|
+
- **A shield on the right arm** is untried, and would need `STRAPPED_TURN=-90`.
|
|
1683
|
+
- **Not seen moving.** The poses were looked at as stills, and the measure is of the meshes; nothing was watched in a running game or in the site's viewer.
|
|
1684
|
+
|
|
1685
|
+
**Verdict.** Keep. A character with a sword and shield has motions of its own.
|
|
1686
|
+
|
|
1642
1687
|
## What has not worked, in one place
|
|
1643
1688
|
|
|
1644
1689
|
So nobody repeats them:
|
|
@@ -1673,7 +1718,7 @@ Two bugs worth remembering, because both produced plausible wrong pictures: glTF
|
|
|
1673
1718
|
- **Sixteen directions and lighting for the sprite cards** (step 31): the in-between views of step 13, and normals from the hidden mesh.
|
|
1674
1719
|
- **More directions, and animation.** Step 13 gives sixteen directions. Thirty-two would spin smoothly, and the same trick on a walk cycle would give walks in the in-between directions, which the generator does not offer.
|
|
1675
1720
|
- **Fix the squat proportions.** Carve at a finer grid, or let the redraw see a true neighbour at full height (the guide sheet does this and kept proportions better on the bare character).
|
|
1676
|
-
- **Held items.** Steps 47 to 51 put a sword in either hand, open or drawn as a fist, a shield on a forearm, and a greatsword in both hands with four motions of its own. Step 52 gave the attack a step and step 53 added a spear with the hands apart, step 54 moved its rear elbow so both bodies hold it with easy wrists, step 55 turned the spear motions side-on, step 56 added an advance that keeps the stance, step 57 wrote root motion for the walks, runs and the advance,
|
|
1721
|
+
- **Held items.** Steps 47 to 51 put a sword in either hand, open or drawn as a fist, a shield on a forearm, and a greatsword in both hands with four motions of its own. Step 52 gave the attack a step and step 53 added a spear with the hands apart, step 54 moved its rear elbow so both bodies hold it with easy wrists, step 55 turned the spear motions side-on, step 56 added an advance that keeps the stance, step 57 wrote root motion for the walks, runs and the advance, step 58 added a cut and a thrust that carry the character forward, and step 59 wrote seven motions for a sword and shield. Still to do: a handle sized to the hand, a hand that grips the shield's strap, and motions for a left-handed sword.
|
|
1677
1722
|
- **A score that sees cleanliness.** Colour error against one drawing cannot tell a clean redraw from a torn render.
|
|
1678
1723
|
- **Fewer, larger pieces in the unwrap.** The chest unwraps into a few large pieces, but the character comes out in hundreds of small ones, which is fine for a program and poor for a person or an image model to paint on. One piece per view, like a folded paper model, would make the texture a sprite sheet.
|
|
1679
1724
|
- **Carve at a finer grid** than one voxel per pixel, so thin objects survive.
|
|
@@ -1842,6 +1887,9 @@ python3 research/scripts/retarget.py <character.glb> <library.glb> <out.glb>
|
|
|
1842
1887
|
CHAINS="Cape=3x4" ITEMS="Cape=<cape.glb>:Hips,Spine,Chest:loose" python3 research/scripts/rig.py <body.glb> <body.rig.json> - - <character.glb>
|
|
1843
1888
|
python3 research/scripts/sway.py <animated.glb> <out.glb>
|
|
1844
1889
|
|
|
1890
|
+
# Add shield motions for a character with a strapped shield (step 59). Run it before sway.py.
|
|
1891
|
+
python3 research/scripts/shield.py <animated.glb> <with-shield-motions.glb>
|
|
1892
|
+
|
|
1845
1893
|
# Write root motion for the walks, runs and the spear advance (step 57). Run it last.
|
|
1846
1894
|
python3 research/scripts/rootmotion.py <animated.glb> <with-root-motion.glb>
|
|
1847
1895
|
|
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
# Parallax backgrounds
|
|
2
|
+
|
|
3
|
+
This is a research note, not a feature: nothing here is a PixelKiln command, and the scripts are rough. PixelKiln can generate a scenic background as one flat picture. A parallax background is several layers that scroll at different speeds as the camera moves. This note covers the ways to build one and the ways to get the layers out of AI generators. Steps 1 to 11 use art we already had. Step 12 records how a game that already uses PixelKiln builds its skyline. Steps 13 to 16 spent 17 PixelLab generations and $0.24 of Retro Diffusion. Step 17 ran a layer-splitting model on our own 12 GB GPU.
|
|
4
|
+
|
|
5
|
+
Last updated 23 November 2026.
|
|
6
|
+
|
|
7
|
+
## Summary
|
|
8
|
+
|
|
9
|
+
| # | Approach | Tool or model | Result | Verdict |
|
|
10
|
+
|---|---|---|---|---|
|
|
11
|
+
| 1 | Check whether our backgrounds wrap horizontally | Our script | 9 of 10 benchmark backgrounds show a seam 1.3 to 5.6 times the normal column-to-column step | None of them loops as generated. |
|
|
12
|
+
| 2 | Make a flat picture loop with no new generation | Our script | A cut at matching columns, a crossfade snapped to the palette, or a mirror image all close the seam with no new colours | Keep the cut and the crossfade. Both repeat a picture with a clear focal point. |
|
|
13
|
+
| 3 | Split a flat picture into depth layers by distance from the sky colour | Our script | Recombines exactly, but the bands follow colour, not distance: the volcano is cut in half | Drop. |
|
|
14
|
+
| 4 | Split by a depth model's map | Depth Anything V2 Small, CPU, under 1.2 s a picture | Clean bands on the two PixelLab landscapes; a scene framed by tall trees cannot be split this way | Keep for open landscapes. |
|
|
15
|
+
| 5 | Pan a camera over the layers | Our script | Reads as depth. Outlines left behind and a plume that drags a strip of sky with it are the two faults | Keep, with a 2 px grow (step 6). |
|
|
16
|
+
| 6 | Grow each near layer upward | Our script | The stray outline lines are gone; the plume fault stays | Keep. |
|
|
17
|
+
| 7 | Scroll each row at its own speed instead of using layers | Our script | Good on ground that recedes to a horizon; shears anything tall | Keep for floors, water and valleys. |
|
|
18
|
+
| 8 | Measure atmospheric perspective by depth band | Our script | PixelLab's scenes get closer to the sky colour with distance; Retro Diffusion's and ComfyUI's do not | Push far layers back by hand: step 9. |
|
|
19
|
+
| 9 | Push a layer toward the sky colour with the palette held | Our script | Contrast down a third, no new colours | Keep. |
|
|
20
|
+
| 10 | Round layer offsets so they never move when the camera does not | Simulation | Rounding each layer's own position moves layers 3 to 25 times while the camera stands still; rounding the camera first moves them 0 times | Keep: round the camera first. |
|
|
21
|
+
| 11 | Read what LDtk does with a parallax factor | LDtk source | A layer moves on screen at 1 − factor of the camera, and is shrunk to that scale unless `parallaxScaling` is off | Export pixel art with `parallaxScaling: false`. |
|
|
22
|
+
| 12 | Build layers from separate silhouettes instead of cutting one picture | A game using PixelKiln, Godot 4; our script to replay it | Three generated silhouettes a biome, laid in overlapping runs in two hazed tiers over a shader sky; the layers only ever rise from where they were placed | Keep. The best route found: nothing is cut, nothing hidden has to be invented. |
|
|
23
|
+
| 13 | Cut by depth per pixel instead of per column | Depth Anything V2 Small, our script | The plume moves on its own and the sky stays whole; the cheap fill smears sideways where a framing tree moves away | Keep the per-pixel cut. The fill needs step 14. |
|
|
24
|
+
| 14 | Inpaint what a near layer hid | PixelLab `inpaint_image`, 10 generations | Forest and slope in place of smears; nothing outside the mask changed; 2 new colours | Keep for a scene that has to be split. |
|
|
25
|
+
| 15 | Generate each layer on its own, wide | PixelLab pixflux with one forced palette, 4 generations; Retro Diffusion environment with `tile_x`, $0.24 | PixelLab's four layers agree and scroll as one scene; Retro Diffusion's each draw a whole scene, and background removal breaks the seam `tile_x` made | Keep PixelLab with a shared palette. Retro Diffusion's environment style is not a layer generator. |
|
|
26
|
+
| 16 | Generate silhouettes and compose a skyline from them | PixelLab pixflux, 3 generations; our script | Usable landforms, but none fades at the foot as asked, so each run ends on a hard dark base | Keep the route; the faded foot needs a different generator or a cleanup pass. |
|
|
27
|
+
| 17 | Ask a layer-splitting model for the layers | Qwen-Image-Layered fp8 in ComfyUI, RTX 3060 12 GB, 35 to 42 minutes a picture | The sky and sun come apart from the land with the hidden sun filled in; far range, volcano, near ridges and lava stay in one layer; a blank fill layer and a pink blob take the other slots | Drop for parallax: it splits sky from scene, not near from far, and it is too slow on this card. |
|
|
28
|
+
|
|
29
|
+
## Ways to make the effect
|
|
30
|
+
|
|
31
|
+
There are six ways to make a background move with depth. Most games combine two of them.
|
|
32
|
+
|
|
33
|
+
**Layers composed from separate sprites.** Each layer is assembled in the engine from several transparent silhouettes, generated one at a time, laid side by side with overlap, flips and jitter. Nothing is cut from a finished scene, so nothing hidden behind a near layer has to be invented, and a layer is as wide as the run, not the generator's canvas. Step 12 is a working example.
|
|
34
|
+
|
|
35
|
+
**Separate layers.** Each depth is its own picture, scrolled at a fraction of the camera's speed. The far layer moves least. This is the standard approach and what every editor and engine supports directly. Sky, far range, middle ground, near ground and foreground occluders is the usual split, though no single source states it as a rule (unverified). An artist's guide uses "several layers" and stresses balance over a fixed count ([Pixelblog 23](https://www.slynyrd.com/blog/2019/11/12/pixelblog-23-parallax-scrolling)); Godot's tutorial uses five ([Godot 2D parallax](https://docs.godotengine.org/en/stable/tutorials/2d/2d_parallax.html)).
|
|
36
|
+
|
|
37
|
+
**Line scroll (raster scroll).** One picture, with each row scrolled at its own speed. The Mega Drive's video chip can scroll each line or each 8 pixel row of a plane on its own ([Sega Retro](https://segaretro.org/Sega_Mega_Drive/Scrolling)), and the SNES does it through HDMA ([nesdev HDMA examples](https://snes.nesdev.org/wiki/HDMA_examples)). It suits ground that recedes to a horizon, water and cloud bands. It shears anything tall (step 7).
|
|
38
|
+
|
|
39
|
+
**Pseudo-3D floors (Mode 7).** A floor plane is scaled differently on every line, so it recedes in perspective ([nesdev Mode 7](https://snes.nesdev.org/wiki/Mode_7_transform)). It belongs with racing and overhead games more than side-scrolling backgrounds, and is out of scope here.
|
|
40
|
+
|
|
41
|
+
**Depth-map displacement (2.5D).** One picture and a depth map; a shader moves each pixel by its depth, as in Facebook's 3D photos. Facebook's format fills the gaps that open with mobile-tuned heuristics, and learned fill tends to look "too smooth" ([Shih et al. 2020](https://arxiv.org/abs/2004.04727v3)). For pixel art, resampling each pixel breaks the grid and the filled gaps break the palette (our inference, not tested). Discrete layers keep both. Not pursued.
|
|
42
|
+
|
|
43
|
+
**Pointer or tilt parallax.** The same layers, driven by the mouse or the device's tilt in a menu or title screen instead of by a camera. The layers are the same; only the input differs.
|
|
44
|
+
|
|
45
|
+
## Ways to get the layers out of a generator
|
|
46
|
+
|
|
47
|
+
| Route | What it needs | Status here |
|
|
48
|
+
|---|---|---|
|
|
49
|
+
| Generate silhouettes and compose each layer from them in the engine | A few transparent landforms a biome, each fading out at its foot; placement rules in the game | Step 12: in use in a game. |
|
|
50
|
+
| Generate each layer on its own, with a transparent background | A prompt per layer; the layers must agree in palette, light and horizon | Step 15. A forced palette shared by every layer is what makes them agree. |
|
|
51
|
+
| Generate one picture and split it with a depth model | A depth model and a fill for what the near layers hid | Steps 4 to 6, 13 and 14. |
|
|
52
|
+
| A model that outputs layers directly | LayerDiffuse on SDXL, or Qwen-Image-Layered | Step 17: Qwen-Image-Layered splits sky from scene, not by distance, and takes over half an hour a picture on a 12 GB card. LayerDiffuse is untried. Neither is trained on pixel art. |
|
|
53
|
+
| A wide picture that wraps, then cut into layers | A provider's seamless option, or step 2 on the result | Retro Diffusion's `tile_x` is the only hosted seamless flag found. |
|
|
54
|
+
|
|
55
|
+
## 1. Do our backgrounds wrap?
|
|
56
|
+
|
|
57
|
+
**Question.** A parallax layer usually repeats sideways forever. Do the backgrounds PixelKiln already generates join up when placed end to end?
|
|
58
|
+
|
|
59
|
+
**Setup.** `parallax.py seam` on the ten scenic backgrounds from the [provider benchmark](./PROVIDER_BENCHMARK.md). The seam is the mean absolute RGB difference between the last column and the first. It is divided by the median difference between neighbouring columns inside the picture. A ratio near 1 means the join is no rougher than the picture itself.
|
|
60
|
+
|
|
61
|
+
**Result.**
|
|
62
|
+
|
|
63
|
+
| Picture | Seam | Inside | Ratio |
|
|
64
|
+
|---|---|---|---|
|
|
65
|
+
| ComfyUI alpine valley | 14.9 | 3.1 | 4.7 |
|
|
66
|
+
| ComfyUI volcanic pass | 8.2 | 1.7 | 4.8 |
|
|
67
|
+
| PixelLab alpine valley A | 11.6 | 6.1 | 1.9 |
|
|
68
|
+
| PixelLab volcanic pass A | 7.5 | 3.2 | 2.4 |
|
|
69
|
+
| PixelLab alpine valley B | 10.0 | 7.4 | 1.3 |
|
|
70
|
+
| PixelLab volcanic pass B | 4.8 | 2.1 | 2.3 |
|
|
71
|
+
| Retro Diffusion alpine valley A | 1.5 | 7.7 | 0.2 |
|
|
72
|
+
| Retro Diffusion volcanic pass A | 20.6 | 6.6 | 3.1 |
|
|
73
|
+
| Retro Diffusion alpine valley B | 43.1 | 7.7 | 5.6 |
|
|
74
|
+
| Retro Diffusion volcanic pass B | 22.7 | 6.3 | 3.6 |
|
|
75
|
+
|
|
76
|
+
The one low ratio is a coincidence of composition: Retro Diffusion's alpine valley A is framed by near-black trees down both edges.
|
|
77
|
+
|
|
78
|
+
**Verdict.** No benchmark background loops as generated, and none was asked to. A layer has to be made to loop, either when it is generated or afterwards.
|
|
79
|
+
|
|
80
|
+
## 2. Make a flat picture loop
|
|
81
|
+
|
|
82
|
+
**Question.** Can a picture that does not wrap be made to, without a new generation and without new colours?
|
|
83
|
+
|
|
84
|
+
**Setup.** `parallax.py loop` with three methods, on PixelLab's alpine valley A (256×256) and volcanic pass A (384×384):
|
|
85
|
+
|
|
86
|
+
- **Cut**: find the two columns at least 60% of the width apart where the right one best continues into the left, and crop to them.
|
|
87
|
+
- **Crossfade**: blend the last eighth of the width into the first eighth, drop the last eighth, and snap every blended pixel to the nearest colour already in the picture.
|
|
88
|
+
- **Mirror**: place the picture next to its mirror image.
|
|
89
|
+
|
|
90
|
+
**Result.**
|
|
91
|
+
|
|
92
|
+
| Method | Alpine valley | Volcanic pass | New colours |
|
|
93
|
+
|---|---|---|---|
|
|
94
|
+
| Cut | 1.9 → 1.0, columns 12 to 245 | 2.4 → 0.9, columns 50 to 384 | 0 |
|
|
95
|
+
| Crossfade | 1.9 → 0.8, 224 wide | 2.4 → 0.6, 336 wide | 0 |
|
|
96
|
+
| Mirror | 1.9 → 0.0, 512 wide | not run | 0 |
|
|
97
|
+
|
|
98
|
+

|
|
99
|
+
|
|
100
|
+
**Verdict.** The cut and the crossfade both make a loop that holds up at the join. The mirror closes the seam perfectly and shows its symmetry at once ([picture](../website/public/research/parallax/alpine-mirror.png)). All three expose the bigger problem: a scenic picture has a focal point, and a repeating peak or volcano is obvious. A loop wants a layer with no single landmark, which is also Pixelblog 23's advice. Landmarks belong on a layer of their own that does not repeat, or repeats rarely.
|
|
101
|
+
|
|
102
|
+
## 3. Split by distance from the sky colour
|
|
103
|
+
|
|
104
|
+
**Question.** Distant things in a landscape are closer to the sky colour. Is that enough to cut a flat picture into depth layers, with no model?
|
|
105
|
+
|
|
106
|
+
**Setup.** `parallax.py split <png> <out> 4`. Nearness is each pixel's RGB distance from the median colour of the top rows, median-filtered over 5×5. A 1D k-means finds three cut points. For each cut, a skyline is the first row in each column where nearness stays above the cut for three rows, kept in depth order. Layer *k* is everything from its skyline down. Where a nearer layer hid it, the gap is filled by reflecting the layer's own rows, so a revealed gap shows its texture rather than a smear. Composited at rest, the layers rebuild the source exactly; the script checks this.
|
|
107
|
+
|
|
108
|
+
**Result.** On the volcano (left), the bands follow colour: the lit flank of the volcano lands in one band and its shadowed flank in another, and the sun gets a band of its own.
|
|
109
|
+
|
|
110
|
+

|
|
111
|
+
|
|
112
|
+
**Verdict.** Drop. Colour is a poor stand-in for distance as soon as a scene has its own light.
|
|
113
|
+
|
|
114
|
+
## 4. Split by a depth model
|
|
115
|
+
|
|
116
|
+
**Question.** Does a monocular depth model give bands that follow the scene's real depth?
|
|
117
|
+
|
|
118
|
+
**Setup.** `depth.py` runs [Depth Anything V2 Small](https://github.com/DepthAnything/Depth-Anything-V2) (24.8M parameters, Apache-2.0; the larger checkpoints are CC-BY-NC-4.0) through Hugging Face Transformers 5.24 and PyTorch 2.15 on the CPU of a Mac. The picture is enlarged twice with nearest neighbour first, and the map is brought back to the picture's size. Then the same split as step 3, using the map as nearness.
|
|
119
|
+
|
|
120
|
+
**Result.** Under 1.2 s a picture. On both PixelLab landscapes the bands follow the scene: sky and distant range, the volcano or the far valley, the middle ridges, and the near ridges or trees.
|
|
121
|
+
|
|
122
|
+

|
|
123
|
+
|
|
124
|
+
Retro Diffusion's alpine valley A is the exception. Tall trees frame it from the top of the picture to the bottom on both sides. A skyline split assumes the near ground starts lower in every column than what is behind it, so it puts the whole frame in the nearest layer along with the full column above it, and most of each layer would have to be invented as the camera moves.
|
|
125
|
+
|
|
126
|
+

|
|
127
|
+
|
|
128
|
+
The script also counts the pixels a layer does not have but would show if the layer in front of it moved a twelfth of the picture's width (32 px on the volcano) relative to it. These are the pixels the fill makes up. With the depth map they are 15 to 40% of a layer on the PixelLab pictures, and 29 to 101% on the framed Retro Diffusion one. The count is an upper bound and depends on how far the camera travels.
|
|
129
|
+
|
|
130
|
+
**Verdict.** Keep, for open landscapes composed as layers already. A scene composed for one frame needs per-pixel layers and a real fill, which this note has not tried.
|
|
131
|
+
|
|
132
|
+
## 5. Pan a camera over the layers
|
|
133
|
+
|
|
134
|
+
**Question.** Do the depth-model layers read as depth when they move, and what breaks?
|
|
135
|
+
|
|
136
|
+
**Setup.** `parallax.py preview`: the four layers at factors 0.1, 0.3, 0.6 and 1.0 of the camera's movement, a view three quarters of the picture wide, a 96 px eased pan, 60 frames, offsets rounded as in step 10.
|
|
137
|
+
|
|
138
|
+
**Result.** It reads as depth: the volcano drifts against the sky and the near ridges sweep across it. Two faults show at the far end of the pan (left, before step 6):
|
|
139
|
+
|
|
140
|
+
- **Outlines left behind.** Each ridge's dark outline sits just above its skyline, so it was assigned to the layer behind. When the ridge moves, its outline stays put as a stray line.
|
|
141
|
+
- **The plume drags a strip of sky.** The depth model puts the smoke nearer than the sky behind it. Since a layer here is everything below a skyline, the strip of sky between the smoke and the volcano's slope moves with the volcano.
|
|
142
|
+
|
|
143
|
+

|
|
144
|
+
|
|
145
|
+

|
|
146
|
+
|
|
147
|
+

|
|
148
|
+
|
|
149
|
+
**Verdict.** Keep, with step 6. Floating things (smoke, clouds, birds, a moon) need to be cut out as their own sprites instead of riding a skyline.
|
|
150
|
+
|
|
151
|
+
## 6. Grow each near layer
|
|
152
|
+
|
|
153
|
+
**Question.** Does lifting each skyline a couple of pixels make the near shapes take their outlines with them?
|
|
154
|
+
|
|
155
|
+
**Setup.** `GROW=2` (and 4) on the split: each skyline moves up by that many rows before the layers are cut.
|
|
156
|
+
|
|
157
|
+
**Result.** At 2 px the stray lines are gone (picture above, right). 4 px looks no better, so the smaller grow is kept. The plume fault from step 5 is unchanged, as expected.
|
|
158
|
+
|
|
159
|
+
**Verdict.** Keep 2 px.
|
|
160
|
+
|
|
161
|
+
## 7. Scroll each row instead
|
|
162
|
+
|
|
163
|
+
**Question.** For a scene that is mostly ground receding to a horizon, is per-row scrolling a cheaper route than layers, with nothing to cut or fill?
|
|
164
|
+
|
|
165
|
+
**Setup.** `parallax.py line <png> <out> <horizon-row>`. Rows above the horizon move at 0.15 of the camera; below it the factor rises to 1.0 at the bottom row along a 1.5 power curve. Horizon at row 100 of 256 for the alpine valley and row 150 of 384 for the volcano.
|
|
166
|
+
|
|
167
|
+
**Result.** The alpine valley's forested floor and river sweep convincingly, with no gaps to fill. The volcano shows the limit: its cone and the near ridges stand across many rows, so each row slides by a different amount and they lean.
|
|
168
|
+
|
|
169
|
+

|
|
170
|
+
|
|
171
|
+

|
|
172
|
+
|
|
173
|
+
**Verdict.** Keep for floors, water, cloud bands and wide valleys. Combine it with layers: line-scroll the ground layer and move the tall shapes as layers.
|
|
174
|
+
|
|
175
|
+
## 8. Do generators already push the distance back?
|
|
176
|
+
|
|
177
|
+
**Question.** Atmospheric perspective makes distant layers lower in contrast and closer to the sky colour (a summary of several art guides, such as [Pinnguaq](https://pinnguaq.com/?p=1295); not checked against each). Do the generated backgrounds already do this, so the layers can be used as cut?
|
|
178
|
+
|
|
179
|
+
**Setup.** `parallax.py bands <png> 4 <depth.png>`: for each depth band, the standard deviation of luminance and the mean RGB distance from the sky colour.
|
|
180
|
+
|
|
181
|
+
**Result.** Distance from the sky colour, far band to near band:
|
|
182
|
+
|
|
183
|
+
| Picture | Band 0 | 1 | 2 | 3 | Colours |
|
|
184
|
+
|---|---|---|---|---|---|
|
|
185
|
+
| PixelLab volcanic pass A | 36.8 | 97.6 | 156.5 | 186.7 | 25 to 39 a band |
|
|
186
|
+
| PixelLab alpine valley A | 61.4 | 140.1 | 170.9 | 243.7 | 26 to 30 a band |
|
|
187
|
+
| Retro Diffusion volcanic pass A | 119.2 | 63.6 | 80.7 | 96.7 | 20 to 26 a band |
|
|
188
|
+
| ComfyUI volcanic pass | 58.0 | 36.8 | 66.4 | 73.5 | 11,204 to 17,903 a band |
|
|
189
|
+
|
|
190
|
+
Luminance contrast does not fall steadily with distance in any of them.
|
|
191
|
+
|
|
192
|
+
**Verdict.** PixelLab's scenes are lit for depth; Retro Diffusion's night canyon and the ComfyUI benchmark are not. The ComfyUI benchmark output was not reduced to a palette, so its colour counts are not comparable. Layers cut from a picture that is not lit for depth need pushing back by hand.
|
|
193
|
+
|
|
194
|
+
## 9. Push a layer back
|
|
195
|
+
|
|
196
|
+
**Question.** Can a layer be pushed toward the sky colour without adding colours?
|
|
197
|
+
|
|
198
|
+
**Setup.** `parallax.py haze <layer.png> <out.png> 0.35`: each pixel is mixed 35% toward the sky colour, then snapped to the nearest colour already in the layer.
|
|
199
|
+
|
|
200
|
+
**Result.** On the alpine valley's second layer, luminance contrast falls from 21.8 to 14.6, and the layer uses 19 of its 35 colours. No colour is new.
|
|
201
|
+
|
|
202
|
+

|
|
203
|
+
|
|
204
|
+
**Verdict.** Keep. The snap means the layer can only use colours it already has, so a push toward a sky colour the layer lacks would need the sky's colours added to its palette first.
|
|
205
|
+
|
|
206
|
+
## 10. Rounding
|
|
207
|
+
|
|
208
|
+
**Question.** Pixel art has to move in whole pixels. A layer at a factor of 0.3 is at a fractional position most of the time. Which rounding keeps layers from twitching when the camera stops?
|
|
209
|
+
|
|
210
|
+
**Setup.** `parallax.py jitter` simulates a camera that follows a character walking 120 px in 3 s, then stops and settles with a small overshoot: 360 frames at 60 fps. It counts the frames where a layer moves a pixel while the rounded camera does not. Two schemes: round each layer's own position, `round(cam × f)`; or round the camera, then take the layer from it, `floor(round(cam) × f)`.
|
|
211
|
+
|
|
212
|
+
**Result.**
|
|
213
|
+
|
|
214
|
+
| Factor | Moves while the camera is still, own rounding | Camera rounded first | Steps in all |
|
|
215
|
+
|---|---|---|---|
|
|
216
|
+
| 0.10 | 3 | 0 | 12 |
|
|
217
|
+
| 0.25 | 21 | 0 | 30 |
|
|
218
|
+
| 0.30 | 10 | 0 | 36 |
|
|
219
|
+
| 0.50 | 22 | 0 | 60 |
|
|
220
|
+
| 0.60 | 25 | 0 | 72 |
|
|
221
|
+
|
|
222
|
+
At a steady 1 px a frame, factors 0.25 and 0.5 step every 4 and 2 frames. Factors 0.3, 0.4, 0.6 and 0.75 step on an uneven rhythm, such as 3, 3, 4 for 0.3.
|
|
223
|
+
|
|
224
|
+
**Verdict.** Round the camera to whole pixels first and derive every layer from that. Prefer factors that are simple fractions (1/2, 1/4, 1/8) where an even rhythm matters. An artist's guide takes the same line from the other end: whole pixels per frame, and loop widths with many divisors, such as 96 ([Pixelblog 23](https://www.slynyrd.com/blog/2019/11/12/pixelblog-23-parallax-scrolling)).
|
|
225
|
+
|
|
226
|
+
## 11. What LDtk does with a parallax factor
|
|
227
|
+
|
|
228
|
+
**Question.** PixelKiln's LDtk export writes `parallaxFactorX: 0`, `parallaxFactorY: 0` and `parallaxScaling: true` on every layer ([`ldtk-export.ts`](../src/pipeline/ldtk-export.ts)). What would a non-zero factor do?
|
|
229
|
+
|
|
230
|
+
**Setup.** Read the LDtk source. `Camera.getParallaxOffsetX` returns `levelX * parallaxFactorX`, minus half the layer's width times the factor when scaling is off ([Camera.hx](https://github.com/deepnight/ldtk/blob/master/src/electron.renderer/display/Camera.hx)). `LayerDef.getScale` returns `1 - parallaxFactorX` when `parallaxScaling` is on and the factor is not zero ([LayerDef.hx](https://github.com/deepnight/ldtk/blob/master/src/electron.renderer/data/def/LayerDef.hx)). The schema gives the range as -1 to 1, default 0 ([JSON schema](https://ldtk.io/files/JSON_SCHEMA.json)).
|
|
231
|
+
|
|
232
|
+
**Result.** The layer is offset by the camera position times the factor, so on screen it moves at 1 − factor of the camera's speed. 0 is an ordinary layer. A positive factor is farther away, and 1 never moves. A negative factor is nearer than the level. With `parallaxScaling` on, the layer is also drawn at 1 − factor of its size, so a far layer shrinks.
|
|
233
|
+
|
|
234
|
+
The same layer, at a quarter of the camera's speed, in each tool:
|
|
235
|
+
|
|
236
|
+
| Tool | Setting | Source |
|
|
237
|
+
|---|---|---|
|
|
238
|
+
| LDtk | `parallaxFactorX: 0.75`, `parallaxScaling: false` | Source above |
|
|
239
|
+
| Tiled | `parallaxx: 0.25` | [Tiled manual](https://doc.mapeditor.org/en/latest/manual/layers/) |
|
|
240
|
+
| Godot 4 `Parallax2D` | `scroll_scale = Vector2(0.25, 1)` | [Godot class reference](https://docs.godotengine.org/en/stable/classes/class_parallax2d.html) |
|
|
241
|
+
| Phaser 3 | `setScrollFactor(0.25, 1)` | [Phaser API](https://docs.phaser.io/api-documentation/3.90.0/namespace/gameobjects-components-scrollfactor) |
|
|
242
|
+
| Unity | Scripted; no official parallax package found (unverified) | — |
|
|
243
|
+
|
|
244
|
+
**Verdict.** LDtk counts the other way from every other tool here: its factor is how much the layer follows the camera, not how fast it moves. An exporter has to write 1 − speed. It also has to set `parallaxScaling: false` for pixel art, or LDtk draws a far layer at a fraction of its size and off the pixel grid. Not yet checked in the LDtk editor itself.
|
|
245
|
+
|
|
246
|
+
## 12. Layers built from separate silhouettes
|
|
247
|
+
|
|
248
|
+
**Question.** Steps 3 to 6 cut one picture into layers and then have to invent what the near layers hid. A game that uses PixelKiln does the opposite: it composes each layer from separate sprites. How is it built, and what does it settle that splitting does not?
|
|
249
|
+
|
|
250
|
+
**Setup.** Read from the game's Godot 4 source (its backdrop and sky scripts and their tests), not run in the game. The game is top-down with an isometric look. The camera can pan north past the playfield's edge to look at the skyline, so the movement is mostly vertical. `parallax.py compose` replays the layout and the offsets outside the engine to check the numbers.
|
|
251
|
+
|
|
252
|
+
**Result.** How it is put together:
|
|
253
|
+
|
|
254
|
+
- **The art is silhouettes, not scenes.** Each biome has three landforms, generated one at a time from prompts of the form "distant <landform>, fading to nothing at its foot, hazy dusk lighting as if seen from far away, no ground plane, no sky, isolated landform only, transparent background". The first set was 224 to 256 px wide from PixelLab. They were later redrawn at 768×336 through Scenario, with the bottom 30% faded to transparent so the foot dissolves into the haze rather than ending on a hard edge. A forest or jungle biome has none: its treeline is its horizon.
|
|
255
|
+
- **A layer is a run of those silhouettes.** Each next sprite starts 72% of the way across the one before it, plus a random gap of up to 16 px, so the shapes overlap into one skyline instead of reading as a row of objects. Each sprite is flipped at random, the same one never comes twice in a row, and the feet jitter ±12 px. A seeded generator of its own places them, so adding a landform never moves anything else.
|
|
256
|
+
- **Two tiers.** The far tier stands 40 px deeper than the near one. Both are tinted toward the biome's dusk colour, the far one by 0.5 and the near one by 0.3. That is aerial perspective from a tint, not from the art (compare step 9). A dust storm pales both further.
|
|
257
|
+
- **The sky is not generated.** It is a shader: four flat colour bands for each time of day, each nudged toward a colour for the biome's air, with clouds, an overcast deck, or stars and a moon drawn over the bands. The same sky colour tints the playfield a little, so the two agree.
|
|
258
|
+
- **Movement.** The playfield moves 1:1 with the camera. The sky follows at 0.6, the far tier at 0.85 and the near tier at 0.92. The offset is `round((1 − rate) × clamp(viewTop − edge, −360, 0))`, where 360 px is how far the camera may look past the edge. The x offset is the same shape, centred on the playfield. Offsets are whole world pixels, and a world pixel is one texel at every zoom the game allows.
|
|
259
|
+
- **Anchored so nothing ever sinks.** At the southernmost view that can see the skyline, every layer sits exactly where it sits with parallax off; from there the layers only rise. So the game's rule that a tree's foot must stand in front of the mountains' base holds at every camera position.
|
|
260
|
+
- **The gap under a rising layer is ground, not sky.** A rising tier would open a strip above the playfield. A thin "skirt" of distant ground fills it: the biome's ground colour hazed 0.2 toward the horizon band, 24 px solid with a 12 px stepped fade above and below. Its top rides with the tier and its foot stays put. The sky's top rises while its foot stays fixed, so its bottom edge never shows. Nothing ever floats.
|
|
261
|
+
- **No loop.** The world is bounded, so each run is laid past both ends of the playfield by the most that layer can drift, `(1 − rate) × reach`, plus a 400 px margin. No side edge shows and no seam is needed (compare steps 1 and 2).
|
|
262
|
+
- **Heat shimmer** in hot biomes moves each band of three texel rows sideways by whole texels, stepped at the game's 8 fps animation rate: line scroll (step 7) used for an effect rather than for depth.
|
|
263
|
+
|
|
264
|
+
**Tuning.** The first prototype moved the layers at 0.3, 0.5 and 0.75, each tier with a 64 px skirt. The owner's review was that less could be more. At full headroom the old rates lift the sky, far and near layers 252, 180 and 90 px, against 144, 54 and 29 px for the current ones: `compose` gives the same figures from the formula. Close rates for the two tiers keep them together, so no band of sky opens between them, and one thin skirt replaced two wide ones that had read as haze between the layers and the playfield.
|
|
265
|
+
|
|
266
|
+
**Open check.** The offsets are rounded from the camera's own, unrounded view top. Step 10 found that this moves a layer while the camera is still, unless the camera's position is already whole pixels. The game snaps 2D transforms to pixels and snaps its smoothed view onto its target, but whether the view top is ever fractional while settling was not checked.
|
|
267
|
+
|
|
268
|
+
**Verdict.** Keep. This is the most practical route in this note. Generators are good at one isolated shape on a transparent background and poor at agreeing across several pictures. Composing layers from silhouettes asks them only for the first. Splitting a picture (steps 3 to 6) is still the route when there is one finished scene to animate.
|
|
269
|
+
|
|
270
|
+
## 13. Cut by depth per pixel
|
|
271
|
+
|
|
272
|
+
**Question.** Steps 4 to 6 cut along one skyline per column, which fails on a scene framed by tall trees and drags sky along with anything floating. Does assigning each pixel to its own depth band fix both?
|
|
273
|
+
|
|
274
|
+
**Setup.** `parallax.py cut <png> <out> 4 <depth.png> <reach>`, with `GROW=2`. Each pixel goes to its band from the Depth Anything map, then a 3×3 median removes specks, and each near band takes 2 px from the bands behind it (step 6). A layer is filled only where it could be uncovered: hidden pixels within `reach` px of something at its depth or farther. Reach is the pan, 96 px on the volcano and 64 on the framed valley. The fill copies the nearest pixel of the layer's own in the same row, then the nearest in any direction. The script writes each layer's invented pixels as a mask for step 14.
|
|
275
|
+
|
|
276
|
+
**Result.** Both pictures recombine exactly at rest. On the volcano the plume now moves with its own band and the sky behind it stays sky (right; the skyline cut of step 6 on the left). The framed valley no longer loses whole columns to the trees.
|
|
277
|
+
|
|
278
|
+

|
|
279
|
+
|
|
280
|
+

|
|
281
|
+
|
|
282
|
+

|
|
283
|
+
|
|
284
|
+
The price is invention. The fill has to make up 115 to 189% of a layer's own pixel count on the volcano and 175 to 333% on the framed valley, because the bands are thin and the pan is long. Where a framing tree slides away, the cheap fill shows as sideways smears (step 14, left).
|
|
285
|
+
|
|
286
|
+
**Verdict.** Keep the per-pixel cut. The fill is the weak part.
|
|
287
|
+
|
|
288
|
+
## 14. Inpaint what a near layer hid
|
|
289
|
+
|
|
290
|
+
**Question.** Can a hosted inpainting model replace the smeared fill with something that belongs in the scene, without changing the pixels around it?
|
|
291
|
+
|
|
292
|
+
**Setup.** The framed valley's third layer (the trees and cabins in the middle ground), whose fill covers 22,794 pixels. The input was layers 0 to 2 composited, so the model sees an opaque picture, and the mask was the invented pixels from step 13. PixelLab `inpaint_image` at 256×256, seed 4242, `crop_to_mask` on, described as "the valley floor continuing behind: pine trees, grassy riverbank and distant mountain slopes in the same pixel-art style and colours, no large tree trunks in the foreground". 10 generations.
|
|
293
|
+
|
|
294
|
+
**Result.** No pixel outside the mask changed. The fill used 31 colours, 2 of them not elsewhere in the picture. At the far end of the pan, the smears to the left of the cabin and along the mountain's edge became forest and slope (right). The two farther layers still carry the cheap fill.
|
|
295
|
+
|
|
296
|
+

|
|
297
|
+
|
|
298
|
+
**Verdict.** Keep, for a scene that has to be split. A full set costs one inpaint per layer that can be uncovered: 30 generations for a four-layer 256 px scene, 75 at 384 px. Generating the layers separately (step 15) costs far less.
|
|
299
|
+
|
|
300
|
+
## 15. Generate each layer on its own
|
|
301
|
+
|
|
302
|
+
**Question.** Instead of cutting a scene, can each layer be generated as its own wide picture that agrees with the others and wraps?
|
|
303
|
+
|
|
304
|
+
**Setup.** One volcanic dusk set from each hosted provider: a sky, a far range, a volcano and near ridges. The manifests are in [`benchmarks/parallax-layers`](../benchmarks/parallax-layers).
|
|
305
|
+
|
|
306
|
+
- **PixelLab** through PixelKiln: pixflux, `view: side`, seed 4242, and one forced palette for every layer, the 44 colours of the step 4 volcano. The sky is 400×160 and opaque; the three layers are 400×100 with background removal (under pixflux's 40,000 px transparency limit). 4 generations.
|
|
307
|
+
- **Retro Diffusion**: `rd_plus__environment` with `tile_x`, seed 4242. The sky is 384×160; the layers are 384×96 with `remove_bg`. $0.06 an image, $0.24 in all. PixelKiln refused to send these: Retro Diffusion quoted $0.06 for every size tried, above PixelKiln's offline estimate of $0.044 for 384×96, so the four were sent straight to the API with the same quote check.
|
|
308
|
+
|
|
309
|
+
The PixelLab layers were looped with step 2's crossfade, because pixflux has no seamless option. Both sets were stacked with their bottoms on rows 150, 175 and 200 of a 200 px canvas, and scrolled one way at 0.05, 0.25, 0.5 and 1.0 so every seam passes.
|
|
310
|
+
|
|
311
|
+
**Result.**
|
|
312
|
+
|
|
313
|
+

|
|
314
|
+
|
|
315
|
+

|
|
316
|
+
|
|
317
|
+
- **PixelLab** reads as one scene: same palette, same light, a clean cutout on all three layers (60 to 71% transparent). The far range came back as a flat two-colour silhouette, so it reads as a band of fog. The sky drew a mountain and hills along its bottom despite "no mountains".
|
|
318
|
+
- **Retro Diffusion** does not. The environment style draws a whole scene whatever the prompt says: the sky has its own volcano and river, the far layer is a range with sky still on it, and the near layer is a wall. `tile_x` works on the drawing: the sky wraps with a seam no rougher than its inside (ratio 1.0). Background removal then breaks it: the near layer keeps ground on one side of the join and removes it on the other (seam ratio 3.9).
|
|
319
|
+
|
|
320
|
+
**Verdict.** Keep PixelLab pixflux with one forced palette for every layer: it is the cheapest route in this note and the layers agree. Retro Diffusion's environment style is a scene generator, not a layer generator; its `tile_x` is still the only hosted seamless option found, and would suit a sky or a layer that needs no background removal.
|
|
321
|
+
|
|
322
|
+
## 16. A skyline from generated silhouettes
|
|
323
|
+
|
|
324
|
+
**Question.** Step 12's route asks a generator for isolated landforms that fade out at the foot. Does a cheap generator deliver them?
|
|
325
|
+
|
|
326
|
+
**Setup.** Three PixelLab pixflux silhouettes at 200×100, background removed, on the step 15 palette, with prompts in step 12's pattern: "a distant <landform>, fading to nothing at its foot, hazy dusk light as if seen from far away, no ground plane, no sky, isolated landform only". 3 generations. `parallax.py compose` laid them in runs at three times their size, with step 12's rates (0.6, 0.85, 0.92) and the camera panning north.
|
|
327
|
+
|
|
328
|
+
**Result.** The landforms are usable and cut out cleanly, 44 to 73% transparent. None fades at the foot: pixel-art background removal gives a pixel either fully on or off, so each comes back with a hard dark base, a disc under the cone and a plateau under the mesa. In a run those bases read as a black band where step 12's game shows haze.
|
|
329
|
+
|
|
330
|
+

|
|
331
|
+
|
|
332
|
+
**Verdict.** Keep the route. The faded foot has to come from somewhere else: a generator that returns soft alpha (the game's redraws came from Scenario), a dithered fade drawn afterwards, or a skirt and treeline in front, as step 12's game uses.
|
|
333
|
+
|
|
334
|
+
## 17. A model that splits a picture into layers
|
|
335
|
+
|
|
336
|
+
**Question.** [Qwen-Image-Layered](https://github.com/QwenLM/Qwen-Image-Layered) is trained to break a picture into RGBA layers and fill in what each layer hides. Does it give depth bands, and does it run on a 12 GB card?
|
|
337
|
+
|
|
338
|
+
**Setup.** ComfyUI 0.34 on an RTX 3060 (12 GB) with 32 GB of RAM, using the fp8 model (20.5 GB), the fp8 Qwen 2.5 VL 7B text encoder and the layered VAE: about 30 GB of downloads. The step 4 volcano, enlarged from 384 to 640 px by nearest neighbour, went through the official "Image to Layers" graph as an API workflow: euler, 50 steps, CFG 4.0, seed 42, a short description of the scene as the prompt. One run asked for 4 layers, one for 3.
|
|
339
|
+
|
|
340
|
+
**Result.**
|
|
341
|
+
|
|
342
|
+

|
|
343
|
+
|
|
344
|
+
- **It runs, slowly.** The model does not fit beside the desktop's own use of the card, so ComfyUI streams the weights from system RAM every step: about 40 s a step, 35 minutes for 4 layers and 42 for 3.
|
|
345
|
+
- **The split is sky against everything else.** In both runs the back layer is a flat near-white fill and one layer holds the sky and sun. A single layer holds the far range, the volcano and its plume, the near ridges and the lava. The 4-layer run spent its extra slot on a pink blob over the lower half that matches nothing in the scene. Nothing in front can move at a different speed from anything behind it.
|
|
346
|
+
- **What it does well.** The sun behind the volcano is filled in on the sky layer, which is the work step 14 paid PixelLab to do. Stacked back to front, the layers rebuild the input to within 3.5 of 255 per channel on average.
|
|
347
|
+
- **It is not pixel art afterwards.** The input has 44 colours; each layer has 22,000 to 50,000, and the scene layer's alpha is mostly 192 to 254 rather than fully opaque. Every layer would need snapping back to the palette and a hard alpha.
|
|
348
|
+
|
|
349
|
+
Other prompts, seeds and the full-precision model were not tried. The model's documentation says the prompt does not choose what goes in each layer.
|
|
350
|
+
|
|
351
|
+
**Verdict.** Drop for parallax. It separates the objects a person would select, not the distances a camera would see, and a picture takes over half an hour on this card. Splitting by a depth map (steps 4 and 13) with inpainting (step 14) stays the route for a picture that has to be split.
|
|
352
|
+
|
|
353
|
+
## A proposal for PixelKiln
|
|
354
|
+
|
|
355
|
+
Research only; nothing here is built.
|
|
356
|
+
|
|
357
|
+
**A parallax set in the manifest.** A set names its layers in order, far to near, and what they share:
|
|
358
|
+
|
|
359
|
+
```jsonc
|
|
360
|
+
"parallax": {
|
|
361
|
+
"volcanic-dusk": {
|
|
362
|
+
"palette": ["#050a14", "..."], // one forced palette for every layer (step 15)
|
|
363
|
+
"width": 400, // every layer, so they wrap together
|
|
364
|
+
"loop": "crossfade", // or "provider" where the provider is seamless, or "none" for a bounded level
|
|
365
|
+
"layers": [
|
|
366
|
+
{ "asset": "volcanic-sky", "speed": 0.05, "bottom": 160 },
|
|
367
|
+
{ "asset": "volcanic-far", "speed": 0.25, "bottom": 150, "haze": 0.5 },
|
|
368
|
+
{ "asset": "volcanic-mid", "speed": 0.5, "bottom": 175 },
|
|
369
|
+
{ "asset": "volcanic-near", "speed": 1.0, "bottom": 200 }
|
|
370
|
+
]
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
`speed` is the fraction of the camera's movement, the convention of Tiled, Godot and Phaser, so it is what a person would type. `bottom` places a layer on a shared canvas. `haze` is step 9's push toward the sky colour, done after generation with the palette held. The assets are ordinary manifest assets, so planning, budgets, the lockfile and review work as they do today. A silhouette set (step 12) would be the same shape with runs instead of single layers.
|
|
376
|
+
|
|
377
|
+
**Export.**
|
|
378
|
+
|
|
379
|
+
- **Tiled** fits best: an image layer per parallax layer, with `parallaxx` set to the speed and `repeatx` for a looping layer.
|
|
380
|
+
- **Godot**: a `Parallax2D` per layer, `scroll_scale` set to the speed and `repeat_size` to the width.
|
|
381
|
+
- **LDtk** has no image layer. Each layer would be a Tiles layer over a tileset cut from the layer's picture, with `parallaxFactorX` written as 1 − speed and `parallaxScaling: false` (step 11).
|
|
382
|
+
|
|
383
|
+
**A preview.** `parallax.py scroll` and `compose` already show a set moving. A `pixelkiln parallax preview` that writes the same GIF would let a person judge a set before export.
|
|
384
|
+
|
|
385
|
+
## What other people are doing
|
|
386
|
+
|
|
387
|
+
- **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) decomposes 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.
|
|
388
|
+
- **Seamless generation.** Circular padding in the convolutional layers makes a diffusion model's output wrap; ComfyUI has nodes for it, including X-only tiling ([ComfyUI-seamless-tiling](https://github.com/spinagon/ComfyUI-seamless-tiling)). It works on U-Net models such as SDXL and reportedly not on transformer models (unverified). The other route is to shift the picture by half its width and inpaint the seam.
|
|
389
|
+
- **Providers.** Retro Diffusion's API takes `tile_x` and `tile_y` booleans for seamless output and `remove_bg` for transparency ([api-examples](https://github.com/Retro-Diffusion/api-examples)); PixelKiln already exposes them as `tileX` and `tileY` ([Retro Diffusion](./RETRO_DIFFUSION.md)). Which styles honour them is unverified. PixelLab's v2 API has no parallax or seamless option that was found; pixflux offers a transparent background, a forced palette and an init image, up to 400×400 ([API](https://api.pixellab.ai/v2/llms.txt)). Scenario's tiling options are texture tools rather than scene tools ([help](https://help.scenario.com/articles/3312894507-scenario-texture-the-essentials)).
|
|
390
|
+
- **Classic hardware.** The Mega Drive has two scrolling planes with per-line scroll tables ([RasterScroll](https://rasterscroll.com/mdgraphics/graphical-effects/row-column-scrolling/)). Games such as *Thunder Force IV* fake many layers from them by scrolling groups of lines at different speeds.
|
|
391
|
+
|
|
392
|
+
## What has not worked
|
|
393
|
+
|
|
394
|
+
- Splitting by colour (step 3). A scene's own lighting moves colours around more than distance does.
|
|
395
|
+
- Skyline layers for a scene framed by tall near objects (step 4), and for anything floating (step 5).
|
|
396
|
+
- Line scroll on tall shapes (step 7).
|
|
397
|
+
- A cheap fill for what near layers hid, wherever a framing object moves far (step 13).
|
|
398
|
+
- Retro Diffusion's environment style as a layer generator (step 15), and its background removal on a seamless picture.
|
|
399
|
+
- Asking pixflux for a foot that fades out (step 16).
|
|
400
|
+
- Qwen-Image-Layered as a depth splitter (step 17).
|
|
401
|
+
|
|
402
|
+
## What is next
|
|
403
|
+
|
|
404
|
+
- **Build the proposal** above: the manifest shape, a preview, and Tiled, Godot and LDtk export. Open the LDtk result in the editor to check the factor's direction.
|
|
405
|
+
- **A faded foot for silhouettes** (step 16): soft alpha from Scenario, or a dithered fade drawn after generation and held to the palette.
|
|
406
|
+
- **A second PixelLab layer set** at another time of day on the same palette, to see whether a forced palette keeps sets consistent across a biome.
|
|
407
|
+
- **Retro Diffusion `tile_x` without background removal** on each layer, with the background keyed out afterwards so the seam survives.
|
|
408
|
+
- **Fix PixelKiln's Retro Diffusion estimate** for `rd_plus__environment`, which now quotes a flat $0.06 (step 15).
|
|
409
|
+
|
|
410
|
+
## Running the scripts
|
|
411
|
+
|
|
412
|
+
They need numpy, pillow and scipy; `depth.py` also needs torch and transformers.
|
|
413
|
+
|
|
414
|
+
```bash
|
|
415
|
+
# How badly each picture wraps.
|
|
416
|
+
python3 research/scripts/parallax.py seam <png>...
|
|
417
|
+
|
|
418
|
+
# Make one wrap: cut, crossfade or mirror. Also writes <out>.twice.png.
|
|
419
|
+
python3 research/scripts/parallax.py loop <png> <out.png> cut
|
|
420
|
+
|
|
421
|
+
# Depth map, brighter is nearer.
|
|
422
|
+
python3 research/scripts/depth.py <png> <depth.png>
|
|
423
|
+
|
|
424
|
+
# Four layers along depth skylines, grown 2 px. Writes layer0..3.png, bands.png and nearness.png.
|
|
425
|
+
GROW=2 python3 research/scripts/parallax.py split <png> <out-dir> 4 <depth.png>
|
|
426
|
+
|
|
427
|
+
# Pan a camera over the layers.
|
|
428
|
+
python3 research/scripts/parallax.py preview <out.gif> 0.1,0.3,0.6,1.0 <out-dir>/layer0.png <out-dir>/layer1.png <out-dir>/layer2.png <out-dir>/layer3.png
|
|
429
|
+
|
|
430
|
+
# Per-row scroll below a horizon row.
|
|
431
|
+
python3 research/scripts/parallax.py line <png> <out.gif> 100
|
|
432
|
+
|
|
433
|
+
# Contrast and sky distance per depth band; push a layer back.
|
|
434
|
+
python3 research/scripts/parallax.py bands <png> 4 <depth.png>
|
|
435
|
+
python3 research/scripts/parallax.py haze <layer.png> <out.png> 0.35
|
|
436
|
+
|
|
437
|
+
# Rounding schemes.
|
|
438
|
+
python3 research/scripts/parallax.py jitter
|
|
439
|
+
|
|
440
|
+
# Per-pixel layers with a fill within <reach> px, and each layer's invented pixels as a mask.
|
|
441
|
+
GROW=2 python3 research/scripts/parallax.py cut <png> <out-dir> 4 <depth.png> 96
|
|
442
|
+
|
|
443
|
+
# Stack layers that wrap, each with its bottom on a row of a 200 px canvas, and scroll one way.
|
|
444
|
+
python3 research/scripts/parallax.py scroll <out.gif> 0.05,0.25,0.5,1.0 200 sky.png@160 far.png@150 mid.png@175 near.png@200
|
|
445
|
+
|
|
446
|
+
# Layers composed from separate silhouettes; the camera pans north to the skyline. Rates are sky,far,near.
|
|
447
|
+
python3 research/scripts/parallax.py compose <out.gif> 0.6,0.85,0.92 7 <silhouette.png>...
|
|
448
|
+
```
|
package/package.json
CHANGED
|
@@ -152,6 +152,9 @@ Read only the reference needed for the current decision:
|
|
|
152
152
|
read [references/tiles.md](references/tiles.md). It covers which generator
|
|
153
153
|
to pick, how sets connect, every export format and what it refuses, and
|
|
154
154
|
what has and has not been checked in an engine.
|
|
155
|
+
- For a scrolling background in layers, looping a background sideways, or
|
|
156
|
+
parallax settings for Tiled, Godot, Phaser or LDtk, read
|
|
157
|
+
[references/parallax.md](references/parallax.md).
|
|
155
158
|
- For Retro Diffusion styles, USD budgets, environment assets, animation, or
|
|
156
159
|
experimental limits, read
|
|
157
160
|
[references/retro-diffusion.md](references/retro-diffusion.md).
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Parallax backgrounds
|
|
2
|
+
|
|
3
|
+
PixelKiln has no parallax command or manifest field yet. This page is what the
|
|
4
|
+
research so far supports. The full note, with pictures and numbers, is at
|
|
5
|
+
https://pixelkiln.griffen.codes/docs/research-parallax.
|
|
6
|
+
|
|
7
|
+
## The route to try first
|
|
8
|
+
|
|
9
|
+
Compose each layer in the engine from separate silhouettes rather than cutting
|
|
10
|
+
layers out of one scene. Generate a few distant landforms per biome, one at a
|
|
11
|
+
time, each "fading to nothing at its foot, no ground plane, no sky, isolated
|
|
12
|
+
landform only, transparent background". In the game, lay them in overlapping
|
|
13
|
+
runs (each next one about 72% of the way across the last, random flips, never
|
|
14
|
+
the same twice in a row, a few pixels of jitter), in two tiers tinted toward a
|
|
15
|
+
dusk or haze colour, over a sky the engine draws. Nothing hidden has to be
|
|
16
|
+
invented, and a run can be as wide as the level. A game using PixelKiln ships
|
|
17
|
+
this; its numbers are in step 12 of the research note.
|
|
18
|
+
|
|
19
|
+
- Small, close rates for the tiers (0.85 and 0.92 of the camera) keep them
|
|
20
|
+
together; wide spreads open bands of sky between them.
|
|
21
|
+
- Anchor the layers where they sit with parallax off and let them only rise,
|
|
22
|
+
and fill the strip a rising layer uncovers with a thin band of distant
|
|
23
|
+
ground, not sky, so nothing floats.
|
|
24
|
+
- A bounded level needs no loop: extend each run past both ends by the most
|
|
25
|
+
that layer can drift.
|
|
26
|
+
|
|
27
|
+
## Generating whole layers
|
|
28
|
+
|
|
29
|
+
- PixelLab pixflux with ONE forced palette (`palette`) on every layer is the
|
|
30
|
+
cheapest route that gives layers which agree: four layers for four
|
|
31
|
+
generations. Opaque sky; the other layers with background removal, at most
|
|
32
|
+
40,000 px each (400×100) to stay transparent. pixflux has no seamless
|
|
33
|
+
option, so loop each layer afterwards.
|
|
34
|
+
- Retro Diffusion's `rd_plus__environment` draws a whole scene whatever the
|
|
35
|
+
prompt says, so it is not a layer generator. Its `tileX` does wrap the
|
|
36
|
+
drawing, but `removeBg` breaks the seam it made.
|
|
37
|
+
- Pixel-art background removal is all or nothing per pixel: a silhouette asked
|
|
38
|
+
to fade at its foot comes back with a hard base. Plan a dithered fade, a
|
|
39
|
+
ground strip or a treeline in front.
|
|
40
|
+
|
|
41
|
+
## Before generating
|
|
42
|
+
|
|
43
|
+
- A parallax background is several layers, not one scene. A single scenic
|
|
44
|
+
picture has a focal point, and a repeating focal point is obvious. Put
|
|
45
|
+
landmarks on a layer that does not repeat, and keep looping layers free of
|
|
46
|
+
any single landmark.
|
|
47
|
+
- No benchmark background wraps horizontally as generated. Ask for seamless
|
|
48
|
+
output where the provider has it (Retro Diffusion `tileX`), or loop the
|
|
49
|
+
result afterwards and check the join.
|
|
50
|
+
- Keep the layers on one palette, one width and one horizon row. Far layers
|
|
51
|
+
should sit closer to the sky colour and lower in contrast. PixelLab's scenes
|
|
52
|
+
already do this; Retro Diffusion's and ComfyUI's benchmark scenes did not.
|
|
53
|
+
|
|
54
|
+
## Splitting a picture you already have
|
|
55
|
+
|
|
56
|
+
- A monocular depth model (Depth Anything V2 Small, Apache-2.0, about a second
|
|
57
|
+
on a CPU) gives usable bands for an open landscape. Colour alone does not.
|
|
58
|
+
- It fails on a scene framed by tall near objects, and anything floating
|
|
59
|
+
(smoke, clouds, a moon) must be cut out as its own sprite.
|
|
60
|
+
- Cut per pixel, not per column, so floating things keep their own layer.
|
|
61
|
+
- Whatever a near layer hid has to be invented when it moves. Say so before
|
|
62
|
+
promising a clean result from a flat picture. PixelLab `inpaint_image` on
|
|
63
|
+
the invented pixels gives a believable fill and leaves the rest untouched,
|
|
64
|
+
at 10 to 25 generations a layer by canvas size.
|
|
65
|
+
- Do not reach for a layer-splitting model (Qwen-Image-Layered) for depth
|
|
66
|
+
bands: it separated sky from everything else, kept near and far land in
|
|
67
|
+
one layer, and took over half an hour a picture on a 12 GB card.
|
|
68
|
+
- For ground that recedes to a horizon, per-row (line) scrolling of the one
|
|
69
|
+
picture needs no cutting at all, but it shears tall shapes.
|
|
70
|
+
|
|
71
|
+
## In the game
|
|
72
|
+
|
|
73
|
+
- Round the camera to whole pixels first, then derive each layer's offset from
|
|
74
|
+
that. Rounding each layer separately moves layers while the camera is still.
|
|
75
|
+
- Factors of 1/2, 1/4 and 1/8 step on an even rhythm; 0.3 or 0.6 do not.
|
|
76
|
+
- Engine settings for a layer at a quarter of the camera's speed: Tiled
|
|
77
|
+
`parallaxx: 0.25`; Godot `Parallax2D.scroll_scale = (0.25, 1)`; Phaser
|
|
78
|
+
`setScrollFactor(0.25, 1)`; LDtk `parallaxFactorX: 0.75` with
|
|
79
|
+
`parallaxScaling: false`. LDtk's factor is how much the layer follows the
|
|
80
|
+
camera, and with scaling on it also shrinks the layer off the pixel grid.
|
|
81
|
+
PixelKiln's LDtk export writes factor 0 today.
|