qdrj Posted April 9, 2015 Share Posted April 9, 2015 I'm tuning performance for my game. I'm using SpriteBatches where it is possible. So I have looked at PIXI sources(version 2.2.8) and made next assumptions about SpriteBatch performance: WebGL: Inside each SpriteBatch I should use textures only from one spritesheet. Otherwise on each render WebGLFastSpriteBatch.flush is called which is expensive operation and should be avoided. Canvas: SpriteBatch children can be from different spritesheets it won't affect performance. But we should avoid child rotation because it would call context.setTransform multiple times. Overall: Using sb for canvas improves performance very slightly. For WebGL it gives significant boost. Please correct me if I wrong. Thanks in advance! Quote Link to comment Share on other sites More sharing options...
xerver Posted April 9, 2015 Share Posted April 9, 2015 Thats pretty much it, I wouldn't try to use them differently based on renderer though. Flat array of children, only basic transforms, and share a spritesheet. If you do those it will be faster (especially using ParticleContainer in v3). Quote Link to comment Share on other sites More sharing options...
qdrj Posted April 14, 2015 Author Share Posted April 14, 2015 Thats pretty much it, I wouldn't try to use them differently based on renderer though. Flat array of children, only basic transforms, and share a spritesheet. If you do those it will be faster (especially using ParticleContainer in v3). What are basic transformations? Which transforms are more expensive than others? Quote Link to comment Share on other sites More sharing options...
Sebi Posted April 14, 2015 Share Posted April 14, 2015 What are basic transformations? Which transforms are more expensive than others? Translate, Scale, Rotate are the basic transformations. Translate and Scale are the cheapest, Rotate is slightly more expensive because of the sinus/cosinus calculation. Non basic would probably be something like shear/skew. Also alpha and the visible property should work fine in SpriteBatches, not sure if tint is supported in the ParticleContainer of v3. The ParticleContainer in v3 allows us to define which properties of the Sprite we wish to upload to the GPU. If your Batch never uses scale, you can disable it. If it never uses the alpha property, you can disable it. etc. Quote Link to comment Share on other sites More sharing options...
xerver Posted April 15, 2015 Share Posted April 15, 2015 > Also alpha and the visible property should work fine in SpriteBatches, not sure if tint is supported in the ParticleContainer of v3. Yes, alpha is: https://github.com/GoodBoyDigital/pixi.js/blob/dev/src/core/particles/ParticleContainer.js#L29-L34 Honestly not 100% sure about visible property. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.