AI-generated pixel art image: a side-view landscape staggered in layers like stage scenery, pale mountains in the back, darker forested hills in front of them, a small knight running across a grass platform and dark bushes in the foreground Five layers of a side-view scene with their scroll factors at a camera speed of 120 pixels per second: sky 0, mountains 0.25, hills 0.5, game world 1, foreground 1.5

Your character runs across a platform, and behind it sits a flat picture that moves along like wallpaper. Nothing is wrong with the picture. It just doesn’t feel like a place.

Parallax fixes that with one simple trick: things that are far away move slower than things that are close. Mountains barely creep, hills drift, the ground rushes by. Your brain reads the difference in speed as distance, and a flat scene turns into a world with depth.

In this tutorial you’ll plan a background in layers, choose a width that loops cleanly, draw layers that repeat without a visible seam and bring them into Godot 4 with the Parallax2D node. It connects the pixel art series with the Godot articles: you’ll need the base resolution from Choosing the Right Resolution and Sprite Size and the project settings from Crisp Pixel Art in Godot 4.

What You’ll Need

  1. A pixel art editor with layers. I use Aseprite. If you’re new to it, start with the Aseprite beginner guide.
  2. Godot 4.3 or newer, because the Parallax2D node arrived with that version. I checked the Godot steps against the official documentation for Godot 4.7, the current stable version.
  3. A Godot project set up for crisp pixel art with a fixed base resolution. I’ll use 320×180 as the example.
  4. A level with a Camera2D that follows your character. A few platforms from the tileset tutorial are enough.
  5. About 45 minutes for planning and setup, plus the time you want to spend drawing.

Step 1: Split the Scene into Layers by Distance

AI-generated pixel art image: a side-view night landscape in three clearly separated layers against a dark blue starry sky, pale blue-grey mountains in the back, green hills with fir trees in the middle, very dark bushes and grey rocks at the front

Before you draw anything, decide what is how far away. A side-view scene usually breaks down like this, from back to front:

  1. Sky. The furthest thing there is. It can stand still.
  2. Far layer. Mountains, a skyline, distant clouds.
  3. Middle layer. Hills, a forest, buildings.
  4. Game world. Your tilemap, the player, enemies. This is not a parallax layer. It moves exactly with the camera.
  5. Foreground. A few bushes, grass or pillars in front of the player. Optional.

Three background layers are plenty for a first scene. Every extra layer is another image you have to draw so that it loops.

One thing matters more than the number of layers: the scene has to show depth even when nothing moves. Raymond Schlitter puts it this way in his Pixelblog on parallax scrolling: “Parallax will enhance the sense of depth but it may not be convincing if your scene doesn’t already convey depth when static.”

So give each layer its distance in the drawing itself. In his Pixelblog on landscapes, Schlitter describes atmospheric perspective like this: “The further the object, the more it takes on the color of atmospheric haze.” In a daytime scene, close objects are more saturated and have clear contrast between light and shadow, while far objects are less saturated and use fewer colors. In practice that means: pick your sky color first, then let the far layers drift toward it. If you want the color side in more detail, Color Theory for Games explains why cool colors recede, and Environment Thumbnails shows how to plan foreground, midground and background in three values.


Step 2: Choose a Width That Loops Cleanly

A parallax layer is a strip that repeats forever. Its width decides two things: whether it fills the screen, and how well it works as a loop.

For the game, the rule is short. The Godot documentation on 2D parallax says the endless repeat is easiest to work with when you have “an image designed to repeat seamlessly and is the same size or larger than your viewport”. With a base resolution of 320×180, every layer is at least 320 pixels wide. That’s the number I’ll use from here on.

For a loop outside the engine, you need a bit of arithmetic. Maybe you want an animated GIF of your scene for your game page, or a title screen that scrolls by itself. Then every layer has to be back at its starting point when the animation repeats. Schlitter’s method for that is strict about whole pixels, because “fundamentally speaking, you can’t move a half pixel.” Every layer moves by the same whole number of pixels in every frame.

His example canvas is 96 pixels wide, and the loop has as many frames as the canvas has pixels: 96. The rest follows from that:

  • A layer that moves 1 pixel per frame travels 96 pixels during the loop (1 × 96). That’s exactly one canvas width, so the image repeats once.
  • At 2 pixels per frame it travels 192 pixels (2 × 96), two canvas widths.
  • At 3 pixels per frame it’s 288 pixels (3 × 96), at 4 pixels per frame 384 pixels (4 × 96).

