pixijs / filters

Collection of community-authored custom display filters for PixiJS

Home Page:https://pixijs.io/filters/docs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Outline filter does not scale with renderer

rizen opened this issue · comments

If you scale the pixi renderer something like this:

let zoom = 50;
const scale_factor = zoom / 100;
      app.stage.scale.x = scale_factor;
      app.stage.scale.y = scale_factor;
      app.renderer.resize(
        width * scale_factor,
        height * scale_factor
      );

And apply an OutlineFilter to the objects on the stage, the width applied in the filter doesn't get scaled. So if you set a width of 10px on the filter, it's 10px regardless of whether the renderer scale is at 50% of its original size or 100%.

I've set up a demo here: https://jsfiddle.net/plainblackguy/dfcm6hjL/44/

What I'd expect is that the width of the filter be 5px if I set the scale of the renderer to 50%.

Of course, it's 100% possible that I'm just misunderstanding something. Thanks for your time.

That's not really how filters work. They don't care about the scale of the display object.

You can do something like this to scale the thickness depending on the scale.
https://jsfiddle.net/bigtimebuddy/m3Lf2p78/

The fact that filters "don't care" and everything else "does care", seems a bit odd to me.

Shall I take your reply to mean "won't fix"? It's not ideal, but at least if I know that you're not going to change your mind, I can work to craft some sort of a solution to walk the tree of objects and apply my own scaling.

None of our filters adapt to the world scale. Even the built-in filters like BlurFilter. It's up to the user to manage. If we were going to change the current behavior, that would be a discussion for the main repo. I can definitely can see not scaling the outline thickness (in your example) as desirable. One person's unintended behavior is another's expected behavior.

Thanks for your help.