Will construct ignore draw calls for invisible layers?

Discussion and feedback on Construct 2

Post » Sun Jun 26, 2016 10:53 pm

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
B
32
S
10
Posts: 370
Reputation: 3,156

Post » Sun Jun 26, 2016 10:57 pm

By dynamically setting collisions on and off for certain objects I reduced a lot. There must be other better ways though as well
B
43
S
12
G
14
Posts: 488
Reputation: 10,570

Post » Sun Jun 26, 2016 11:30 pm

Tinimations wrote: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.
B
75
S
28
G
32
Posts: 481
Reputation: 19,713

Post » Mon Jun 27, 2016 12:33 am

@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. :(
B
32
S
10
Posts: 370
Reputation: 3,156

Post » Mon Jun 27, 2016 11:39 am

Is this not what rendering & collision cells are for?
Image
B
243
S
30
G
13
Posts: 1,787
Reputation: 18,770

Post » Tue Jun 28, 2016 12:27 pm

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.
Scirra Founder
B
395
S
233
G
88
Posts: 24,376
Reputation: 193,842


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 13 guests