Last active
February 28, 2020 16:04
-
-
Save takumifukasawa/5103a8d9dfad37ba256ac1411a1f9308 to your computer and use it in GitHub Desktop.
pixijs v4.6.0: 実際の画像の大きさに合わせてfilterのshader側でuvを[0-1]に収めるための関数
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 実際の画像の大きさに合わせてfilterのshader側でuvを[0-1]に収めるための関数 | |
// 参考: http://www.html5gamedevs.com/topic/23790-uv-in-filters/ | |
export default (vert, frag, uniforms = {}) => { | |
if (!uniforms.mappedMatrix) { | |
uniforms.mappedMatrix = { | |
type: 'mat3', | |
value: new PIXI.Matrix(), | |
}; | |
} | |
const filter = new PIXI.Filter(vert, frag, uniforms); | |
filter.apply = function apply(filterManager, input, output) { | |
filterManager.calculateNormalizedScreenSpaceMatrix(this.uniforms.mappedMatrix); | |
filterManager.applyFilter(this, input, output); | |
}; | |
return filter; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment