Jump to content

How to reduce drawcall


GBear
 Share

Recommended Posts

hi. 

how can i reduce drawcall..

first. i packed images.

    effect 2 image

    ui       1 image

    map   object 1image

                     bg 49 image( doing culling)

   char   main - 1packed

             monster - one by one

 

but my game draw call is not low  

normally 30-100 and hardly 100-1000(200 same monster use two skill(2 effect by spine))

and. i'm using pixi-particle and this is using high drawcall T-T

 

is drawcall up if container layer is complicated like following example?

for example iconObject(Container) has like following

                         - icon image - sprite

                         - count         - bitmaptext 

                         - name         - bitmaptext

                        - special button - sprite

                       - bg                    - sprite

 

how can i reduce drawcall?

please give me tips..

 

Link to comment
Share on other sites

Find whichever object has the most instances, and separate it into another container. I also use a trick like shadow.position = char.position , so position of two objects will be ALWAYS synchronized  even if they are in different containers and dont have parent-child relation :) If you have 100 objects of the same type, same texture in one container, it will be optimized. And ParticleContainer/SkiinedMeshPatch can optimize it even further.

Link to comment
Share on other sites

@ivan.popelyshev hi ivan..
 

is there a reason sprite can't use 'batch' when sprite has mask ?

and i don't know correct reason. but when i use two emitter or more on same container and same time(emitter is pixi-particle and emitter has different texture and same basetexture))

drawcall is up very fast..

emitter has different texture and same basetexture and same container like following

        container - emitter1_container - 

                        - emiiter2_container

if added 100 of emitter1 only or emiiter2 is same. . it's good... batch, it was optimized..   

but if it used same time T-T....


 

      

 

Link to comment
Share on other sites

it looks because blendSwap

Quote

if (currentBaseTexture !== nextTexture || blendSwap || shaderSwap)

emitters has different blendMode in this case

 

T-T.. how can i control  in this case...

differnt blendmode different Shader, different Position and different drawOrder by position  
T-T...

do you have ideas?
 

Link to comment
Share on other sites

Quote

 I also use a trick like shadow.position = char.position , so position of two objects will be ALWAYS synchronized  even if they are in different containers and dont have parent-child relation

what's the meaning?

Link to comment
Share on other sites

I think he's saying that if you move char, shadow will automatically update and move with it, so you can bind two things that way that don't have to be in the same container.   I was looking at that too.  I wouldn't have thought it would do that.  I would have thought it only would do it for the one call and when character changed it would need to be redone, or maybe it does.  I think I read javascript does a lot of reference copies, so maybe that's why.

Link to comment
Share on other sites

@fire7side hi..

Quote

I think he's saying that if you move char, shadow will automatically update and move with it, so you can bind two things that way that don't have to be in the same container.

can draworder control in this case?

my game need drawing order between characters and objects and etc...
 

how can i control draworder if container is different 

 

 

Link to comment
Share on other sites

I've just started using Pixi also.  Although I did try it a time ago for a little while.  I don't think there is anyway you could control drawing order unless they are in the same container.  You're kind of stuck there.  You might could have two containers and shift from one container to the other.  Like foreground and background.  Haven't tried anything like that, though.

Link to comment
Share on other sites

draworder is changing in real time on my game.

every frame  calculated ..

T-T So container can't be separated .  

ui and game are separated   

and game is separated between object and bg

and object container is always sorting every frame

 

object container is big problem..

 

Link to comment
Share on other sites

You're the only one that can figure it out.  Sometimes there are certain things that can be separated, like for instance particles can all be in one container.  Maybe there are more game elements like that which can be grouped, or you can figure out a way that they can be grouped without changing the game.  Other things can also slow down a game like destroying objects, it's better to keep an object pool for game speed, things like bullets, or enemies that die often can be re-used instead of destroyed.  If the objects don't need to be rotated, then you can use CacheAsBitmap, there's an example for it in the pixi examples.  I haven't done any of them yet, though, because I just haven't worked with Pixi long enough.  I talked to one guy and he said CacheAsBitmap made a huge difference for him in game speed.  Make sure you clean up debug lines, also, like if you use console.log like I do, that will slow it down a lot.  Then there's just code, like maybe not checking something every frame if you don't need it.  Another thing I've done is redesigned the game because it didn't work that way.  I used things that didn't need to move as much in the game.  

Link to comment
Share on other sites

  • 2 weeks later...
16 minutes ago, GBear said:

If children's sprite is changed and cacheAsBitmap is true, child sprite isn't redraw sprite?

if i wanna redraw.. what can i do?   

cacheAsBitmap to false?

 

yes.. 

 

1.cacheAsBitmap  set true;

2.create new sprite when process 'render' 

3.draw created sprite..
 

 

^^;

Link to comment
Share on other sites

  • 5 years later...
On 3/17/2016 at 2:54 PM, ivan.popelyshev said:

@GBear better not to use cacheAsBitmap. At all. 

Pixiv4 will have multiple ways of improving performance, and they're much more effective.

Can you please profile your app and give me the timeline of one render operation ? 

What did you mean by that ? 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...