Schlitter sums it up in two key points: “Screen width = total number of frames in loop” and “Times image repeats = pixel movement per frame (scroll rate)”.

Loop width example on a 96 pixel wide canvas with a loop of 96 frames: a layer moving 1 pixel per frame travels 96 pixels, at 2 pixels per frame 192 pixels, at 3 pixels per frame 288 pixels and at 4 pixels per frame 384 pixels

The exact condition behind all of this is: the distance a layer travels during the loop has to be a whole multiple of the width of its image. That’s why Schlitter recommends a canvas width that divides into many whole numbers. His 96 pixels divide by 1, 2, 3, 4, 6, 8, 12, 16, 24, 32 and 48, and that buys you two things:

  • Slow layers. If a layer moves only 1 pixel every 2 frames, it travels 48 pixels in 96 frames (96 × 0.5). The loop only closes if the image repeats every 48 pixels, so the canvas width has to be divisible by 2 (96 ÷ 2 = 48).
  • Short loops. If your layers move at 2, 4 and 6 pixels per frame, 48 frames are enough: the layers travel 96, 192 and 288 pixels (2 × 48, 4 × 48, 6 × 48), which is one, two and three canvas widths.

Our 320 pixels are a friendly number too. They divide by 2, 4, 5, 8, 10, 16, 20, 32, 40, 64, 80 and 160. A motif that repeats every 160 or every 80 pixels fits in without a remainder (320 ÷ 2 and 320 ÷ 4).

In Godot you don’t have to do this arithmetic for the loop itself. The engine wraps every layer on its own, no matter how fast it moves. What stays important is the thinking in whole pixels. It comes back in Step 8.


Step 3: Draw Layers That Tile Without a Seam

Create a new sprite in Aseprite with your base resolution, 320×180 pixels, and a transparent background. Add one layer per depth layer from Step 1 and name them: sky, mountains, hills, and foreground if you want one.

Now draw each layer so that its right edge continues into its left edge. Schlitter describes the idea in one sentence: “it’s best to make images that can loop at the seams of the canvas, and repeat them.”

Aseprite has a helper for this. The Tiled Mode sits in the View → Tiled Mode submenu, and the documentation calls it “a simple method to draw patterns quickly”. Choose Tiled in X Axis there. That’s the option for a strip that repeats horizontally.

A few rules for the drawing itself:

  1. Match the edges. Where a hill leaves the canvas on the right at a height of 40 pixels, it has to enter on the left at 40 pixels. Check the seam before you add detail.
  2. Leave the sky open. Everything except the sky layer needs transparent pixels above its silhouette, otherwise it covers the layers behind it.
  3. Avoid landmarks. This is the most important one. In Schlitter’s words: “Balanced layers without dominant points of interest help hide the loop.” A single huge mountain or one bright red tree will come around again and again, and the player will notice the rhythm. Several shapes of similar weight hide it.
  4. Vary within the strip. The flip side, also from Schlitter: “some layers can look monotonous when repeated many times in the loop.” Give the strip three or four different hill heights instead of one bump copied four times.
  5. Less detail in the distance. Far layers get large, calm shapes in few colors. Save the small details for layers close to the player.

Step 4: Export Each Layer as Its Own PNG

Godot needs every layer as a separate image. In Aseprite, open File → Export → Export As. The export dialog has a Layers field that decides what ends up in the file. Either select one layer in the timeline and choose Selected layers, or hide all other layers and keep Visible layers. Export as PNG and repeat this for every layer.

Name the files after the layers: sky.png, mountains.png, hills.png, foreground.png. Keep the size at 100 %. Scaling is the engine’s job, as the Godot setup article explains.

Keep your .aseprite file with all layers. It’s your original.


Step 5: Build the Layer Stack with Parallax2D

Copy the PNGs into your Godot project and open your level scene.

Use Parallax2D, not the older nodes. Many tutorials online still show a ParallaxBackground with ParallaxLayer children. In the class reference of Godot 4.7, both are marked as deprecated with the note “Use the Parallax2D node instead.” The parallax page of the documentation covers Parallax2D only and says it’s “recommended to use over the ParallaxLayer and ParallaxBackground nodes”. Parallax2D came with Godot 4.3 in August 2024.

