DisplayObject.filters questions

Recommended Posts

I have some questions about filters and how they behave in Pixi.js.

1. When settings filters on a display object like this:

stage.filters = [filter1, filter2, filter3, filter4];

Is the order defined in the list is the same when rendered?

2. Does Pixi.js create brand new FrameBuffer Objects for each filter, or does it reuses the output of the previous filter as input for the next filter?

Sorry if I'm not really clear or accurate since I'm not a WebGL expert ^^

Thanks for your insights :)

Share this post

Link to post
Share on other sites

Good questions.

1. Yes, but i dont remember which one is applied first or last.

2. There's a pool of temporary pow2 render textures that is used. Also it needs only two textures, it swaps them every time.

We want to evade the unnecessary resize (slow on mobile), that's why pooled textures have pow2 size. It comes with a drawback - https://github.com/pixijs/pixi.js/wiki/v4-Creating-Filters

Also you can set the blendMode of last/first filter, it works like blendmode of sprite.

Also this thing wont work because of stupid setter:

var f = [filter1, filter2, filter3, filter4];
stage.filters = f; // COPIES THE ARRAY!!!
f.push(filter5); // wasnt added to stage  :(

//lets fix that
stage._filters = f; // link by referencem yes, its a hack.
f.push(filter6); // added to stage :)


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.