How to get scrolling tiled background image?

Neither of TheKing’s methods are bad or a workaround, they are -the- ways to do it. Godot and Gamemaker have these options built-in…but how do you think they are doing it? It is either in a shader, or by drawing the same image repeatedly and offsetting them.

In fact you can look at Godot’s code (background, layer) and see. Basically all the ParallaxBackground node does is offset all its child layers whenever the camera moves. The mirroring feature looks like a shader thing, presumably the same as Pkeod’s method (but with all the work done for you already).


Anyway. So are you using premade assets you find? Can you simply scale them to a power of 2 size? I imagine it’s hard to find assets that match the exact size you want anyway. It should also be possible to wrap the UVs with a non-power of 2 size, provided you input the image size into your shader. I seem to recall there was a way to calculate the remapped UVs inside an atlas (see this thread), but I don’t remember how much of pain it was to do. Defold definitely could be better in this area.

3 Likes