instance or objects? the best performance

0 favourites
From the Asset Store
Best car suspension with spring effect and very cool terrain generation.
  • thats odd for only 4 objects, you're sure its the sinebehavior? no lag if you completly remove the behavior?

    anyway hard to tell whats causing that..

    yes, is for the sine behavior... it's strange but cooconJS works better if you disable the webGL...

  • I experimented with this at one point.

    It seems like the way construct works is that it renders objects in the order of their uid. If there is a string of the same object type occupying a range of uid values (say, 1 thru 100), some optimizations kick in (don't exactly know what).

    OTOH, if they are all jumbled, the renderer is constantly switching to a different object, and it slows down the draw calls. Thus, if you have a lot of objects that are spawned randomly, draw calls go up, even if you only have a couple different types of objects.

    I imagine having the same object with each instance having a different frame would cause a drop in performance compared to the same object with each instance having the same frame. But I could be wrong, as I haven't experimented with this.

    Here's the thread I started where this was discussed:

    Ashley's response partly covers what I'm talking about above, except for the UID sorting, which I inferred from my own tests.

  • Colludium is right.

    In WebGl rendering version WebGL can render the same textures numerous times once. Where as rendering of different textures requires more draw calls.

    In C2; C2 treates one Sprite object and all the images as a single texture. So while you see the division of frames it is in fact better optimized for WebGL rendering. Where as different sprites are always rendering different image textures.

    minimize the number of sprites as much as possible. In fact it's best to to creat the game with master Sprite's that are only pinned to gameplay objects. Used image sprites have collisions off, where as gameplay objects never render.

    So it's always better to minimize sprite used. however C2 still needs to groups sprites by transfer size which is most of the time 2048.

  • This is very interesting. I had wondered why some people took the approach of using a sprite object plus an invisible 'logic/mover' sprite...though, somehow it seems like using 2 objects versus 1 would have to be slower logic-wise, even if one is invisible and one has no cols. Guess I'll have to try and see...

    How does this work outside of WebGL, or has anyone tested it?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • TiAm,

    When I turn off WebGL on my 'little test' the draw calls cpu use for drawing the 99 instances of an object goes up to the same amount as required to draw the 99 different objects. Although I was generally aware of this principle before I must confess to being surprised that WebGL was so beneficial. If I get the chance later I'll try this on mobile chrome and see if there's any difference on a mobile browser.

    So, if there will be no WebGL in the final product then there's nothing to be gained by going through the pain of trying to minimise the number of individual objects in a project - the only thing that can save cpu demand here is, as was already apparent, minimising the number of objects on screen.... Which is interesting to me because I already find that just by enabling WebGL on my old laptop (only 6 years old) the performance can sometimes become a bit choppy. So my personal policy has been to avoid WebGL when designing for a market that could be using older hardware.

    Thanks , some good advice there as always.

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