Jump to content

How to add additional filters?


Wendigo
 Share

Recommended Posts

Hi community,

I'm trying to add an additional filter to a sprite in Pixi v4 but somehow this only works when I add the filters at the same time like so:

mysprite.filters = [new PIXI.filters.BlurFilter(), new PIXI.filters.NoiseFilter()];

My goal is to dynamically add and remove filters on the sprites at a later time. I have tried this (see below), but when I examine the "mysprite.filters" property, the debugger still tells me that there is only one filter on the sprite:

mysprite.filters = [new PIXI.filters.BlurFilter()];
...
mysprite.filters.push(new PIXI.filters.NoiseFilter());

What is the correct way to add additional filters to a sprite?

Thanks in advance. :)

Link to comment
Share on other sites

Thanks for the reply.  ?

Did I get you right, that I have to assign the "active" filters to the "mysprite.filters" array again, each time I want to add/remove one of the filters in Pixi v4? I didn't really understand what you said about the "getter that clones array". Is that an alternative approach to add filters?

Do you have a recommendation on how to do this in a memory and performance efficient way? I'm trying to add filter support to the GDevelop game engine so the active filters and filter settings might get changed frequently.

Link to comment
Share on other sites

I'm talking about this disaster: https://github.com/pixijs/pixi.js/blob/v4.x/src/core/display/DisplayObject.js#L627 

PixiJS is not a closed black box like Flash was, its fine to look at sources and think how can you fix it.

No, filter objects changes are fine, the problem is only in array of filters.

I also recommend to add "filter.filterArea= renderer.screen" option somewhere, like, "use fullscreen mode for filter", i cant give you more details, please read article about filters in v4 in pixijs wiki if you want more.

Additional filters are good stuff, but every filter adds one or more framebuffer changes and it can be performance heavy, so beware (unless you have your own stage tree like me that tracks all changes and caches filters. I'm the only one so far who does 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...