Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pixels on bottom edge of RenderTexture are inconsistent when using BlurFilterPass in Pixi5 #5969

Closed
jmlee2k opened this issue Jul 29, 2019 · 5 comments

Comments

@jmlee2k
Copy link
Contributor

jmlee2k commented Jul 29, 2019

Expected Behavior

Pixels in generated texture should be consistent with source object

Current Behavior

Pixels at bottom edge of generated texture are not consistent

Steps to Reproduce

  • Apply a BlurFilterPass to a sprite
  • Render it to a RenderTexture

Pixi5 example (not working) - https://www.pixiplayground.com/#/edit/4kgn~bpbYpQMU17cVu5Xl
Pixi4 example (working) - https://www.pixiplayground.com/#/edit/fH6RLPM_wFUd_~piDZF7s

Both of these samples have near-identical code (with only pixi4 -> pixi5 differences).

Sorry for the vague issue title, but I'm not actually sure what's happening. When comparing the pixi4 and pixi5 samples above, the pixi4 sample works correctly, while the pixi5 sample has a red blur at the bottom of the texture. It could be a sampling issue since it only occurs at the edge of the texture, but that's just a guess.

Note: The actual blur is different between Pixi4's BlurYFilter and Pixi5's BlurFilterPass, but that's not part of the issue.

@jmlee2k jmlee2k changed the title Pixels on bottom edge of RenderTexture are inconsistent when using BlurFilterPass Pixels on bottom edge of RenderTexture are inconsistent when using BlurFilterPass in Pixi5 Jul 29, 2019
@ivanpopelyshev
Copy link
Collaborator

ivanpopelyshev commented Jul 29, 2019

I worked with v5 blur a lot. Yes, there can be differences on edge.

This exact difference happens because v5 applies padding BEFORE fit to source, and v4 applies it AFTER.

v4: https://github.com/pixijs/pixi.js/blob/v4.x/src/core/renderers/webgl/managers/FilterManager.js#L147
v5:
https://github.com/pixijs/pixi.js/blob/dev/packages/core/src/filters/FilterSystem.js#L217

You can switch off autoFit (filter.autoFit = false) , it will work but it will compute whole area of the container. If you want to emulate v4 behaviour to the point, try this thing:

// required
filter.autoFit = false;
container.filters = [filter];

//optional
container.filterArea = container.getBounds();
//now somehow we need source frame size... like, your renderTexture frame?
container.filterArea.fit(rt.frame);
//or screen frame?
container.filterArea.fit(renderer.screen);
//padding will be applied automatically by filterSystem, like before

@ivanpopelyshev
Copy link
Collaborator

@jmlee2k
Copy link
Contributor Author

jmlee2k commented Jul 29, 2019

Thanks for the quick response! I think we'll be able to use this to fix the problem we're having.

@bigtimebuddy
Copy link
Member

Seems addressed, closing.

@ivanpopelyshev
Copy link
Collaborator

Yeah , we can add compatibility mode later, i added a mention to wiki.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants