Will construct ignore draw calls for invisible layers?

0 favourites
  • 6 posts
From the Asset Store
Casino? money? who knows? but the target is the same!
  • So a little followup on the whole optimizing a big scene thing. My optimizing worked, but not well enough. I need to go further. The debugger reports that draw calls is the biggest performance hog on this specific level with several thousand objects.

    I see two options: Dynamically destroy and create assets as I progress through the level to keep the object count low, or put asset outside the screen on an invisible layer. My question is, will this last option have any effect?

    It's hard for me to tell since I won't notice any performance issues before i export (which takes about 20 min) and try it on my laptop, so I would appreciate some advice before i tackle the potential huge undertaking of the first option.

    Thanks

  • By dynamically setting collisions on and off for certain objects I reduced a lot. There must be other better ways though as well

  • I see two options: Dynamically destroy and create assets as I progress through the level to keep the object count low, or put asset outside the screen on an invisible layer. My question is, will this last option have any effect?

    Are you sure the draw calls are caused by objects off-screen? Because - they shouldn't. As long as it's offscreen, C2 doesn't render them. So you have some logic going on, but there should be no draw calls.

    Dynamically creating and destroying objects has its own share of problems and caveats.

    The first thing I would test is move the cam somewhere with one or no objects on screen and check if something changes. I'm almost 100% certain that the offscreen stuff isn't your problem.

  • Eisenhans Thanks for the heads up. Made more dedicated tests and the draw call % definately goes down way faster when I only send assets on screen to the invisible layer. Not much difference when I only send assets outside of the canvas. Guess I'll just have to cut down on amount of objects in the scene.

  • Is this not what rendering & collision cells are for?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Construct 2 only issues draw calls for objects that are visible and on-screen. Invisible layers are skipped completely and issue no draw calls at all regardless of their content.

    In extreme cases (which I guess you might be seeing) a huge number of off-screen objects can still cause overhead in draw calls due to all of them having to reject the bounding box test which checks if they are on-screen. This is a tiny super-fast check though so you will need thousands of objects to see any effect here. This is precisely the problem render cells are designed to solve: it means it only checks instances near the viewport, rather than everything on the entire layout. (But note the restrictions on render cells.)

    Invisible layers on the other hand skip their contents entirely (since it makes no difference if they are on or off screen), so it is faster to hide large numbers of instances by putting them on an invisible layer than moving them offscreen. This is a micro-optimisation though, so again is only important with thousands of objects, and render cells should in theory avoid the need to use this workaround.

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