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

Render to an empty filter texture if the filter source frame does not intersect the current source frame #8091

Merged
merged 7 commits into from
Apr 29, 2022
29 changes: 20 additions & 9 deletions packages/core/src/filters/FilterSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,20 +188,31 @@ export class FilterSystem implements ISystem

state.sourceFrame.pad(padding);

const sourceFrameProjected = this.tempRect.copyFrom(renderTextureSystem.sourceFrame);

// Project source frame into world space (if projection is applied)
if (renderer.projection.transform)
{
this.transformAABB(
tempMatrix.copyFrom(renderer.projection.transform).invert(),
sourceFrameProjected
);
}

if (autoFit)
{
const sourceFrameProjected = this.tempRect.copyFrom(renderTextureSystem.sourceFrame);
state.sourceFrame.fit(sourceFrameProjected);

// Project source frame into world space (if projection is applied)
if (renderer.projection.transform)
if (state.sourceFrame.width <= 0 || state.sourceFrame.height <= 0)
{
this.transformAABB(
tempMatrix.copyFrom(renderer.projection.transform).invert(),
sourceFrameProjected
);
state.sourceFrame.width = 0;
state.sourceFrame.height = 0;
}

state.sourceFrame.fit(sourceFrameProjected);
}
else if (!state.sourceFrame.intersects(sourceFrameProjected))
{
state.sourceFrame.width = 0;
state.sourceFrame.height = 0;
}

// Round sourceFrame in screen space based on render-texture.
Expand Down