Filters with original graphics rendered on top?

Recommended Posts

I'm trying to apply a series of filters to a Graphics object:

const filters = [
  new PIXI.filters.BlurFilter(10), 

Is there any way with filters to render the original graphics on top? I tried duplicating the Graphics object without filters but it's slow.

In SVG it would be done like this:

<filter id="myFilter">
  <feGaussianBlur in="SourceGraphic" stdDeviation="10"/>
  <feColorMatrix mode="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 18 -7" result="result"/>
  <feComposite in="SourceGraphic" in2="result" operator="atop"/>


Share this post

Link to post
Share on other sites

Yes, you have to make your own composite filter based on BlurFilter for that. You can wait when someone writes it for you here , or just try to experiment with blurfilter inputs output

something like Filter that uses BlurFilter inside and then uses itself with CLEAR=FALSE

Share this post

Link to post
Share on other sites

Thanks for that. I've tried to follow your suggestion but I'm not getting the results I expected. I'm not sure what I'm doing wrong.

export default class MyFilter extends Filter {
  constructor() {
    this.blurFilter = new BlurFilter(10);
    this.colorMatrixFilter = new ColorMatrixFilter();
    this.colorMatrixFilter.matrix = [1, 0, 0, 0, 0,  0, 1, 0, 0, 0,  0, 0, 1, 0, 0,  0, 0, 0, 3, -2];

  apply(filterManager, input, output, clearMode) {
    const renderTarget = filterManager.getFilterTexture();
    this.blurFilter.apply(filterManager, input, renderTarget, CLEAR_MODES.CLEAR);
    this.colorMatrixFilter.apply(filterManager, renderTarget, output, CLEAR_MODES.BLEND);
    super.apply(filterManager, input, output, CLEAR_MODES.BLEND);

This line seems to be the problem. When I comment it out, I kind of get the results I want but the original graphics are not on top.

super.apply(filterManager, input, output, CLEAR_MODES.BLEND);


Edited by Mark_

Share this post

Link to post
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.

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.


  • Recently Browsing   0 members

    No registered users viewing this page.