Now build the stack:

  1. Add one Parallax2D node per background layer and name it after the layer.
  2. Give each Parallax2D a Sprite2D as a child and assign the matching PNG as its texture.
  3. On every Sprite2D, turn off Centered.

The third point is easy to miss. The documentation is explicit about it: “Make sure that the top left of the textures used are at the (0, 0) crossing”. A Sprite2D is centered by default, so half of your image ends up left of and above the origin. The repeat from Step 7 starts at (0, 0) and extends to the right and down, which means a centered image is only partly covered by it. With Centered turned off, the top left corner of the texture sits exactly on the origin.

Then sort the nodes in the scene tree. Godot draws 2D nodes in tree order, from top to bottom as shown in the editor, so nodes further down end up in front:

Level (Node2D)
├─ Sky (Parallax2D)
│  └─ Sprite2D
├─ Mountains (Parallax2D)
│  └─ Sprite2D
├─ Hills (Parallax2D)
│  └─ Sprite2D
├─ TileMapLayer
├─ Player (with Camera2D)
└─ Foreground (Parallax2D)
   └─ Sprite2D

The foreground comes after the player, so it’s drawn over the character.

One consequence of the (0, 0) rule: your layers are 180 pixels high, and their top edge sits at y = 0. With the scroll values from Step 6 they keep that height in the world. So build your level in a way that the camera looks at the area from y = 0 to y = 180.


Step 6: Set the Speed with scroll_scale

Select a Parallax2D and look for Scroll Scale in the Inspector. The documentation calls this property the “backbone of the parallax effect”. It works as a multiplier for the scroll speed, separately for x and y:

  • 1 scrolls at the same speed as the camera. That’s how your tilemap behaves anyway.
  • A value below 1 scrolls slower and makes the layer look further away.
  • 0 stops the layer completely.
  • A value above 1 scrolls faster and makes the layer look closer.

The example scene in the documentation uses (0.7, 1) for a forest, (0.5, 1) for hills, (0.3, 1) and (0.2, 1) for two cloud layers and (0.1, 1) for the sky. The y value stays at 1 there, so the layers only lag behind horizontally.

For our scene I’ll start with these values:

Layer scroll_scale On screen at a camera speed of 120 px/s
Sky (0, 1) 0 px/s
Mountains (0.25, 1) 30 px/s (120 × 0.25)
Hills (0.5, 1) 60 px/s (120 × 0.5)
Foreground (1.5, 1) 180 px/s (120 × 1.5)

Why these numbers and not the ones from the documentation? Because they result in clean steps on a pixel grid. Step 8 shows the calculation.


Step 7: Make It Endless with repeat_size

Right now your layers end after 320 pixels. The property repeat_size, Repeat Size in the Inspector, changes that. According to the class reference, it repeats the texture of each child and offsets it by this value. It adds: “If an axis is set to 0, the Texture2D will not be repeated.”

Set repeat_size to (320, 0) on the mountains, the hills and the foreground: the width of your image in x, and 0 in y, because the scene only repeats horizontally. The sky doesn’t move, so it doesn’t need a repeat.

The documentation explains what happens behind the scenes. Godot adds a single copy of the layer, offset by repeat_size. While the camera scrolls between the image and its copy, the node invisibly snaps back, and the image appears to go on forever.

If you prefer to set the values in a script, attach this one to a Parallax2D:

extends Parallax2D

func _ready() -> void:
	scroll_scale = Vector2(0.25, 1.0)
	repeat_size = Vector2(320.0, 0.0)

If your image is narrower than the screen, the repeat can’t work, because one copy isn’t enough to fill the gap. The documentation shows this with a 288×208 texture in a 500×300 viewport and lists several ways out. The one that suits pixel art is to repeat the texture inside the Sprite2D:

  1. Set Texture → Repeat of the Sprite2D to Enabled.
  2. Turn on the region (region_enabled). Depending on your Godot version, that’s a checkbox right on the Region section or a row called Enabled inside it.
  3. Set the region’s rect to a multiple of your texture size that covers the viewport.

A strip that is 160 pixels wide needs a region width of 320 pixels (160 × 2) for our 320 pixel screen, and the repeat_size is then (320, 0) as well.

