trsh Posted December 22, 2015 Share Posted December 22, 2015 I have googled a lot and haven't really found any good materials on tips how to improve render performance, or have to not screw it up. Please share if u know. 1 question from my side:Is there any point to free movie clips, sprites and them textures when they are not needed? Like the character goes behind the scene. Will that freeing not result in a LAG? If yes, what's the best approach? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted December 22, 2015 Share Posted December 22, 2015 you need to set "sprite.renderable = false" when your character is still in scene but off-screen (too far away from it) trsh 1 Quote Link to comment Share on other sites More sharing options...
trsh Posted December 22, 2015 Author Share Posted December 22, 2015 I do stage.removeChild, as i wont need it later. But does it free the gpu mem? Quote Link to comment Share on other sites More sharing options...
xerver Posted December 22, 2015 Share Posted December 22, 2015 I do stage.removeChild, as i wont need it later. But does it free the gpu mem? Make sure to call .destroy() on the object you are done with, and to cleanup textures you no longer need call .destroy(true) on them as well. Quote Link to comment Share on other sites More sharing options...
colourclash Posted December 23, 2015 Share Posted December 23, 2015 Make sure to call .destroy() on the object you are done with, and to cleanup textures you no longer need call .destroy(true) on them as well.Hi, does that mean to effectively destroy a sprite I should:this.removeChild(someSprite);someSprite.destroy();If I call destroy() on a Container does it also 'destroy' it's children?Are the textures the sprite is using also destroyed? Quote Link to comment Share on other sites More sharing options...
colourclash Posted December 23, 2015 Share Posted December 23, 2015 Could someone also clarify sprite.renderable = false vs sprite.visible = false?Pardon all the questions, but knowing the most performant way to temporarily hide a display object would be gold! Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted December 23, 2015 Share Posted December 23, 2015 Ok, first, mainly GPU memory is used only for textures. If you are using loader or Sprite.fromImage() then don do anything - textures are cached, and they'll be re-used. That code will upload only ONE texture to GPU: var spr1= Sprite.fromImage("my.png")var spr2= Sprite.fromImage("my.png")var spr3= Sprite.fromImage("my.png")var spr4= Sprite.fromImage("my.png")var spr5= Sprite.fromImage("my.png")var spr6= Sprite.fromImage("my.png")But if you creating many dynamic textures (PIXI.Text for example), destroy() them after use. renderable=false tells pixi to not call renderWebGL(), while visible=false also stops updateTransform() and that means getBounds() wont return you correct result. Quote Link to comment Share on other sites More sharing options...
trsh Posted December 24, 2015 Author Share Posted December 24, 2015 Ok, first, mainly GPU memory is used only for textures. If you are using loader or Sprite.fromImage() then don do anything - textures are cached, and they'll be re-used. That code will upload only ONE texture to GPU: var spr1= Sprite.fromImage("my.png")var spr2= Sprite.fromImage("my.png")var spr3= Sprite.fromImage("my.png")var spr4= Sprite.fromImage("my.png")var spr5= Sprite.fromImage("my.png")var spr6= Sprite.fromImage("my.png")But if you creating many dynamic textures (PIXI.Text for example), destroy() them after use. renderable=false tells pixi to not call renderWebGL(), while visible=false also stops updateTransform() and that means getBounds() wont return you correct result. Yeah, but imagine I have a kind of intro in my game (sprite animations - MovieClip). When that ends, those animations will no longer be needed in the level. Is in not wise then to clear them totaly from memory, to free space for later added ones? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted December 24, 2015 Share Posted December 24, 2015 If you dont need that thing anymore, then destroy its texture. There's another option - destroy() your renderer and re-create it, that will remove every texture from GPU. That's what I use between levels sometimes. Quote Link to comment Share on other sites More sharing options...
trsh Posted December 26, 2015 Author Share Posted December 26, 2015 If you dont need that thing anymore, then destroy its texture. There's another option - destroy() your renderer and re-create it, that will remove every texture from GPU. That's what I use between levels sometimes. Thanks for the tip! 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.