Layers and performance hits

0 favourites
  • 11 posts
From the Asset Store
Firebase: Analytics, Dynamic Links, Remote Config, Performance, Crashlytics on Android, iOS & Web Browser
  • Hey everyone,

    It seems, that increased layer numbers in projects increases the load on the cpu while running the game. I made a test in which I compared the same game but where one instance had many layers and one did not (3 compared to 15).

    I have generally used layers to help me organize objects. This results in no more than a few extra layers. But now I am working on a large project and need many layers. Even though they are not doing anything as far as I can tell it is still increasing cpu usage (3layers 25% cpu)(15layers 65% cpu) intel i5.

    anyone have some tips or insight when dealing with layers?

    It would be nice to have organizational layers that do not have any effect on how construct2 runs - it would only be an editor thing.

  • It definitely has a performance hit, so use only as much as you absolutely NEED. Just ask yourself whether its a NEED or a WANT feature when you optimize your game. If its a WANT, is there a way to achieve a similar outcome/result with less work for the CPU? If so, do it. If not, make a call whether its important enough to stay.

    Trim the fat so to speak.

    I only have layers I need in my games, its never used for organizing objects because that's what the Z sorting command and spawning timing is for. My max layers is 6.

  • 12 extra layers should absolutely not cause a 40% increase in CPU use, especially on an i5. My game has somewhere around 20 layers and when running on an old amd Athlon 4400+, the CPU low point is around 35%, and that's also running the thousands of events in the event sheet at the same time (not all the events are running each tick, of course).

    I'm not sure what's causing it, though. Are you using layer effects? Forcing the layers to have their own texture? Try making a copy of your capx and experiment, delete everything except the layers, try deactivating all the events, turning all the layer's settings back to their defaults, etc.

  • Arima Good point, using a WebGL shader effect on a layer is extremely taxing. In my test, just one one layer using an effect with a static sprite cuts performance in half on mobiles.

  • Using layers has almost zero performance overhead, unless:

    • you set 'force own texture' to 'yes'
    • you set opacity to something other than 100 (which forces its own texture)
    • you set a blend mode other than 'normal' (which forces its own texture)
    • you apply any shader effects (which forces its own texture)

    In other words, a layer with default settings has no overhead, but will use an entire offscreen texture and have to render via that every frame if you change any of the above rendering settings.

  • Ashley - Just so I know, if you have a layer transparency set to say 50%, but then have that invisible, will that cause a performance hit?

    I have done this as I have invisible boxes as collision, but want them transparent so I can line them up perfectly in layout view.

  • Invisible layers are not rendered at all, so have no performance impact regardless of their other settings.

  • Ashley Thanks for the info - That all makes sense. if you are rotating layers/layout does that make a difference?

    - I suppose you are right. I have a lot of wants wrapped up in how I chose to layer my game. Thanks.

    Arima - I am running multiple force to own texture layers. (do different blend modes affect a layer the same way as a webgl effect in terms of cpu usage?

    This is my current layer list, it is running fine so far. I think my computer was performing poorly when I was doing some stress tests. I am running the following on an i5 with 25-40% cpu usage. This includes calculating physics as well:

    layout effects + post processing including scaling and rotating


    light effects (screen, dodge, or other effects used)

    BackGround (destination over)

    Climate effects

    Liquid (using various shaders)

    Foreground parallax

    Light effects and illumination (multiply/forces own texture)

    Explosions, fire, lasers, and other nonsense (additive blend mode)

    Tilelayer (foreground)

    TileLayer (active)

    TileLaye (background)

    Background parallax 1

    BGP 2

    BGP 3

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I don't know. The easiest way to find out would be to make a test .capx that replicates the layer setup only, and check the CPU use with each part on or off.

  • Ashley - "you apply any shader effects (which forces its own texture)

    Does this apply to shader effects applied to the layer, or effects applied to any objects in that layer?

  • Only shader effects on the layer itself.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)