Parallax backgrounds
Build a scrolling background in layers, sideways or climbing: one palette, silhouettes or whole layers from PixelLab, finished by script, then previewed and exported to Tiled, Godot and LDtk with pixelkiln parallax.
A parallax background is a stack of layers that scroll at different speeds as
the camera moves. This guide builds one from ordinary manifest assets, finishes
the pieces with a free script, and then hands the stack to pixelkiln parallax, which previews it and exports it to Tiled, Godot and LDtk. Everything below was run
to make the pictures on this page: two biomes, 51 PixelLab generations in all,
including the retries, and a climb for a camera that scrolls up. The evidence behind each choice is in the
research note.


Pick a route
Both routes start the same way, with one palette and a pixflux style. They differ in what you generate.
| Route | What you generate | Best for |
|---|---|---|
| Silhouettes | Four or five isolated landforms a biome, each about 240 px wide. The game lays them in overlapping runs. | Levels wider than any picture. No layer needs to loop, and the runs never repeat exactly. |
| Whole layers | A far range, a middle layer and a near layer, each 400×100, looped afterwards. | The fewest steps. A short level, a title screen, a menu. |
The two mix well. Both pictures above use a whole far range and a whole near layer; the volcanic one puts two runs of silhouettes between them.
The sky is not generated in either route. It is a few flat bands of palette colours, drawn by the script or by the engine. Hosted generators draw mountains and suns into a sky whatever the prompt says.
1. Choose one palette
Every layer uses the same forced palette. It is the single setting that
makes separately generated layers look like one scene. The easiest source is
a picture you already like: its colours, 30 to 50 of them, become the palette.
The volcanic set uses the 44 colours of a PixelLab volcano; the alpine set uses
the 38 colours of a PixelLab mountain valley.
Check the palette has pale colours as well as dark ones. A tier is pushed toward the sky by mixing its colours and snapping the result back to the palette (step 5). A palette with few pale colours flattens a tinted tier into one or two colours.
2. Write the manifest
One pixflux style per seed, with background removal, view: side and the
palette. Listing several styles on an asset gives several candidates of it,
one per seed, so you can keep the best.
{
"name": "my-game",
"provider": "pixellab",
"styles": {
"parallax-a": {
"generator": "pixflux",
"noBackground": true,
"view": "side",
"seed": 101,
"palette": ["#050a14", "#2e3253", "#7b5f94", "..."],
"outDir": "assets/parallax/volcanic/a"
},
"parallax-b": {
"generator": "pixflux",
"noBackground": true,
"view": "side",
"seed": 202,
"palette": ["#050a14", "#2e3253", "#7b5f94", "..."],
"outDir": "assets/parallax/volcanic/b"
}
},
"assets": {
"landform-cone": {
"prompt": "a single dark basalt volcanic cone, muted violet, low contrast, simple shading, about two thirds as wide as the picture, its slopes flare out to a flat base, a lone landform game sprite on a plain empty background, nothing else in the picture: no clouds, no moon, no sun, no hills or ground around it, side view, transparent background",
"width": 256,
"height": 128,
"styles": ["parallax-a", "parallax-b"]
},
"layer-near": {
"prompt": "dark jagged volcanic hills close to the viewer, uneven heights and irregular shapes, a few glowing lava cracks, nearly black, spans the full width, flat bottom edge, no sky, no ground plane, side view, transparent background",
"width": 400,
"height": 100,
"styles": ["parallax-a", "parallax-b"]
}
}
}
The complete manifests for both biomes are in
benchmarks/parallax-refined.
Keep transparent pixflux pictures at 40,000 px or less (400×100, 256×128). Larger ones come back with their background.
Prompts that work
For a silhouette, describe one object as a game sprite and list what must not be in the picture. Leave the distance out of the prompt: the haze comes later, from the palette.
- Use "a lone landform game sprite on a plain empty background, nothing else in the picture: no clouds, no moon, no sun, no hills or ground around it".
- Use "about two thirds as wide as the picture" so it does not run off the sides.
- Avoid "distant", "seen from far away", "hazy dusk light" and "fading to nothing at its foot". They make pixflux paint a whole scene. In the first round, every volcanic silhouette asked for that way came back with ground, clouds or a moon, and 14 of 18 silhouettes ran off the canvas.
- Avoid a glow at a crater's top. Pixflux draws it as a setting sun.

