Layer effects cause performance issues when used a lot. In my case i have only 2 effects that i want to use but the problem is i have 4 different layers. Running the 2 effect on all of them causes a really heavy lag spike.
Is there any way to make all layers get affected by the effects while only running them once?
Are they many objects in each layer? What type of effect are you running?
Im running shockwave and pixellate. There is a time teleport ability in the game so for the effect i run the 2 effects each time players teleports for each of the 4 layers. There is like 3 objects in base layer but as you play the game you put down more buildings and enemies spawn so in average there is around 30 to 100 objects in base layer. There is also a layer that contains 0 to 30 max objects each run. other 2 layers only contain 3 to 5 objects. I need to layers for ordering objects and gui stuff so i cant decrease the number of layersç
So the effects only happened when the player teleports. After that are they disabled?
Edit:
Never tried this before but can you try and make an invisible layer that appears in top of everything. Attach a semi-transparent Sprite that covers the entire screen then when the player teleports you make the layer visible and apply the effects. Then rehide it again. This might reduce the stress on the object.
Ps: I recommend you doing this on a copy of your project
Thanks for the answer. It works with some effects but it doesnt helps with effects like shockwave. Its like rendering objects thru a glass but only the glass affected by the shaders. The only effect that works the best is CTR. I cannot find anything to help this problem so instead of optimizing shader i focused to optimize the code and decrease the objects in the layers so its a bit better right now. I wish gdevelops shaders and light engine were more customizable.