@pixi/filter-displacement
Advanced tools
Comparing version 5.0.0-rc.2 to 5.0.0-rc.3
/*! | ||
* @pixi/filter-displacement - v5.0.0-rc.2 | ||
* Compiled Mon, 18 Feb 2019 23:45:28 UTC | ||
* @pixi/filter-displacement - v5.0.0-rc.3 | ||
* Compiled Fri, 22 Mar 2019 16:33:44 UTC | ||
* | ||
@@ -13,3 +13,3 @@ * @pixi/filter-displacement is licensed under the MIT License. | ||
var fragment = "varying vec2 vFilterCoord;\nvarying vec2 vTextureCoord;\n\nuniform vec2 scale;\nuniform sampler2D uSampler;\nuniform sampler2D mapSampler;\n\nuniform highp vec4 inputSize;\nuniform vec4 inputClamp;\n\nvoid main(void)\n{\n vec4 map = texture2D(mapSampler, vFilterCoord);\n\n map -= 0.5;\n map.xy *= scale * inputSize.zw;\n\n gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw));\n}\n"; | ||
var fragment = "varying vec2 vFilterCoord;\nvarying vec2 vTextureCoord;\n\nuniform vec2 scale;\nuniform mat2 rotation;\nuniform sampler2D uSampler;\nuniform sampler2D mapSampler;\n\nuniform highp vec4 inputSize;\nuniform vec4 inputClamp;\n\nvoid main(void)\n{\n vec4 map = texture2D(mapSampler, vFilterCoord);\n\n map -= 0.5;\n map.xy = scale * inputSize.zw * (rotation * map.xy);\n\n gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw));\n}\n"; | ||
@@ -24,2 +24,8 @@ /** | ||
* | ||
* The way it works is it uses the values of the displacement map to look up the | ||
* correct pixels to output. This means it's not technically moving the original. | ||
* Instead, it's starting at the output and asking "which pixel from the original goes here". | ||
* For example, if a displacement map pixel has `red = 1` and the filter scale is `20`, | ||
* this filter will output the pixel approximately 20 pixels to the right of the original. | ||
* | ||
* @class | ||
@@ -29,3 +35,3 @@ * @extends PIXI.Filter | ||
*/ | ||
var DisplacementFilter = /*@__PURE__*/(function (Filter$$1) { | ||
var DisplacementFilter = /*@__PURE__*/(function (Filter) { | ||
function DisplacementFilter(sprite, scale) | ||
@@ -37,6 +43,7 @@ { | ||
Filter$$1.call(this, vertex, fragment, { | ||
Filter.call(this, vertex, fragment, { | ||
mapSampler: sprite._texture, | ||
filterMatrix: maskMatrix, | ||
scale: { x: 1, y: 1 }, | ||
rotation: new Float32Array([1, 0, 0, 1]), | ||
}); | ||
@@ -59,4 +66,4 @@ | ||
if ( Filter$$1 ) DisplacementFilter.__proto__ = Filter$$1; | ||
DisplacementFilter.prototype = Object.create( Filter$$1 && Filter$$1.prototype ); | ||
if ( Filter ) DisplacementFilter.__proto__ = Filter; | ||
DisplacementFilter.prototype = Object.create( Filter && Filter.prototype ); | ||
DisplacementFilter.prototype.constructor = DisplacementFilter; | ||
@@ -79,2 +86,15 @@ | ||
// Extract rotation from world transform | ||
var wt = this.maskSprite.transform.worldTransform; | ||
var lenX = Math.sqrt((wt.a * wt.a) + (wt.b * wt.b)); | ||
var lenY = Math.sqrt((wt.c * wt.c) + (wt.d * wt.d)); | ||
if (lenX !== 0 && lenY !== 0) | ||
{ | ||
this.uniforms.rotation[0] = wt.a / lenX; | ||
this.uniforms.rotation[1] = wt.b / lenX; | ||
this.uniforms.rotation[2] = wt.c / lenY; | ||
this.uniforms.rotation[3] = wt.d / lenY; | ||
} | ||
// draw the filter... | ||
@@ -81,0 +101,0 @@ filterManager.applyFilter(this, input, output); |
/*! | ||
* @pixi/filter-displacement - v5.0.0-rc.2 | ||
* Compiled Mon, 18 Feb 2019 23:45:28 UTC | ||
* @pixi/filter-displacement - v5.0.0-rc.3 | ||
* Compiled Fri, 22 Mar 2019 16:33:44 UTC | ||
* | ||
@@ -17,3 +17,3 @@ * @pixi/filter-displacement is licensed under the MIT License. | ||
var fragment = "varying vec2 vFilterCoord;\nvarying vec2 vTextureCoord;\n\nuniform vec2 scale;\nuniform sampler2D uSampler;\nuniform sampler2D mapSampler;\n\nuniform highp vec4 inputSize;\nuniform vec4 inputClamp;\n\nvoid main(void)\n{\n vec4 map = texture2D(mapSampler, vFilterCoord);\n\n map -= 0.5;\n map.xy *= scale * inputSize.zw;\n\n gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw));\n}\n"; | ||
var fragment = "varying vec2 vFilterCoord;\nvarying vec2 vTextureCoord;\n\nuniform vec2 scale;\nuniform mat2 rotation;\nuniform sampler2D uSampler;\nuniform sampler2D mapSampler;\n\nuniform highp vec4 inputSize;\nuniform vec4 inputClamp;\n\nvoid main(void)\n{\n vec4 map = texture2D(mapSampler, vFilterCoord);\n\n map -= 0.5;\n map.xy = scale * inputSize.zw * (rotation * map.xy);\n\n gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw));\n}\n"; | ||
@@ -28,2 +28,8 @@ /** | ||
* | ||
* The way it works is it uses the values of the displacement map to look up the | ||
* correct pixels to output. This means it's not technically moving the original. | ||
* Instead, it's starting at the output and asking "which pixel from the original goes here". | ||
* For example, if a displacement map pixel has `red = 1` and the filter scale is `20`, | ||
* this filter will output the pixel approximately 20 pixels to the right of the original. | ||
* | ||
* @class | ||
@@ -44,2 +50,3 @@ * @extends PIXI.Filter | ||
scale: { x: 1, y: 1 }, | ||
rotation: new Float32Array([1, 0, 0, 1]), | ||
}); | ||
@@ -81,2 +88,15 @@ | ||
// Extract rotation from world transform | ||
var wt = this.maskSprite.transform.worldTransform; | ||
var lenX = Math.sqrt((wt.a * wt.a) + (wt.b * wt.b)); | ||
var lenY = Math.sqrt((wt.c * wt.c) + (wt.d * wt.d)); | ||
if (lenX !== 0 && lenY !== 0) | ||
{ | ||
this.uniforms.rotation[0] = wt.a / lenX; | ||
this.uniforms.rotation[1] = wt.b / lenX; | ||
this.uniforms.rotation[2] = wt.c / lenY; | ||
this.uniforms.rotation[3] = wt.d / lenY; | ||
} | ||
// draw the filter... | ||
@@ -83,0 +103,0 @@ filterManager.applyFilter(this, input, output); |
{ | ||
"name": "@pixi/filter-displacement", | ||
"version": "5.0.0-rc.2", | ||
"version": "5.0.0-rc.3", | ||
"main": "lib/filter-displacement.js", | ||
"module": "lib/filter-displacement.es.js", | ||
"bundle": "dist/filter-displacement.js", | ||
"namespace": "PIXI.filters", | ||
"description": "Filter that allows offsetting of pixel values to create warping effects", | ||
@@ -22,12 +24,13 @@ "author": "Mat Groves", | ||
"files": [ | ||
"lib" | ||
"lib", | ||
"dist" | ||
], | ||
"dependencies": { | ||
"@pixi/core": "^5.0.0-rc.2", | ||
"@pixi/math": "^5.0.0-rc.2" | ||
"@pixi/core": "^5.0.0-rc.3", | ||
"@pixi/math": "^5.0.0-rc.3" | ||
}, | ||
"devDependencies": { | ||
"floss": "^2.1.5" | ||
"floss": "^2.2.0" | ||
}, | ||
"gitHead": "53b354f4e01d3baee7223756dd09a3163ad29d0f" | ||
"gitHead": "8bd27c8b903ae2c8f90d91d64e82d65b19ac1cdb" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42251
11
334
Updated@pixi/core@^5.0.0-rc.3
Updated@pixi/math@^5.0.0-rc.3