Parallax 2D and its cons

Godot Version

4.6.3

Question

So I’ve been using parallax for a lot, not for simple backgrounds but for complex environment which gives the sense of depth. I love the parallax2D node, the only issue is workflow and performance.

The more parallax layers you add, the more it will lag, but that is expected since every single layer gets rendered individually unlike 3D which uses depth buffer. or so I think?
My other issue which is workflow, I sometimes want to add small parallax varieties on some places, sometimes it’s hard to guess and you may have to add another parallax layer.

The solution for this is just working on the game in a 3D environment, but I’ve been building this game for 8 months and it’s fully 2D. i didn’t do this at the start since I didnt think too much on graphics but now since my game has evolved, it matters.

Here are some screenshots from my metroidvania, to let you know that I rely on parallax even tho its not too obvious on a static image

3D would have the same limitations, it also has to render everything it’s told to render. Depth buffering very likely causes more of a performance hit than 2D’s painter algorithm/z-indexing; but they both play a very minor performance hit.


Your environments look great! Not sure how to help much with workflow issues, maybe creating a plugin/tool for those one-off parallax layers that may be slowing you down? There may be ways to test or preview quicker too, but I’m not sure what you are doing specifically so it’s hard to recommend workflow changes or tools without knowing the workflow.

The lag might be because of the size of the textures you add.

Also, look for the parallax2d preview plugin. It will help you easily preview and tweak parallax layers.

Does each texture in every layer cover the whole screen? How big is each image?

I already use that, but it’s still not ideal workflow wise, imagine I want an object to have a specific parallax scroll scale, then I’d have to add a new Paralalx2D node just for that object, there isn’t much freedom since it will start lagging after having lots of them unlike just placing them on the z axis

They are pretty small since it’s on pixel art, the thing is that I just have too many layers and that could cause performance drops

Have you run the profiler? It’s important to get accurate tests if you are hoping to fix performance issues

I did and it wasnt really a graphical issue, but once I added more layers, the game lagged more on lower devices

The game runs fine but the more layers I add, the more it lags on low end, which is normal I guess

If it’s not a graphical issue then it may not be the Parallax2D’s fault, it’s not a very heavy node- mostly a unique Transform2D, certainly less overhead than using 3D for both graphics and processing transforms.

What does your scene tree look like anyways? How many layers do you have? Are your levels partitioned?

I’m not sure with what you mean with Partitions, but I have 15 parallax layers, they are all needed and the game does run better with less layers, The scene tree is straight forward, but the BG and FG scene also contain their own layers for dust particles and such, it makes things very immersive in my opinion.

Partitioning would be if you have a system for loading/unloading sections of your world, typically “seamlessly” without a loading screen.

15 layers doesn’t sound that bad, might be time to start posting those profiler logs, for both visual profiler and standard script processing

My game is split in rooms so loading/unloading is already done. I cant really guess what’s bad performance wise since my RTX 40 60 is running at 400FPS, but on low end it reaches 20 or less which is unplayable.

I also use transparency layers (without parallax) so background layers start blending to a solid color for the sake of depth. which might not be so good on old GPUs/iGPUs

Like gertkeno said, what the Parallax2D node does is updates your child node’s position every frame and could be done on the lowest spec computer you could throw at it. For most cases, if your PC doesn’t slow down when you have 15 images on screen, putting them in 15 Parallax2D nodes won’t either.

What could cause a slowdown (and would with or without Parallax2D) is if you are trying to display a large number of incredibly large HD renderings and repeat them (possibly hundreds of times). From the screenshots though, it looks like you have very low resolution textures, but maybe use HD effects like lights (which are pretty expensive). There wouldn’t be a way around that though. Parallax2D’s pseudo-infinite repeat feature is the optimized alternative, since (if you set it up correctly) it should only repeat each image once rather than enough to cover your level.

If you show your setup, we may be able to determine where your performance bottleneck is if you’re having low framerate issues.

It seems to me you are using a ParallaxLayers for each node.

How many parallax layers do you currently have?

I use Parallax2D, not ParallaxLayer, and I have arround 15-17 layers

the lights are not HD in fact, I only have 1 light texture which is 64x80 pixels

Have you tried compatibility mode for the lower end devices? I’m assuming integrated graphics or phones, those will get (some) better performance on OpenGL with Compatibility mode. Maybe reducing GPU effects like full screen shaders if any or GPU-particle nodes?

Then, yeah, we’ll need to see your setup, because none of that would cause big performance issues.

It does run better, but it also looks worse, and it only gives like 10 more FPS, so it’s not really worth it.