Construct 2 object performance

0 favourites
  • 11 posts
From the Asset Store
Casino? money? who knows? but the target is the same!
  • Hi

    Im working on a game, and i have a lot (well not really, i think) of objects, in the game that are part of the scenery, Such as trees, rocks etc. These objects doesnt do anything, and are not checked every tick for anything. However i decided that i wanted to add some sort of shadows to them, so i made a copy of them and gave them a black and white effect, and lowered the opacity, and its ok, nothing fancy.

    However since these are sprites as well, it will make the amount of objects go to between 1300-1550 in total, at the moment, and thats when not all objects have shadows. However it seems that construct have a hard time dealing with this amount of objects, which is pretty annoying as it puts a lot of limits to things you can do in my opinion.

    I have been really careful to make sure, that these objects are not tested or doing anything every tick, not that it should matter i guess. But personally i dont think 1300-1550 objects should be such a big problem for computers today, I have a pretty decent one, Intel I5 with a good graphic card and loads of memory, as i also use it to make 3D graphics with. But to see it starting to crawl on a game this simple is a bit disappointing, compared to other games i can run, without any problems.

    Are there anything that can be done about it, or is it simply that construct 2 engine is just not capable of handling more than around 1000 sprites decent?

    On a side node, i started by adding blur effect to the shadows as well, and that seems to really have a huge impact on performance, so had to remove it all together, as it went from bad, to really bad performance.

    The last test i did, it were with about 1200 objects, with no blur and it sometimes drop down to around 44 fps, even though nothing is going on in the game as its game speed is 0.

    With Blur effect and 1100 objects, it goes to 30 fps and occasionally goes to 58 fps for short periods of time.

  • Did some more testing, and cranked up the amount of objects and it seems that also the black and white effect have a huge impact on performance. Whether its all the effects that have such impact on performance i dont know. But seems that if you just dont use them its a lot better. This are the results i got, for those that cares, or have similar problems.

    Effect: Black and white

    Total objects: 3240

    CPU: 0,78

    FPS: 15

    Total objects: 3280

    CPU: 0,8

    FPS: 15

    Effect: Black and white and blur horizontal and vertical

    Total objects: 3287

    CPU: 0,98

    FPS: 6

    Total objects: 3371

    CPU: 1+

    FPS: 6

    Effect: None

    Total objects: 3280

    CPU: 0,25

    FPS: 60

    Total objects: 3267

    CPU: 0,25

    FPS: 60

  • I've also noticed lag spikes with excessive shader usage. It's probably your shader usage that's the issue, 1500 objects should present no problem to PC's today.

    Have you tried putting all the shadows on another layer and adding a layer effect? That might improve performance, but it might not.

    Your only other option is to manually recolor all the sprites and have a separate shadow object/animation frame.

    Otherwise, it's always possible the lag spikes are something Ashley can solve. Again, probably not.

    Sorry if this wasn't as helpful as you hoped :/

  • It isn't the object count, it's the effects! It sounds to me like you put the black effect on each of the objects and then placed them around. So it has to calculate that effect for each object every tick. This is horribly inefficient and would slow down any computer. I have far more objects than you are describing in my scenes with shadow sprites and it has essentially no impact. But I'm also not using effects to achieve it.

    There are two solutions that will drastically improve performance. The first, which is the better option, is to make separate shadow sprites for your objects, place them on a shadow layer, lower that layer's opacity. Import your shadow sprites at 100% opacity and then lower the shadow layer's opacity so they blend with each other. Effects, especially blur, are really expensive to run. You should really only be using them for more dynamic elements. Ie, use blur only on an object where the blur needs to change or go away dynamically.

    The other, which is a kind of middle ground, is to put all of your objects on the layer and then apply your black effect to the layer, not the objects. This way, it processes the effect once over a larger area instead of potentially 500-600 times with how your were describing. I would go with the other option I described and pre-bake as much as possible, though. I have far more than 1,000 objects on my layouts with no ill effect, and my computer is far weaker than yours.

  • I might be wrong but it seems that these effects are cpu based, and therefore the performance goes with them. So as long as you dont use them it can handle a lot more.

    Its not really a problem for me, as i can just make the shadows as you suggested, and that what i will do :). But i was a bit surprised that the impacts on performance these effect have are so servere, that at least to me, they are completely useless. As i really dont like any type of performance drops when i play games my self, so to make one that does it my self, would be really bad :D.

  • The other, which is a kind of middle ground, is to put all of your objects on the layer and then apply your black effect to the layer, not the objects. This way, it processes the effect once over a larger area instead of potentially 500-600 times with how your were describing.

    Yeah thats what i did, i added it to the family, which probably werent a good idea. However i didnt expect it to update the effect every tick, but guess it doesnt that. Hence the bad performance it gives.

  • With sprite objects that are not doing anything, Construct 2 is approximately as fast as a native engine. So you are either hitting the limit of your hardware, or these sprites are actually doing something (perhaps collision testing?).

    Are all those objects on-screen? If so, that's a lot, but a desktop computer should be able to handle it no problem. If they're mostly offscreen it's definitely not rendering that's the problem, and again suggests it's the logic. If you share your .capx, I could take a look and comment further.

    Applying effects to lots of individual instances is pretty inefficient. It's way, way faster to apply a layer effect, and put all the objects on that layer, if it's possible to do it that way. For example if you can put all your shadows on a single layer with a blur effect, that should run pretty well.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Im pretty sure it were my own fault, as i had added the effect to the family and therefore all objects. I have now changed it so its a layer effect and it works a lot better.

    However i tested my game in chrome and suddenly some of the images wouldnt load and just turn black. I saw another one posting about this problem and you mentioned that it were a bug in Chrome, because he had to many objects, think he had 6000. However i dont have that many. But do you know if there have been made a solution to this problem, or a workaround?

    As Chrome seem to be the only browser capable of running the game without other side effects.

    In internet explorer sound and music wont play at all. And the graphic quality seems to be a lot lower than with chrome.

    In firefox sound doesnt play correctly, meaning that it doesnt seem to be able to handle looping sounds correctly. However the graphic quality seems fine. But it seems to use more CPU than Chrome. However it runs without lagging so at the moment i use that, but would prefer chrome if it werent for the missing graphic.

  • All black sprites seems like a graphics card driver issue. Try updating to the latest drivers.

  • I have updated my drives a few days ago. And it havent always been like that, it just suddenly happend.

    This is what it looks like, first its black except the buttons. then this one shows up.

    Which seems to be the Exit buttons graphic zoomed way in, but the 4 small black squares are graphic and the background is also a sprite as well. And have nothing to do with the exit button that it shows, for some reason.

    <img src="https://www.dropbox.com/s/iurx1is9ev9s383/Image_test.jpg" border="0" />

  • Screenshot

    I cant edit my posts, just get a 500 server error, but this should work.

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