diff --git a/src/core/renderers/webgl/filters/filterTransforms.js b/src/core/renderers/webgl/filters/filterTransforms.js index 851ad69..f955a9d 100644 --- a/src/core/renderers/webgl/filters/filterTransforms.js +++ b/src/core/renderers/webgl/filters/filterTransforms.js @@ -40,36 +40,13 @@ // this will map the filter coord so that a texture can be used based on the transform of a sprite export function calculateSpriteMatrix(outputMatrix, filterArea, textureSize, sprite) { - const worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX); const texture = sprite._texture.baseTexture; - - // TODO unwrap? - const mappedMatrix = outputMatrix.identity(); - - // scale.. - const ratio = textureSize.height / textureSize.width; - - mappedMatrix.translate(filterArea.x / textureSize.width, filterArea.y / textureSize.height); - - mappedMatrix.scale(1, ratio); - - const translateScaleX = (textureSize.width / texture.width); - const translateScaleY = (textureSize.height / texture.height); - - worldTransform.tx /= texture.width * translateScaleX; - - // this...? free beer for anyone who can explain why this makes sense! - worldTransform.ty /= texture.width * translateScaleX; - // worldTransform.ty /= texture.height * translateScaleY; + const mappedMatrix = outputMatrix.set(textureSize.width, 0, 0, textureSize.height, filterArea.x, filterArea.y); + const worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX); worldTransform.invert(); mappedMatrix.prepend(worldTransform); - - // apply inverse scale.. - mappedMatrix.scale(1, 1 / ratio); - - mappedMatrix.scale(translateScaleX, translateScaleY); - + mappedMatrix.scale(1.0 / texture.width, 1.0 / texture.height); mappedMatrix.translate(sprite.anchor.x, sprite.anchor.y); return mappedMatrix;