Jump to content

How can I implement glow filter on shapes


Gorgi Kakasevski
 Share

Recommended Posts

I want to use glow filter in my pixi project. I found implementation in v2 which don't work in v3 (http://codepen.io/mishaa/pen/raKzrm). Also when I try the filter on circle (in v2), the filter is only shown in the rectangle in which the circle is placed (see the image bellow). 

I try to use pixi extra filters (https://github.com/pixijs/pixi-extra-filters) but I can't include in my project. Some help or simple example pls

Capture.JPG

Link to comment
Share on other sites

I'm not advanced user of pixi, I just add <script src="/public/js/pixi.min.js"></script> to my projects. I try to add <script src="/public/js/pixi-extra-filters.min.js"></script> after pixi.min js and then I try to use the filter: shape.filters = [GlowFilter(renderer.width, renderer.height, 15, 2, 1, 0xFF0000, 0.5)]; or PIXI.filters.GlowFilter but as I see this is not the right way.

Link to comment
Share on other sites

Tnx, this is what I need.

But I have a little problem when I apply the filter on shape. In this case the filter is applied only in rectangle in which the shape is drawn. To solve this problem I made a trick, I put the shape in container and add invisible circles (with 0px radius) on the four edges. I can't find other solution.

 

Capture.JPG

Link to comment
Share on other sites

How does it perform?

Maybe my implementation was too naive, but my attempt at a programatic glow filter turned out to be too expensive for what I wanted. I replaced my glows with a .png gradient sprite and colored it with `sprite.tint`.

_ndkvudw.png

Here's the gradient image: https://github.com/danneu/p2-space-arena/blob/4f89d3c2bb0e36a7abc3e7495135f3e246f3aa40/static/img/circle-gradient16.png It's a white circle that fades to opacity 0 at the edges.

I found no decrease in quality as I kept halving the .png size, but stopped at 16x16 pixels. Maybe it could be made even smaller.

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