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

Blendmode Multiply with filter make sprite black #7224

Closed
Bouh opened this issue Feb 4, 2021 · 5 comments
Closed

Blendmode Multiply with filter make sprite black #7224

Bouh opened this issue Feb 4, 2021 · 5 comments
Labels
👍 Not A Bug Verified issue and is working as intended.

Comments

@Bouh
Copy link
Contributor

Bouh commented Feb 4, 2021

Expected Behavior

Blendmode and effect should working together.

Current Behavior

Blendmode multiply make sprite black with blur effect, maybe with other effects too.

Steps to Reproduce

https://www.pixiplayground.com/#/edit/XIU2u6lFUP3iyrl3VEmRN

Environment

  • pixi.js version: 6.0 and lower
  • Browser & Version: Chrome 87
  • OS & Version: w10
    Running Example
@bigtimebuddy
Copy link
Member

Try this instead.

//dude.blendMode = PIXI.BLEND_MODES.MULTIPLY;

var blurFilter = new PIXI.filters.BlurFilter();
blurFilter.blendMode = PIXI.BLEND_MODES.MULTIPLY;
dude.filters = [blurFilter]

@Bouh
Copy link
Contributor Author

Bouh commented Feb 5, 2021

It works like you suggest, any idea why the blend mode on sprite is not correct?
Blend mode on object and filters are different?

@bigtimebuddy
Copy link
Member

bigtimebuddy commented Feb 5, 2021

This is working as intended, but I can see why this is confusing.

In general, for filters to work, Pixi does a "snapshot" of your display object to another surface then applies the filters to that. Because blend modes are a post-process, when you use multiply to your original container of sprites Pixi doesn't know what to multiply the pixels to when it does the snapshot because blend modes take into account the pixels below the object. What you actually need to do is add the blend-mode to is the filter, which will apply it to the snapshot of the original source.

Now, this would work if you the bunnies weren't on a transparent background because there's some information about what to multiply.
https://jsfiddle.net/bigtimebuddy/to5k9z0s/

In that case, we create an opaque background, add multiply to the bunnies, then blur. Everything is 👍

@bigtimebuddy bigtimebuddy added the 👍 Not A Bug Verified issue and is working as intended. label Feb 5, 2021
@Bouh
Copy link
Contributor Author

Bouh commented Feb 5, 2021

Thanks for the explanation! :)

@bigtimebuddy
Copy link
Member

Sure, I'm going to close this seems like I answered your question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👍 Not A Bug Verified issue and is working as intended.
Projects
None yet
Development

No branches or pull requests

2 participants