Wynell Posted January 30, 2021 Share Posted January 30, 2021 Hello! I have a set of PNG images, that have the same size and other properties, and exactly in *my* application it's easier to create and use some Animated Texture, than to create a PIXI.AnimatedSprite instance. I've experimented a bit and this is what I got working: https://www.pixiplayground.com/#/edit/IuyUNZg5u6oLYeBihQH_n I think doing things this way is a bad idea, but why? Is there a better way to do this? Why I want to make an Animated Texture instead of using a PIXI.AnimatedSprite? Because my Entity class extends PIXI.Sprite and I think extending PIXI.AnimatedSprite in Static sprite cases is not a good idea... Or is it? If I use PIXI.AnimatedSprite in static sprite cases, will it affect performance then? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 30, 2021 Share Posted January 30, 2021 (edited) performance is same. Did you look inside AnimatedSprite and Texture classes? if you want truly animate texture itself, you have to use renderTexture and copy videomemory each time, and its slower. Edited January 30, 2021 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
Wynell Posted January 31, 2021 Author Share Posted January 31, 2021 19 hours ago, ivan.popelyshev said: performance is same. Did you look inside AnimatedSprite and Texture classes? if you want truly animate texture itself, you have to use renderTexture and copy videomemory each time, and its slower. If I pre-load the animation's baseTextures, they will be cached, right? But if I use RenderTexture, I will re-render the texture each time I think I don't understand something in the Textures, BaseTextures, RenderTextures, their Caching and Performance... Is there a place where I can read more about them all? Besides the documentation So from the two options above (baseTexture replacing and RenderTexture) which is better for the performance? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 31, 2021 Share Posted January 31, 2021 > Is there a place where I can read more about them all? Besides the documentation The best way is to know whats underneath. https://webglfundamentals.org/webgl/lessons/ "cache" in this case means whether or not baseTexture holds a link to actual WebGLTexture object that exists in GPU Process. To help people, Pixi deletes webgl texture if they weren't used for render for some time. Unfortunately that doesnt mean GPU Process frees that memory, because browser inner workings is a problem, and in case when there's tight fit - its better not to do it. Why pixi does it? Because people on their own usually dont manage gpu memory and its not possible to know whether texture will be needed or not, those objects are not managed by javascript GC! Just turn off pixi gc and it goes away. RenderTexture is framebuffer where you can render something into, and pixi gc does not manage it - only you can dispose it. Also it exists purely in GPU process, so there's no way to re-upload it for pixi, you have to re-create it yourself after you disposed it. Quote Link to comment Share on other sites More sharing options...
Wynell Posted February 1, 2021 Author Share Posted February 1, 2021 10 hours ago, ivan.popelyshev said: > Is there a place where I can read more about them all? Besides the documentation The best way is to know whats underneath. https://webglfundamentals.org/webgl/lessons/ "cache" in this case means whether or not baseTexture holds a link to actual WebGLTexture object that exists in GPU Process. To help people, Pixi deletes webgl texture if they weren't used for render for some time. Unfortunately that doesnt mean GPU Process frees that memory, because browser inner workings is a problem, and in case when there's tight fit - its better not to do it. Why pixi does it? Because people on their own usually dont manage gpu memory and its not possible to know whether texture will be needed or not, those objects are not managed by javascript GC! Just turn off pixi gc and it goes away. RenderTexture is framebuffer where you can render something into, and pixi gc does not manage it - only you can dispose it. Also it exists purely in GPU process, so there's no way to re-upload it for pixi, you have to re-create it yourself after you disposed it. How can I cache frames, if I create a renderTexture? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted February 2, 2021 Share Posted February 2, 2021 (edited) Sorry, that requires extra explanations i probably dont have time. Whats your case, i still dont understand? Edited February 2, 2021 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted February 2, 2021 Share Posted February 2, 2021 The thing is, AnimatedSprite is just a sprite that changes its own texture. AnimatedSprite implementation is generic stuff I recommend to replace as soon as you see when something is "not optimized" or has limitations. 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.