For a whole layer, ask for the full width and a flat bottom edge. A far range comes back as a flat single-colour band, which is right for the farthest layer; it is recoloured in step 5.
3. Plan and generate
pixelkiln plan
pixelkiln gen --budget pixellab=18
plan lists one generation an image at these sizes. Three seeds of six assets
is 18 generations a biome. Plan for a retry round: the alpine and volcanic sets
each needed one.
4. Keep the best candidate
Look at every candidate on a plain colour, then reject the ones that break the stack:
- A silhouette that touches the left or right edge. Its cut-off side shows as a straight vertical line in a run.
- Anything with a horizon line, a reflection, clouds or a moon in it.
- A whole layer that does not span the width. It leaves gaps when it repeats.
- A middle layer that is one landmark, such as a single volcano. It is fine, but draw it once instead of looping it (step 6), or the repeat is obvious.
The script prints the numbers for the first check:
python3 research/scripts/parallax.py screen assets/parallax/volcanic/*/landform-*.png
edge 0.00/0.00 means nothing touches either side. The script needs numpy,
pillow and scipy.
5. Finish the pieces
All of these are free and keep every pixel on the palette.
P="python3 research/scripts/parallax.py"
# Silhouettes: trim, then thin out the bottom 30% with an ordered dither.
$P foot cone.png cone.foot.png 0.3
# One copy a tier, each pulled toward its own colour and snapped to the palette.
$P tint cone.foot.png cone.far.png "#7f4776" 0.55 pixelkiln.manifest.json
$P tint cone.foot.png cone.near.png "#403a61" 0.4 pixelkiln.manifest.json
# Whole layers: loop at the best matching columns. Recolour the flat far range.
$P loop layer-far.png far.png cut
$P tint far.png far.png "#936090" 1 pixelkiln.manifest.json
$P loop layer-near.png near.png cut

The dithered foot. Background removal leaves every pixel fully on or off, so a silhouette cannot fade by alpha. Thinning its bottom rows with a 4×4 pattern makes it dissolve into whatever is behind it and keeps it pixel art.
Depth order. The farther a layer, the closer to the sky's colour and the lower its contrast. Check the order from back to front: the far range lightest, then the far tier, the near tier, and the near layer darkest. Snow can stay bright on a near tier, as long as its shadows are darker than the range behind it. Tinting every tier toward one light haze colour gets the order backwards: the near tier ends up lighter than the range behind it.
The far range. Pick a palette colour that sits between the sky bands behind it, darker than the horizon and lighter than the tiers.
6. Preview the stack
Name the stack in the manifest, under parallax, far layer first. A layer is
a generated asset, a finished file, or sky bands that PixelKiln draws.
This is the alpine set from the pictures above:
"parallax": {
"alpine-dusk": {
"view": [384, 216], // the game's view in pixels
"travel": 480, // how far the camera moves across the level
"layers": [
{ "name": "sky", "sky": ["#405e9c", "#60649f", "#a596b9", "#c38eb3", "#de889c", "#f9b59c"], "speed": 0 },
{ "name": "far", "file": "picked/far.png", "bottom": 150, "speed": 0.125, "extend": true },
{ "name": "mid", "file": "picked/mid.png", "bottom": 204, "speed": 0.25 },
{ "name": "ground", "sky": ["#040920"], "bottom": 422, "speed": 1 },
{ "name": "near", "file": "picked/near.png", "bottom": 256, "speed": 1 }
]
}
}
pixelkiln parallax preview alpine-dusk
It writes parallax/alpine-dusk/alpine-dusk.preview.html, a page that
scrolls the set in a browser with a slider to stop it anywhere, and a strip of
frames from the start to the far end (--frames sets how many). It spends
nothing.
bottomis the canvas row a layer's foot sits on; the canvas starts at the top-left of the view.xmoves a layer sideways.- Layers repeat sideways unless
"repeat": false. For one that repeats, the command measures the join and warns when it is more than twice as rough as the rest of the picture, so loop it first. extend: truerepeats a layer's bottom row down to the foot of the view, so the layers in front dissolve into distant land, not into sky.assetreads the generated picture from the lockfile. Addstylewhen the asset has more than one.- A one-colour
skyis a flat fill. Thegroundlayer above fills the strip under the treeline.
The command has no silhouette runs yet. Lay runs with the script, which draws the sky and scrolls the whole stack from a small JSON file:
{
"view": [384, 216],
"sky": ["#2e3253", "#503e68", "#7b5f94", "#ad628e", "#d66283", "#f96076"],
"seed": 7,
"frames": 120,
"travel": 480,
"layers": [
{ "image": "far.png", "bottom": 150, "speed": 0.125, "extend": true },
{ "run": ["cone.far.png", "rim.far.png", "mesa.far.png"], "foot": 158, "speed": 0.25 },
{ "run": ["cone.near.png", "rim.near.png", "mesa.near.png"], "foot": 176, "speed": 0.5 },
{ "fill": "#0e0c20", "top": 206, "speed": 1 },
{ "image": "near.png", "bottom": 246, "speed": 1 }
]
}
STILL=still.png SCALE=2 python3 research/scripts/parallax.py skyline preview.webp stack.json
extendon the far range repeats its bottom row to the foot of the view, so the tiers' dithered feet dissolve into distant land, not into sky.- A run lays its sprites left to right, each starting 72% of the way across the last, flipped at random and never the same one twice in a row.
- An image with
"repeat": falseand anxis drawn once: use it for a landmark. - The camera pans
travelpixels and back. Watch the far end of the pan for seams, floating feet and gaps under the near layer.
The specs and the build script for both biomes are in
benchmarks/parallax-refined.
7. Put it in the engine
pixelkiln parallax export alpine-dusk # Tiled, Godot and LDtk
pixelkiln parallax export alpine-dusk --format godot # one of them
Each format goes in its own folder under parallax/<set>/ (or --out), with
the layer pictures it uses and a provenance record:
| Format | What it writes |
|---|---|
| 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). |
| 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). |
| 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. |
We checked the exports against the preview, pixel for pixel, at camera positions sideways, climbing and in a vertical loop. Godot 4.7, Tiled 1.12's renderer and Phaser 3.80 drew every one the same as the preview, and so did the LDtk level drawn the way LDtk's editor draws it. Step 22 of the research note has the numbers.
- Godot. Turn on Rendering > 2D > Snap 2D Transforms to Pixel for pixel art. Without it, a layer sitting on a half pixel is sampled differently.
- Tiled. Leave the map's parallax origin at (0, 0). Tiled 1.11 and later draw a non-zero origin with the opposite sign to its manual, so the export puts the start into each layer's offset instead.
- LDtk. A layer faster than the camera can show more than the level holds, and LDtk draws nothing past a level's edge. The command warns when tiles are lost. Where a layer's speed leaves LDtk's offset between two pixels, it can round a pixel away from the preview later in the level.
- Phaser. It has no file format. Use
setScrollFactor(speed, speedY)withroundPixelson, as the table below says.
Speed is the fraction of the camera's movement a layer follows. The previews use 0 for the sky, 1/8 for the far range, 1/4 and 1/2 for the two tiers, and 1 for the near layer.
- Round the camera to whole pixels first, then take each layer's offset from that rounded position. Rounding each layer on its own moves layers while the camera stands still.
- Prefer simple fractions (1/2, 1/4, 1/8). They step on an even rhythm; 0.3 or 0.6 do not.
- Keep the tiers' speeds close together. A wide spread opens bands of sky between them.
- A bounded level needs no loop. Lay each run past both ends of the level by the most that layer can drift.
The same layer at a quarter of the camera's speed in each tool:
| Tool | Setting |
|---|---|
| Tiled | parallaxx: 0.25 |
| Godot 4 | Parallax2D.scroll_scale = Vector2(0.25, 1) |
| Phaser 3 | setScrollFactor(0.25, 1) |
| LDtk | parallaxFactorX: 0.75 with parallaxScaling: false |
LDtk counts the other way: its factor is how much the layer follows the
camera, so write 1 − speed. With parallaxScaling on it also shrinks a far
layer off the pixel grid. pixelkiln parallax export writes both settings
for you.
8. Scroll vertically
A camera that climbs needs more than the sideways stack. The climb below uses the alpine palette, 14 PixelLab generations and one Retro Diffusion picture for the loop further down.

- Draw layers tall, or place things at height. The 400×100 strips above are made for one height. Climbing past them, the near layer drops out early and the far range's extension fills half the view. Give the camera something to pass at every height: a tall landmark, clouds scattered up the climb, a wall.
- Give every layer headroom. A layer has to be drawn the view's height plus climb × its vertical speed above it. For a 480 px climb that is 48 rows at 1/10 and all 480 at full speed.
- Place the layers for the lowest view. Then a climb only moves them down the screen and never uncovers their feet.
- Move the sky. A sky at speed 0 looks the same at every height. At 0.3 of the climb its bands walk from dusk at the horizon to night at the top.
- Generate clouds as puffy sprites. "a single puffy cumulus cloud, pink-lit top and blue-violet shaded underside, simple shading, about two thirds as wide as the picture, a lone cloud game sprite on a plain empty background, nothing else in the picture: no sky, no sun, no moon, no mountains" came back usable on three seeds of three. Thin streaks and flat banks did not, on four tries.
- Build the wall from a pillar. Asked for a cliff wall, pixflux draws a
pillar with a summit.
wallkeeps the summit and repeats the body below it at the rows where it loops best. Pick the candidate whose ledges are far apart, so the repeat is hard to spot.
# Stack a cliff into a wall 700 rows tall, keeping its top 100 rows as the summit.
$P wall cliff.png wall.png 700 100
# Vertical preview: the camera climbs and comes back.
STILL=strip.png SCALE=2 $P climb climb.webp climb.json
A climb spec is the side-scrolling one with climb in place of travel,
speed_y on any layer whose vertical speed differs, and two more layer kinds:
{
"view": [240, 256],
"sky": ["#040920", "#142b60", "#405e9c", "#a596b9", "#de889c", "#f9b59c"],
"sky_speed": 0,
"sky_speed_y": 0.3,
"stars": 80,
"climb": 480,
"layers": [
{ "image": "far.png", "bottom": 200, "speed": 0.1, "extend": true },
{ "image": "massif.png", "repeat": false, "x": 60, "bottom": 262, "speed": 0.2, "extend": true },
{ "scatter": ["puff-a.far.png", "puff-b.far.png"], "top": -520, "bottom": 60, "count": 7, "speed": 0.4 },
{ "image": "wall.png", "repeat": false, "x": -8, "bottom": 300, "speed": 1 },
{ "scatter": ["puff-a.png", "puff-b.png"], "top": -720, "bottom": -120, "count": 5, "speed": 1.3 }
]
}
Rows count from the top of the view at the start of the climb, so negative
rows are above it. scatter places one sprite per height band between top
and bottom. An image with "repeat_y": true repeats upward instead of
sideways.
For a background that scrolls up forever, such as a vertical shooter's,
generate it with Retro Diffusion's tileY on rd_plus__default and no
background removal. It wraps vertically; pixflux has no seamless option. Keep
the rest of the set on that picture's colours: snapped to a palette with few of
its colours, the sky below kept 5 of its 47.

In the manifest, a climbing set has climb (and travel: 0 if it never
moves sideways), speedY on layers, and repeatY for a vertical loop. Sky
bands are drawn tall enough for the climb at their vertical speed. Scatter
sprites one layer each, with "repeat": false. The climb and the loop above
are both in benchmarks/parallax-vertical/climb:
"endless": {
"view": [192, 256],
"travel": 0,
"climb": 768,
"layers": [
{ "name": "sky", "file": "picked/sky-tile.png", "speed": 0, "speedY": 0.5, "repeatY": true },
{ "name": "cloud_1", "file": "picked/a-cloud-puff.sky.png", "x": 10, "bottom": -60, "speed": 0, "speedY": 1, "repeat": false }
]
}
For a layer that repeats vertically the command measures that join too. The Retro Diffusion sky's comes out at 1.6. The command counts only the steps where the picture changes, so it reads a little lower than the script's 1.9.
The same layer at a quarter of the camera's speed both ways:
| Tool | Setting |
|---|---|
| Tiled | parallaxx: 0.25, parallaxy: 0.25; repeaty on an image layer that loops |
| Godot 4 | Parallax2D.scroll_scale = Vector2(0.25, 0.25); repeat_size.y for a loop |
| Phaser 3 | setScrollFactor(0.25, 0.25) |
| LDtk | parallaxFactorX: 0.75, parallaxFactorY: 0.75 with parallaxScaling: false |
The specs, manifests and build script are in
benchmarks/parallax-vertical, and step 19
of the research note has the numbers.
9. A second time of day
To show the same place at another time, recolour the finished set instead of generating it again. A palette swap keeps every shape, so the two times line up when the game fades from one to the other, and it costs nothing.

-
Take a palette for the new time the way you took the first one. The night palette here is the 42 colours of PixelLab's mountain valley, sent again with the same prompt and seed and "at night" in place of "at dusk".
-
Swap each finished piece onto it by luminance rank, the far range, layers, landforms and tier copies alike:
$P recolour far.png far.night.png dusk.manifest.json night.manifest.json coolcoolleaves out the new palette's light colours, those whose red is above their blue: lit windows, lamplight and the moon. Without it, pink-lit snow turns orange. -
Draw the sky from the new palette.
Generating the set again on the new palette also gives layers that agree, but
in a different place. Every peak moves. "At night" in a prompt also brought a
moon or stars into 7 of 9 pictures, two of them despite "no moon, no stars" in
the prompt. Generate only
what the new time adds, such as a moon, as its own sprite. A swap keeps the
light where the first time put it, which suits dusk to night; light from
another side needs new pictures. The manifests and build script are in
benchmarks/parallax-night.
What this guide does not cover
- Splitting a finished scene into layers. A depth model and inpainting can do it, at 10 to 25 PixelLab generations a layer for the fill; see steps 4, 13 and 14 of the research note.
- Retro Diffusion for sideways layers, beyond this. Its environment style
draws a whole scene whatever the prompt says (step 15).
rd_plus__defaultwithtileX, no background removal and "a plain flat chroma-key green background" in the prompt gives a layer that loops as generated, once the background is keyed out by script (parallax.py key). Retro Diffusion's own background removal breaks the seam. The default style drew a flat background on 2 of 3 tries, and its colours are its own, so the rest of the set has to follow them (step 21). - Silhouette runs, haze, dithered feet and looping inside
pixelkiln parallax. Finish those pieces withparallax.pyand name the results asfilelayers.
