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

make GodrayFilter work with DropShadowFilter? #297

Open
andrewljohnson opened this issue May 6, 2021 · 3 comments
Open

make GodrayFilter work with DropShadowFilter? #297

andrewljohnson opened this issue May 6, 2021 · 3 comments

Comments

@andrewljohnson
Copy link

Is it possible to have a GodrayFilter work with DropShadowFilter?

When I add them both to a sprite, the DropShadowFilter seems to reveal the black image used to create the GodRay effect.

@bigtimebuddy
Copy link
Member

Could you provide an example?

@andrewljohnson
Copy link
Author

andrewljohnson commented May 7, 2021

Thanks for following up. Here's code and video showing:

  • sprite with drop shadow
  • sprite with godray
  • sprite with both
shadow-vs-godray-vs-together.mov

Maybe I'm handling dragdrop wrong? Here's the code:

var godray = new PIXI.filters.GodrayFilter();
var incrementGodrayTime = () => {
    godray.time += gameUX.app.ticker.elapsedMS / 1000;
}

function onDragStart(event, card, gameUX) {
    gameUX.app.ticker.add(incrementGodrayTime)
    card.data = event.data;
    card.dragging = true;
    card.filters = [
        godray,   // using both filters together creates the black border
        new PIXI.filters.DropShadowFilter({ distance: 15, outerStrength: 2 }),
    ];

    gameUX.app.stage.addChild(gameUX.inPlay);
    gameUX.app.stage.toLocal(gameUX.inPlay.position, gameUX.inPlayAndMenuRow, gameUX.inPlay.position);
    gameUX.app.stage.addChild(card);
    gameUX.app.stage.toLocal(card.position, card.parent, card.newPosition);
    var newPosition = card.data.getLocalPosition(card.parent);
    card.position.x = newPosition.x;
    card.position.y = newPosition.y;
}

@bigtimebuddy
Copy link
Member

I'd assume this is a problem with clear, right @SukantPal?

apply(filterManager: FilterSystem, input: RenderTexture, output: RenderTexture, clear: CLEAR_MODES): void
{
const target = filterManager.getFilterTexture();
this._tintFilter.apply(filterManager, input, target, 1);
this._blurFilter.apply(filterManager, target, output, clear);
if (this.shadowOnly !== true)
{
filterManager.applyFilter(this, input, output, 0);
}
filterManager.returnFilterTexture(target);
}

apply(filterManager: FilterSystem, input: RenderTexture, output: RenderTexture, clear: CLEAR_MODES): void
{
const { width, height } = input.filterFrame as Rectangle;
this.uniforms.light = this.parallel ? this._angleLight : this.center;
this.uniforms.parallel = this.parallel;
this.uniforms.dimensions[0] = width;
this.uniforms.dimensions[1] = height;
this.uniforms.aspect = height / width;
this.uniforms.time = this.time;
this.uniforms.alpha = this.alpha;
// draw the filter...
filterManager.applyFilter(this, input, output, clear);
}

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

2 participants