Jump to content

Is this way to create an animated texture bad?


Wynell
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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? 

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...