diff --git a/src/core/renderers/webgl/filters/filterTransforms.js b/src/core/renderers/webgl/filters/filterTransforms.js index e6c1a06..ec86d38 100644 --- a/src/core/renderers/webgl/filters/filterTransforms.js +++ b/src/core/renderers/webgl/filters/filterTransforms.js @@ -24,42 +24,18 @@ }; -var calculateNormalisedScreenSpaceMatrix = function (outputMatrix, filterArea, textureSize) +var calculateNormalizedScreenSpaceMatrix = function (outputMatrix, filterArea, textureSize) { - //var worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX), - var texture = {width:800, height:600};//sprite._texture.baseTexture; - - // TODO unwrap? var mappedMatrix = outputMatrix.identity(); - // scale.. - var ratio = textureSize.height / textureSize.width; - mappedMatrix.translate(filterArea.x / textureSize.width, filterArea.y / textureSize.height ); - mappedMatrix.scale(1 , ratio); - - var translateScaleX = (textureSize.width / texture.width); - var 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; - - // worldTransform.invert(); - // mappedMatrix.prepend(worldTransform); - - // apply inverse scale.. - mappedMatrix.scale(1 , 1/ratio); + var translateScaleX = (textureSize.width / filterArea.width); + var translateScaleY = (textureSize.height / filterArea.height); mappedMatrix.scale( translateScaleX , translateScaleY ); - // mappedMatrix.translate(sprite.anchor.x, sprite.anchor.y); - return mappedMatrix; - }; // this will map the filter coord so that a texture can be used based on the transform of a sprite @@ -102,6 +78,6 @@ module.exports = { calculateScreenSpaceMatrix:calculateScreenSpaceMatrix, - calculateNormalisedScreenSpaceMatrix:calculateNormalisedScreenSpaceMatrix, + calculateNormalizedScreenSpaceMatrix:calculateNormalizedScreenSpaceMatrix, calculateSpriteMatrix:calculateSpriteMatrix }; diff --git a/src/core/renderers/webgl/filters/filterTransforms.js b/src/core/renderers/webgl/filters/filterTransforms.js index e6c1a06..ec86d38 100644 --- a/src/core/renderers/webgl/filters/filterTransforms.js +++ b/src/core/renderers/webgl/filters/filterTransforms.js @@ -24,42 +24,18 @@ }; -var calculateNormalisedScreenSpaceMatrix = function (outputMatrix, filterArea, textureSize) +var calculateNormalizedScreenSpaceMatrix = function (outputMatrix, filterArea, textureSize) { - //var worldTransform = sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX), - var texture = {width:800, height:600};//sprite._texture.baseTexture; - - // TODO unwrap? var mappedMatrix = outputMatrix.identity(); - // scale.. - var ratio = textureSize.height / textureSize.width; - mappedMatrix.translate(filterArea.x / textureSize.width, filterArea.y / textureSize.height ); - mappedMatrix.scale(1 , ratio); - - var translateScaleX = (textureSize.width / texture.width); - var 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; - - // worldTransform.invert(); - // mappedMatrix.prepend(worldTransform); - - // apply inverse scale.. - mappedMatrix.scale(1 , 1/ratio); + var translateScaleX = (textureSize.width / filterArea.width); + var translateScaleY = (textureSize.height / filterArea.height); mappedMatrix.scale( translateScaleX , translateScaleY ); - // mappedMatrix.translate(sprite.anchor.x, sprite.anchor.y); - return mappedMatrix; - }; // this will map the filter coord so that a texture can be used based on the transform of a sprite @@ -102,6 +78,6 @@ module.exports = { calculateScreenSpaceMatrix:calculateScreenSpaceMatrix, - calculateNormalisedScreenSpaceMatrix:calculateNormalisedScreenSpaceMatrix, + calculateNormalizedScreenSpaceMatrix:calculateNormalizedScreenSpaceMatrix, calculateSpriteMatrix:calculateSpriteMatrix }; diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index cbf8323..0e4086b 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -321,13 +321,16 @@ return filterTransforms.calculateScreenSpaceMatrix(outputMatrix, currentState.sourceFrame, currentState.renderTarget.size); }; -FilterManager.prototype.calculateNormalisedScreenSpaceMatrix = function (outputMatrix) +/** + * Multiply vTextureCoord to this matrix to achieve (0,0,1,1) for filterArea + * + * @param outputMatrix {PIXI.Matrix} + */ +FilterManager.prototype.calculateNormalizedScreenSpaceMatrix = function (outputMatrix) { var currentState = this.filterData.stack[this.filterData.index]; - - - return filterTransforms.calculateNormalisedScreenSpaceMatrix(outputMatrix, currentState.sourceFrame, currentState.renderTarget.size, currentState.destinationFrame); + return filterTransforms.calculateNormalizedScreenSpaceMatrix(outputMatrix, currentState.sourceFrame, currentState.renderTarget.size, currentState.destinationFrame); }; // this will map the filter coord so that a texture can be used based on the transform of a sprite