If you scale a layer, watch out. The documentation notes that “some settings like Parallax2D.repeat_size and Sprite2D.region_rect do not take scaling into account”. If you scale a Sprite2D with a 160 pixel texture by 2, it covers 320 pixels, and the repeat_size has to be 320 (160 × 2), not 160. For pixel art I’d avoid the problem altogether: draw the layers in their final size and leave the scale at 1.


Step 8: Keep the Motion on Whole Pixels

Now Schlitter’s half pixel comes back. He builds his loops in Photoshop’s frame animation timeline, where every layer moves a fixed number of pixels per frame. In Godot you don’t choose pixels per frame. You choose a scroll_scale, and the engine calculates the rest. The translation between the two is simple arithmetic, and it’s worth doing once.

With the stretch mode viewport from the setup article, Godot renders the whole game at your base resolution. The finished image has 320×180 pixels and nothing in between, so a layer can only ever be shown on whole game pixels.

Say your character runs at 120 pixels per second and the camera follows it. Godot runs 60 physics ticks per second by default, so the camera moves 2 pixels per tick (120 ÷ 60). Each layer moves across the screen at the camera speed times its scroll_scale:

scroll_scale Per tick What you see
1.5 3 px (2 × 1.5) 3 pixels every tick
1 2 px (2 × 1) 2 pixels every tick
0.5 1 px (2 × 0.5) 1 pixel every tick
0.25 0.5 px (2 × 0.25) 1 pixel every 2 ticks
0.125 0.25 px (2 × 0.125) 1 pixel every 4 ticks
0.3 0.6 px (2 × 0.3) uneven: step, pause, step, pause, step, then the same again without a pause

The last row is the problem case. At 0.6 pixels per tick, the layer covers 3 pixels in 5 ticks, and those three steps can’t be spread evenly. The layer moves in a stumbling rhythm, and the eye picks that up as jitter. The values in the rows above it produce regular steps.

So here is the rule for choosing scroll factors: multiply your usual camera speed per tick by the scroll_scale. The result should be a whole number of pixels, or one pixel every whole number of ticks. If your camera moves 1, 2 or 4 pixels per tick, halving is the easy way to get there: 1, 0.5, 0.25, 0.125. At 3 pixels per tick it already fails at 0.5, because that gives 1.5 pixels per tick (3 × 0.5).

Four honest limits of this calculation:

  1. It assumes a constant camera speed. Acceleration, a jump or camera smoothing change the speed from tick to tick, and the pattern with it. Use the calculation for your starting values, then judge the result with your eyes.
  2. Slow layers show their steps. Schlitter tries to avoid anything slower than 1 pixel per frame, “as the motion can look a bit jittery”. His example runs at 0.08 seconds per frame, so 1 pixel per frame means 12.5 pixels per second (1 ÷ 0.08). A layer with a scroll_scale of 0.125 moves at 15 pixels per second in our example (120 × 0.125), which is the same range. If a far layer seems to twitch instead of drift, make it faster or let it stand still with 0.
  3. It only applies to the viewport stretch mode. The Godot documentation on multiple resolutions says: if you are fine with sprites moving in “sub-pixel” positions, use the stretch mode canvas_items instead. Layers then glide smoothly, but your pixels no longer sit on one common grid.
  4. It assumes movement in physics ticks. The table holds if your character moves in _physics_process and the project setting Physics → Common → Physics Interpolation is off, which is the default. With interpolation on, Godot shows positions between two ticks, and the pattern changes.

There’s also a project setting that belongs here: Rendering → 2D → Snap → Snap 2D Transforms to Pixel. The class reference says about nodes with this setting: “Their position can still be sub-pixel, but the decimals will not have effect as the position is rounded.” It also warns that this comes “at the cost of less smooth movement, especially when Camera2D smoothing is enabled”. If your layers shimmer against each other while the camera moves, this is the first setting to try. Point 5 in Step 6 of the setup article has the details.


Step 9: Test with Camera, Zoom and Drifting Clouds

