how to fix laggy movement for more than 2 background layers in 2D?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Sarthak

So I have a simple 2D project containing 5 layers (4 parallax bg layers , 1 ground layer).
Then I have a player scene which has a simple controller and a capsule shape.
Now, this runs perfectly on pc.

MY DEVICE - Redmi Note 5 (RAM- 3GB)

PROBLEM - But when I export for android, the game suddenly becomes laggy.

a) lowering the image resolution (Doesn’t work)
b)reducing the the no of bg layers (It works perfectly if there are 2 layers. As I increase
the layers to 3 it goes back to laggy)
c) Trying on a better phone (It works on highest end phones)

So why does it break at more than 2 layers ?
Is it a RAM thing (my device has 3gb)?
Is there any other way to fix it?
Will there be same result if I use any other engine?

Pls help me with this … I cant go any further before I fix this.
Thank You

if anyone facing this issue…
i tried everything it didnt work. So I switched to unity and it works like a charm.

Sarthak | 2020-10-08 07:17

:bust_in_silhouette: Reply From: Calinou

Rendering several parallax layers requires a lot of overdraw, which is too much for some mobile devices (or integrated graphics to handle).

If you use more than 3-4 parallax layers in your game, you’ll want to add a “minimal parallax layers” in-game setting for people with low-end devices. When that setting is enabled, only render the parallax layers that are essential to gameplay somehow. This can also be beneficial for accessibility and player visibility. See Lag/Stutter in Android builds when adding 6 or more ParallaxLayers · Issue #63352 · godotengine/godot · GitHub.

Alternatively, you can reduce the rendering resolution* by setting Display > Window > Stretch > Shrink to 2 in the Project Settings. This will render everything (both 2D and 3D) at half resolution, reducing the required pixel fillrate by 75%.

*: This is different to reducing the parallax image’s resolution, which indeed has no noticeable performance impact unless you’re bound by memory bandwidth (or are running out of memory).