Jump to content

PixiJS filters not working correctly


GoogleFeud
 Share

Recommended Posts

Hello everybody! I'm making a little game using pixi.js, and I want to use the `OldFilmFilter`. This is how I use it:

const img = Sprite.from("...");

img.filters = [new OldFilmFilter()];

 

but, for some reason the filter doesn't work like it's supposed to. As you can see in the demo (https://filters.pixijs.download/v3.2.0/demo/index.html) the noise is animated, and there's other stuff going on. However, my image only comes out gray - there's no animation to it, it's just gray.

I'm using Pixi v6.2.1, and pixi-filters v4.1.5

 

show.png

Link to comment
Share on other sites

  • 1 year later...

If anyone happens to have this exact same issue here in 2023, like me, the solution is to randomize the seed of the filter every tick (or in whatever interval), like so:

import {Application} from 'pixi.js';
import {OldFilmFilter} from 'pixi-filters';

const app = new Application(/* your stuff */);
app.stage.addChild(/* your stuff */);
app.stage.filters = [new OldFilmFilter()];

app.ticker.add(() => {
	app.stage.filters[0].seed = Math.random(); // <-- this line is needed
});

I had to pick apart the code in the filter demos to figure this out...

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