Run the scene and check four things.

  1. Walk to the right for a long time. Watch one layer at a time. You shouldn’t be able to tell where it starts over. If you can, the edges don’t match (Step 3) or the repeat_size isn’t the width of your image (Step 7).
  2. Walk to the left, past the start of the level. The repeat works in both directions. If a layer ends here, check that Centered is off and that the image starts at (0, 0).
  3. Zoom the camera out, if your game does that. The documentation shows what happens with a Camera2D zoom of (0.5, 0.5): the camera sees twice as much in each direction, and a layer that fit before is suddenly too small. At a zoom of 0.5, our 320 pixel screen shows 640 pixels of the world (320 ÷ 0.5). This is what the property repeat_times is for. The class reference describes it with the words “Useful for when zooming out with a camera.” In the documentation’s example, a value of 3 adds one extra repeat behind and one in front.
  4. Let the clouds drift. A Parallax2D can move without the camera. The class reference describes the property autoscroll like this: “Velocity at which the offset scrolls automatically, in pixels per second.” Put a cloud strip in its own Parallax2D between the sky and the mountains, give it a scroll_scale of (0.125, 1) and a repeat_size, and set autoscroll to something small like (-6, 0). At 6 pixels per second, the clouds move one pixel every sixth of a second, which is every 10 frames at 60 frames per second (60 ÷ 6). Flip the sign to reverse the direction.

Common Mistakes

Following a tutorial for the old nodes. ParallaxBackground and ParallaxLayer still exist, but both are deprecated. Their properties have different names, and tips for them don’t transfer to Parallax2D. Check which node a tutorial uses before you copy its settings.

Leaving the sprite centered. The repeat starts at (0, 0) and grows to the right and down. A centered image only fills part of that area, and the layer is cut off while scrolling. Turn off Centered on every Sprite2D in a parallax layer.

Fixing a wrong position with repeat_times. More repeats can hide the mistake above. The documentation calls that “a brute force solution”. Fix the position first and keep repeat_times for zooming.

A layer that is narrower than the screen. If the image doesn’t cover the viewport, a gap appears at the edge. Draw every layer at least as wide as your base resolution, or repeat it with a region as described in Step 7.

A landmark in a repeating layer. The lonely castle on the hill looks great the first time and like a wallpaper pattern the fifth time. Put unique things into the level itself, not into a strip that repeats.

Scroll factors that produce uneven steps. Values like 0.3 or 0.7 look harmless, but on a pixel grid they can make a layer stumble. Do the short calculation from Step 8 for your own camera speed.

Scaling a layer and forgetting the repeat_size. The repeat_size doesn’t follow the scale of the child. After scaling, the layer either overlaps itself or shows gaps. Leave the scale at 1 or adjust the value.

Adding motion to a scene without depth. If all layers have the same colors, the same contrast and the same amount of detail, different speeds won’t save them. Go back to Step 1 and separate the layers in the drawing first.


Quick Reference

  • Layers: sky, far layer, middle layer, game world, optional foreground. Far layers closer to the sky color, with less saturation and fewer colors
  • Width: at least the width of your base resolution, for example 320 pixels. For a loop outside the engine: travel per loop = whole multiple of the image width
  • Seamless: right edge continues into left edge, Aseprite View → Tiled Mode → Tiled in X Axis, no landmarks
  • Godot nodes: one Parallax2D per layer with a Sprite2D child, Centered off, far layers at the top of the scene tree
  • scroll_scale: 1 like the camera, below 1 further away, 0 standing still, above 1 closer. Starting values: 0, 0.25, 0.5, 1.5
  • repeat_size: (image width, 0) for a horizontal loop, for example (320, 0)
  • repeat_times: only when the camera zooms out, for example 3
  • autoscroll: pixels per second for layers that move by themselves
  • Whole pixels: camera speed per tick × scroll_scale = whole pixels, or one pixel every whole number of ticks

What You’ve Learned

  • How to split a scene into layers by distance and show that distance in the drawing
  • What makes a loop close, and why a width with many divisors is practical
  • How to draw layers that tile horizontally and hide the repeat
  • How to set up Parallax2D in Godot 4 with scroll_scale and repeat_size
  • How to choose scroll factors that give regular steps on a pixel grid
  • Which mistakes cause gaps, cut-off layers and jitter

Next up: a parallax background needs a world in front of it. If you haven’t built one yet, Building a Tileset in Aseprite for Godot 4 takes you from the first tile to a painted level. And if you want to plan the mood of your scene before you draw the layers, start with Environment Thumbnails.


Sources