question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Alpha masks disable additive blending mode

See original GitHub issue

It appears that applying an alpha mask to a Pixi object will disable the additive blending mode.

var imageEntity = new PIXI.Sprite(this.imageTexture);
imageEntity.blendMode = PIXI.BLEND_MODES.ADD;

var mask = new PIXI.Sprite(this.maskTexture);
imageEntity.addChild(mask);
imageEntity.mask = mask;

stage.addChild(imageEntity);

I seem to remember this having been reported in the past but was unable to find it.

We are using Pixi V.4.0.0.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
ivanpopelyshevcommented, May 24, 2018

You are already at the point where docs are useless, you have to clone the repo.

https://github.com/pixijs/pixi.js/blob/dev/src/core/renderers/webgl/filters/spriteMask/SpriteMaskFilter.js

Assume we have alphaSprite and mySprite

var spriteMaskFilter = new PIXI.filters.SpriteMaskFilter();
spriteMaskFilter.glShaderKey = 'uniqueMaskKey'; // ask filterManager to cache filter shader, handy if you use many of them

spriteMaskFilter.sprite = alphaSprite;
alphaSprite.renderable = false;

mySprite.filters = [spriteMaskFilter];
1reaction
chesovnikcommented, May 23, 2018

Maybe, I have the same problem. If I create mask from Graphics and apply it to Graphics it works fine. If I apply blend mode to these Graphics everything is okey too. But if I apply blend mode and then make mask — blend mode doesn’t work.

let overlay = new Graphics(); overlay.lineStyle(5,0xFF3300,1); overlay.beginFill(0x66CCFF); overlay.drawRect(window.innerWidth / 2, 0, window.innerWidth / 2, window.innerHeight); overlay.endFill();

let rectangle = new Graphics(); rectangle.lineStyle(5,0xFF3300,1); rectangle.drawRect(window.innerWidth / 3, window.innerHeight / 3, 500, 500);

overlay.blendMode = PIXI.BLEND_MODES.MULTIPLY; overlay.mask = rectangle; app.stage.addChild(overlay); app.stage.addChild(rectangle);

PixiJS 4.7.3 - ✰ WebGL ✰

Read more comments on GitHub >

github_iconTop Results From Across the Web

Alpha masks disable additive blending mode #3824 - GitHub
It appears that applying an alpha mask to a Pixi object will disable the additive blending mode. var imageEntity = new PIXI.Sprite(this.
Read more >
Use blending modes and layer styles in After Effects
Most blending modes modify only color values of the source layer, not the alpha channel. The Alpha Add blending mode affects the alpha...
Read more >
Blending Modes Explained - The Complete Guide to ...
Blending Modes are mathematical equations that blend layers based on their hue, saturation, luminosity, or a combination of these components.
Read more >
Tag: additive blending - Learn OpenGL ES
We'll look at how to turn blending on and off, how to set different blending modes, and how different blending modes mimic real-life...
Read more >
Simple alpha additive blend material. - Unity Forum
Set the albedo color multiplier to black and using the same texture for both the albedo and emission, and set the rendering mode...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found