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

Fix mask combine filter bug #1842

Merged
merged 1 commit into from Feb 4, 2016
Merged

Fix mask combine filter bug #1842

merged 1 commit into from Feb 4, 2016

Conversation

hightopo
Copy link
Contributor

@hightopo hightopo commented Jun 8, 2015

In the demo (code below), i create a group with a rect mask, and create a sprite as group's child with a blurXY filter, then nothing is displayed.

So i hack WebGLFilterManager's pushFilter and popFilter method, in pushFilter method i create a new stencilManager instance and save the old one, in popFilter i destroy the new stencilManager and restore the old one, then this workaround works rightly as i expect.

I think this is a bug for PIXI, so i hope @photonstorm or @englercj can help me checking whether this fixing is right or not, thanks.

var game = new Phaser.Game(800, 600, Phaser.WEBGL, 'phaser-example', { preload: preload, create: create });

function preload() {
    game.load.image('phaser', 'assets/sprites/phaser2.png');
    game.load.script('filterX', '../filters/BlurX.js');
    game.load.script('filterY', '../filters/BlurY.js');
}

function create() {
    var logo = game.add.sprite(game.world.centerX, game.world.centerY, 'phaser');
    logo.anchor.setTo(0.5, 0.5);

    var blurX = game.add.filter('BlurX');
    var blurY = game.add.filter('BlurY');

    logo.filters = [blurX, blurY];
    var group = game.add.group();
        group.addChild(logo);
        group.mask = game.add.graphics();
        group.mask.beginFill(0xff);
        group.mask.drawRect(0,0,500,500);
}

After i hack WebGLFilterManager's code, i can get the right effect like below:
filter-mask-bug

In the demo (code below), i create a group with a rect mask, and create a sprite as child with a blurXY filter, then nothing is displayed. 
So i hack WebGLFilterManager's pushFilter and popFilter method, in pushFilter method i create a new stencilManager instance and cache the old one, in popFilter i destroy the new stencilManager and restore the old one, then this workaround works rightly as i expect.

I think this is bug for PIXI, so i hope @GoodBoyDigital and @photonstorm can help me to check whether this fixing is right or not, thanks.
 
		var game = new Phaser.Game(800, 600, Phaser.WEBGL, 'phaser-example', { preload: preload, create: create });

		function preload() {

			game.load.image('phaser', 'assets/sprites/phaser2.png');
			game.load.script('filterX', '../filters/BlurX.js');
			game.load.script('filterY', '../filters/BlurY.js');

		}

		function create() {

			var logo = game.add.sprite(game.world.centerX, game.world.centerY, 'phaser');
			logo.anchor.setTo(0.5, 0.5);

			var blurX = game.add.filter('BlurX');
			var blurY = game.add.filter('BlurY');

			logo.filters = [blurX, blurY];
			var group = game.add.group();
				group.addChild(logo);
				group.mask = game.add.graphics();
				group.mask.beginFill(0xff);
				group.mask.drawRect(0,0,500,500);
		}
@hightopo hightopo mentioned this pull request Jun 8, 2015
photonstorm added a commit that referenced this pull request Feb 4, 2016
@photonstorm photonstorm merged commit 2a94883 into phaserjs:dev Feb 4, 2016
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

Successfully merging this pull request may close these issues.

None yet

2 participants