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

Support for viewport scaling #231

Open
ShukantPal opened this issue Nov 7, 2019 · 1 comment
Open

Support for viewport scaling #231

ShukantPal opened this issue Nov 7, 2019 · 1 comment

Comments

@ShukantPal
Copy link
Member

Our team is implementing a "zoomable" renderer, and for this we require the filter's effects also increase according to the current scale/zoom.

To solve this problem, we multiply certain quantities by the current scale. For example, in motion-blur we multiply the velocity by the current viewport scale.

apply(filterManager, input, output, clear, state) {
 const widthInverse = 1 / state.sourceFrame.width
 const heightInverse = 1 / state.sourceFrame.height

 this.uniforms.velocity[0] = this._velocity[0] * widthInverse
 this.uniforms.velocity[1] = this._velocity[1] * heightInverse

 if (this.viewport) {
    this.uniforms.velocity[0] *= this.viewport.scale.x
    this.uniforms.velocity[1] *= this.viewport.scale.y
  }

  filterManager.applyFilter(this, input, output, clear)
}

We have done this to motion-blur, drop-shadow, bevel and (possibly) others too. Would you guys accept this style on your codebase? (It is a backward-compatible change)

@SamHope1992
Copy link

Out of interest where are you multiplying this in the dropshadow filter? I'm not having any lock applying this to the offsets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants