diff --git a/src/filters/ascii/AsciiFilter.js b/src/filters/ascii/AsciiFilter.js deleted file mode 100644 index ac64fd1..0000000 --- a/src/filters/ascii/AsciiFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -// TODO (cengler) - The Y is flipped in this shader for some reason. - -/** - * @author Vico @vicocotea - * original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h - */ - -/** - * An ASCII filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function AsciiFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./ascii.frag') - ); - - this.size = 8; -} - -AsciiFilter.prototype = Object.create(core.Filter.prototype); -AsciiFilter.prototype.constructor = AsciiFilter; -module.exports = AsciiFilter; - -Object.defineProperties(AsciiFilter.prototype, { - /** - * The pixel size used by the filter. - * - * @member {number} - * @memberof PIXI.filters.AsciiFilter# - */ - size: { - get: function () - { - return this.uniforms.pixelSize; - }, - set: function (value) - { - this.uniforms.pixelSize = value; - } - } -}); diff --git a/src/filters/ascii/AsciiFilter.js b/src/filters/ascii/AsciiFilter.js deleted file mode 100644 index ac64fd1..0000000 --- a/src/filters/ascii/AsciiFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -// TODO (cengler) - The Y is flipped in this shader for some reason. - -/** - * @author Vico @vicocotea - * original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h - */ - -/** - * An ASCII filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function AsciiFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./ascii.frag') - ); - - this.size = 8; -} - -AsciiFilter.prototype = Object.create(core.Filter.prototype); -AsciiFilter.prototype.constructor = AsciiFilter; -module.exports = AsciiFilter; - -Object.defineProperties(AsciiFilter.prototype, { - /** - * The pixel size used by the filter. - * - * @member {number} - * @memberof PIXI.filters.AsciiFilter# - */ - size: { - get: function () - { - return this.uniforms.pixelSize; - }, - set: function (value) - { - this.uniforms.pixelSize = value; - } - } -}); diff --git a/src/filters/ascii/ascii.frag b/src/filters/ascii/ascii.frag deleted file mode 100644 index 5608d6e..0000000 --- a/src/filters/ascii/ascii.frag +++ /dev/null @@ -1,70 +0,0 @@ -varying vec2 vTextureCoord; - -uniform vec4 filterArea; -uniform float pixelSize; -uniform sampler2D uSampler; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -vec2 getMod(vec2 coord, vec2 size) -{ - return mod( coord , size) / size; -} - -float character(float n, vec2 p) -{ - p = floor(p*vec2(4.0, -4.0) + 2.5); - if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y) - { - if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; - } - return 0.0; -} - -void main() -{ - vec2 coord = mapCoord(vTextureCoord); - - // get the rounded color.. - vec2 pixCoord = pixelate(coord, vec2(pixelSize)); - pixCoord = unmapCoord(pixCoord); - - vec4 color = texture2D(uSampler, pixCoord); - - // determine the character to use - float gray = (color.r + color.g + color.b) / 3.0; - - float n = 65536.0; // . - if (gray > 0.2) n = 65600.0; // : - if (gray > 0.3) n = 332772.0; // * - if (gray > 0.4) n = 15255086.0; // o - if (gray > 0.5) n = 23385164.0; // & - if (gray > 0.6) n = 15252014.0; // 8 - if (gray > 0.7) n = 13199452.0; // @ - if (gray > 0.8) n = 11512810.0; // # - - // get the mod.. - vec2 modd = getMod(coord, vec2(pixelSize)); - - gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); - -} \ No newline at end of file diff --git a/src/filters/ascii/AsciiFilter.js b/src/filters/ascii/AsciiFilter.js deleted file mode 100644 index ac64fd1..0000000 --- a/src/filters/ascii/AsciiFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -// TODO (cengler) - The Y is flipped in this shader for some reason. - -/** - * @author Vico @vicocotea - * original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h - */ - -/** - * An ASCII filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function AsciiFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./ascii.frag') - ); - - this.size = 8; -} - -AsciiFilter.prototype = Object.create(core.Filter.prototype); -AsciiFilter.prototype.constructor = AsciiFilter; -module.exports = AsciiFilter; - -Object.defineProperties(AsciiFilter.prototype, { - /** - * The pixel size used by the filter. - * - * @member {number} - * @memberof PIXI.filters.AsciiFilter# - */ - size: { - get: function () - { - return this.uniforms.pixelSize; - }, - set: function (value) - { - this.uniforms.pixelSize = value; - } - } -}); diff --git a/src/filters/ascii/ascii.frag b/src/filters/ascii/ascii.frag deleted file mode 100644 index 5608d6e..0000000 --- a/src/filters/ascii/ascii.frag +++ /dev/null @@ -1,70 +0,0 @@ -varying vec2 vTextureCoord; - -uniform vec4 filterArea; -uniform float pixelSize; -uniform sampler2D uSampler; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -vec2 getMod(vec2 coord, vec2 size) -{ - return mod( coord , size) / size; -} - -float character(float n, vec2 p) -{ - p = floor(p*vec2(4.0, -4.0) + 2.5); - if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y) - { - if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; - } - return 0.0; -} - -void main() -{ - vec2 coord = mapCoord(vTextureCoord); - - // get the rounded color.. - vec2 pixCoord = pixelate(coord, vec2(pixelSize)); - pixCoord = unmapCoord(pixCoord); - - vec4 color = texture2D(uSampler, pixCoord); - - // determine the character to use - float gray = (color.r + color.g + color.b) / 3.0; - - float n = 65536.0; // . - if (gray > 0.2) n = 65600.0; // : - if (gray > 0.3) n = 332772.0; // * - if (gray > 0.4) n = 15255086.0; // o - if (gray > 0.5) n = 23385164.0; // & - if (gray > 0.6) n = 15252014.0; // 8 - if (gray > 0.7) n = 13199452.0; // @ - if (gray > 0.8) n = 11512810.0; // # - - // get the mod.. - vec2 modd = getMod(coord, vec2(pixelSize)); - - gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); - -} \ No newline at end of file diff --git a/src/filters/bloom/BloomFilter.js b/src/filters/bloom/BloomFilter.js deleted file mode 100644 index 1a9c713..0000000 --- a/src/filters/bloom/BloomFilter.js +++ /dev/null @@ -1,97 +0,0 @@ -var core = require('../../core'), - BlurXFilter = require('../blur/BlurXFilter'), - BlurYFilter = require('../blur/BlurYFilter'); - VoidFilter = require('../void/VoidFilter'); - -/** - * The BloomFilter applies a Gaussian blur to an object. - * The strength of the blur can be set for x- and y-axis separately. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function BloomFilter() -{ - core.Filter.call(this); - - this.blurXFilter = new BlurXFilter(); - this.blurYFilter = new BlurYFilter(); - - this.blurYFilter.blendMode = core.BLEND_MODES.SCREEN; - - this.defaultFilter = new VoidFilter(); -} - -BloomFilter.prototype = Object.create(core.Filter.prototype); -BloomFilter.prototype.constructor = BloomFilter; -module.exports = BloomFilter; - -BloomFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - //TODO - copyTexSubImage2D could be used here? - this.defaultFilter.apply(filterManager, input, output); - - this.blurXFilter.apply(filterManager, input, renderTarget); - this.blurYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(BloomFilter.prototype, { - /** - * Sets the strength of both the blurX and blurY properties simultaneously - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blur: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = this.blurYFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurX property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurX: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurY property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurY: { - get: function () - { - return this.blurYFilter.blur; - }, - set: function (value) - { - this.blurYFilter.blur = value; - } - } -}); diff --git a/src/filters/ascii/AsciiFilter.js b/src/filters/ascii/AsciiFilter.js deleted file mode 100644 index ac64fd1..0000000 --- a/src/filters/ascii/AsciiFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -// TODO (cengler) - The Y is flipped in this shader for some reason. - -/** - * @author Vico @vicocotea - * original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h - */ - -/** - * An ASCII filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function AsciiFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./ascii.frag') - ); - - this.size = 8; -} - -AsciiFilter.prototype = Object.create(core.Filter.prototype); -AsciiFilter.prototype.constructor = AsciiFilter; -module.exports = AsciiFilter; - -Object.defineProperties(AsciiFilter.prototype, { - /** - * The pixel size used by the filter. - * - * @member {number} - * @memberof PIXI.filters.AsciiFilter# - */ - size: { - get: function () - { - return this.uniforms.pixelSize; - }, - set: function (value) - { - this.uniforms.pixelSize = value; - } - } -}); diff --git a/src/filters/ascii/ascii.frag b/src/filters/ascii/ascii.frag deleted file mode 100644 index 5608d6e..0000000 --- a/src/filters/ascii/ascii.frag +++ /dev/null @@ -1,70 +0,0 @@ -varying vec2 vTextureCoord; - -uniform vec4 filterArea; -uniform float pixelSize; -uniform sampler2D uSampler; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -vec2 getMod(vec2 coord, vec2 size) -{ - return mod( coord , size) / size; -} - -float character(float n, vec2 p) -{ - p = floor(p*vec2(4.0, -4.0) + 2.5); - if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y) - { - if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; - } - return 0.0; -} - -void main() -{ - vec2 coord = mapCoord(vTextureCoord); - - // get the rounded color.. - vec2 pixCoord = pixelate(coord, vec2(pixelSize)); - pixCoord = unmapCoord(pixCoord); - - vec4 color = texture2D(uSampler, pixCoord); - - // determine the character to use - float gray = (color.r + color.g + color.b) / 3.0; - - float n = 65536.0; // . - if (gray > 0.2) n = 65600.0; // : - if (gray > 0.3) n = 332772.0; // * - if (gray > 0.4) n = 15255086.0; // o - if (gray > 0.5) n = 23385164.0; // & - if (gray > 0.6) n = 15252014.0; // 8 - if (gray > 0.7) n = 13199452.0; // @ - if (gray > 0.8) n = 11512810.0; // # - - // get the mod.. - vec2 modd = getMod(coord, vec2(pixelSize)); - - gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); - -} \ No newline at end of file diff --git a/src/filters/bloom/BloomFilter.js b/src/filters/bloom/BloomFilter.js deleted file mode 100644 index 1a9c713..0000000 --- a/src/filters/bloom/BloomFilter.js +++ /dev/null @@ -1,97 +0,0 @@ -var core = require('../../core'), - BlurXFilter = require('../blur/BlurXFilter'), - BlurYFilter = require('../blur/BlurYFilter'); - VoidFilter = require('../void/VoidFilter'); - -/** - * The BloomFilter applies a Gaussian blur to an object. - * The strength of the blur can be set for x- and y-axis separately. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function BloomFilter() -{ - core.Filter.call(this); - - this.blurXFilter = new BlurXFilter(); - this.blurYFilter = new BlurYFilter(); - - this.blurYFilter.blendMode = core.BLEND_MODES.SCREEN; - - this.defaultFilter = new VoidFilter(); -} - -BloomFilter.prototype = Object.create(core.Filter.prototype); -BloomFilter.prototype.constructor = BloomFilter; -module.exports = BloomFilter; - -BloomFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - //TODO - copyTexSubImage2D could be used here? - this.defaultFilter.apply(filterManager, input, output); - - this.blurXFilter.apply(filterManager, input, renderTarget); - this.blurYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(BloomFilter.prototype, { - /** - * Sets the strength of both the blurX and blurY properties simultaneously - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blur: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = this.blurYFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurX property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurX: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurY property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurY: { - get: function () - { - return this.blurYFilter.blur; - }, - set: function (value) - { - this.blurYFilter.blur = value; - } - } -}); diff --git a/src/filters/convolution/ConvolutionFilter.js b/src/filters/convolution/ConvolutionFilter.js deleted file mode 100644 index 51775ba..0000000 --- a/src/filters/convolution/ConvolutionFilter.js +++ /dev/null @@ -1,87 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ConvolutionFilter class applies a matrix convolution filter effect. - * A convolution combines pixels in the input image with neighboring pixels to produce a new image. - * A wide variety of image effects can be achieved through convolutions, including blurring, edge - * detection, sharpening, embossing, and beveling. The matrix should be specified as a 9 point Array. - * See http://docs.gimp.org/en/plug-in-convmatrix.html for more info. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - * @param matrix {number[]} An array of values used for matrix transformation. Specified as a 9 point Array. - * @param width {number} Width of the object you are transforming - * @param height {number} Height of the object you are transforming - */ -function ConvolutionFilter(matrix, width, height) -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./convolution.frag') - ); - - this.matrix = matrix; - this.width = width; - this.height = height; -} - -ConvolutionFilter.prototype = Object.create(core.Filter.prototype); -ConvolutionFilter.prototype.constructor = ConvolutionFilter; -module.exports = ConvolutionFilter; - -Object.defineProperties(ConvolutionFilter.prototype, { - /** - * An array of values used for matrix transformation. Specified as a 9 point Array. - * - * @member {number[]} - * @memberof PIXI.filters.ConvolutionFilter# - */ - matrix: { - get: function () - { - return this.uniforms.matrix; - }, - set: function (value) - { - this.uniforms.matrix = new Float32Array(value); - } - }, - - /** - * Width of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - width: { - get: function () - { - return 1/this.uniforms.texelSize[0]; - }, - set: function (value) - { - this.uniforms.texelSize[0] = 1/value; - } - }, - - /** - * Height of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - height: { - get: function () - { - return 1/this.uniforms.texelSize[1]; - }, - set: function (value) - { - this.uniforms.texelSize[1] = 1/value; - } - } -}); diff --git a/src/filters/ascii/AsciiFilter.js b/src/filters/ascii/AsciiFilter.js deleted file mode 100644 index ac64fd1..0000000 --- a/src/filters/ascii/AsciiFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -// TODO (cengler) - The Y is flipped in this shader for some reason. - -/** - * @author Vico @vicocotea - * original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h - */ - -/** - * An ASCII filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function AsciiFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./ascii.frag') - ); - - this.size = 8; -} - -AsciiFilter.prototype = Object.create(core.Filter.prototype); -AsciiFilter.prototype.constructor = AsciiFilter; -module.exports = AsciiFilter; - -Object.defineProperties(AsciiFilter.prototype, { - /** - * The pixel size used by the filter. - * - * @member {number} - * @memberof PIXI.filters.AsciiFilter# - */ - size: { - get: function () - { - return this.uniforms.pixelSize; - }, - set: function (value) - { - this.uniforms.pixelSize = value; - } - } -}); diff --git a/src/filters/ascii/ascii.frag b/src/filters/ascii/ascii.frag deleted file mode 100644 index 5608d6e..0000000 --- a/src/filters/ascii/ascii.frag +++ /dev/null @@ -1,70 +0,0 @@ -varying vec2 vTextureCoord; - -uniform vec4 filterArea; -uniform float pixelSize; -uniform sampler2D uSampler; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -vec2 getMod(vec2 coord, vec2 size) -{ - return mod( coord , size) / size; -} - -float character(float n, vec2 p) -{ - p = floor(p*vec2(4.0, -4.0) + 2.5); - if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y) - { - if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; - } - return 0.0; -} - -void main() -{ - vec2 coord = mapCoord(vTextureCoord); - - // get the rounded color.. - vec2 pixCoord = pixelate(coord, vec2(pixelSize)); - pixCoord = unmapCoord(pixCoord); - - vec4 color = texture2D(uSampler, pixCoord); - - // determine the character to use - float gray = (color.r + color.g + color.b) / 3.0; - - float n = 65536.0; // . - if (gray > 0.2) n = 65600.0; // : - if (gray > 0.3) n = 332772.0; // * - if (gray > 0.4) n = 15255086.0; // o - if (gray > 0.5) n = 23385164.0; // & - if (gray > 0.6) n = 15252014.0; // 8 - if (gray > 0.7) n = 13199452.0; // @ - if (gray > 0.8) n = 11512810.0; // # - - // get the mod.. - vec2 modd = getMod(coord, vec2(pixelSize)); - - gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); - -} \ No newline at end of file diff --git a/src/filters/bloom/BloomFilter.js b/src/filters/bloom/BloomFilter.js deleted file mode 100644 index 1a9c713..0000000 --- a/src/filters/bloom/BloomFilter.js +++ /dev/null @@ -1,97 +0,0 @@ -var core = require('../../core'), - BlurXFilter = require('../blur/BlurXFilter'), - BlurYFilter = require('../blur/BlurYFilter'); - VoidFilter = require('../void/VoidFilter'); - -/** - * The BloomFilter applies a Gaussian blur to an object. - * The strength of the blur can be set for x- and y-axis separately. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function BloomFilter() -{ - core.Filter.call(this); - - this.blurXFilter = new BlurXFilter(); - this.blurYFilter = new BlurYFilter(); - - this.blurYFilter.blendMode = core.BLEND_MODES.SCREEN; - - this.defaultFilter = new VoidFilter(); -} - -BloomFilter.prototype = Object.create(core.Filter.prototype); -BloomFilter.prototype.constructor = BloomFilter; -module.exports = BloomFilter; - -BloomFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - //TODO - copyTexSubImage2D could be used here? - this.defaultFilter.apply(filterManager, input, output); - - this.blurXFilter.apply(filterManager, input, renderTarget); - this.blurYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(BloomFilter.prototype, { - /** - * Sets the strength of both the blurX and blurY properties simultaneously - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blur: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = this.blurYFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurX property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurX: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurY property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurY: { - get: function () - { - return this.blurYFilter.blur; - }, - set: function (value) - { - this.blurYFilter.blur = value; - } - } -}); diff --git a/src/filters/convolution/ConvolutionFilter.js b/src/filters/convolution/ConvolutionFilter.js deleted file mode 100644 index 51775ba..0000000 --- a/src/filters/convolution/ConvolutionFilter.js +++ /dev/null @@ -1,87 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ConvolutionFilter class applies a matrix convolution filter effect. - * A convolution combines pixels in the input image with neighboring pixels to produce a new image. - * A wide variety of image effects can be achieved through convolutions, including blurring, edge - * detection, sharpening, embossing, and beveling. The matrix should be specified as a 9 point Array. - * See http://docs.gimp.org/en/plug-in-convmatrix.html for more info. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - * @param matrix {number[]} An array of values used for matrix transformation. Specified as a 9 point Array. - * @param width {number} Width of the object you are transforming - * @param height {number} Height of the object you are transforming - */ -function ConvolutionFilter(matrix, width, height) -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./convolution.frag') - ); - - this.matrix = matrix; - this.width = width; - this.height = height; -} - -ConvolutionFilter.prototype = Object.create(core.Filter.prototype); -ConvolutionFilter.prototype.constructor = ConvolutionFilter; -module.exports = ConvolutionFilter; - -Object.defineProperties(ConvolutionFilter.prototype, { - /** - * An array of values used for matrix transformation. Specified as a 9 point Array. - * - * @member {number[]} - * @memberof PIXI.filters.ConvolutionFilter# - */ - matrix: { - get: function () - { - return this.uniforms.matrix; - }, - set: function (value) - { - this.uniforms.matrix = new Float32Array(value); - } - }, - - /** - * Width of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - width: { - get: function () - { - return 1/this.uniforms.texelSize[0]; - }, - set: function (value) - { - this.uniforms.texelSize[0] = 1/value; - } - }, - - /** - * Height of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - height: { - get: function () - { - return 1/this.uniforms.texelSize[1]; - }, - set: function (value) - { - this.uniforms.texelSize[1] = 1/value; - } - } -}); diff --git a/src/filters/convolution/convolution.frag b/src/filters/convolution/convolution.frag deleted file mode 100644 index e6fe7b5..0000000 --- a/src/filters/convolution/convolution.frag +++ /dev/null @@ -1,29 +0,0 @@ -precision mediump float; - -varying mediump vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec2 texelSize; -uniform float matrix[9]; - -void main(void) -{ - vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left - vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center - vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right - - vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left - vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center - vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right - - vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left - vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center - vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right - - gl_FragColor = - c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] + - c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] + - c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8]; - - gl_FragColor.a = c22.a; -} diff --git a/src/filters/ascii/AsciiFilter.js b/src/filters/ascii/AsciiFilter.js deleted file mode 100644 index ac64fd1..0000000 --- a/src/filters/ascii/AsciiFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -// TODO (cengler) - The Y is flipped in this shader for some reason. - -/** - * @author Vico @vicocotea - * original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h - */ - -/** - * An ASCII filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function AsciiFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./ascii.frag') - ); - - this.size = 8; -} - -AsciiFilter.prototype = Object.create(core.Filter.prototype); -AsciiFilter.prototype.constructor = AsciiFilter; -module.exports = AsciiFilter; - -Object.defineProperties(AsciiFilter.prototype, { - /** - * The pixel size used by the filter. - * - * @member {number} - * @memberof PIXI.filters.AsciiFilter# - */ - size: { - get: function () - { - return this.uniforms.pixelSize; - }, - set: function (value) - { - this.uniforms.pixelSize = value; - } - } -}); diff --git a/src/filters/ascii/ascii.frag b/src/filters/ascii/ascii.frag deleted file mode 100644 index 5608d6e..0000000 --- a/src/filters/ascii/ascii.frag +++ /dev/null @@ -1,70 +0,0 @@ -varying vec2 vTextureCoord; - -uniform vec4 filterArea; -uniform float pixelSize; -uniform sampler2D uSampler; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -vec2 getMod(vec2 coord, vec2 size) -{ - return mod( coord , size) / size; -} - -float character(float n, vec2 p) -{ - p = floor(p*vec2(4.0, -4.0) + 2.5); - if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y) - { - if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; - } - return 0.0; -} - -void main() -{ - vec2 coord = mapCoord(vTextureCoord); - - // get the rounded color.. - vec2 pixCoord = pixelate(coord, vec2(pixelSize)); - pixCoord = unmapCoord(pixCoord); - - vec4 color = texture2D(uSampler, pixCoord); - - // determine the character to use - float gray = (color.r + color.g + color.b) / 3.0; - - float n = 65536.0; // . - if (gray > 0.2) n = 65600.0; // : - if (gray > 0.3) n = 332772.0; // * - if (gray > 0.4) n = 15255086.0; // o - if (gray > 0.5) n = 23385164.0; // & - if (gray > 0.6) n = 15252014.0; // 8 - if (gray > 0.7) n = 13199452.0; // @ - if (gray > 0.8) n = 11512810.0; // # - - // get the mod.. - vec2 modd = getMod(coord, vec2(pixelSize)); - - gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); - -} \ No newline at end of file diff --git a/src/filters/bloom/BloomFilter.js b/src/filters/bloom/BloomFilter.js deleted file mode 100644 index 1a9c713..0000000 --- a/src/filters/bloom/BloomFilter.js +++ /dev/null @@ -1,97 +0,0 @@ -var core = require('../../core'), - BlurXFilter = require('../blur/BlurXFilter'), - BlurYFilter = require('../blur/BlurYFilter'); - VoidFilter = require('../void/VoidFilter'); - -/** - * The BloomFilter applies a Gaussian blur to an object. - * The strength of the blur can be set for x- and y-axis separately. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function BloomFilter() -{ - core.Filter.call(this); - - this.blurXFilter = new BlurXFilter(); - this.blurYFilter = new BlurYFilter(); - - this.blurYFilter.blendMode = core.BLEND_MODES.SCREEN; - - this.defaultFilter = new VoidFilter(); -} - -BloomFilter.prototype = Object.create(core.Filter.prototype); -BloomFilter.prototype.constructor = BloomFilter; -module.exports = BloomFilter; - -BloomFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - //TODO - copyTexSubImage2D could be used here? - this.defaultFilter.apply(filterManager, input, output); - - this.blurXFilter.apply(filterManager, input, renderTarget); - this.blurYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(BloomFilter.prototype, { - /** - * Sets the strength of both the blurX and blurY properties simultaneously - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blur: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = this.blurYFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurX property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurX: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurY property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurY: { - get: function () - { - return this.blurYFilter.blur; - }, - set: function (value) - { - this.blurYFilter.blur = value; - } - } -}); diff --git a/src/filters/convolution/ConvolutionFilter.js b/src/filters/convolution/ConvolutionFilter.js deleted file mode 100644 index 51775ba..0000000 --- a/src/filters/convolution/ConvolutionFilter.js +++ /dev/null @@ -1,87 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ConvolutionFilter class applies a matrix convolution filter effect. - * A convolution combines pixels in the input image with neighboring pixels to produce a new image. - * A wide variety of image effects can be achieved through convolutions, including blurring, edge - * detection, sharpening, embossing, and beveling. The matrix should be specified as a 9 point Array. - * See http://docs.gimp.org/en/plug-in-convmatrix.html for more info. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - * @param matrix {number[]} An array of values used for matrix transformation. Specified as a 9 point Array. - * @param width {number} Width of the object you are transforming - * @param height {number} Height of the object you are transforming - */ -function ConvolutionFilter(matrix, width, height) -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./convolution.frag') - ); - - this.matrix = matrix; - this.width = width; - this.height = height; -} - -ConvolutionFilter.prototype = Object.create(core.Filter.prototype); -ConvolutionFilter.prototype.constructor = ConvolutionFilter; -module.exports = ConvolutionFilter; - -Object.defineProperties(ConvolutionFilter.prototype, { - /** - * An array of values used for matrix transformation. Specified as a 9 point Array. - * - * @member {number[]} - * @memberof PIXI.filters.ConvolutionFilter# - */ - matrix: { - get: function () - { - return this.uniforms.matrix; - }, - set: function (value) - { - this.uniforms.matrix = new Float32Array(value); - } - }, - - /** - * Width of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - width: { - get: function () - { - return 1/this.uniforms.texelSize[0]; - }, - set: function (value) - { - this.uniforms.texelSize[0] = 1/value; - } - }, - - /** - * Height of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - height: { - get: function () - { - return 1/this.uniforms.texelSize[1]; - }, - set: function (value) - { - this.uniforms.texelSize[1] = 1/value; - } - } -}); diff --git a/src/filters/convolution/convolution.frag b/src/filters/convolution/convolution.frag deleted file mode 100644 index e6fe7b5..0000000 --- a/src/filters/convolution/convolution.frag +++ /dev/null @@ -1,29 +0,0 @@ -precision mediump float; - -varying mediump vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec2 texelSize; -uniform float matrix[9]; - -void main(void) -{ - vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left - vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center - vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right - - vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left - vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center - vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right - - vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left - vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center - vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right - - gl_FragColor = - c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] + - c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] + - c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8]; - - gl_FragColor.a = c22.a; -} diff --git a/src/filters/crosshatch/CrossHatchFilter.js b/src/filters/crosshatch/CrossHatchFilter.js deleted file mode 100644 index a8da95d..0000000 --- a/src/filters/crosshatch/CrossHatchFilter.js +++ /dev/null @@ -1,23 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * A Cross Hatch effect filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function CrossHatchFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./crosshatch.frag') - ); -} - -CrossHatchFilter.prototype = Object.create(core.Filter.prototype); -CrossHatchFilter.prototype.constructor = CrossHatchFilter; -module.exports = CrossHatchFilter; diff --git a/src/filters/ascii/AsciiFilter.js b/src/filters/ascii/AsciiFilter.js deleted file mode 100644 index ac64fd1..0000000 --- a/src/filters/ascii/AsciiFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -// TODO (cengler) - The Y is flipped in this shader for some reason. - -/** - * @author Vico @vicocotea - * original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h - */ - -/** - * An ASCII filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function AsciiFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./ascii.frag') - ); - - this.size = 8; -} - -AsciiFilter.prototype = Object.create(core.Filter.prototype); -AsciiFilter.prototype.constructor = AsciiFilter; -module.exports = AsciiFilter; - -Object.defineProperties(AsciiFilter.prototype, { - /** - * The pixel size used by the filter. - * - * @member {number} - * @memberof PIXI.filters.AsciiFilter# - */ - size: { - get: function () - { - return this.uniforms.pixelSize; - }, - set: function (value) - { - this.uniforms.pixelSize = value; - } - } -}); diff --git a/src/filters/ascii/ascii.frag b/src/filters/ascii/ascii.frag deleted file mode 100644 index 5608d6e..0000000 --- a/src/filters/ascii/ascii.frag +++ /dev/null @@ -1,70 +0,0 @@ -varying vec2 vTextureCoord; - -uniform vec4 filterArea; -uniform float pixelSize; -uniform sampler2D uSampler; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -vec2 getMod(vec2 coord, vec2 size) -{ - return mod( coord , size) / size; -} - -float character(float n, vec2 p) -{ - p = floor(p*vec2(4.0, -4.0) + 2.5); - if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y) - { - if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; - } - return 0.0; -} - -void main() -{ - vec2 coord = mapCoord(vTextureCoord); - - // get the rounded color.. - vec2 pixCoord = pixelate(coord, vec2(pixelSize)); - pixCoord = unmapCoord(pixCoord); - - vec4 color = texture2D(uSampler, pixCoord); - - // determine the character to use - float gray = (color.r + color.g + color.b) / 3.0; - - float n = 65536.0; // . - if (gray > 0.2) n = 65600.0; // : - if (gray > 0.3) n = 332772.0; // * - if (gray > 0.4) n = 15255086.0; // o - if (gray > 0.5) n = 23385164.0; // & - if (gray > 0.6) n = 15252014.0; // 8 - if (gray > 0.7) n = 13199452.0; // @ - if (gray > 0.8) n = 11512810.0; // # - - // get the mod.. - vec2 modd = getMod(coord, vec2(pixelSize)); - - gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); - -} \ No newline at end of file diff --git a/src/filters/bloom/BloomFilter.js b/src/filters/bloom/BloomFilter.js deleted file mode 100644 index 1a9c713..0000000 --- a/src/filters/bloom/BloomFilter.js +++ /dev/null @@ -1,97 +0,0 @@ -var core = require('../../core'), - BlurXFilter = require('../blur/BlurXFilter'), - BlurYFilter = require('../blur/BlurYFilter'); - VoidFilter = require('../void/VoidFilter'); - -/** - * The BloomFilter applies a Gaussian blur to an object. - * The strength of the blur can be set for x- and y-axis separately. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function BloomFilter() -{ - core.Filter.call(this); - - this.blurXFilter = new BlurXFilter(); - this.blurYFilter = new BlurYFilter(); - - this.blurYFilter.blendMode = core.BLEND_MODES.SCREEN; - - this.defaultFilter = new VoidFilter(); -} - -BloomFilter.prototype = Object.create(core.Filter.prototype); -BloomFilter.prototype.constructor = BloomFilter; -module.exports = BloomFilter; - -BloomFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - //TODO - copyTexSubImage2D could be used here? - this.defaultFilter.apply(filterManager, input, output); - - this.blurXFilter.apply(filterManager, input, renderTarget); - this.blurYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(BloomFilter.prototype, { - /** - * Sets the strength of both the blurX and blurY properties simultaneously - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blur: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = this.blurYFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurX property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurX: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurY property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurY: { - get: function () - { - return this.blurYFilter.blur; - }, - set: function (value) - { - this.blurYFilter.blur = value; - } - } -}); diff --git a/src/filters/convolution/ConvolutionFilter.js b/src/filters/convolution/ConvolutionFilter.js deleted file mode 100644 index 51775ba..0000000 --- a/src/filters/convolution/ConvolutionFilter.js +++ /dev/null @@ -1,87 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ConvolutionFilter class applies a matrix convolution filter effect. - * A convolution combines pixels in the input image with neighboring pixels to produce a new image. - * A wide variety of image effects can be achieved through convolutions, including blurring, edge - * detection, sharpening, embossing, and beveling. The matrix should be specified as a 9 point Array. - * See http://docs.gimp.org/en/plug-in-convmatrix.html for more info. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - * @param matrix {number[]} An array of values used for matrix transformation. Specified as a 9 point Array. - * @param width {number} Width of the object you are transforming - * @param height {number} Height of the object you are transforming - */ -function ConvolutionFilter(matrix, width, height) -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./convolution.frag') - ); - - this.matrix = matrix; - this.width = width; - this.height = height; -} - -ConvolutionFilter.prototype = Object.create(core.Filter.prototype); -ConvolutionFilter.prototype.constructor = ConvolutionFilter; -module.exports = ConvolutionFilter; - -Object.defineProperties(ConvolutionFilter.prototype, { - /** - * An array of values used for matrix transformation. Specified as a 9 point Array. - * - * @member {number[]} - * @memberof PIXI.filters.ConvolutionFilter# - */ - matrix: { - get: function () - { - return this.uniforms.matrix; - }, - set: function (value) - { - this.uniforms.matrix = new Float32Array(value); - } - }, - - /** - * Width of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - width: { - get: function () - { - return 1/this.uniforms.texelSize[0]; - }, - set: function (value) - { - this.uniforms.texelSize[0] = 1/value; - } - }, - - /** - * Height of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - height: { - get: function () - { - return 1/this.uniforms.texelSize[1]; - }, - set: function (value) - { - this.uniforms.texelSize[1] = 1/value; - } - } -}); diff --git a/src/filters/convolution/convolution.frag b/src/filters/convolution/convolution.frag deleted file mode 100644 index e6fe7b5..0000000 --- a/src/filters/convolution/convolution.frag +++ /dev/null @@ -1,29 +0,0 @@ -precision mediump float; - -varying mediump vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec2 texelSize; -uniform float matrix[9]; - -void main(void) -{ - vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left - vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center - vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right - - vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left - vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center - vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right - - vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left - vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center - vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right - - gl_FragColor = - c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] + - c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] + - c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8]; - - gl_FragColor.a = c22.a; -} diff --git a/src/filters/crosshatch/CrossHatchFilter.js b/src/filters/crosshatch/CrossHatchFilter.js deleted file mode 100644 index a8da95d..0000000 --- a/src/filters/crosshatch/CrossHatchFilter.js +++ /dev/null @@ -1,23 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * A Cross Hatch effect filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function CrossHatchFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./crosshatch.frag') - ); -} - -CrossHatchFilter.prototype = Object.create(core.Filter.prototype); -CrossHatchFilter.prototype.constructor = CrossHatchFilter; -module.exports = CrossHatchFilter; diff --git a/src/filters/crosshatch/crosshatch.frag b/src/filters/crosshatch/crosshatch.frag deleted file mode 100644 index 635ba4b..0000000 --- a/src/filters/crosshatch/crosshatch.frag +++ /dev/null @@ -1,44 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -void main(void) -{ - float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb); - - gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); - - if (lum < 1.00) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.75) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.50) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.3) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } -} diff --git a/src/filters/ascii/AsciiFilter.js b/src/filters/ascii/AsciiFilter.js deleted file mode 100644 index ac64fd1..0000000 --- a/src/filters/ascii/AsciiFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -// TODO (cengler) - The Y is flipped in this shader for some reason. - -/** - * @author Vico @vicocotea - * original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h - */ - -/** - * An ASCII filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function AsciiFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./ascii.frag') - ); - - this.size = 8; -} - -AsciiFilter.prototype = Object.create(core.Filter.prototype); -AsciiFilter.prototype.constructor = AsciiFilter; -module.exports = AsciiFilter; - -Object.defineProperties(AsciiFilter.prototype, { - /** - * The pixel size used by the filter. - * - * @member {number} - * @memberof PIXI.filters.AsciiFilter# - */ - size: { - get: function () - { - return this.uniforms.pixelSize; - }, - set: function (value) - { - this.uniforms.pixelSize = value; - } - } -}); diff --git a/src/filters/ascii/ascii.frag b/src/filters/ascii/ascii.frag deleted file mode 100644 index 5608d6e..0000000 --- a/src/filters/ascii/ascii.frag +++ /dev/null @@ -1,70 +0,0 @@ -varying vec2 vTextureCoord; - -uniform vec4 filterArea; -uniform float pixelSize; -uniform sampler2D uSampler; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -vec2 getMod(vec2 coord, vec2 size) -{ - return mod( coord , size) / size; -} - -float character(float n, vec2 p) -{ - p = floor(p*vec2(4.0, -4.0) + 2.5); - if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y) - { - if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; - } - return 0.0; -} - -void main() -{ - vec2 coord = mapCoord(vTextureCoord); - - // get the rounded color.. - vec2 pixCoord = pixelate(coord, vec2(pixelSize)); - pixCoord = unmapCoord(pixCoord); - - vec4 color = texture2D(uSampler, pixCoord); - - // determine the character to use - float gray = (color.r + color.g + color.b) / 3.0; - - float n = 65536.0; // . - if (gray > 0.2) n = 65600.0; // : - if (gray > 0.3) n = 332772.0; // * - if (gray > 0.4) n = 15255086.0; // o - if (gray > 0.5) n = 23385164.0; // & - if (gray > 0.6) n = 15252014.0; // 8 - if (gray > 0.7) n = 13199452.0; // @ - if (gray > 0.8) n = 11512810.0; // # - - // get the mod.. - vec2 modd = getMod(coord, vec2(pixelSize)); - - gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); - -} \ No newline at end of file diff --git a/src/filters/bloom/BloomFilter.js b/src/filters/bloom/BloomFilter.js deleted file mode 100644 index 1a9c713..0000000 --- a/src/filters/bloom/BloomFilter.js +++ /dev/null @@ -1,97 +0,0 @@ -var core = require('../../core'), - BlurXFilter = require('../blur/BlurXFilter'), - BlurYFilter = require('../blur/BlurYFilter'); - VoidFilter = require('../void/VoidFilter'); - -/** - * The BloomFilter applies a Gaussian blur to an object. - * The strength of the blur can be set for x- and y-axis separately. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function BloomFilter() -{ - core.Filter.call(this); - - this.blurXFilter = new BlurXFilter(); - this.blurYFilter = new BlurYFilter(); - - this.blurYFilter.blendMode = core.BLEND_MODES.SCREEN; - - this.defaultFilter = new VoidFilter(); -} - -BloomFilter.prototype = Object.create(core.Filter.prototype); -BloomFilter.prototype.constructor = BloomFilter; -module.exports = BloomFilter; - -BloomFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - //TODO - copyTexSubImage2D could be used here? - this.defaultFilter.apply(filterManager, input, output); - - this.blurXFilter.apply(filterManager, input, renderTarget); - this.blurYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(BloomFilter.prototype, { - /** - * Sets the strength of both the blurX and blurY properties simultaneously - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blur: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = this.blurYFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurX property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurX: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurY property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurY: { - get: function () - { - return this.blurYFilter.blur; - }, - set: function (value) - { - this.blurYFilter.blur = value; - } - } -}); diff --git a/src/filters/convolution/ConvolutionFilter.js b/src/filters/convolution/ConvolutionFilter.js deleted file mode 100644 index 51775ba..0000000 --- a/src/filters/convolution/ConvolutionFilter.js +++ /dev/null @@ -1,87 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ConvolutionFilter class applies a matrix convolution filter effect. - * A convolution combines pixels in the input image with neighboring pixels to produce a new image. - * A wide variety of image effects can be achieved through convolutions, including blurring, edge - * detection, sharpening, embossing, and beveling. The matrix should be specified as a 9 point Array. - * See http://docs.gimp.org/en/plug-in-convmatrix.html for more info. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - * @param matrix {number[]} An array of values used for matrix transformation. Specified as a 9 point Array. - * @param width {number} Width of the object you are transforming - * @param height {number} Height of the object you are transforming - */ -function ConvolutionFilter(matrix, width, height) -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./convolution.frag') - ); - - this.matrix = matrix; - this.width = width; - this.height = height; -} - -ConvolutionFilter.prototype = Object.create(core.Filter.prototype); -ConvolutionFilter.prototype.constructor = ConvolutionFilter; -module.exports = ConvolutionFilter; - -Object.defineProperties(ConvolutionFilter.prototype, { - /** - * An array of values used for matrix transformation. Specified as a 9 point Array. - * - * @member {number[]} - * @memberof PIXI.filters.ConvolutionFilter# - */ - matrix: { - get: function () - { - return this.uniforms.matrix; - }, - set: function (value) - { - this.uniforms.matrix = new Float32Array(value); - } - }, - - /** - * Width of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - width: { - get: function () - { - return 1/this.uniforms.texelSize[0]; - }, - set: function (value) - { - this.uniforms.texelSize[0] = 1/value; - } - }, - - /** - * Height of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - height: { - get: function () - { - return 1/this.uniforms.texelSize[1]; - }, - set: function (value) - { - this.uniforms.texelSize[1] = 1/value; - } - } -}); diff --git a/src/filters/convolution/convolution.frag b/src/filters/convolution/convolution.frag deleted file mode 100644 index e6fe7b5..0000000 --- a/src/filters/convolution/convolution.frag +++ /dev/null @@ -1,29 +0,0 @@ -precision mediump float; - -varying mediump vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec2 texelSize; -uniform float matrix[9]; - -void main(void) -{ - vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left - vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center - vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right - - vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left - vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center - vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right - - vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left - vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center - vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right - - gl_FragColor = - c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] + - c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] + - c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8]; - - gl_FragColor.a = c22.a; -} diff --git a/src/filters/crosshatch/CrossHatchFilter.js b/src/filters/crosshatch/CrossHatchFilter.js deleted file mode 100644 index a8da95d..0000000 --- a/src/filters/crosshatch/CrossHatchFilter.js +++ /dev/null @@ -1,23 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * A Cross Hatch effect filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function CrossHatchFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./crosshatch.frag') - ); -} - -CrossHatchFilter.prototype = Object.create(core.Filter.prototype); -CrossHatchFilter.prototype.constructor = CrossHatchFilter; -module.exports = CrossHatchFilter; diff --git a/src/filters/crosshatch/crosshatch.frag b/src/filters/crosshatch/crosshatch.frag deleted file mode 100644 index 635ba4b..0000000 --- a/src/filters/crosshatch/crosshatch.frag +++ /dev/null @@ -1,44 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -void main(void) -{ - float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb); - - gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); - - if (lum < 1.00) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.75) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.50) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.3) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } -} diff --git a/src/filters/dot/DotFilter.js b/src/filters/dot/DotFilter.js deleted file mode 100644 index d2bc544..0000000 --- a/src/filters/dot/DotFilter.js +++ /dev/null @@ -1,66 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * @author Mat Groves http://matgroves.com/ @Doormat23 - * original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/fun/dotscreen.js - */ - -/** - * This filter applies a dotscreen effect making display objects appear to be made out of - * black and white halftone dots like an old printer. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function DotFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./dot.frag') - ); - - this.scale = 1; - this.angle = 5; -} - -DotFilter.prototype = Object.create(core.Filter.prototype); -DotFilter.prototype.constructor = DotFilter; -module.exports = DotFilter; - -Object.defineProperties(DotFilter.prototype, { - /** - * The scale of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - scale: { - get: function () - { - return this.uniforms.scale; - }, - set: function (value) - { - this.uniforms.scale = value; - } - }, - - /** - * The radius of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - angle: { - get: function () - { - return this.uniforms.angle; - }, - set: function (value) - { - this.uniforms.angle = value; - } - } -}); diff --git a/src/filters/ascii/AsciiFilter.js b/src/filters/ascii/AsciiFilter.js deleted file mode 100644 index ac64fd1..0000000 --- a/src/filters/ascii/AsciiFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -// TODO (cengler) - The Y is flipped in this shader for some reason. - -/** - * @author Vico @vicocotea - * original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h - */ - -/** - * An ASCII filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function AsciiFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./ascii.frag') - ); - - this.size = 8; -} - -AsciiFilter.prototype = Object.create(core.Filter.prototype); -AsciiFilter.prototype.constructor = AsciiFilter; -module.exports = AsciiFilter; - -Object.defineProperties(AsciiFilter.prototype, { - /** - * The pixel size used by the filter. - * - * @member {number} - * @memberof PIXI.filters.AsciiFilter# - */ - size: { - get: function () - { - return this.uniforms.pixelSize; - }, - set: function (value) - { - this.uniforms.pixelSize = value; - } - } -}); diff --git a/src/filters/ascii/ascii.frag b/src/filters/ascii/ascii.frag deleted file mode 100644 index 5608d6e..0000000 --- a/src/filters/ascii/ascii.frag +++ /dev/null @@ -1,70 +0,0 @@ -varying vec2 vTextureCoord; - -uniform vec4 filterArea; -uniform float pixelSize; -uniform sampler2D uSampler; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -vec2 getMod(vec2 coord, vec2 size) -{ - return mod( coord , size) / size; -} - -float character(float n, vec2 p) -{ - p = floor(p*vec2(4.0, -4.0) + 2.5); - if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y) - { - if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; - } - return 0.0; -} - -void main() -{ - vec2 coord = mapCoord(vTextureCoord); - - // get the rounded color.. - vec2 pixCoord = pixelate(coord, vec2(pixelSize)); - pixCoord = unmapCoord(pixCoord); - - vec4 color = texture2D(uSampler, pixCoord); - - // determine the character to use - float gray = (color.r + color.g + color.b) / 3.0; - - float n = 65536.0; // . - if (gray > 0.2) n = 65600.0; // : - if (gray > 0.3) n = 332772.0; // * - if (gray > 0.4) n = 15255086.0; // o - if (gray > 0.5) n = 23385164.0; // & - if (gray > 0.6) n = 15252014.0; // 8 - if (gray > 0.7) n = 13199452.0; // @ - if (gray > 0.8) n = 11512810.0; // # - - // get the mod.. - vec2 modd = getMod(coord, vec2(pixelSize)); - - gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); - -} \ No newline at end of file diff --git a/src/filters/bloom/BloomFilter.js b/src/filters/bloom/BloomFilter.js deleted file mode 100644 index 1a9c713..0000000 --- a/src/filters/bloom/BloomFilter.js +++ /dev/null @@ -1,97 +0,0 @@ -var core = require('../../core'), - BlurXFilter = require('../blur/BlurXFilter'), - BlurYFilter = require('../blur/BlurYFilter'); - VoidFilter = require('../void/VoidFilter'); - -/** - * The BloomFilter applies a Gaussian blur to an object. - * The strength of the blur can be set for x- and y-axis separately. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function BloomFilter() -{ - core.Filter.call(this); - - this.blurXFilter = new BlurXFilter(); - this.blurYFilter = new BlurYFilter(); - - this.blurYFilter.blendMode = core.BLEND_MODES.SCREEN; - - this.defaultFilter = new VoidFilter(); -} - -BloomFilter.prototype = Object.create(core.Filter.prototype); -BloomFilter.prototype.constructor = BloomFilter; -module.exports = BloomFilter; - -BloomFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - //TODO - copyTexSubImage2D could be used here? - this.defaultFilter.apply(filterManager, input, output); - - this.blurXFilter.apply(filterManager, input, renderTarget); - this.blurYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(BloomFilter.prototype, { - /** - * Sets the strength of both the blurX and blurY properties simultaneously - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blur: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = this.blurYFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurX property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurX: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurY property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurY: { - get: function () - { - return this.blurYFilter.blur; - }, - set: function (value) - { - this.blurYFilter.blur = value; - } - } -}); diff --git a/src/filters/convolution/ConvolutionFilter.js b/src/filters/convolution/ConvolutionFilter.js deleted file mode 100644 index 51775ba..0000000 --- a/src/filters/convolution/ConvolutionFilter.js +++ /dev/null @@ -1,87 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ConvolutionFilter class applies a matrix convolution filter effect. - * A convolution combines pixels in the input image with neighboring pixels to produce a new image. - * A wide variety of image effects can be achieved through convolutions, including blurring, edge - * detection, sharpening, embossing, and beveling. The matrix should be specified as a 9 point Array. - * See http://docs.gimp.org/en/plug-in-convmatrix.html for more info. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - * @param matrix {number[]} An array of values used for matrix transformation. Specified as a 9 point Array. - * @param width {number} Width of the object you are transforming - * @param height {number} Height of the object you are transforming - */ -function ConvolutionFilter(matrix, width, height) -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./convolution.frag') - ); - - this.matrix = matrix; - this.width = width; - this.height = height; -} - -ConvolutionFilter.prototype = Object.create(core.Filter.prototype); -ConvolutionFilter.prototype.constructor = ConvolutionFilter; -module.exports = ConvolutionFilter; - -Object.defineProperties(ConvolutionFilter.prototype, { - /** - * An array of values used for matrix transformation. Specified as a 9 point Array. - * - * @member {number[]} - * @memberof PIXI.filters.ConvolutionFilter# - */ - matrix: { - get: function () - { - return this.uniforms.matrix; - }, - set: function (value) - { - this.uniforms.matrix = new Float32Array(value); - } - }, - - /** - * Width of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - width: { - get: function () - { - return 1/this.uniforms.texelSize[0]; - }, - set: function (value) - { - this.uniforms.texelSize[0] = 1/value; - } - }, - - /** - * Height of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - height: { - get: function () - { - return 1/this.uniforms.texelSize[1]; - }, - set: function (value) - { - this.uniforms.texelSize[1] = 1/value; - } - } -}); diff --git a/src/filters/convolution/convolution.frag b/src/filters/convolution/convolution.frag deleted file mode 100644 index e6fe7b5..0000000 --- a/src/filters/convolution/convolution.frag +++ /dev/null @@ -1,29 +0,0 @@ -precision mediump float; - -varying mediump vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec2 texelSize; -uniform float matrix[9]; - -void main(void) -{ - vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left - vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center - vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right - - vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left - vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center - vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right - - vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left - vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center - vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right - - gl_FragColor = - c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] + - c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] + - c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8]; - - gl_FragColor.a = c22.a; -} diff --git a/src/filters/crosshatch/CrossHatchFilter.js b/src/filters/crosshatch/CrossHatchFilter.js deleted file mode 100644 index a8da95d..0000000 --- a/src/filters/crosshatch/CrossHatchFilter.js +++ /dev/null @@ -1,23 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * A Cross Hatch effect filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function CrossHatchFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./crosshatch.frag') - ); -} - -CrossHatchFilter.prototype = Object.create(core.Filter.prototype); -CrossHatchFilter.prototype.constructor = CrossHatchFilter; -module.exports = CrossHatchFilter; diff --git a/src/filters/crosshatch/crosshatch.frag b/src/filters/crosshatch/crosshatch.frag deleted file mode 100644 index 635ba4b..0000000 --- a/src/filters/crosshatch/crosshatch.frag +++ /dev/null @@ -1,44 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -void main(void) -{ - float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb); - - gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); - - if (lum < 1.00) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.75) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.50) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.3) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } -} diff --git a/src/filters/dot/DotFilter.js b/src/filters/dot/DotFilter.js deleted file mode 100644 index d2bc544..0000000 --- a/src/filters/dot/DotFilter.js +++ /dev/null @@ -1,66 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * @author Mat Groves http://matgroves.com/ @Doormat23 - * original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/fun/dotscreen.js - */ - -/** - * This filter applies a dotscreen effect making display objects appear to be made out of - * black and white halftone dots like an old printer. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function DotFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./dot.frag') - ); - - this.scale = 1; - this.angle = 5; -} - -DotFilter.prototype = Object.create(core.Filter.prototype); -DotFilter.prototype.constructor = DotFilter; -module.exports = DotFilter; - -Object.defineProperties(DotFilter.prototype, { - /** - * The scale of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - scale: { - get: function () - { - return this.uniforms.scale; - }, - set: function (value) - { - this.uniforms.scale = value; - } - }, - - /** - * The radius of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - angle: { - get: function () - { - return this.uniforms.angle; - }, - set: function (value) - { - this.uniforms.angle = value; - } - } -}); diff --git a/src/filters/dot/dot.frag b/src/filters/dot/dot.frag deleted file mode 100644 index 91341b1..0000000 --- a/src/filters/dot/dot.frag +++ /dev/null @@ -1,28 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; -varying vec4 vColor; - -uniform vec4 filterArea; -uniform sampler2D uSampler; - -uniform float angle; -uniform float scale; - -float pattern() -{ - float s = sin(angle), c = cos(angle); - vec2 tex = vTextureCoord * filterArea.xy; - vec2 point = vec2( - c * tex.x - s * tex.y, - s * tex.x + c * tex.y - ) * scale; - return (sin(point.x) * sin(point.y)) * 4.0; -} - -void main() -{ - vec4 color = texture2D(uSampler, vTextureCoord); - float average = (color.r + color.g + color.b) / 3.0; - gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a); -} diff --git a/src/filters/ascii/AsciiFilter.js b/src/filters/ascii/AsciiFilter.js deleted file mode 100644 index ac64fd1..0000000 --- a/src/filters/ascii/AsciiFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -// TODO (cengler) - The Y is flipped in this shader for some reason. - -/** - * @author Vico @vicocotea - * original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h - */ - -/** - * An ASCII filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function AsciiFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./ascii.frag') - ); - - this.size = 8; -} - -AsciiFilter.prototype = Object.create(core.Filter.prototype); -AsciiFilter.prototype.constructor = AsciiFilter; -module.exports = AsciiFilter; - -Object.defineProperties(AsciiFilter.prototype, { - /** - * The pixel size used by the filter. - * - * @member {number} - * @memberof PIXI.filters.AsciiFilter# - */ - size: { - get: function () - { - return this.uniforms.pixelSize; - }, - set: function (value) - { - this.uniforms.pixelSize = value; - } - } -}); diff --git a/src/filters/ascii/ascii.frag b/src/filters/ascii/ascii.frag deleted file mode 100644 index 5608d6e..0000000 --- a/src/filters/ascii/ascii.frag +++ /dev/null @@ -1,70 +0,0 @@ -varying vec2 vTextureCoord; - -uniform vec4 filterArea; -uniform float pixelSize; -uniform sampler2D uSampler; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -vec2 getMod(vec2 coord, vec2 size) -{ - return mod( coord , size) / size; -} - -float character(float n, vec2 p) -{ - p = floor(p*vec2(4.0, -4.0) + 2.5); - if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y) - { - if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; - } - return 0.0; -} - -void main() -{ - vec2 coord = mapCoord(vTextureCoord); - - // get the rounded color.. - vec2 pixCoord = pixelate(coord, vec2(pixelSize)); - pixCoord = unmapCoord(pixCoord); - - vec4 color = texture2D(uSampler, pixCoord); - - // determine the character to use - float gray = (color.r + color.g + color.b) / 3.0; - - float n = 65536.0; // . - if (gray > 0.2) n = 65600.0; // : - if (gray > 0.3) n = 332772.0; // * - if (gray > 0.4) n = 15255086.0; // o - if (gray > 0.5) n = 23385164.0; // & - if (gray > 0.6) n = 15252014.0; // 8 - if (gray > 0.7) n = 13199452.0; // @ - if (gray > 0.8) n = 11512810.0; // # - - // get the mod.. - vec2 modd = getMod(coord, vec2(pixelSize)); - - gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); - -} \ No newline at end of file diff --git a/src/filters/bloom/BloomFilter.js b/src/filters/bloom/BloomFilter.js deleted file mode 100644 index 1a9c713..0000000 --- a/src/filters/bloom/BloomFilter.js +++ /dev/null @@ -1,97 +0,0 @@ -var core = require('../../core'), - BlurXFilter = require('../blur/BlurXFilter'), - BlurYFilter = require('../blur/BlurYFilter'); - VoidFilter = require('../void/VoidFilter'); - -/** - * The BloomFilter applies a Gaussian blur to an object. - * The strength of the blur can be set for x- and y-axis separately. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function BloomFilter() -{ - core.Filter.call(this); - - this.blurXFilter = new BlurXFilter(); - this.blurYFilter = new BlurYFilter(); - - this.blurYFilter.blendMode = core.BLEND_MODES.SCREEN; - - this.defaultFilter = new VoidFilter(); -} - -BloomFilter.prototype = Object.create(core.Filter.prototype); -BloomFilter.prototype.constructor = BloomFilter; -module.exports = BloomFilter; - -BloomFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - //TODO - copyTexSubImage2D could be used here? - this.defaultFilter.apply(filterManager, input, output); - - this.blurXFilter.apply(filterManager, input, renderTarget); - this.blurYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(BloomFilter.prototype, { - /** - * Sets the strength of both the blurX and blurY properties simultaneously - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blur: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = this.blurYFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurX property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurX: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurY property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurY: { - get: function () - { - return this.blurYFilter.blur; - }, - set: function (value) - { - this.blurYFilter.blur = value; - } - } -}); diff --git a/src/filters/convolution/ConvolutionFilter.js b/src/filters/convolution/ConvolutionFilter.js deleted file mode 100644 index 51775ba..0000000 --- a/src/filters/convolution/ConvolutionFilter.js +++ /dev/null @@ -1,87 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ConvolutionFilter class applies a matrix convolution filter effect. - * A convolution combines pixels in the input image with neighboring pixels to produce a new image. - * A wide variety of image effects can be achieved through convolutions, including blurring, edge - * detection, sharpening, embossing, and beveling. The matrix should be specified as a 9 point Array. - * See http://docs.gimp.org/en/plug-in-convmatrix.html for more info. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - * @param matrix {number[]} An array of values used for matrix transformation. Specified as a 9 point Array. - * @param width {number} Width of the object you are transforming - * @param height {number} Height of the object you are transforming - */ -function ConvolutionFilter(matrix, width, height) -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./convolution.frag') - ); - - this.matrix = matrix; - this.width = width; - this.height = height; -} - -ConvolutionFilter.prototype = Object.create(core.Filter.prototype); -ConvolutionFilter.prototype.constructor = ConvolutionFilter; -module.exports = ConvolutionFilter; - -Object.defineProperties(ConvolutionFilter.prototype, { - /** - * An array of values used for matrix transformation. Specified as a 9 point Array. - * - * @member {number[]} - * @memberof PIXI.filters.ConvolutionFilter# - */ - matrix: { - get: function () - { - return this.uniforms.matrix; - }, - set: function (value) - { - this.uniforms.matrix = new Float32Array(value); - } - }, - - /** - * Width of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - width: { - get: function () - { - return 1/this.uniforms.texelSize[0]; - }, - set: function (value) - { - this.uniforms.texelSize[0] = 1/value; - } - }, - - /** - * Height of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - height: { - get: function () - { - return 1/this.uniforms.texelSize[1]; - }, - set: function (value) - { - this.uniforms.texelSize[1] = 1/value; - } - } -}); diff --git a/src/filters/convolution/convolution.frag b/src/filters/convolution/convolution.frag deleted file mode 100644 index e6fe7b5..0000000 --- a/src/filters/convolution/convolution.frag +++ /dev/null @@ -1,29 +0,0 @@ -precision mediump float; - -varying mediump vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec2 texelSize; -uniform float matrix[9]; - -void main(void) -{ - vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left - vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center - vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right - - vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left - vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center - vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right - - vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left - vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center - vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right - - gl_FragColor = - c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] + - c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] + - c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8]; - - gl_FragColor.a = c22.a; -} diff --git a/src/filters/crosshatch/CrossHatchFilter.js b/src/filters/crosshatch/CrossHatchFilter.js deleted file mode 100644 index a8da95d..0000000 --- a/src/filters/crosshatch/CrossHatchFilter.js +++ /dev/null @@ -1,23 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * A Cross Hatch effect filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function CrossHatchFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./crosshatch.frag') - ); -} - -CrossHatchFilter.prototype = Object.create(core.Filter.prototype); -CrossHatchFilter.prototype.constructor = CrossHatchFilter; -module.exports = CrossHatchFilter; diff --git a/src/filters/crosshatch/crosshatch.frag b/src/filters/crosshatch/crosshatch.frag deleted file mode 100644 index 635ba4b..0000000 --- a/src/filters/crosshatch/crosshatch.frag +++ /dev/null @@ -1,44 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -void main(void) -{ - float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb); - - gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); - - if (lum < 1.00) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.75) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.50) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.3) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } -} diff --git a/src/filters/dot/DotFilter.js b/src/filters/dot/DotFilter.js deleted file mode 100644 index d2bc544..0000000 --- a/src/filters/dot/DotFilter.js +++ /dev/null @@ -1,66 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * @author Mat Groves http://matgroves.com/ @Doormat23 - * original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/fun/dotscreen.js - */ - -/** - * This filter applies a dotscreen effect making display objects appear to be made out of - * black and white halftone dots like an old printer. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function DotFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./dot.frag') - ); - - this.scale = 1; - this.angle = 5; -} - -DotFilter.prototype = Object.create(core.Filter.prototype); -DotFilter.prototype.constructor = DotFilter; -module.exports = DotFilter; - -Object.defineProperties(DotFilter.prototype, { - /** - * The scale of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - scale: { - get: function () - { - return this.uniforms.scale; - }, - set: function (value) - { - this.uniforms.scale = value; - } - }, - - /** - * The radius of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - angle: { - get: function () - { - return this.uniforms.angle; - }, - set: function (value) - { - this.uniforms.angle = value; - } - } -}); diff --git a/src/filters/dot/dot.frag b/src/filters/dot/dot.frag deleted file mode 100644 index 91341b1..0000000 --- a/src/filters/dot/dot.frag +++ /dev/null @@ -1,28 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; -varying vec4 vColor; - -uniform vec4 filterArea; -uniform sampler2D uSampler; - -uniform float angle; -uniform float scale; - -float pattern() -{ - float s = sin(angle), c = cos(angle); - vec2 tex = vTextureCoord * filterArea.xy; - vec2 point = vec2( - c * tex.x - s * tex.y, - s * tex.x + c * tex.y - ) * scale; - return (sin(point.x) * sin(point.y)) * 4.0; -} - -void main() -{ - vec4 color = texture2D(uSampler, vTextureCoord); - float average = (color.r + color.g + color.b) / 3.0; - gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a); -} diff --git a/src/filters/emboss/EmbossFilter.js b/src/filters/emboss/EmbossFilter.js deleted file mode 100644 index 0468d1f..0000000 --- a/src/filters/emboss/EmbossFilter.js +++ /dev/null @@ -1,46 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function EmbossFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./emboss.frag') - ); - - this.strength = 5; -} - -EmbossFilter.prototype = Object.create(core.Filter.prototype); -EmbossFilter.prototype.constructor = EmbossFilter; -module.exports = EmbossFilter; - -Object.defineProperties(EmbossFilter.prototype, { - /** - * Strength of Emboss. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.EmbossFilter# - */ - strength: { - get: function () - { - return this.uniforms.strength; - }, - set: function (value) - { - this.uniforms.strength = value; - } - }, - - -}); diff --git a/src/filters/ascii/AsciiFilter.js b/src/filters/ascii/AsciiFilter.js deleted file mode 100644 index ac64fd1..0000000 --- a/src/filters/ascii/AsciiFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -// TODO (cengler) - The Y is flipped in this shader for some reason. - -/** - * @author Vico @vicocotea - * original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h - */ - -/** - * An ASCII filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function AsciiFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./ascii.frag') - ); - - this.size = 8; -} - -AsciiFilter.prototype = Object.create(core.Filter.prototype); -AsciiFilter.prototype.constructor = AsciiFilter; -module.exports = AsciiFilter; - -Object.defineProperties(AsciiFilter.prototype, { - /** - * The pixel size used by the filter. - * - * @member {number} - * @memberof PIXI.filters.AsciiFilter# - */ - size: { - get: function () - { - return this.uniforms.pixelSize; - }, - set: function (value) - { - this.uniforms.pixelSize = value; - } - } -}); diff --git a/src/filters/ascii/ascii.frag b/src/filters/ascii/ascii.frag deleted file mode 100644 index 5608d6e..0000000 --- a/src/filters/ascii/ascii.frag +++ /dev/null @@ -1,70 +0,0 @@ -varying vec2 vTextureCoord; - -uniform vec4 filterArea; -uniform float pixelSize; -uniform sampler2D uSampler; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -vec2 getMod(vec2 coord, vec2 size) -{ - return mod( coord , size) / size; -} - -float character(float n, vec2 p) -{ - p = floor(p*vec2(4.0, -4.0) + 2.5); - if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y) - { - if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; - } - return 0.0; -} - -void main() -{ - vec2 coord = mapCoord(vTextureCoord); - - // get the rounded color.. - vec2 pixCoord = pixelate(coord, vec2(pixelSize)); - pixCoord = unmapCoord(pixCoord); - - vec4 color = texture2D(uSampler, pixCoord); - - // determine the character to use - float gray = (color.r + color.g + color.b) / 3.0; - - float n = 65536.0; // . - if (gray > 0.2) n = 65600.0; // : - if (gray > 0.3) n = 332772.0; // * - if (gray > 0.4) n = 15255086.0; // o - if (gray > 0.5) n = 23385164.0; // & - if (gray > 0.6) n = 15252014.0; // 8 - if (gray > 0.7) n = 13199452.0; // @ - if (gray > 0.8) n = 11512810.0; // # - - // get the mod.. - vec2 modd = getMod(coord, vec2(pixelSize)); - - gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); - -} \ No newline at end of file diff --git a/src/filters/bloom/BloomFilter.js b/src/filters/bloom/BloomFilter.js deleted file mode 100644 index 1a9c713..0000000 --- a/src/filters/bloom/BloomFilter.js +++ /dev/null @@ -1,97 +0,0 @@ -var core = require('../../core'), - BlurXFilter = require('../blur/BlurXFilter'), - BlurYFilter = require('../blur/BlurYFilter'); - VoidFilter = require('../void/VoidFilter'); - -/** - * The BloomFilter applies a Gaussian blur to an object. - * The strength of the blur can be set for x- and y-axis separately. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function BloomFilter() -{ - core.Filter.call(this); - - this.blurXFilter = new BlurXFilter(); - this.blurYFilter = new BlurYFilter(); - - this.blurYFilter.blendMode = core.BLEND_MODES.SCREEN; - - this.defaultFilter = new VoidFilter(); -} - -BloomFilter.prototype = Object.create(core.Filter.prototype); -BloomFilter.prototype.constructor = BloomFilter; -module.exports = BloomFilter; - -BloomFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - //TODO - copyTexSubImage2D could be used here? - this.defaultFilter.apply(filterManager, input, output); - - this.blurXFilter.apply(filterManager, input, renderTarget); - this.blurYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(BloomFilter.prototype, { - /** - * Sets the strength of both the blurX and blurY properties simultaneously - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blur: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = this.blurYFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurX property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurX: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurY property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurY: { - get: function () - { - return this.blurYFilter.blur; - }, - set: function (value) - { - this.blurYFilter.blur = value; - } - } -}); diff --git a/src/filters/convolution/ConvolutionFilter.js b/src/filters/convolution/ConvolutionFilter.js deleted file mode 100644 index 51775ba..0000000 --- a/src/filters/convolution/ConvolutionFilter.js +++ /dev/null @@ -1,87 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ConvolutionFilter class applies a matrix convolution filter effect. - * A convolution combines pixels in the input image with neighboring pixels to produce a new image. - * A wide variety of image effects can be achieved through convolutions, including blurring, edge - * detection, sharpening, embossing, and beveling. The matrix should be specified as a 9 point Array. - * See http://docs.gimp.org/en/plug-in-convmatrix.html for more info. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - * @param matrix {number[]} An array of values used for matrix transformation. Specified as a 9 point Array. - * @param width {number} Width of the object you are transforming - * @param height {number} Height of the object you are transforming - */ -function ConvolutionFilter(matrix, width, height) -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./convolution.frag') - ); - - this.matrix = matrix; - this.width = width; - this.height = height; -} - -ConvolutionFilter.prototype = Object.create(core.Filter.prototype); -ConvolutionFilter.prototype.constructor = ConvolutionFilter; -module.exports = ConvolutionFilter; - -Object.defineProperties(ConvolutionFilter.prototype, { - /** - * An array of values used for matrix transformation. Specified as a 9 point Array. - * - * @member {number[]} - * @memberof PIXI.filters.ConvolutionFilter# - */ - matrix: { - get: function () - { - return this.uniforms.matrix; - }, - set: function (value) - { - this.uniforms.matrix = new Float32Array(value); - } - }, - - /** - * Width of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - width: { - get: function () - { - return 1/this.uniforms.texelSize[0]; - }, - set: function (value) - { - this.uniforms.texelSize[0] = 1/value; - } - }, - - /** - * Height of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - height: { - get: function () - { - return 1/this.uniforms.texelSize[1]; - }, - set: function (value) - { - this.uniforms.texelSize[1] = 1/value; - } - } -}); diff --git a/src/filters/convolution/convolution.frag b/src/filters/convolution/convolution.frag deleted file mode 100644 index e6fe7b5..0000000 --- a/src/filters/convolution/convolution.frag +++ /dev/null @@ -1,29 +0,0 @@ -precision mediump float; - -varying mediump vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec2 texelSize; -uniform float matrix[9]; - -void main(void) -{ - vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left - vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center - vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right - - vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left - vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center - vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right - - vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left - vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center - vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right - - gl_FragColor = - c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] + - c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] + - c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8]; - - gl_FragColor.a = c22.a; -} diff --git a/src/filters/crosshatch/CrossHatchFilter.js b/src/filters/crosshatch/CrossHatchFilter.js deleted file mode 100644 index a8da95d..0000000 --- a/src/filters/crosshatch/CrossHatchFilter.js +++ /dev/null @@ -1,23 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * A Cross Hatch effect filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function CrossHatchFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./crosshatch.frag') - ); -} - -CrossHatchFilter.prototype = Object.create(core.Filter.prototype); -CrossHatchFilter.prototype.constructor = CrossHatchFilter; -module.exports = CrossHatchFilter; diff --git a/src/filters/crosshatch/crosshatch.frag b/src/filters/crosshatch/crosshatch.frag deleted file mode 100644 index 635ba4b..0000000 --- a/src/filters/crosshatch/crosshatch.frag +++ /dev/null @@ -1,44 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -void main(void) -{ - float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb); - - gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); - - if (lum < 1.00) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.75) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.50) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.3) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } -} diff --git a/src/filters/dot/DotFilter.js b/src/filters/dot/DotFilter.js deleted file mode 100644 index d2bc544..0000000 --- a/src/filters/dot/DotFilter.js +++ /dev/null @@ -1,66 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * @author Mat Groves http://matgroves.com/ @Doormat23 - * original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/fun/dotscreen.js - */ - -/** - * This filter applies a dotscreen effect making display objects appear to be made out of - * black and white halftone dots like an old printer. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function DotFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./dot.frag') - ); - - this.scale = 1; - this.angle = 5; -} - -DotFilter.prototype = Object.create(core.Filter.prototype); -DotFilter.prototype.constructor = DotFilter; -module.exports = DotFilter; - -Object.defineProperties(DotFilter.prototype, { - /** - * The scale of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - scale: { - get: function () - { - return this.uniforms.scale; - }, - set: function (value) - { - this.uniforms.scale = value; - } - }, - - /** - * The radius of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - angle: { - get: function () - { - return this.uniforms.angle; - }, - set: function (value) - { - this.uniforms.angle = value; - } - } -}); diff --git a/src/filters/dot/dot.frag b/src/filters/dot/dot.frag deleted file mode 100644 index 91341b1..0000000 --- a/src/filters/dot/dot.frag +++ /dev/null @@ -1,28 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; -varying vec4 vColor; - -uniform vec4 filterArea; -uniform sampler2D uSampler; - -uniform float angle; -uniform float scale; - -float pattern() -{ - float s = sin(angle), c = cos(angle); - vec2 tex = vTextureCoord * filterArea.xy; - vec2 point = vec2( - c * tex.x - s * tex.y, - s * tex.x + c * tex.y - ) * scale; - return (sin(point.x) * sin(point.y)) * 4.0; -} - -void main() -{ - vec4 color = texture2D(uSampler, vTextureCoord); - float average = (color.r + color.g + color.b) / 3.0; - gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a); -} diff --git a/src/filters/emboss/EmbossFilter.js b/src/filters/emboss/EmbossFilter.js deleted file mode 100644 index 0468d1f..0000000 --- a/src/filters/emboss/EmbossFilter.js +++ /dev/null @@ -1,46 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function EmbossFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./emboss.frag') - ); - - this.strength = 5; -} - -EmbossFilter.prototype = Object.create(core.Filter.prototype); -EmbossFilter.prototype.constructor = EmbossFilter; -module.exports = EmbossFilter; - -Object.defineProperties(EmbossFilter.prototype, { - /** - * Strength of Emboss. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.EmbossFilter# - */ - strength: { - get: function () - { - return this.uniforms.strength; - }, - set: function (value) - { - this.uniforms.strength = value; - } - }, - - -}); diff --git a/src/filters/emboss/emboss.frag b/src/filters/emboss/emboss.frag deleted file mode 100644 index 28b14d9..0000000 --- a/src/filters/emboss/emboss.frag +++ /dev/null @@ -1,26 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform float strength; -uniform vec4 filterArea; - - -void main(void) -{ - vec2 onePixel = vec2(1.0 / filterArea); - - vec4 color; - - color.rgb = vec3(0.5); - - color -= texture2D(uSampler, vTextureCoord - onePixel) * strength; - color += texture2D(uSampler, vTextureCoord + onePixel) * strength; - - color.rgb = vec3((color.r + color.g + color.b) / 3.0); - - float alpha = texture2D(uSampler, vTextureCoord).a; - - gl_FragColor = vec4(color.rgb * alpha, alpha); -} diff --git a/src/filters/ascii/AsciiFilter.js b/src/filters/ascii/AsciiFilter.js deleted file mode 100644 index ac64fd1..0000000 --- a/src/filters/ascii/AsciiFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -// TODO (cengler) - The Y is flipped in this shader for some reason. - -/** - * @author Vico @vicocotea - * original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h - */ - -/** - * An ASCII filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function AsciiFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./ascii.frag') - ); - - this.size = 8; -} - -AsciiFilter.prototype = Object.create(core.Filter.prototype); -AsciiFilter.prototype.constructor = AsciiFilter; -module.exports = AsciiFilter; - -Object.defineProperties(AsciiFilter.prototype, { - /** - * The pixel size used by the filter. - * - * @member {number} - * @memberof PIXI.filters.AsciiFilter# - */ - size: { - get: function () - { - return this.uniforms.pixelSize; - }, - set: function (value) - { - this.uniforms.pixelSize = value; - } - } -}); diff --git a/src/filters/ascii/ascii.frag b/src/filters/ascii/ascii.frag deleted file mode 100644 index 5608d6e..0000000 --- a/src/filters/ascii/ascii.frag +++ /dev/null @@ -1,70 +0,0 @@ -varying vec2 vTextureCoord; - -uniform vec4 filterArea; -uniform float pixelSize; -uniform sampler2D uSampler; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -vec2 getMod(vec2 coord, vec2 size) -{ - return mod( coord , size) / size; -} - -float character(float n, vec2 p) -{ - p = floor(p*vec2(4.0, -4.0) + 2.5); - if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y) - { - if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; - } - return 0.0; -} - -void main() -{ - vec2 coord = mapCoord(vTextureCoord); - - // get the rounded color.. - vec2 pixCoord = pixelate(coord, vec2(pixelSize)); - pixCoord = unmapCoord(pixCoord); - - vec4 color = texture2D(uSampler, pixCoord); - - // determine the character to use - float gray = (color.r + color.g + color.b) / 3.0; - - float n = 65536.0; // . - if (gray > 0.2) n = 65600.0; // : - if (gray > 0.3) n = 332772.0; // * - if (gray > 0.4) n = 15255086.0; // o - if (gray > 0.5) n = 23385164.0; // & - if (gray > 0.6) n = 15252014.0; // 8 - if (gray > 0.7) n = 13199452.0; // @ - if (gray > 0.8) n = 11512810.0; // # - - // get the mod.. - vec2 modd = getMod(coord, vec2(pixelSize)); - - gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); - -} \ No newline at end of file diff --git a/src/filters/bloom/BloomFilter.js b/src/filters/bloom/BloomFilter.js deleted file mode 100644 index 1a9c713..0000000 --- a/src/filters/bloom/BloomFilter.js +++ /dev/null @@ -1,97 +0,0 @@ -var core = require('../../core'), - BlurXFilter = require('../blur/BlurXFilter'), - BlurYFilter = require('../blur/BlurYFilter'); - VoidFilter = require('../void/VoidFilter'); - -/** - * The BloomFilter applies a Gaussian blur to an object. - * The strength of the blur can be set for x- and y-axis separately. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function BloomFilter() -{ - core.Filter.call(this); - - this.blurXFilter = new BlurXFilter(); - this.blurYFilter = new BlurYFilter(); - - this.blurYFilter.blendMode = core.BLEND_MODES.SCREEN; - - this.defaultFilter = new VoidFilter(); -} - -BloomFilter.prototype = Object.create(core.Filter.prototype); -BloomFilter.prototype.constructor = BloomFilter; -module.exports = BloomFilter; - -BloomFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - //TODO - copyTexSubImage2D could be used here? - this.defaultFilter.apply(filterManager, input, output); - - this.blurXFilter.apply(filterManager, input, renderTarget); - this.blurYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(BloomFilter.prototype, { - /** - * Sets the strength of both the blurX and blurY properties simultaneously - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blur: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = this.blurYFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurX property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurX: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurY property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurY: { - get: function () - { - return this.blurYFilter.blur; - }, - set: function (value) - { - this.blurYFilter.blur = value; - } - } -}); diff --git a/src/filters/convolution/ConvolutionFilter.js b/src/filters/convolution/ConvolutionFilter.js deleted file mode 100644 index 51775ba..0000000 --- a/src/filters/convolution/ConvolutionFilter.js +++ /dev/null @@ -1,87 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ConvolutionFilter class applies a matrix convolution filter effect. - * A convolution combines pixels in the input image with neighboring pixels to produce a new image. - * A wide variety of image effects can be achieved through convolutions, including blurring, edge - * detection, sharpening, embossing, and beveling. The matrix should be specified as a 9 point Array. - * See http://docs.gimp.org/en/plug-in-convmatrix.html for more info. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - * @param matrix {number[]} An array of values used for matrix transformation. Specified as a 9 point Array. - * @param width {number} Width of the object you are transforming - * @param height {number} Height of the object you are transforming - */ -function ConvolutionFilter(matrix, width, height) -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./convolution.frag') - ); - - this.matrix = matrix; - this.width = width; - this.height = height; -} - -ConvolutionFilter.prototype = Object.create(core.Filter.prototype); -ConvolutionFilter.prototype.constructor = ConvolutionFilter; -module.exports = ConvolutionFilter; - -Object.defineProperties(ConvolutionFilter.prototype, { - /** - * An array of values used for matrix transformation. Specified as a 9 point Array. - * - * @member {number[]} - * @memberof PIXI.filters.ConvolutionFilter# - */ - matrix: { - get: function () - { - return this.uniforms.matrix; - }, - set: function (value) - { - this.uniforms.matrix = new Float32Array(value); - } - }, - - /** - * Width of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - width: { - get: function () - { - return 1/this.uniforms.texelSize[0]; - }, - set: function (value) - { - this.uniforms.texelSize[0] = 1/value; - } - }, - - /** - * Height of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - height: { - get: function () - { - return 1/this.uniforms.texelSize[1]; - }, - set: function (value) - { - this.uniforms.texelSize[1] = 1/value; - } - } -}); diff --git a/src/filters/convolution/convolution.frag b/src/filters/convolution/convolution.frag deleted file mode 100644 index e6fe7b5..0000000 --- a/src/filters/convolution/convolution.frag +++ /dev/null @@ -1,29 +0,0 @@ -precision mediump float; - -varying mediump vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec2 texelSize; -uniform float matrix[9]; - -void main(void) -{ - vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left - vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center - vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right - - vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left - vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center - vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right - - vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left - vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center - vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right - - gl_FragColor = - c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] + - c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] + - c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8]; - - gl_FragColor.a = c22.a; -} diff --git a/src/filters/crosshatch/CrossHatchFilter.js b/src/filters/crosshatch/CrossHatchFilter.js deleted file mode 100644 index a8da95d..0000000 --- a/src/filters/crosshatch/CrossHatchFilter.js +++ /dev/null @@ -1,23 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * A Cross Hatch effect filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function CrossHatchFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./crosshatch.frag') - ); -} - -CrossHatchFilter.prototype = Object.create(core.Filter.prototype); -CrossHatchFilter.prototype.constructor = CrossHatchFilter; -module.exports = CrossHatchFilter; diff --git a/src/filters/crosshatch/crosshatch.frag b/src/filters/crosshatch/crosshatch.frag deleted file mode 100644 index 635ba4b..0000000 --- a/src/filters/crosshatch/crosshatch.frag +++ /dev/null @@ -1,44 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -void main(void) -{ - float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb); - - gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); - - if (lum < 1.00) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.75) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.50) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.3) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } -} diff --git a/src/filters/dot/DotFilter.js b/src/filters/dot/DotFilter.js deleted file mode 100644 index d2bc544..0000000 --- a/src/filters/dot/DotFilter.js +++ /dev/null @@ -1,66 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * @author Mat Groves http://matgroves.com/ @Doormat23 - * original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/fun/dotscreen.js - */ - -/** - * This filter applies a dotscreen effect making display objects appear to be made out of - * black and white halftone dots like an old printer. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function DotFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./dot.frag') - ); - - this.scale = 1; - this.angle = 5; -} - -DotFilter.prototype = Object.create(core.Filter.prototype); -DotFilter.prototype.constructor = DotFilter; -module.exports = DotFilter; - -Object.defineProperties(DotFilter.prototype, { - /** - * The scale of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - scale: { - get: function () - { - return this.uniforms.scale; - }, - set: function (value) - { - this.uniforms.scale = value; - } - }, - - /** - * The radius of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - angle: { - get: function () - { - return this.uniforms.angle; - }, - set: function (value) - { - this.uniforms.angle = value; - } - } -}); diff --git a/src/filters/dot/dot.frag b/src/filters/dot/dot.frag deleted file mode 100644 index 91341b1..0000000 --- a/src/filters/dot/dot.frag +++ /dev/null @@ -1,28 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; -varying vec4 vColor; - -uniform vec4 filterArea; -uniform sampler2D uSampler; - -uniform float angle; -uniform float scale; - -float pattern() -{ - float s = sin(angle), c = cos(angle); - vec2 tex = vTextureCoord * filterArea.xy; - vec2 point = vec2( - c * tex.x - s * tex.y, - s * tex.x + c * tex.y - ) * scale; - return (sin(point.x) * sin(point.y)) * 4.0; -} - -void main() -{ - vec4 color = texture2D(uSampler, vTextureCoord); - float average = (color.r + color.g + color.b) / 3.0; - gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a); -} diff --git a/src/filters/emboss/EmbossFilter.js b/src/filters/emboss/EmbossFilter.js deleted file mode 100644 index 0468d1f..0000000 --- a/src/filters/emboss/EmbossFilter.js +++ /dev/null @@ -1,46 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function EmbossFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./emboss.frag') - ); - - this.strength = 5; -} - -EmbossFilter.prototype = Object.create(core.Filter.prototype); -EmbossFilter.prototype.constructor = EmbossFilter; -module.exports = EmbossFilter; - -Object.defineProperties(EmbossFilter.prototype, { - /** - * Strength of Emboss. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.EmbossFilter# - */ - strength: { - get: function () - { - return this.uniforms.strength; - }, - set: function (value) - { - this.uniforms.strength = value; - } - }, - - -}); diff --git a/src/filters/emboss/emboss.frag b/src/filters/emboss/emboss.frag deleted file mode 100644 index 28b14d9..0000000 --- a/src/filters/emboss/emboss.frag +++ /dev/null @@ -1,26 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform float strength; -uniform vec4 filterArea; - - -void main(void) -{ - vec2 onePixel = vec2(1.0 / filterArea); - - vec4 color; - - color.rgb = vec3(0.5); - - color -= texture2D(uSampler, vTextureCoord - onePixel) * strength; - color += texture2D(uSampler, vTextureCoord + onePixel) * strength; - - color.rgb = vec3((color.r + color.g + color.b) / 3.0); - - float alpha = texture2D(uSampler, vTextureCoord).a; - - gl_FragColor = vec4(color.rgb * alpha, alpha); -} diff --git a/src/filters/index.js b/src/filters/index.js index 6709e39..54c1a3b 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -9,28 +9,12 @@ * @namespace PIXI.filters */ module.exports = { - AsciiFilter: require('./ascii/AsciiFilter'), - BloomFilter: require('./bloom/BloomFilter'), - ConvolutionFilter: require('./convolution/ConvolutionFilter'), - CrossHatchFilter: require('./crosshatch/CrossHatchFilter'), - DotFilter: require('./dot/DotFilter'), FXAAFilter: require('./fxaa/FXAAFilter'), - // DropShadowFilter: require('./dropshadow/DropShadowFilter'), NoiseFilter: require('./noise/NoiseFilter'), - PixelateFilter: require('./pixelate/PixelateFilter'), - RGBSplitFilter: require('./rgb/RGBSplitFilter'), - EmbossFilter: require('./emboss/EmbossFilter'), - ShockwaveFilter: require('./shockwave/ShockwaveFilter'), - // SmartBlurFilter: require('./blur/SmartBlurFilter'), - TiltShiftFilter: require('./tiltshift/TiltShiftFilter'), - // TiltShiftXFilter: require('./tiltshift/TiltShiftXFilter'), - //TiltShiftYFilter: require('./tiltshift/TiltShiftYFilter'), DisplacementFilter: require('./displacement/DisplacementFilter'), BlurFilter: require('./blur/BlurFilter'), BlurXFilter: require('./blur/BlurXFilter'), BlurYFilter: require('./blur/BlurYFilter'), - ColorMatrixFilter: require('./colormatrix/ColorMatrixFilter'), - TwistFilter: require('./twist/TwistFilter'), VoidFilter: require('./void/VoidFilter') }; diff --git a/src/filters/ascii/AsciiFilter.js b/src/filters/ascii/AsciiFilter.js deleted file mode 100644 index ac64fd1..0000000 --- a/src/filters/ascii/AsciiFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -// TODO (cengler) - The Y is flipped in this shader for some reason. - -/** - * @author Vico @vicocotea - * original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h - */ - -/** - * An ASCII filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function AsciiFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./ascii.frag') - ); - - this.size = 8; -} - -AsciiFilter.prototype = Object.create(core.Filter.prototype); -AsciiFilter.prototype.constructor = AsciiFilter; -module.exports = AsciiFilter; - -Object.defineProperties(AsciiFilter.prototype, { - /** - * The pixel size used by the filter. - * - * @member {number} - * @memberof PIXI.filters.AsciiFilter# - */ - size: { - get: function () - { - return this.uniforms.pixelSize; - }, - set: function (value) - { - this.uniforms.pixelSize = value; - } - } -}); diff --git a/src/filters/ascii/ascii.frag b/src/filters/ascii/ascii.frag deleted file mode 100644 index 5608d6e..0000000 --- a/src/filters/ascii/ascii.frag +++ /dev/null @@ -1,70 +0,0 @@ -varying vec2 vTextureCoord; - -uniform vec4 filterArea; -uniform float pixelSize; -uniform sampler2D uSampler; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -vec2 getMod(vec2 coord, vec2 size) -{ - return mod( coord , size) / size; -} - -float character(float n, vec2 p) -{ - p = floor(p*vec2(4.0, -4.0) + 2.5); - if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y) - { - if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; - } - return 0.0; -} - -void main() -{ - vec2 coord = mapCoord(vTextureCoord); - - // get the rounded color.. - vec2 pixCoord = pixelate(coord, vec2(pixelSize)); - pixCoord = unmapCoord(pixCoord); - - vec4 color = texture2D(uSampler, pixCoord); - - // determine the character to use - float gray = (color.r + color.g + color.b) / 3.0; - - float n = 65536.0; // . - if (gray > 0.2) n = 65600.0; // : - if (gray > 0.3) n = 332772.0; // * - if (gray > 0.4) n = 15255086.0; // o - if (gray > 0.5) n = 23385164.0; // & - if (gray > 0.6) n = 15252014.0; // 8 - if (gray > 0.7) n = 13199452.0; // @ - if (gray > 0.8) n = 11512810.0; // # - - // get the mod.. - vec2 modd = getMod(coord, vec2(pixelSize)); - - gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); - -} \ No newline at end of file diff --git a/src/filters/bloom/BloomFilter.js b/src/filters/bloom/BloomFilter.js deleted file mode 100644 index 1a9c713..0000000 --- a/src/filters/bloom/BloomFilter.js +++ /dev/null @@ -1,97 +0,0 @@ -var core = require('../../core'), - BlurXFilter = require('../blur/BlurXFilter'), - BlurYFilter = require('../blur/BlurYFilter'); - VoidFilter = require('../void/VoidFilter'); - -/** - * The BloomFilter applies a Gaussian blur to an object. - * The strength of the blur can be set for x- and y-axis separately. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function BloomFilter() -{ - core.Filter.call(this); - - this.blurXFilter = new BlurXFilter(); - this.blurYFilter = new BlurYFilter(); - - this.blurYFilter.blendMode = core.BLEND_MODES.SCREEN; - - this.defaultFilter = new VoidFilter(); -} - -BloomFilter.prototype = Object.create(core.Filter.prototype); -BloomFilter.prototype.constructor = BloomFilter; -module.exports = BloomFilter; - -BloomFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - //TODO - copyTexSubImage2D could be used here? - this.defaultFilter.apply(filterManager, input, output); - - this.blurXFilter.apply(filterManager, input, renderTarget); - this.blurYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(BloomFilter.prototype, { - /** - * Sets the strength of both the blurX and blurY properties simultaneously - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blur: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = this.blurYFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurX property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurX: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurY property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurY: { - get: function () - { - return this.blurYFilter.blur; - }, - set: function (value) - { - this.blurYFilter.blur = value; - } - } -}); diff --git a/src/filters/convolution/ConvolutionFilter.js b/src/filters/convolution/ConvolutionFilter.js deleted file mode 100644 index 51775ba..0000000 --- a/src/filters/convolution/ConvolutionFilter.js +++ /dev/null @@ -1,87 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ConvolutionFilter class applies a matrix convolution filter effect. - * A convolution combines pixels in the input image with neighboring pixels to produce a new image. - * A wide variety of image effects can be achieved through convolutions, including blurring, edge - * detection, sharpening, embossing, and beveling. The matrix should be specified as a 9 point Array. - * See http://docs.gimp.org/en/plug-in-convmatrix.html for more info. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - * @param matrix {number[]} An array of values used for matrix transformation. Specified as a 9 point Array. - * @param width {number} Width of the object you are transforming - * @param height {number} Height of the object you are transforming - */ -function ConvolutionFilter(matrix, width, height) -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./convolution.frag') - ); - - this.matrix = matrix; - this.width = width; - this.height = height; -} - -ConvolutionFilter.prototype = Object.create(core.Filter.prototype); -ConvolutionFilter.prototype.constructor = ConvolutionFilter; -module.exports = ConvolutionFilter; - -Object.defineProperties(ConvolutionFilter.prototype, { - /** - * An array of values used for matrix transformation. Specified as a 9 point Array. - * - * @member {number[]} - * @memberof PIXI.filters.ConvolutionFilter# - */ - matrix: { - get: function () - { - return this.uniforms.matrix; - }, - set: function (value) - { - this.uniforms.matrix = new Float32Array(value); - } - }, - - /** - * Width of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - width: { - get: function () - { - return 1/this.uniforms.texelSize[0]; - }, - set: function (value) - { - this.uniforms.texelSize[0] = 1/value; - } - }, - - /** - * Height of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - height: { - get: function () - { - return 1/this.uniforms.texelSize[1]; - }, - set: function (value) - { - this.uniforms.texelSize[1] = 1/value; - } - } -}); diff --git a/src/filters/convolution/convolution.frag b/src/filters/convolution/convolution.frag deleted file mode 100644 index e6fe7b5..0000000 --- a/src/filters/convolution/convolution.frag +++ /dev/null @@ -1,29 +0,0 @@ -precision mediump float; - -varying mediump vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec2 texelSize; -uniform float matrix[9]; - -void main(void) -{ - vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left - vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center - vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right - - vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left - vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center - vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right - - vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left - vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center - vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right - - gl_FragColor = - c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] + - c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] + - c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8]; - - gl_FragColor.a = c22.a; -} diff --git a/src/filters/crosshatch/CrossHatchFilter.js b/src/filters/crosshatch/CrossHatchFilter.js deleted file mode 100644 index a8da95d..0000000 --- a/src/filters/crosshatch/CrossHatchFilter.js +++ /dev/null @@ -1,23 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * A Cross Hatch effect filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function CrossHatchFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./crosshatch.frag') - ); -} - -CrossHatchFilter.prototype = Object.create(core.Filter.prototype); -CrossHatchFilter.prototype.constructor = CrossHatchFilter; -module.exports = CrossHatchFilter; diff --git a/src/filters/crosshatch/crosshatch.frag b/src/filters/crosshatch/crosshatch.frag deleted file mode 100644 index 635ba4b..0000000 --- a/src/filters/crosshatch/crosshatch.frag +++ /dev/null @@ -1,44 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -void main(void) -{ - float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb); - - gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); - - if (lum < 1.00) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.75) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.50) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.3) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } -} diff --git a/src/filters/dot/DotFilter.js b/src/filters/dot/DotFilter.js deleted file mode 100644 index d2bc544..0000000 --- a/src/filters/dot/DotFilter.js +++ /dev/null @@ -1,66 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * @author Mat Groves http://matgroves.com/ @Doormat23 - * original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/fun/dotscreen.js - */ - -/** - * This filter applies a dotscreen effect making display objects appear to be made out of - * black and white halftone dots like an old printer. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function DotFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./dot.frag') - ); - - this.scale = 1; - this.angle = 5; -} - -DotFilter.prototype = Object.create(core.Filter.prototype); -DotFilter.prototype.constructor = DotFilter; -module.exports = DotFilter; - -Object.defineProperties(DotFilter.prototype, { - /** - * The scale of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - scale: { - get: function () - { - return this.uniforms.scale; - }, - set: function (value) - { - this.uniforms.scale = value; - } - }, - - /** - * The radius of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - angle: { - get: function () - { - return this.uniforms.angle; - }, - set: function (value) - { - this.uniforms.angle = value; - } - } -}); diff --git a/src/filters/dot/dot.frag b/src/filters/dot/dot.frag deleted file mode 100644 index 91341b1..0000000 --- a/src/filters/dot/dot.frag +++ /dev/null @@ -1,28 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; -varying vec4 vColor; - -uniform vec4 filterArea; -uniform sampler2D uSampler; - -uniform float angle; -uniform float scale; - -float pattern() -{ - float s = sin(angle), c = cos(angle); - vec2 tex = vTextureCoord * filterArea.xy; - vec2 point = vec2( - c * tex.x - s * tex.y, - s * tex.x + c * tex.y - ) * scale; - return (sin(point.x) * sin(point.y)) * 4.0; -} - -void main() -{ - vec4 color = texture2D(uSampler, vTextureCoord); - float average = (color.r + color.g + color.b) / 3.0; - gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a); -} diff --git a/src/filters/emboss/EmbossFilter.js b/src/filters/emboss/EmbossFilter.js deleted file mode 100644 index 0468d1f..0000000 --- a/src/filters/emboss/EmbossFilter.js +++ /dev/null @@ -1,46 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function EmbossFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./emboss.frag') - ); - - this.strength = 5; -} - -EmbossFilter.prototype = Object.create(core.Filter.prototype); -EmbossFilter.prototype.constructor = EmbossFilter; -module.exports = EmbossFilter; - -Object.defineProperties(EmbossFilter.prototype, { - /** - * Strength of Emboss. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.EmbossFilter# - */ - strength: { - get: function () - { - return this.uniforms.strength; - }, - set: function (value) - { - this.uniforms.strength = value; - } - }, - - -}); diff --git a/src/filters/emboss/emboss.frag b/src/filters/emboss/emboss.frag deleted file mode 100644 index 28b14d9..0000000 --- a/src/filters/emboss/emboss.frag +++ /dev/null @@ -1,26 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform float strength; -uniform vec4 filterArea; - - -void main(void) -{ - vec2 onePixel = vec2(1.0 / filterArea); - - vec4 color; - - color.rgb = vec3(0.5); - - color -= texture2D(uSampler, vTextureCoord - onePixel) * strength; - color += texture2D(uSampler, vTextureCoord + onePixel) * strength; - - color.rgb = vec3((color.r + color.g + color.b) / 3.0); - - float alpha = texture2D(uSampler, vTextureCoord).a; - - gl_FragColor = vec4(color.rgb * alpha, alpha); -} diff --git a/src/filters/index.js b/src/filters/index.js index 6709e39..54c1a3b 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -9,28 +9,12 @@ * @namespace PIXI.filters */ module.exports = { - AsciiFilter: require('./ascii/AsciiFilter'), - BloomFilter: require('./bloom/BloomFilter'), - ConvolutionFilter: require('./convolution/ConvolutionFilter'), - CrossHatchFilter: require('./crosshatch/CrossHatchFilter'), - DotFilter: require('./dot/DotFilter'), FXAAFilter: require('./fxaa/FXAAFilter'), - // DropShadowFilter: require('./dropshadow/DropShadowFilter'), NoiseFilter: require('./noise/NoiseFilter'), - PixelateFilter: require('./pixelate/PixelateFilter'), - RGBSplitFilter: require('./rgb/RGBSplitFilter'), - EmbossFilter: require('./emboss/EmbossFilter'), - ShockwaveFilter: require('./shockwave/ShockwaveFilter'), - // SmartBlurFilter: require('./blur/SmartBlurFilter'), - TiltShiftFilter: require('./tiltshift/TiltShiftFilter'), - // TiltShiftXFilter: require('./tiltshift/TiltShiftXFilter'), - //TiltShiftYFilter: require('./tiltshift/TiltShiftYFilter'), DisplacementFilter: require('./displacement/DisplacementFilter'), BlurFilter: require('./blur/BlurFilter'), BlurXFilter: require('./blur/BlurXFilter'), BlurYFilter: require('./blur/BlurYFilter'), - ColorMatrixFilter: require('./colormatrix/ColorMatrixFilter'), - TwistFilter: require('./twist/TwistFilter'), VoidFilter: require('./void/VoidFilter') }; diff --git a/src/filters/pixelate/PixelateFilter.js b/src/filters/pixelate/PixelateFilter.js deleted file mode 100644 index 6d5a1f2..0000000 --- a/src/filters/pixelate/PixelateFilter.js +++ /dev/null @@ -1,47 +0,0 @@ -var core = require('../../core'); -// @see https://github.com/substack/brfs/issues/25 -var glslify = require('glslify'); - -/** - * This filter applies a pixelate effect making display objects appear 'blocky'. - * - * @class - * @extends PIXI.AbstractFilter - * @memberof PIXI.filters - */ -function PixelateFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./pixelate.frag') - ); - - this.size = [0,0]; - -} - -PixelateFilter.prototype = Object.create(core.Filter.prototype); -PixelateFilter.prototype.constructor = PixelateFilter; -module.exports = PixelateFilter; - -Object.defineProperties(PixelateFilter.prototype, { - /** - * This a point that describes the size of the blocks. - * x is the width of the block and y is the height. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.PixelateFilter# - */ - size: { - get: function () - { - return this.uniforms.size; - }, - set: function (value) - { - this.uniforms.size.value = value; - } - } -}); diff --git a/src/filters/ascii/AsciiFilter.js b/src/filters/ascii/AsciiFilter.js deleted file mode 100644 index ac64fd1..0000000 --- a/src/filters/ascii/AsciiFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -// TODO (cengler) - The Y is flipped in this shader for some reason. - -/** - * @author Vico @vicocotea - * original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h - */ - -/** - * An ASCII filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function AsciiFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./ascii.frag') - ); - - this.size = 8; -} - -AsciiFilter.prototype = Object.create(core.Filter.prototype); -AsciiFilter.prototype.constructor = AsciiFilter; -module.exports = AsciiFilter; - -Object.defineProperties(AsciiFilter.prototype, { - /** - * The pixel size used by the filter. - * - * @member {number} - * @memberof PIXI.filters.AsciiFilter# - */ - size: { - get: function () - { - return this.uniforms.pixelSize; - }, - set: function (value) - { - this.uniforms.pixelSize = value; - } - } -}); diff --git a/src/filters/ascii/ascii.frag b/src/filters/ascii/ascii.frag deleted file mode 100644 index 5608d6e..0000000 --- a/src/filters/ascii/ascii.frag +++ /dev/null @@ -1,70 +0,0 @@ -varying vec2 vTextureCoord; - -uniform vec4 filterArea; -uniform float pixelSize; -uniform sampler2D uSampler; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -vec2 getMod(vec2 coord, vec2 size) -{ - return mod( coord , size) / size; -} - -float character(float n, vec2 p) -{ - p = floor(p*vec2(4.0, -4.0) + 2.5); - if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y) - { - if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; - } - return 0.0; -} - -void main() -{ - vec2 coord = mapCoord(vTextureCoord); - - // get the rounded color.. - vec2 pixCoord = pixelate(coord, vec2(pixelSize)); - pixCoord = unmapCoord(pixCoord); - - vec4 color = texture2D(uSampler, pixCoord); - - // determine the character to use - float gray = (color.r + color.g + color.b) / 3.0; - - float n = 65536.0; // . - if (gray > 0.2) n = 65600.0; // : - if (gray > 0.3) n = 332772.0; // * - if (gray > 0.4) n = 15255086.0; // o - if (gray > 0.5) n = 23385164.0; // & - if (gray > 0.6) n = 15252014.0; // 8 - if (gray > 0.7) n = 13199452.0; // @ - if (gray > 0.8) n = 11512810.0; // # - - // get the mod.. - vec2 modd = getMod(coord, vec2(pixelSize)); - - gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); - -} \ No newline at end of file diff --git a/src/filters/bloom/BloomFilter.js b/src/filters/bloom/BloomFilter.js deleted file mode 100644 index 1a9c713..0000000 --- a/src/filters/bloom/BloomFilter.js +++ /dev/null @@ -1,97 +0,0 @@ -var core = require('../../core'), - BlurXFilter = require('../blur/BlurXFilter'), - BlurYFilter = require('../blur/BlurYFilter'); - VoidFilter = require('../void/VoidFilter'); - -/** - * The BloomFilter applies a Gaussian blur to an object. - * The strength of the blur can be set for x- and y-axis separately. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function BloomFilter() -{ - core.Filter.call(this); - - this.blurXFilter = new BlurXFilter(); - this.blurYFilter = new BlurYFilter(); - - this.blurYFilter.blendMode = core.BLEND_MODES.SCREEN; - - this.defaultFilter = new VoidFilter(); -} - -BloomFilter.prototype = Object.create(core.Filter.prototype); -BloomFilter.prototype.constructor = BloomFilter; -module.exports = BloomFilter; - -BloomFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - //TODO - copyTexSubImage2D could be used here? - this.defaultFilter.apply(filterManager, input, output); - - this.blurXFilter.apply(filterManager, input, renderTarget); - this.blurYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(BloomFilter.prototype, { - /** - * Sets the strength of both the blurX and blurY properties simultaneously - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blur: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = this.blurYFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurX property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurX: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurY property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurY: { - get: function () - { - return this.blurYFilter.blur; - }, - set: function (value) - { - this.blurYFilter.blur = value; - } - } -}); diff --git a/src/filters/convolution/ConvolutionFilter.js b/src/filters/convolution/ConvolutionFilter.js deleted file mode 100644 index 51775ba..0000000 --- a/src/filters/convolution/ConvolutionFilter.js +++ /dev/null @@ -1,87 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ConvolutionFilter class applies a matrix convolution filter effect. - * A convolution combines pixels in the input image with neighboring pixels to produce a new image. - * A wide variety of image effects can be achieved through convolutions, including blurring, edge - * detection, sharpening, embossing, and beveling. The matrix should be specified as a 9 point Array. - * See http://docs.gimp.org/en/plug-in-convmatrix.html for more info. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - * @param matrix {number[]} An array of values used for matrix transformation. Specified as a 9 point Array. - * @param width {number} Width of the object you are transforming - * @param height {number} Height of the object you are transforming - */ -function ConvolutionFilter(matrix, width, height) -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./convolution.frag') - ); - - this.matrix = matrix; - this.width = width; - this.height = height; -} - -ConvolutionFilter.prototype = Object.create(core.Filter.prototype); -ConvolutionFilter.prototype.constructor = ConvolutionFilter; -module.exports = ConvolutionFilter; - -Object.defineProperties(ConvolutionFilter.prototype, { - /** - * An array of values used for matrix transformation. Specified as a 9 point Array. - * - * @member {number[]} - * @memberof PIXI.filters.ConvolutionFilter# - */ - matrix: { - get: function () - { - return this.uniforms.matrix; - }, - set: function (value) - { - this.uniforms.matrix = new Float32Array(value); - } - }, - - /** - * Width of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - width: { - get: function () - { - return 1/this.uniforms.texelSize[0]; - }, - set: function (value) - { - this.uniforms.texelSize[0] = 1/value; - } - }, - - /** - * Height of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - height: { - get: function () - { - return 1/this.uniforms.texelSize[1]; - }, - set: function (value) - { - this.uniforms.texelSize[1] = 1/value; - } - } -}); diff --git a/src/filters/convolution/convolution.frag b/src/filters/convolution/convolution.frag deleted file mode 100644 index e6fe7b5..0000000 --- a/src/filters/convolution/convolution.frag +++ /dev/null @@ -1,29 +0,0 @@ -precision mediump float; - -varying mediump vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec2 texelSize; -uniform float matrix[9]; - -void main(void) -{ - vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left - vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center - vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right - - vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left - vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center - vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right - - vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left - vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center - vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right - - gl_FragColor = - c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] + - c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] + - c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8]; - - gl_FragColor.a = c22.a; -} diff --git a/src/filters/crosshatch/CrossHatchFilter.js b/src/filters/crosshatch/CrossHatchFilter.js deleted file mode 100644 index a8da95d..0000000 --- a/src/filters/crosshatch/CrossHatchFilter.js +++ /dev/null @@ -1,23 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * A Cross Hatch effect filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function CrossHatchFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./crosshatch.frag') - ); -} - -CrossHatchFilter.prototype = Object.create(core.Filter.prototype); -CrossHatchFilter.prototype.constructor = CrossHatchFilter; -module.exports = CrossHatchFilter; diff --git a/src/filters/crosshatch/crosshatch.frag b/src/filters/crosshatch/crosshatch.frag deleted file mode 100644 index 635ba4b..0000000 --- a/src/filters/crosshatch/crosshatch.frag +++ /dev/null @@ -1,44 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -void main(void) -{ - float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb); - - gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); - - if (lum < 1.00) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.75) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.50) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.3) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } -} diff --git a/src/filters/dot/DotFilter.js b/src/filters/dot/DotFilter.js deleted file mode 100644 index d2bc544..0000000 --- a/src/filters/dot/DotFilter.js +++ /dev/null @@ -1,66 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * @author Mat Groves http://matgroves.com/ @Doormat23 - * original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/fun/dotscreen.js - */ - -/** - * This filter applies a dotscreen effect making display objects appear to be made out of - * black and white halftone dots like an old printer. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function DotFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./dot.frag') - ); - - this.scale = 1; - this.angle = 5; -} - -DotFilter.prototype = Object.create(core.Filter.prototype); -DotFilter.prototype.constructor = DotFilter; -module.exports = DotFilter; - -Object.defineProperties(DotFilter.prototype, { - /** - * The scale of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - scale: { - get: function () - { - return this.uniforms.scale; - }, - set: function (value) - { - this.uniforms.scale = value; - } - }, - - /** - * The radius of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - angle: { - get: function () - { - return this.uniforms.angle; - }, - set: function (value) - { - this.uniforms.angle = value; - } - } -}); diff --git a/src/filters/dot/dot.frag b/src/filters/dot/dot.frag deleted file mode 100644 index 91341b1..0000000 --- a/src/filters/dot/dot.frag +++ /dev/null @@ -1,28 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; -varying vec4 vColor; - -uniform vec4 filterArea; -uniform sampler2D uSampler; - -uniform float angle; -uniform float scale; - -float pattern() -{ - float s = sin(angle), c = cos(angle); - vec2 tex = vTextureCoord * filterArea.xy; - vec2 point = vec2( - c * tex.x - s * tex.y, - s * tex.x + c * tex.y - ) * scale; - return (sin(point.x) * sin(point.y)) * 4.0; -} - -void main() -{ - vec4 color = texture2D(uSampler, vTextureCoord); - float average = (color.r + color.g + color.b) / 3.0; - gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a); -} diff --git a/src/filters/emboss/EmbossFilter.js b/src/filters/emboss/EmbossFilter.js deleted file mode 100644 index 0468d1f..0000000 --- a/src/filters/emboss/EmbossFilter.js +++ /dev/null @@ -1,46 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function EmbossFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./emboss.frag') - ); - - this.strength = 5; -} - -EmbossFilter.prototype = Object.create(core.Filter.prototype); -EmbossFilter.prototype.constructor = EmbossFilter; -module.exports = EmbossFilter; - -Object.defineProperties(EmbossFilter.prototype, { - /** - * Strength of Emboss. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.EmbossFilter# - */ - strength: { - get: function () - { - return this.uniforms.strength; - }, - set: function (value) - { - this.uniforms.strength = value; - } - }, - - -}); diff --git a/src/filters/emboss/emboss.frag b/src/filters/emboss/emboss.frag deleted file mode 100644 index 28b14d9..0000000 --- a/src/filters/emboss/emboss.frag +++ /dev/null @@ -1,26 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform float strength; -uniform vec4 filterArea; - - -void main(void) -{ - vec2 onePixel = vec2(1.0 / filterArea); - - vec4 color; - - color.rgb = vec3(0.5); - - color -= texture2D(uSampler, vTextureCoord - onePixel) * strength; - color += texture2D(uSampler, vTextureCoord + onePixel) * strength; - - color.rgb = vec3((color.r + color.g + color.b) / 3.0); - - float alpha = texture2D(uSampler, vTextureCoord).a; - - gl_FragColor = vec4(color.rgb * alpha, alpha); -} diff --git a/src/filters/index.js b/src/filters/index.js index 6709e39..54c1a3b 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -9,28 +9,12 @@ * @namespace PIXI.filters */ module.exports = { - AsciiFilter: require('./ascii/AsciiFilter'), - BloomFilter: require('./bloom/BloomFilter'), - ConvolutionFilter: require('./convolution/ConvolutionFilter'), - CrossHatchFilter: require('./crosshatch/CrossHatchFilter'), - DotFilter: require('./dot/DotFilter'), FXAAFilter: require('./fxaa/FXAAFilter'), - // DropShadowFilter: require('./dropshadow/DropShadowFilter'), NoiseFilter: require('./noise/NoiseFilter'), - PixelateFilter: require('./pixelate/PixelateFilter'), - RGBSplitFilter: require('./rgb/RGBSplitFilter'), - EmbossFilter: require('./emboss/EmbossFilter'), - ShockwaveFilter: require('./shockwave/ShockwaveFilter'), - // SmartBlurFilter: require('./blur/SmartBlurFilter'), - TiltShiftFilter: require('./tiltshift/TiltShiftFilter'), - // TiltShiftXFilter: require('./tiltshift/TiltShiftXFilter'), - //TiltShiftYFilter: require('./tiltshift/TiltShiftYFilter'), DisplacementFilter: require('./displacement/DisplacementFilter'), BlurFilter: require('./blur/BlurFilter'), BlurXFilter: require('./blur/BlurXFilter'), BlurYFilter: require('./blur/BlurYFilter'), - ColorMatrixFilter: require('./colormatrix/ColorMatrixFilter'), - TwistFilter: require('./twist/TwistFilter'), VoidFilter: require('./void/VoidFilter') }; diff --git a/src/filters/pixelate/PixelateFilter.js b/src/filters/pixelate/PixelateFilter.js deleted file mode 100644 index 6d5a1f2..0000000 --- a/src/filters/pixelate/PixelateFilter.js +++ /dev/null @@ -1,47 +0,0 @@ -var core = require('../../core'); -// @see https://github.com/substack/brfs/issues/25 -var glslify = require('glslify'); - -/** - * This filter applies a pixelate effect making display objects appear 'blocky'. - * - * @class - * @extends PIXI.AbstractFilter - * @memberof PIXI.filters - */ -function PixelateFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./pixelate.frag') - ); - - this.size = [0,0]; - -} - -PixelateFilter.prototype = Object.create(core.Filter.prototype); -PixelateFilter.prototype.constructor = PixelateFilter; -module.exports = PixelateFilter; - -Object.defineProperties(PixelateFilter.prototype, { - /** - * This a point that describes the size of the blocks. - * x is the width of the block and y is the height. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.PixelateFilter# - */ - size: { - get: function () - { - return this.uniforms.size; - }, - set: function (value) - { - this.uniforms.size.value = value; - } - } -}); diff --git a/src/filters/pixelate/pixelate.frag b/src/filters/pixelate/pixelate.frag deleted file mode 100644 index 80ad2ee..0000000 --- a/src/filters/pixelate/pixelate.frag +++ /dev/null @@ -1,40 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform vec2 size; -uniform sampler2D uSampler; - -uniform vec4 filterArea; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -void main(void) -{ - vec2 coord = mapCoord(vTextureCoord); - - coord = pixelate(coord, size); - - coord = unmapCoord(coord); - - gl_FragColor = texture2D(uSampler, coord); -} diff --git a/src/filters/ascii/AsciiFilter.js b/src/filters/ascii/AsciiFilter.js deleted file mode 100644 index ac64fd1..0000000 --- a/src/filters/ascii/AsciiFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -// TODO (cengler) - The Y is flipped in this shader for some reason. - -/** - * @author Vico @vicocotea - * original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h - */ - -/** - * An ASCII filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function AsciiFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./ascii.frag') - ); - - this.size = 8; -} - -AsciiFilter.prototype = Object.create(core.Filter.prototype); -AsciiFilter.prototype.constructor = AsciiFilter; -module.exports = AsciiFilter; - -Object.defineProperties(AsciiFilter.prototype, { - /** - * The pixel size used by the filter. - * - * @member {number} - * @memberof PIXI.filters.AsciiFilter# - */ - size: { - get: function () - { - return this.uniforms.pixelSize; - }, - set: function (value) - { - this.uniforms.pixelSize = value; - } - } -}); diff --git a/src/filters/ascii/ascii.frag b/src/filters/ascii/ascii.frag deleted file mode 100644 index 5608d6e..0000000 --- a/src/filters/ascii/ascii.frag +++ /dev/null @@ -1,70 +0,0 @@ -varying vec2 vTextureCoord; - -uniform vec4 filterArea; -uniform float pixelSize; -uniform sampler2D uSampler; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -vec2 getMod(vec2 coord, vec2 size) -{ - return mod( coord , size) / size; -} - -float character(float n, vec2 p) -{ - p = floor(p*vec2(4.0, -4.0) + 2.5); - if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y) - { - if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; - } - return 0.0; -} - -void main() -{ - vec2 coord = mapCoord(vTextureCoord); - - // get the rounded color.. - vec2 pixCoord = pixelate(coord, vec2(pixelSize)); - pixCoord = unmapCoord(pixCoord); - - vec4 color = texture2D(uSampler, pixCoord); - - // determine the character to use - float gray = (color.r + color.g + color.b) / 3.0; - - float n = 65536.0; // . - if (gray > 0.2) n = 65600.0; // : - if (gray > 0.3) n = 332772.0; // * - if (gray > 0.4) n = 15255086.0; // o - if (gray > 0.5) n = 23385164.0; // & - if (gray > 0.6) n = 15252014.0; // 8 - if (gray > 0.7) n = 13199452.0; // @ - if (gray > 0.8) n = 11512810.0; // # - - // get the mod.. - vec2 modd = getMod(coord, vec2(pixelSize)); - - gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); - -} \ No newline at end of file diff --git a/src/filters/bloom/BloomFilter.js b/src/filters/bloom/BloomFilter.js deleted file mode 100644 index 1a9c713..0000000 --- a/src/filters/bloom/BloomFilter.js +++ /dev/null @@ -1,97 +0,0 @@ -var core = require('../../core'), - BlurXFilter = require('../blur/BlurXFilter'), - BlurYFilter = require('../blur/BlurYFilter'); - VoidFilter = require('../void/VoidFilter'); - -/** - * The BloomFilter applies a Gaussian blur to an object. - * The strength of the blur can be set for x- and y-axis separately. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function BloomFilter() -{ - core.Filter.call(this); - - this.blurXFilter = new BlurXFilter(); - this.blurYFilter = new BlurYFilter(); - - this.blurYFilter.blendMode = core.BLEND_MODES.SCREEN; - - this.defaultFilter = new VoidFilter(); -} - -BloomFilter.prototype = Object.create(core.Filter.prototype); -BloomFilter.prototype.constructor = BloomFilter; -module.exports = BloomFilter; - -BloomFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - //TODO - copyTexSubImage2D could be used here? - this.defaultFilter.apply(filterManager, input, output); - - this.blurXFilter.apply(filterManager, input, renderTarget); - this.blurYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(BloomFilter.prototype, { - /** - * Sets the strength of both the blurX and blurY properties simultaneously - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blur: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = this.blurYFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurX property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurX: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurY property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurY: { - get: function () - { - return this.blurYFilter.blur; - }, - set: function (value) - { - this.blurYFilter.blur = value; - } - } -}); diff --git a/src/filters/convolution/ConvolutionFilter.js b/src/filters/convolution/ConvolutionFilter.js deleted file mode 100644 index 51775ba..0000000 --- a/src/filters/convolution/ConvolutionFilter.js +++ /dev/null @@ -1,87 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ConvolutionFilter class applies a matrix convolution filter effect. - * A convolution combines pixels in the input image with neighboring pixels to produce a new image. - * A wide variety of image effects can be achieved through convolutions, including blurring, edge - * detection, sharpening, embossing, and beveling. The matrix should be specified as a 9 point Array. - * See http://docs.gimp.org/en/plug-in-convmatrix.html for more info. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - * @param matrix {number[]} An array of values used for matrix transformation. Specified as a 9 point Array. - * @param width {number} Width of the object you are transforming - * @param height {number} Height of the object you are transforming - */ -function ConvolutionFilter(matrix, width, height) -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./convolution.frag') - ); - - this.matrix = matrix; - this.width = width; - this.height = height; -} - -ConvolutionFilter.prototype = Object.create(core.Filter.prototype); -ConvolutionFilter.prototype.constructor = ConvolutionFilter; -module.exports = ConvolutionFilter; - -Object.defineProperties(ConvolutionFilter.prototype, { - /** - * An array of values used for matrix transformation. Specified as a 9 point Array. - * - * @member {number[]} - * @memberof PIXI.filters.ConvolutionFilter# - */ - matrix: { - get: function () - { - return this.uniforms.matrix; - }, - set: function (value) - { - this.uniforms.matrix = new Float32Array(value); - } - }, - - /** - * Width of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - width: { - get: function () - { - return 1/this.uniforms.texelSize[0]; - }, - set: function (value) - { - this.uniforms.texelSize[0] = 1/value; - } - }, - - /** - * Height of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - height: { - get: function () - { - return 1/this.uniforms.texelSize[1]; - }, - set: function (value) - { - this.uniforms.texelSize[1] = 1/value; - } - } -}); diff --git a/src/filters/convolution/convolution.frag b/src/filters/convolution/convolution.frag deleted file mode 100644 index e6fe7b5..0000000 --- a/src/filters/convolution/convolution.frag +++ /dev/null @@ -1,29 +0,0 @@ -precision mediump float; - -varying mediump vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec2 texelSize; -uniform float matrix[9]; - -void main(void) -{ - vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left - vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center - vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right - - vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left - vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center - vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right - - vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left - vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center - vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right - - gl_FragColor = - c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] + - c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] + - c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8]; - - gl_FragColor.a = c22.a; -} diff --git a/src/filters/crosshatch/CrossHatchFilter.js b/src/filters/crosshatch/CrossHatchFilter.js deleted file mode 100644 index a8da95d..0000000 --- a/src/filters/crosshatch/CrossHatchFilter.js +++ /dev/null @@ -1,23 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * A Cross Hatch effect filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function CrossHatchFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./crosshatch.frag') - ); -} - -CrossHatchFilter.prototype = Object.create(core.Filter.prototype); -CrossHatchFilter.prototype.constructor = CrossHatchFilter; -module.exports = CrossHatchFilter; diff --git a/src/filters/crosshatch/crosshatch.frag b/src/filters/crosshatch/crosshatch.frag deleted file mode 100644 index 635ba4b..0000000 --- a/src/filters/crosshatch/crosshatch.frag +++ /dev/null @@ -1,44 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -void main(void) -{ - float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb); - - gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); - - if (lum < 1.00) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.75) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.50) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.3) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } -} diff --git a/src/filters/dot/DotFilter.js b/src/filters/dot/DotFilter.js deleted file mode 100644 index d2bc544..0000000 --- a/src/filters/dot/DotFilter.js +++ /dev/null @@ -1,66 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * @author Mat Groves http://matgroves.com/ @Doormat23 - * original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/fun/dotscreen.js - */ - -/** - * This filter applies a dotscreen effect making display objects appear to be made out of - * black and white halftone dots like an old printer. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function DotFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./dot.frag') - ); - - this.scale = 1; - this.angle = 5; -} - -DotFilter.prototype = Object.create(core.Filter.prototype); -DotFilter.prototype.constructor = DotFilter; -module.exports = DotFilter; - -Object.defineProperties(DotFilter.prototype, { - /** - * The scale of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - scale: { - get: function () - { - return this.uniforms.scale; - }, - set: function (value) - { - this.uniforms.scale = value; - } - }, - - /** - * The radius of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - angle: { - get: function () - { - return this.uniforms.angle; - }, - set: function (value) - { - this.uniforms.angle = value; - } - } -}); diff --git a/src/filters/dot/dot.frag b/src/filters/dot/dot.frag deleted file mode 100644 index 91341b1..0000000 --- a/src/filters/dot/dot.frag +++ /dev/null @@ -1,28 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; -varying vec4 vColor; - -uniform vec4 filterArea; -uniform sampler2D uSampler; - -uniform float angle; -uniform float scale; - -float pattern() -{ - float s = sin(angle), c = cos(angle); - vec2 tex = vTextureCoord * filterArea.xy; - vec2 point = vec2( - c * tex.x - s * tex.y, - s * tex.x + c * tex.y - ) * scale; - return (sin(point.x) * sin(point.y)) * 4.0; -} - -void main() -{ - vec4 color = texture2D(uSampler, vTextureCoord); - float average = (color.r + color.g + color.b) / 3.0; - gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a); -} diff --git a/src/filters/emboss/EmbossFilter.js b/src/filters/emboss/EmbossFilter.js deleted file mode 100644 index 0468d1f..0000000 --- a/src/filters/emboss/EmbossFilter.js +++ /dev/null @@ -1,46 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function EmbossFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./emboss.frag') - ); - - this.strength = 5; -} - -EmbossFilter.prototype = Object.create(core.Filter.prototype); -EmbossFilter.prototype.constructor = EmbossFilter; -module.exports = EmbossFilter; - -Object.defineProperties(EmbossFilter.prototype, { - /** - * Strength of Emboss. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.EmbossFilter# - */ - strength: { - get: function () - { - return this.uniforms.strength; - }, - set: function (value) - { - this.uniforms.strength = value; - } - }, - - -}); diff --git a/src/filters/emboss/emboss.frag b/src/filters/emboss/emboss.frag deleted file mode 100644 index 28b14d9..0000000 --- a/src/filters/emboss/emboss.frag +++ /dev/null @@ -1,26 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform float strength; -uniform vec4 filterArea; - - -void main(void) -{ - vec2 onePixel = vec2(1.0 / filterArea); - - vec4 color; - - color.rgb = vec3(0.5); - - color -= texture2D(uSampler, vTextureCoord - onePixel) * strength; - color += texture2D(uSampler, vTextureCoord + onePixel) * strength; - - color.rgb = vec3((color.r + color.g + color.b) / 3.0); - - float alpha = texture2D(uSampler, vTextureCoord).a; - - gl_FragColor = vec4(color.rgb * alpha, alpha); -} diff --git a/src/filters/index.js b/src/filters/index.js index 6709e39..54c1a3b 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -9,28 +9,12 @@ * @namespace PIXI.filters */ module.exports = { - AsciiFilter: require('./ascii/AsciiFilter'), - BloomFilter: require('./bloom/BloomFilter'), - ConvolutionFilter: require('./convolution/ConvolutionFilter'), - CrossHatchFilter: require('./crosshatch/CrossHatchFilter'), - DotFilter: require('./dot/DotFilter'), FXAAFilter: require('./fxaa/FXAAFilter'), - // DropShadowFilter: require('./dropshadow/DropShadowFilter'), NoiseFilter: require('./noise/NoiseFilter'), - PixelateFilter: require('./pixelate/PixelateFilter'), - RGBSplitFilter: require('./rgb/RGBSplitFilter'), - EmbossFilter: require('./emboss/EmbossFilter'), - ShockwaveFilter: require('./shockwave/ShockwaveFilter'), - // SmartBlurFilter: require('./blur/SmartBlurFilter'), - TiltShiftFilter: require('./tiltshift/TiltShiftFilter'), - // TiltShiftXFilter: require('./tiltshift/TiltShiftXFilter'), - //TiltShiftYFilter: require('./tiltshift/TiltShiftYFilter'), DisplacementFilter: require('./displacement/DisplacementFilter'), BlurFilter: require('./blur/BlurFilter'), BlurXFilter: require('./blur/BlurXFilter'), BlurYFilter: require('./blur/BlurYFilter'), - ColorMatrixFilter: require('./colormatrix/ColorMatrixFilter'), - TwistFilter: require('./twist/TwistFilter'), VoidFilter: require('./void/VoidFilter') }; diff --git a/src/filters/pixelate/PixelateFilter.js b/src/filters/pixelate/PixelateFilter.js deleted file mode 100644 index 6d5a1f2..0000000 --- a/src/filters/pixelate/PixelateFilter.js +++ /dev/null @@ -1,47 +0,0 @@ -var core = require('../../core'); -// @see https://github.com/substack/brfs/issues/25 -var glslify = require('glslify'); - -/** - * This filter applies a pixelate effect making display objects appear 'blocky'. - * - * @class - * @extends PIXI.AbstractFilter - * @memberof PIXI.filters - */ -function PixelateFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./pixelate.frag') - ); - - this.size = [0,0]; - -} - -PixelateFilter.prototype = Object.create(core.Filter.prototype); -PixelateFilter.prototype.constructor = PixelateFilter; -module.exports = PixelateFilter; - -Object.defineProperties(PixelateFilter.prototype, { - /** - * This a point that describes the size of the blocks. - * x is the width of the block and y is the height. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.PixelateFilter# - */ - size: { - get: function () - { - return this.uniforms.size; - }, - set: function (value) - { - this.uniforms.size.value = value; - } - } -}); diff --git a/src/filters/pixelate/pixelate.frag b/src/filters/pixelate/pixelate.frag deleted file mode 100644 index 80ad2ee..0000000 --- a/src/filters/pixelate/pixelate.frag +++ /dev/null @@ -1,40 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform vec2 size; -uniform sampler2D uSampler; - -uniform vec4 filterArea; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -void main(void) -{ - vec2 coord = mapCoord(vTextureCoord); - - coord = pixelate(coord, size); - - coord = unmapCoord(coord); - - gl_FragColor = texture2D(uSampler, coord); -} diff --git a/src/filters/rgb/RGBSplitFilter.js b/src/filters/rgb/RGBSplitFilter.js deleted file mode 100644 index 9609514..0000000 --- a/src/filters/rgb/RGBSplitFilter.js +++ /dev/null @@ -1,80 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function RGBSplitFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./rgb-split.frag') - ); - - this.red = [-10, 0]; - this.green = [0, 10]; - this.blue = [0, 0]; -} - -RGBSplitFilter.prototype = Object.create(core.Filter.prototype); -RGBSplitFilter.prototype.constructor = RGBSplitFilter; -module.exports = RGBSplitFilter; - -Object.defineProperties(RGBSplitFilter.prototype, { - /** - * Red channel offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - red: { - get: function () - { - return this.uniforms.red; - }, - set: function (value) - { - this.uniforms.red = value; - } - }, - - /** - * Green channel offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - green: { - get: function () - { - return this.uniforms.green; - }, - set: function (value) - { - this.uniforms.green = value; - } - }, - - /** - * Blue offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - blue: { - get: function () - { - return this.uniforms.blue.value; - }, - set: function (value) - { - this.uniforms.blue.value = value; - } - } -}); diff --git a/src/filters/ascii/AsciiFilter.js b/src/filters/ascii/AsciiFilter.js deleted file mode 100644 index ac64fd1..0000000 --- a/src/filters/ascii/AsciiFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -// TODO (cengler) - The Y is flipped in this shader for some reason. - -/** - * @author Vico @vicocotea - * original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h - */ - -/** - * An ASCII filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function AsciiFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./ascii.frag') - ); - - this.size = 8; -} - -AsciiFilter.prototype = Object.create(core.Filter.prototype); -AsciiFilter.prototype.constructor = AsciiFilter; -module.exports = AsciiFilter; - -Object.defineProperties(AsciiFilter.prototype, { - /** - * The pixel size used by the filter. - * - * @member {number} - * @memberof PIXI.filters.AsciiFilter# - */ - size: { - get: function () - { - return this.uniforms.pixelSize; - }, - set: function (value) - { - this.uniforms.pixelSize = value; - } - } -}); diff --git a/src/filters/ascii/ascii.frag b/src/filters/ascii/ascii.frag deleted file mode 100644 index 5608d6e..0000000 --- a/src/filters/ascii/ascii.frag +++ /dev/null @@ -1,70 +0,0 @@ -varying vec2 vTextureCoord; - -uniform vec4 filterArea; -uniform float pixelSize; -uniform sampler2D uSampler; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -vec2 getMod(vec2 coord, vec2 size) -{ - return mod( coord , size) / size; -} - -float character(float n, vec2 p) -{ - p = floor(p*vec2(4.0, -4.0) + 2.5); - if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y) - { - if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; - } - return 0.0; -} - -void main() -{ - vec2 coord = mapCoord(vTextureCoord); - - // get the rounded color.. - vec2 pixCoord = pixelate(coord, vec2(pixelSize)); - pixCoord = unmapCoord(pixCoord); - - vec4 color = texture2D(uSampler, pixCoord); - - // determine the character to use - float gray = (color.r + color.g + color.b) / 3.0; - - float n = 65536.0; // . - if (gray > 0.2) n = 65600.0; // : - if (gray > 0.3) n = 332772.0; // * - if (gray > 0.4) n = 15255086.0; // o - if (gray > 0.5) n = 23385164.0; // & - if (gray > 0.6) n = 15252014.0; // 8 - if (gray > 0.7) n = 13199452.0; // @ - if (gray > 0.8) n = 11512810.0; // # - - // get the mod.. - vec2 modd = getMod(coord, vec2(pixelSize)); - - gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); - -} \ No newline at end of file diff --git a/src/filters/bloom/BloomFilter.js b/src/filters/bloom/BloomFilter.js deleted file mode 100644 index 1a9c713..0000000 --- a/src/filters/bloom/BloomFilter.js +++ /dev/null @@ -1,97 +0,0 @@ -var core = require('../../core'), - BlurXFilter = require('../blur/BlurXFilter'), - BlurYFilter = require('../blur/BlurYFilter'); - VoidFilter = require('../void/VoidFilter'); - -/** - * The BloomFilter applies a Gaussian blur to an object. - * The strength of the blur can be set for x- and y-axis separately. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function BloomFilter() -{ - core.Filter.call(this); - - this.blurXFilter = new BlurXFilter(); - this.blurYFilter = new BlurYFilter(); - - this.blurYFilter.blendMode = core.BLEND_MODES.SCREEN; - - this.defaultFilter = new VoidFilter(); -} - -BloomFilter.prototype = Object.create(core.Filter.prototype); -BloomFilter.prototype.constructor = BloomFilter; -module.exports = BloomFilter; - -BloomFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - //TODO - copyTexSubImage2D could be used here? - this.defaultFilter.apply(filterManager, input, output); - - this.blurXFilter.apply(filterManager, input, renderTarget); - this.blurYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(BloomFilter.prototype, { - /** - * Sets the strength of both the blurX and blurY properties simultaneously - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blur: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = this.blurYFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurX property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurX: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurY property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurY: { - get: function () - { - return this.blurYFilter.blur; - }, - set: function (value) - { - this.blurYFilter.blur = value; - } - } -}); diff --git a/src/filters/convolution/ConvolutionFilter.js b/src/filters/convolution/ConvolutionFilter.js deleted file mode 100644 index 51775ba..0000000 --- a/src/filters/convolution/ConvolutionFilter.js +++ /dev/null @@ -1,87 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ConvolutionFilter class applies a matrix convolution filter effect. - * A convolution combines pixels in the input image with neighboring pixels to produce a new image. - * A wide variety of image effects can be achieved through convolutions, including blurring, edge - * detection, sharpening, embossing, and beveling. The matrix should be specified as a 9 point Array. - * See http://docs.gimp.org/en/plug-in-convmatrix.html for more info. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - * @param matrix {number[]} An array of values used for matrix transformation. Specified as a 9 point Array. - * @param width {number} Width of the object you are transforming - * @param height {number} Height of the object you are transforming - */ -function ConvolutionFilter(matrix, width, height) -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./convolution.frag') - ); - - this.matrix = matrix; - this.width = width; - this.height = height; -} - -ConvolutionFilter.prototype = Object.create(core.Filter.prototype); -ConvolutionFilter.prototype.constructor = ConvolutionFilter; -module.exports = ConvolutionFilter; - -Object.defineProperties(ConvolutionFilter.prototype, { - /** - * An array of values used for matrix transformation. Specified as a 9 point Array. - * - * @member {number[]} - * @memberof PIXI.filters.ConvolutionFilter# - */ - matrix: { - get: function () - { - return this.uniforms.matrix; - }, - set: function (value) - { - this.uniforms.matrix = new Float32Array(value); - } - }, - - /** - * Width of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - width: { - get: function () - { - return 1/this.uniforms.texelSize[0]; - }, - set: function (value) - { - this.uniforms.texelSize[0] = 1/value; - } - }, - - /** - * Height of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - height: { - get: function () - { - return 1/this.uniforms.texelSize[1]; - }, - set: function (value) - { - this.uniforms.texelSize[1] = 1/value; - } - } -}); diff --git a/src/filters/convolution/convolution.frag b/src/filters/convolution/convolution.frag deleted file mode 100644 index e6fe7b5..0000000 --- a/src/filters/convolution/convolution.frag +++ /dev/null @@ -1,29 +0,0 @@ -precision mediump float; - -varying mediump vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec2 texelSize; -uniform float matrix[9]; - -void main(void) -{ - vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left - vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center - vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right - - vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left - vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center - vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right - - vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left - vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center - vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right - - gl_FragColor = - c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] + - c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] + - c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8]; - - gl_FragColor.a = c22.a; -} diff --git a/src/filters/crosshatch/CrossHatchFilter.js b/src/filters/crosshatch/CrossHatchFilter.js deleted file mode 100644 index a8da95d..0000000 --- a/src/filters/crosshatch/CrossHatchFilter.js +++ /dev/null @@ -1,23 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * A Cross Hatch effect filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function CrossHatchFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./crosshatch.frag') - ); -} - -CrossHatchFilter.prototype = Object.create(core.Filter.prototype); -CrossHatchFilter.prototype.constructor = CrossHatchFilter; -module.exports = CrossHatchFilter; diff --git a/src/filters/crosshatch/crosshatch.frag b/src/filters/crosshatch/crosshatch.frag deleted file mode 100644 index 635ba4b..0000000 --- a/src/filters/crosshatch/crosshatch.frag +++ /dev/null @@ -1,44 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -void main(void) -{ - float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb); - - gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); - - if (lum < 1.00) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.75) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.50) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.3) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } -} diff --git a/src/filters/dot/DotFilter.js b/src/filters/dot/DotFilter.js deleted file mode 100644 index d2bc544..0000000 --- a/src/filters/dot/DotFilter.js +++ /dev/null @@ -1,66 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * @author Mat Groves http://matgroves.com/ @Doormat23 - * original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/fun/dotscreen.js - */ - -/** - * This filter applies a dotscreen effect making display objects appear to be made out of - * black and white halftone dots like an old printer. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function DotFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./dot.frag') - ); - - this.scale = 1; - this.angle = 5; -} - -DotFilter.prototype = Object.create(core.Filter.prototype); -DotFilter.prototype.constructor = DotFilter; -module.exports = DotFilter; - -Object.defineProperties(DotFilter.prototype, { - /** - * The scale of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - scale: { - get: function () - { - return this.uniforms.scale; - }, - set: function (value) - { - this.uniforms.scale = value; - } - }, - - /** - * The radius of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - angle: { - get: function () - { - return this.uniforms.angle; - }, - set: function (value) - { - this.uniforms.angle = value; - } - } -}); diff --git a/src/filters/dot/dot.frag b/src/filters/dot/dot.frag deleted file mode 100644 index 91341b1..0000000 --- a/src/filters/dot/dot.frag +++ /dev/null @@ -1,28 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; -varying vec4 vColor; - -uniform vec4 filterArea; -uniform sampler2D uSampler; - -uniform float angle; -uniform float scale; - -float pattern() -{ - float s = sin(angle), c = cos(angle); - vec2 tex = vTextureCoord * filterArea.xy; - vec2 point = vec2( - c * tex.x - s * tex.y, - s * tex.x + c * tex.y - ) * scale; - return (sin(point.x) * sin(point.y)) * 4.0; -} - -void main() -{ - vec4 color = texture2D(uSampler, vTextureCoord); - float average = (color.r + color.g + color.b) / 3.0; - gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a); -} diff --git a/src/filters/emboss/EmbossFilter.js b/src/filters/emboss/EmbossFilter.js deleted file mode 100644 index 0468d1f..0000000 --- a/src/filters/emboss/EmbossFilter.js +++ /dev/null @@ -1,46 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function EmbossFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./emboss.frag') - ); - - this.strength = 5; -} - -EmbossFilter.prototype = Object.create(core.Filter.prototype); -EmbossFilter.prototype.constructor = EmbossFilter; -module.exports = EmbossFilter; - -Object.defineProperties(EmbossFilter.prototype, { - /** - * Strength of Emboss. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.EmbossFilter# - */ - strength: { - get: function () - { - return this.uniforms.strength; - }, - set: function (value) - { - this.uniforms.strength = value; - } - }, - - -}); diff --git a/src/filters/emboss/emboss.frag b/src/filters/emboss/emboss.frag deleted file mode 100644 index 28b14d9..0000000 --- a/src/filters/emboss/emboss.frag +++ /dev/null @@ -1,26 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform float strength; -uniform vec4 filterArea; - - -void main(void) -{ - vec2 onePixel = vec2(1.0 / filterArea); - - vec4 color; - - color.rgb = vec3(0.5); - - color -= texture2D(uSampler, vTextureCoord - onePixel) * strength; - color += texture2D(uSampler, vTextureCoord + onePixel) * strength; - - color.rgb = vec3((color.r + color.g + color.b) / 3.0); - - float alpha = texture2D(uSampler, vTextureCoord).a; - - gl_FragColor = vec4(color.rgb * alpha, alpha); -} diff --git a/src/filters/index.js b/src/filters/index.js index 6709e39..54c1a3b 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -9,28 +9,12 @@ * @namespace PIXI.filters */ module.exports = { - AsciiFilter: require('./ascii/AsciiFilter'), - BloomFilter: require('./bloom/BloomFilter'), - ConvolutionFilter: require('./convolution/ConvolutionFilter'), - CrossHatchFilter: require('./crosshatch/CrossHatchFilter'), - DotFilter: require('./dot/DotFilter'), FXAAFilter: require('./fxaa/FXAAFilter'), - // DropShadowFilter: require('./dropshadow/DropShadowFilter'), NoiseFilter: require('./noise/NoiseFilter'), - PixelateFilter: require('./pixelate/PixelateFilter'), - RGBSplitFilter: require('./rgb/RGBSplitFilter'), - EmbossFilter: require('./emboss/EmbossFilter'), - ShockwaveFilter: require('./shockwave/ShockwaveFilter'), - // SmartBlurFilter: require('./blur/SmartBlurFilter'), - TiltShiftFilter: require('./tiltshift/TiltShiftFilter'), - // TiltShiftXFilter: require('./tiltshift/TiltShiftXFilter'), - //TiltShiftYFilter: require('./tiltshift/TiltShiftYFilter'), DisplacementFilter: require('./displacement/DisplacementFilter'), BlurFilter: require('./blur/BlurFilter'), BlurXFilter: require('./blur/BlurXFilter'), BlurYFilter: require('./blur/BlurYFilter'), - ColorMatrixFilter: require('./colormatrix/ColorMatrixFilter'), - TwistFilter: require('./twist/TwistFilter'), VoidFilter: require('./void/VoidFilter') }; diff --git a/src/filters/pixelate/PixelateFilter.js b/src/filters/pixelate/PixelateFilter.js deleted file mode 100644 index 6d5a1f2..0000000 --- a/src/filters/pixelate/PixelateFilter.js +++ /dev/null @@ -1,47 +0,0 @@ -var core = require('../../core'); -// @see https://github.com/substack/brfs/issues/25 -var glslify = require('glslify'); - -/** - * This filter applies a pixelate effect making display objects appear 'blocky'. - * - * @class - * @extends PIXI.AbstractFilter - * @memberof PIXI.filters - */ -function PixelateFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./pixelate.frag') - ); - - this.size = [0,0]; - -} - -PixelateFilter.prototype = Object.create(core.Filter.prototype); -PixelateFilter.prototype.constructor = PixelateFilter; -module.exports = PixelateFilter; - -Object.defineProperties(PixelateFilter.prototype, { - /** - * This a point that describes the size of the blocks. - * x is the width of the block and y is the height. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.PixelateFilter# - */ - size: { - get: function () - { - return this.uniforms.size; - }, - set: function (value) - { - this.uniforms.size.value = value; - } - } -}); diff --git a/src/filters/pixelate/pixelate.frag b/src/filters/pixelate/pixelate.frag deleted file mode 100644 index 80ad2ee..0000000 --- a/src/filters/pixelate/pixelate.frag +++ /dev/null @@ -1,40 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform vec2 size; -uniform sampler2D uSampler; - -uniform vec4 filterArea; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -void main(void) -{ - vec2 coord = mapCoord(vTextureCoord); - - coord = pixelate(coord, size); - - coord = unmapCoord(coord); - - gl_FragColor = texture2D(uSampler, coord); -} diff --git a/src/filters/rgb/RGBSplitFilter.js b/src/filters/rgb/RGBSplitFilter.js deleted file mode 100644 index 9609514..0000000 --- a/src/filters/rgb/RGBSplitFilter.js +++ /dev/null @@ -1,80 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function RGBSplitFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./rgb-split.frag') - ); - - this.red = [-10, 0]; - this.green = [0, 10]; - this.blue = [0, 0]; -} - -RGBSplitFilter.prototype = Object.create(core.Filter.prototype); -RGBSplitFilter.prototype.constructor = RGBSplitFilter; -module.exports = RGBSplitFilter; - -Object.defineProperties(RGBSplitFilter.prototype, { - /** - * Red channel offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - red: { - get: function () - { - return this.uniforms.red; - }, - set: function (value) - { - this.uniforms.red = value; - } - }, - - /** - * Green channel offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - green: { - get: function () - { - return this.uniforms.green; - }, - set: function (value) - { - this.uniforms.green = value; - } - }, - - /** - * Blue offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - blue: { - get: function () - { - return this.uniforms.blue.value; - }, - set: function (value) - { - this.uniforms.blue.value = value; - } - } -}); diff --git a/src/filters/rgb/rgb-split.frag b/src/filters/rgb/rgb-split.frag deleted file mode 100644 index 46fed0f..0000000 --- a/src/filters/rgb/rgb-split.frag +++ /dev/null @@ -1,17 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec4 filterArea; -uniform vec2 red; -uniform vec2 green; -uniform vec2 blue; - -void main(void) -{ - gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/filterArea.xy).r; - gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/filterArea.xy).g; - gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/filterArea.xy).b; - gl_FragColor.a = texture2D(uSampler, vTextureCoord).a; -} diff --git a/src/filters/ascii/AsciiFilter.js b/src/filters/ascii/AsciiFilter.js deleted file mode 100644 index ac64fd1..0000000 --- a/src/filters/ascii/AsciiFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -// TODO (cengler) - The Y is flipped in this shader for some reason. - -/** - * @author Vico @vicocotea - * original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h - */ - -/** - * An ASCII filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function AsciiFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./ascii.frag') - ); - - this.size = 8; -} - -AsciiFilter.prototype = Object.create(core.Filter.prototype); -AsciiFilter.prototype.constructor = AsciiFilter; -module.exports = AsciiFilter; - -Object.defineProperties(AsciiFilter.prototype, { - /** - * The pixel size used by the filter. - * - * @member {number} - * @memberof PIXI.filters.AsciiFilter# - */ - size: { - get: function () - { - return this.uniforms.pixelSize; - }, - set: function (value) - { - this.uniforms.pixelSize = value; - } - } -}); diff --git a/src/filters/ascii/ascii.frag b/src/filters/ascii/ascii.frag deleted file mode 100644 index 5608d6e..0000000 --- a/src/filters/ascii/ascii.frag +++ /dev/null @@ -1,70 +0,0 @@ -varying vec2 vTextureCoord; - -uniform vec4 filterArea; -uniform float pixelSize; -uniform sampler2D uSampler; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -vec2 getMod(vec2 coord, vec2 size) -{ - return mod( coord , size) / size; -} - -float character(float n, vec2 p) -{ - p = floor(p*vec2(4.0, -4.0) + 2.5); - if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y) - { - if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; - } - return 0.0; -} - -void main() -{ - vec2 coord = mapCoord(vTextureCoord); - - // get the rounded color.. - vec2 pixCoord = pixelate(coord, vec2(pixelSize)); - pixCoord = unmapCoord(pixCoord); - - vec4 color = texture2D(uSampler, pixCoord); - - // determine the character to use - float gray = (color.r + color.g + color.b) / 3.0; - - float n = 65536.0; // . - if (gray > 0.2) n = 65600.0; // : - if (gray > 0.3) n = 332772.0; // * - if (gray > 0.4) n = 15255086.0; // o - if (gray > 0.5) n = 23385164.0; // & - if (gray > 0.6) n = 15252014.0; // 8 - if (gray > 0.7) n = 13199452.0; // @ - if (gray > 0.8) n = 11512810.0; // # - - // get the mod.. - vec2 modd = getMod(coord, vec2(pixelSize)); - - gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); - -} \ No newline at end of file diff --git a/src/filters/bloom/BloomFilter.js b/src/filters/bloom/BloomFilter.js deleted file mode 100644 index 1a9c713..0000000 --- a/src/filters/bloom/BloomFilter.js +++ /dev/null @@ -1,97 +0,0 @@ -var core = require('../../core'), - BlurXFilter = require('../blur/BlurXFilter'), - BlurYFilter = require('../blur/BlurYFilter'); - VoidFilter = require('../void/VoidFilter'); - -/** - * The BloomFilter applies a Gaussian blur to an object. - * The strength of the blur can be set for x- and y-axis separately. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function BloomFilter() -{ - core.Filter.call(this); - - this.blurXFilter = new BlurXFilter(); - this.blurYFilter = new BlurYFilter(); - - this.blurYFilter.blendMode = core.BLEND_MODES.SCREEN; - - this.defaultFilter = new VoidFilter(); -} - -BloomFilter.prototype = Object.create(core.Filter.prototype); -BloomFilter.prototype.constructor = BloomFilter; -module.exports = BloomFilter; - -BloomFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - //TODO - copyTexSubImage2D could be used here? - this.defaultFilter.apply(filterManager, input, output); - - this.blurXFilter.apply(filterManager, input, renderTarget); - this.blurYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(BloomFilter.prototype, { - /** - * Sets the strength of both the blurX and blurY properties simultaneously - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blur: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = this.blurYFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurX property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurX: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurY property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurY: { - get: function () - { - return this.blurYFilter.blur; - }, - set: function (value) - { - this.blurYFilter.blur = value; - } - } -}); diff --git a/src/filters/convolution/ConvolutionFilter.js b/src/filters/convolution/ConvolutionFilter.js deleted file mode 100644 index 51775ba..0000000 --- a/src/filters/convolution/ConvolutionFilter.js +++ /dev/null @@ -1,87 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ConvolutionFilter class applies a matrix convolution filter effect. - * A convolution combines pixels in the input image with neighboring pixels to produce a new image. - * A wide variety of image effects can be achieved through convolutions, including blurring, edge - * detection, sharpening, embossing, and beveling. The matrix should be specified as a 9 point Array. - * See http://docs.gimp.org/en/plug-in-convmatrix.html for more info. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - * @param matrix {number[]} An array of values used for matrix transformation. Specified as a 9 point Array. - * @param width {number} Width of the object you are transforming - * @param height {number} Height of the object you are transforming - */ -function ConvolutionFilter(matrix, width, height) -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./convolution.frag') - ); - - this.matrix = matrix; - this.width = width; - this.height = height; -} - -ConvolutionFilter.prototype = Object.create(core.Filter.prototype); -ConvolutionFilter.prototype.constructor = ConvolutionFilter; -module.exports = ConvolutionFilter; - -Object.defineProperties(ConvolutionFilter.prototype, { - /** - * An array of values used for matrix transformation. Specified as a 9 point Array. - * - * @member {number[]} - * @memberof PIXI.filters.ConvolutionFilter# - */ - matrix: { - get: function () - { - return this.uniforms.matrix; - }, - set: function (value) - { - this.uniforms.matrix = new Float32Array(value); - } - }, - - /** - * Width of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - width: { - get: function () - { - return 1/this.uniforms.texelSize[0]; - }, - set: function (value) - { - this.uniforms.texelSize[0] = 1/value; - } - }, - - /** - * Height of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - height: { - get: function () - { - return 1/this.uniforms.texelSize[1]; - }, - set: function (value) - { - this.uniforms.texelSize[1] = 1/value; - } - } -}); diff --git a/src/filters/convolution/convolution.frag b/src/filters/convolution/convolution.frag deleted file mode 100644 index e6fe7b5..0000000 --- a/src/filters/convolution/convolution.frag +++ /dev/null @@ -1,29 +0,0 @@ -precision mediump float; - -varying mediump vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec2 texelSize; -uniform float matrix[9]; - -void main(void) -{ - vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left - vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center - vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right - - vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left - vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center - vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right - - vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left - vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center - vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right - - gl_FragColor = - c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] + - c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] + - c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8]; - - gl_FragColor.a = c22.a; -} diff --git a/src/filters/crosshatch/CrossHatchFilter.js b/src/filters/crosshatch/CrossHatchFilter.js deleted file mode 100644 index a8da95d..0000000 --- a/src/filters/crosshatch/CrossHatchFilter.js +++ /dev/null @@ -1,23 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * A Cross Hatch effect filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function CrossHatchFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./crosshatch.frag') - ); -} - -CrossHatchFilter.prototype = Object.create(core.Filter.prototype); -CrossHatchFilter.prototype.constructor = CrossHatchFilter; -module.exports = CrossHatchFilter; diff --git a/src/filters/crosshatch/crosshatch.frag b/src/filters/crosshatch/crosshatch.frag deleted file mode 100644 index 635ba4b..0000000 --- a/src/filters/crosshatch/crosshatch.frag +++ /dev/null @@ -1,44 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -void main(void) -{ - float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb); - - gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); - - if (lum < 1.00) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.75) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.50) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.3) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } -} diff --git a/src/filters/dot/DotFilter.js b/src/filters/dot/DotFilter.js deleted file mode 100644 index d2bc544..0000000 --- a/src/filters/dot/DotFilter.js +++ /dev/null @@ -1,66 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * @author Mat Groves http://matgroves.com/ @Doormat23 - * original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/fun/dotscreen.js - */ - -/** - * This filter applies a dotscreen effect making display objects appear to be made out of - * black and white halftone dots like an old printer. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function DotFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./dot.frag') - ); - - this.scale = 1; - this.angle = 5; -} - -DotFilter.prototype = Object.create(core.Filter.prototype); -DotFilter.prototype.constructor = DotFilter; -module.exports = DotFilter; - -Object.defineProperties(DotFilter.prototype, { - /** - * The scale of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - scale: { - get: function () - { - return this.uniforms.scale; - }, - set: function (value) - { - this.uniforms.scale = value; - } - }, - - /** - * The radius of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - angle: { - get: function () - { - return this.uniforms.angle; - }, - set: function (value) - { - this.uniforms.angle = value; - } - } -}); diff --git a/src/filters/dot/dot.frag b/src/filters/dot/dot.frag deleted file mode 100644 index 91341b1..0000000 --- a/src/filters/dot/dot.frag +++ /dev/null @@ -1,28 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; -varying vec4 vColor; - -uniform vec4 filterArea; -uniform sampler2D uSampler; - -uniform float angle; -uniform float scale; - -float pattern() -{ - float s = sin(angle), c = cos(angle); - vec2 tex = vTextureCoord * filterArea.xy; - vec2 point = vec2( - c * tex.x - s * tex.y, - s * tex.x + c * tex.y - ) * scale; - return (sin(point.x) * sin(point.y)) * 4.0; -} - -void main() -{ - vec4 color = texture2D(uSampler, vTextureCoord); - float average = (color.r + color.g + color.b) / 3.0; - gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a); -} diff --git a/src/filters/emboss/EmbossFilter.js b/src/filters/emboss/EmbossFilter.js deleted file mode 100644 index 0468d1f..0000000 --- a/src/filters/emboss/EmbossFilter.js +++ /dev/null @@ -1,46 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function EmbossFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./emboss.frag') - ); - - this.strength = 5; -} - -EmbossFilter.prototype = Object.create(core.Filter.prototype); -EmbossFilter.prototype.constructor = EmbossFilter; -module.exports = EmbossFilter; - -Object.defineProperties(EmbossFilter.prototype, { - /** - * Strength of Emboss. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.EmbossFilter# - */ - strength: { - get: function () - { - return this.uniforms.strength; - }, - set: function (value) - { - this.uniforms.strength = value; - } - }, - - -}); diff --git a/src/filters/emboss/emboss.frag b/src/filters/emboss/emboss.frag deleted file mode 100644 index 28b14d9..0000000 --- a/src/filters/emboss/emboss.frag +++ /dev/null @@ -1,26 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform float strength; -uniform vec4 filterArea; - - -void main(void) -{ - vec2 onePixel = vec2(1.0 / filterArea); - - vec4 color; - - color.rgb = vec3(0.5); - - color -= texture2D(uSampler, vTextureCoord - onePixel) * strength; - color += texture2D(uSampler, vTextureCoord + onePixel) * strength; - - color.rgb = vec3((color.r + color.g + color.b) / 3.0); - - float alpha = texture2D(uSampler, vTextureCoord).a; - - gl_FragColor = vec4(color.rgb * alpha, alpha); -} diff --git a/src/filters/index.js b/src/filters/index.js index 6709e39..54c1a3b 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -9,28 +9,12 @@ * @namespace PIXI.filters */ module.exports = { - AsciiFilter: require('./ascii/AsciiFilter'), - BloomFilter: require('./bloom/BloomFilter'), - ConvolutionFilter: require('./convolution/ConvolutionFilter'), - CrossHatchFilter: require('./crosshatch/CrossHatchFilter'), - DotFilter: require('./dot/DotFilter'), FXAAFilter: require('./fxaa/FXAAFilter'), - // DropShadowFilter: require('./dropshadow/DropShadowFilter'), NoiseFilter: require('./noise/NoiseFilter'), - PixelateFilter: require('./pixelate/PixelateFilter'), - RGBSplitFilter: require('./rgb/RGBSplitFilter'), - EmbossFilter: require('./emboss/EmbossFilter'), - ShockwaveFilter: require('./shockwave/ShockwaveFilter'), - // SmartBlurFilter: require('./blur/SmartBlurFilter'), - TiltShiftFilter: require('./tiltshift/TiltShiftFilter'), - // TiltShiftXFilter: require('./tiltshift/TiltShiftXFilter'), - //TiltShiftYFilter: require('./tiltshift/TiltShiftYFilter'), DisplacementFilter: require('./displacement/DisplacementFilter'), BlurFilter: require('./blur/BlurFilter'), BlurXFilter: require('./blur/BlurXFilter'), BlurYFilter: require('./blur/BlurYFilter'), - ColorMatrixFilter: require('./colormatrix/ColorMatrixFilter'), - TwistFilter: require('./twist/TwistFilter'), VoidFilter: require('./void/VoidFilter') }; diff --git a/src/filters/pixelate/PixelateFilter.js b/src/filters/pixelate/PixelateFilter.js deleted file mode 100644 index 6d5a1f2..0000000 --- a/src/filters/pixelate/PixelateFilter.js +++ /dev/null @@ -1,47 +0,0 @@ -var core = require('../../core'); -// @see https://github.com/substack/brfs/issues/25 -var glslify = require('glslify'); - -/** - * This filter applies a pixelate effect making display objects appear 'blocky'. - * - * @class - * @extends PIXI.AbstractFilter - * @memberof PIXI.filters - */ -function PixelateFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./pixelate.frag') - ); - - this.size = [0,0]; - -} - -PixelateFilter.prototype = Object.create(core.Filter.prototype); -PixelateFilter.prototype.constructor = PixelateFilter; -module.exports = PixelateFilter; - -Object.defineProperties(PixelateFilter.prototype, { - /** - * This a point that describes the size of the blocks. - * x is the width of the block and y is the height. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.PixelateFilter# - */ - size: { - get: function () - { - return this.uniforms.size; - }, - set: function (value) - { - this.uniforms.size.value = value; - } - } -}); diff --git a/src/filters/pixelate/pixelate.frag b/src/filters/pixelate/pixelate.frag deleted file mode 100644 index 80ad2ee..0000000 --- a/src/filters/pixelate/pixelate.frag +++ /dev/null @@ -1,40 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform vec2 size; -uniform sampler2D uSampler; - -uniform vec4 filterArea; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -void main(void) -{ - vec2 coord = mapCoord(vTextureCoord); - - coord = pixelate(coord, size); - - coord = unmapCoord(coord); - - gl_FragColor = texture2D(uSampler, coord); -} diff --git a/src/filters/rgb/RGBSplitFilter.js b/src/filters/rgb/RGBSplitFilter.js deleted file mode 100644 index 9609514..0000000 --- a/src/filters/rgb/RGBSplitFilter.js +++ /dev/null @@ -1,80 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function RGBSplitFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./rgb-split.frag') - ); - - this.red = [-10, 0]; - this.green = [0, 10]; - this.blue = [0, 0]; -} - -RGBSplitFilter.prototype = Object.create(core.Filter.prototype); -RGBSplitFilter.prototype.constructor = RGBSplitFilter; -module.exports = RGBSplitFilter; - -Object.defineProperties(RGBSplitFilter.prototype, { - /** - * Red channel offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - red: { - get: function () - { - return this.uniforms.red; - }, - set: function (value) - { - this.uniforms.red = value; - } - }, - - /** - * Green channel offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - green: { - get: function () - { - return this.uniforms.green; - }, - set: function (value) - { - this.uniforms.green = value; - } - }, - - /** - * Blue offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - blue: { - get: function () - { - return this.uniforms.blue.value; - }, - set: function (value) - { - this.uniforms.blue.value = value; - } - } -}); diff --git a/src/filters/rgb/rgb-split.frag b/src/filters/rgb/rgb-split.frag deleted file mode 100644 index 46fed0f..0000000 --- a/src/filters/rgb/rgb-split.frag +++ /dev/null @@ -1,17 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec4 filterArea; -uniform vec2 red; -uniform vec2 green; -uniform vec2 blue; - -void main(void) -{ - gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/filterArea.xy).r; - gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/filterArea.xy).g; - gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/filterArea.xy).b; - gl_FragColor.a = texture2D(uSampler, vTextureCoord).a; -} diff --git a/src/filters/shockwave/ShockwaveFilter.js b/src/filters/shockwave/ShockwaveFilter.js deleted file mode 100644 index 709bb86..0000000 --- a/src/filters/shockwave/ShockwaveFilter.js +++ /dev/null @@ -1,89 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ColorMatrixFilter class lets you apply a 4x4 matrix transformation on the RGBA - * color and alpha values of every pixel on your displayObject to produce a result - * with a new set of RGBA color and alpha values. It's pretty powerful! - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function ShockwaveFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./shockwave.frag'), - // custom uniforms - { - center: { type: 'v2', value: { x: 0.5, y: 0.5 } }, - params: { type: 'v3', value: { x: 10, y: 0.8, z: 0.1 } }, - time: { type: '1f', value: 0 } - } - ); - - this.center = [0.5, 0.5]; - this.params = [10, 0.8, 0.1]; - this.time = 0; -} - -ShockwaveFilter.prototype = Object.create(core.Filter.prototype); -ShockwaveFilter.prototype.constructor = ShockwaveFilter; -module.exports = ShockwaveFilter; - -Object.defineProperties(ShockwaveFilter.prototype, { - /** - * Sets the center of the shockwave in normalized screen coords. That is - * (0,0) is the top-left and (1,1) is the bottom right. - * - * @member {object} - * @memberof PIXI.filters.ShockwaveFilter# - */ - center: { - get: function () - { - return this.uniforms.center; - }, - set: function (value) - { - this.uniforms.center = value; - } - }, - /** - * Sets the params of the shockwave. These modify the look and behavior of - * the shockwave as it ripples out. - * - * @member {object} - * @memberof PIXI.filters.ShockwaveFilter# - */ - params: { - get: function () - { - return this.uniforms.params; - }, - set: function (value) - { - this.uniforms.params = value; - } - }, - /** - * Sets the elapsed time of the shockwave. This controls the speed at which - * the shockwave ripples out. - * - * @member {number} - * @memberof PIXI.filters.ShockwaveFilter# - */ - time: { - get: function () - { - return this.uniforms.time; - }, - set: function (value) - { - this.uniforms.time = value; - } - } -}); diff --git a/src/filters/ascii/AsciiFilter.js b/src/filters/ascii/AsciiFilter.js deleted file mode 100644 index ac64fd1..0000000 --- a/src/filters/ascii/AsciiFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -// TODO (cengler) - The Y is flipped in this shader for some reason. - -/** - * @author Vico @vicocotea - * original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h - */ - -/** - * An ASCII filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function AsciiFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./ascii.frag') - ); - - this.size = 8; -} - -AsciiFilter.prototype = Object.create(core.Filter.prototype); -AsciiFilter.prototype.constructor = AsciiFilter; -module.exports = AsciiFilter; - -Object.defineProperties(AsciiFilter.prototype, { - /** - * The pixel size used by the filter. - * - * @member {number} - * @memberof PIXI.filters.AsciiFilter# - */ - size: { - get: function () - { - return this.uniforms.pixelSize; - }, - set: function (value) - { - this.uniforms.pixelSize = value; - } - } -}); diff --git a/src/filters/ascii/ascii.frag b/src/filters/ascii/ascii.frag deleted file mode 100644 index 5608d6e..0000000 --- a/src/filters/ascii/ascii.frag +++ /dev/null @@ -1,70 +0,0 @@ -varying vec2 vTextureCoord; - -uniform vec4 filterArea; -uniform float pixelSize; -uniform sampler2D uSampler; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -vec2 getMod(vec2 coord, vec2 size) -{ - return mod( coord , size) / size; -} - -float character(float n, vec2 p) -{ - p = floor(p*vec2(4.0, -4.0) + 2.5); - if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y) - { - if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; - } - return 0.0; -} - -void main() -{ - vec2 coord = mapCoord(vTextureCoord); - - // get the rounded color.. - vec2 pixCoord = pixelate(coord, vec2(pixelSize)); - pixCoord = unmapCoord(pixCoord); - - vec4 color = texture2D(uSampler, pixCoord); - - // determine the character to use - float gray = (color.r + color.g + color.b) / 3.0; - - float n = 65536.0; // . - if (gray > 0.2) n = 65600.0; // : - if (gray > 0.3) n = 332772.0; // * - if (gray > 0.4) n = 15255086.0; // o - if (gray > 0.5) n = 23385164.0; // & - if (gray > 0.6) n = 15252014.0; // 8 - if (gray > 0.7) n = 13199452.0; // @ - if (gray > 0.8) n = 11512810.0; // # - - // get the mod.. - vec2 modd = getMod(coord, vec2(pixelSize)); - - gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); - -} \ No newline at end of file diff --git a/src/filters/bloom/BloomFilter.js b/src/filters/bloom/BloomFilter.js deleted file mode 100644 index 1a9c713..0000000 --- a/src/filters/bloom/BloomFilter.js +++ /dev/null @@ -1,97 +0,0 @@ -var core = require('../../core'), - BlurXFilter = require('../blur/BlurXFilter'), - BlurYFilter = require('../blur/BlurYFilter'); - VoidFilter = require('../void/VoidFilter'); - -/** - * The BloomFilter applies a Gaussian blur to an object. - * The strength of the blur can be set for x- and y-axis separately. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function BloomFilter() -{ - core.Filter.call(this); - - this.blurXFilter = new BlurXFilter(); - this.blurYFilter = new BlurYFilter(); - - this.blurYFilter.blendMode = core.BLEND_MODES.SCREEN; - - this.defaultFilter = new VoidFilter(); -} - -BloomFilter.prototype = Object.create(core.Filter.prototype); -BloomFilter.prototype.constructor = BloomFilter; -module.exports = BloomFilter; - -BloomFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - //TODO - copyTexSubImage2D could be used here? - this.defaultFilter.apply(filterManager, input, output); - - this.blurXFilter.apply(filterManager, input, renderTarget); - this.blurYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(BloomFilter.prototype, { - /** - * Sets the strength of both the blurX and blurY properties simultaneously - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blur: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = this.blurYFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurX property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurX: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurY property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurY: { - get: function () - { - return this.blurYFilter.blur; - }, - set: function (value) - { - this.blurYFilter.blur = value; - } - } -}); diff --git a/src/filters/convolution/ConvolutionFilter.js b/src/filters/convolution/ConvolutionFilter.js deleted file mode 100644 index 51775ba..0000000 --- a/src/filters/convolution/ConvolutionFilter.js +++ /dev/null @@ -1,87 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ConvolutionFilter class applies a matrix convolution filter effect. - * A convolution combines pixels in the input image with neighboring pixels to produce a new image. - * A wide variety of image effects can be achieved through convolutions, including blurring, edge - * detection, sharpening, embossing, and beveling. The matrix should be specified as a 9 point Array. - * See http://docs.gimp.org/en/plug-in-convmatrix.html for more info. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - * @param matrix {number[]} An array of values used for matrix transformation. Specified as a 9 point Array. - * @param width {number} Width of the object you are transforming - * @param height {number} Height of the object you are transforming - */ -function ConvolutionFilter(matrix, width, height) -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./convolution.frag') - ); - - this.matrix = matrix; - this.width = width; - this.height = height; -} - -ConvolutionFilter.prototype = Object.create(core.Filter.prototype); -ConvolutionFilter.prototype.constructor = ConvolutionFilter; -module.exports = ConvolutionFilter; - -Object.defineProperties(ConvolutionFilter.prototype, { - /** - * An array of values used for matrix transformation. Specified as a 9 point Array. - * - * @member {number[]} - * @memberof PIXI.filters.ConvolutionFilter# - */ - matrix: { - get: function () - { - return this.uniforms.matrix; - }, - set: function (value) - { - this.uniforms.matrix = new Float32Array(value); - } - }, - - /** - * Width of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - width: { - get: function () - { - return 1/this.uniforms.texelSize[0]; - }, - set: function (value) - { - this.uniforms.texelSize[0] = 1/value; - } - }, - - /** - * Height of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - height: { - get: function () - { - return 1/this.uniforms.texelSize[1]; - }, - set: function (value) - { - this.uniforms.texelSize[1] = 1/value; - } - } -}); diff --git a/src/filters/convolution/convolution.frag b/src/filters/convolution/convolution.frag deleted file mode 100644 index e6fe7b5..0000000 --- a/src/filters/convolution/convolution.frag +++ /dev/null @@ -1,29 +0,0 @@ -precision mediump float; - -varying mediump vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec2 texelSize; -uniform float matrix[9]; - -void main(void) -{ - vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left - vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center - vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right - - vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left - vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center - vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right - - vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left - vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center - vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right - - gl_FragColor = - c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] + - c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] + - c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8]; - - gl_FragColor.a = c22.a; -} diff --git a/src/filters/crosshatch/CrossHatchFilter.js b/src/filters/crosshatch/CrossHatchFilter.js deleted file mode 100644 index a8da95d..0000000 --- a/src/filters/crosshatch/CrossHatchFilter.js +++ /dev/null @@ -1,23 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * A Cross Hatch effect filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function CrossHatchFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./crosshatch.frag') - ); -} - -CrossHatchFilter.prototype = Object.create(core.Filter.prototype); -CrossHatchFilter.prototype.constructor = CrossHatchFilter; -module.exports = CrossHatchFilter; diff --git a/src/filters/crosshatch/crosshatch.frag b/src/filters/crosshatch/crosshatch.frag deleted file mode 100644 index 635ba4b..0000000 --- a/src/filters/crosshatch/crosshatch.frag +++ /dev/null @@ -1,44 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -void main(void) -{ - float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb); - - gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); - - if (lum < 1.00) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.75) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.50) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.3) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } -} diff --git a/src/filters/dot/DotFilter.js b/src/filters/dot/DotFilter.js deleted file mode 100644 index d2bc544..0000000 --- a/src/filters/dot/DotFilter.js +++ /dev/null @@ -1,66 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * @author Mat Groves http://matgroves.com/ @Doormat23 - * original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/fun/dotscreen.js - */ - -/** - * This filter applies a dotscreen effect making display objects appear to be made out of - * black and white halftone dots like an old printer. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function DotFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./dot.frag') - ); - - this.scale = 1; - this.angle = 5; -} - -DotFilter.prototype = Object.create(core.Filter.prototype); -DotFilter.prototype.constructor = DotFilter; -module.exports = DotFilter; - -Object.defineProperties(DotFilter.prototype, { - /** - * The scale of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - scale: { - get: function () - { - return this.uniforms.scale; - }, - set: function (value) - { - this.uniforms.scale = value; - } - }, - - /** - * The radius of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - angle: { - get: function () - { - return this.uniforms.angle; - }, - set: function (value) - { - this.uniforms.angle = value; - } - } -}); diff --git a/src/filters/dot/dot.frag b/src/filters/dot/dot.frag deleted file mode 100644 index 91341b1..0000000 --- a/src/filters/dot/dot.frag +++ /dev/null @@ -1,28 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; -varying vec4 vColor; - -uniform vec4 filterArea; -uniform sampler2D uSampler; - -uniform float angle; -uniform float scale; - -float pattern() -{ - float s = sin(angle), c = cos(angle); - vec2 tex = vTextureCoord * filterArea.xy; - vec2 point = vec2( - c * tex.x - s * tex.y, - s * tex.x + c * tex.y - ) * scale; - return (sin(point.x) * sin(point.y)) * 4.0; -} - -void main() -{ - vec4 color = texture2D(uSampler, vTextureCoord); - float average = (color.r + color.g + color.b) / 3.0; - gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a); -} diff --git a/src/filters/emboss/EmbossFilter.js b/src/filters/emboss/EmbossFilter.js deleted file mode 100644 index 0468d1f..0000000 --- a/src/filters/emboss/EmbossFilter.js +++ /dev/null @@ -1,46 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function EmbossFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./emboss.frag') - ); - - this.strength = 5; -} - -EmbossFilter.prototype = Object.create(core.Filter.prototype); -EmbossFilter.prototype.constructor = EmbossFilter; -module.exports = EmbossFilter; - -Object.defineProperties(EmbossFilter.prototype, { - /** - * Strength of Emboss. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.EmbossFilter# - */ - strength: { - get: function () - { - return this.uniforms.strength; - }, - set: function (value) - { - this.uniforms.strength = value; - } - }, - - -}); diff --git a/src/filters/emboss/emboss.frag b/src/filters/emboss/emboss.frag deleted file mode 100644 index 28b14d9..0000000 --- a/src/filters/emboss/emboss.frag +++ /dev/null @@ -1,26 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform float strength; -uniform vec4 filterArea; - - -void main(void) -{ - vec2 onePixel = vec2(1.0 / filterArea); - - vec4 color; - - color.rgb = vec3(0.5); - - color -= texture2D(uSampler, vTextureCoord - onePixel) * strength; - color += texture2D(uSampler, vTextureCoord + onePixel) * strength; - - color.rgb = vec3((color.r + color.g + color.b) / 3.0); - - float alpha = texture2D(uSampler, vTextureCoord).a; - - gl_FragColor = vec4(color.rgb * alpha, alpha); -} diff --git a/src/filters/index.js b/src/filters/index.js index 6709e39..54c1a3b 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -9,28 +9,12 @@ * @namespace PIXI.filters */ module.exports = { - AsciiFilter: require('./ascii/AsciiFilter'), - BloomFilter: require('./bloom/BloomFilter'), - ConvolutionFilter: require('./convolution/ConvolutionFilter'), - CrossHatchFilter: require('./crosshatch/CrossHatchFilter'), - DotFilter: require('./dot/DotFilter'), FXAAFilter: require('./fxaa/FXAAFilter'), - // DropShadowFilter: require('./dropshadow/DropShadowFilter'), NoiseFilter: require('./noise/NoiseFilter'), - PixelateFilter: require('./pixelate/PixelateFilter'), - RGBSplitFilter: require('./rgb/RGBSplitFilter'), - EmbossFilter: require('./emboss/EmbossFilter'), - ShockwaveFilter: require('./shockwave/ShockwaveFilter'), - // SmartBlurFilter: require('./blur/SmartBlurFilter'), - TiltShiftFilter: require('./tiltshift/TiltShiftFilter'), - // TiltShiftXFilter: require('./tiltshift/TiltShiftXFilter'), - //TiltShiftYFilter: require('./tiltshift/TiltShiftYFilter'), DisplacementFilter: require('./displacement/DisplacementFilter'), BlurFilter: require('./blur/BlurFilter'), BlurXFilter: require('./blur/BlurXFilter'), BlurYFilter: require('./blur/BlurYFilter'), - ColorMatrixFilter: require('./colormatrix/ColorMatrixFilter'), - TwistFilter: require('./twist/TwistFilter'), VoidFilter: require('./void/VoidFilter') }; diff --git a/src/filters/pixelate/PixelateFilter.js b/src/filters/pixelate/PixelateFilter.js deleted file mode 100644 index 6d5a1f2..0000000 --- a/src/filters/pixelate/PixelateFilter.js +++ /dev/null @@ -1,47 +0,0 @@ -var core = require('../../core'); -// @see https://github.com/substack/brfs/issues/25 -var glslify = require('glslify'); - -/** - * This filter applies a pixelate effect making display objects appear 'blocky'. - * - * @class - * @extends PIXI.AbstractFilter - * @memberof PIXI.filters - */ -function PixelateFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./pixelate.frag') - ); - - this.size = [0,0]; - -} - -PixelateFilter.prototype = Object.create(core.Filter.prototype); -PixelateFilter.prototype.constructor = PixelateFilter; -module.exports = PixelateFilter; - -Object.defineProperties(PixelateFilter.prototype, { - /** - * This a point that describes the size of the blocks. - * x is the width of the block and y is the height. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.PixelateFilter# - */ - size: { - get: function () - { - return this.uniforms.size; - }, - set: function (value) - { - this.uniforms.size.value = value; - } - } -}); diff --git a/src/filters/pixelate/pixelate.frag b/src/filters/pixelate/pixelate.frag deleted file mode 100644 index 80ad2ee..0000000 --- a/src/filters/pixelate/pixelate.frag +++ /dev/null @@ -1,40 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform vec2 size; -uniform sampler2D uSampler; - -uniform vec4 filterArea; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -void main(void) -{ - vec2 coord = mapCoord(vTextureCoord); - - coord = pixelate(coord, size); - - coord = unmapCoord(coord); - - gl_FragColor = texture2D(uSampler, coord); -} diff --git a/src/filters/rgb/RGBSplitFilter.js b/src/filters/rgb/RGBSplitFilter.js deleted file mode 100644 index 9609514..0000000 --- a/src/filters/rgb/RGBSplitFilter.js +++ /dev/null @@ -1,80 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function RGBSplitFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./rgb-split.frag') - ); - - this.red = [-10, 0]; - this.green = [0, 10]; - this.blue = [0, 0]; -} - -RGBSplitFilter.prototype = Object.create(core.Filter.prototype); -RGBSplitFilter.prototype.constructor = RGBSplitFilter; -module.exports = RGBSplitFilter; - -Object.defineProperties(RGBSplitFilter.prototype, { - /** - * Red channel offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - red: { - get: function () - { - return this.uniforms.red; - }, - set: function (value) - { - this.uniforms.red = value; - } - }, - - /** - * Green channel offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - green: { - get: function () - { - return this.uniforms.green; - }, - set: function (value) - { - this.uniforms.green = value; - } - }, - - /** - * Blue offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - blue: { - get: function () - { - return this.uniforms.blue.value; - }, - set: function (value) - { - this.uniforms.blue.value = value; - } - } -}); diff --git a/src/filters/rgb/rgb-split.frag b/src/filters/rgb/rgb-split.frag deleted file mode 100644 index 46fed0f..0000000 --- a/src/filters/rgb/rgb-split.frag +++ /dev/null @@ -1,17 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec4 filterArea; -uniform vec2 red; -uniform vec2 green; -uniform vec2 blue; - -void main(void) -{ - gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/filterArea.xy).r; - gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/filterArea.xy).g; - gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/filterArea.xy).b; - gl_FragColor.a = texture2D(uSampler, vTextureCoord).a; -} diff --git a/src/filters/shockwave/ShockwaveFilter.js b/src/filters/shockwave/ShockwaveFilter.js deleted file mode 100644 index 709bb86..0000000 --- a/src/filters/shockwave/ShockwaveFilter.js +++ /dev/null @@ -1,89 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ColorMatrixFilter class lets you apply a 4x4 matrix transformation on the RGBA - * color and alpha values of every pixel on your displayObject to produce a result - * with a new set of RGBA color and alpha values. It's pretty powerful! - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function ShockwaveFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./shockwave.frag'), - // custom uniforms - { - center: { type: 'v2', value: { x: 0.5, y: 0.5 } }, - params: { type: 'v3', value: { x: 10, y: 0.8, z: 0.1 } }, - time: { type: '1f', value: 0 } - } - ); - - this.center = [0.5, 0.5]; - this.params = [10, 0.8, 0.1]; - this.time = 0; -} - -ShockwaveFilter.prototype = Object.create(core.Filter.prototype); -ShockwaveFilter.prototype.constructor = ShockwaveFilter; -module.exports = ShockwaveFilter; - -Object.defineProperties(ShockwaveFilter.prototype, { - /** - * Sets the center of the shockwave in normalized screen coords. That is - * (0,0) is the top-left and (1,1) is the bottom right. - * - * @member {object} - * @memberof PIXI.filters.ShockwaveFilter# - */ - center: { - get: function () - { - return this.uniforms.center; - }, - set: function (value) - { - this.uniforms.center = value; - } - }, - /** - * Sets the params of the shockwave. These modify the look and behavior of - * the shockwave as it ripples out. - * - * @member {object} - * @memberof PIXI.filters.ShockwaveFilter# - */ - params: { - get: function () - { - return this.uniforms.params; - }, - set: function (value) - { - this.uniforms.params = value; - } - }, - /** - * Sets the elapsed time of the shockwave. This controls the speed at which - * the shockwave ripples out. - * - * @member {number} - * @memberof PIXI.filters.ShockwaveFilter# - */ - time: { - get: function () - { - return this.uniforms.time; - }, - set: function (value) - { - this.uniforms.time = value; - } - } -}); diff --git a/src/filters/shockwave/shockwave.frag b/src/filters/shockwave/shockwave.frag deleted file mode 100644 index db2642e..0000000 --- a/src/filters/shockwave/shockwave.frag +++ /dev/null @@ -1,27 +0,0 @@ -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -uniform vec2 center; -uniform vec3 params; // 10.0, 0.8, 0.1 -uniform float time; - -void main() -{ - vec2 uv = vTextureCoord; - vec2 texCoord = uv; - - float dist = distance(uv, center); - - if ( (dist <= (time + params.z)) && (dist >= (time - params.z)) ) - { - float diff = (dist - time); - float powDiff = 1.0 - pow(abs(diff*params.x), params.y); - - float diffTime = diff * powDiff; - vec2 diffUV = normalize(uv - center); - texCoord = uv + (diffUV * diffTime); - } - - gl_FragColor = texture2D(uSampler, texCoord); -} diff --git a/src/filters/ascii/AsciiFilter.js b/src/filters/ascii/AsciiFilter.js deleted file mode 100644 index ac64fd1..0000000 --- a/src/filters/ascii/AsciiFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -// TODO (cengler) - The Y is flipped in this shader for some reason. - -/** - * @author Vico @vicocotea - * original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h - */ - -/** - * An ASCII filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function AsciiFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./ascii.frag') - ); - - this.size = 8; -} - -AsciiFilter.prototype = Object.create(core.Filter.prototype); -AsciiFilter.prototype.constructor = AsciiFilter; -module.exports = AsciiFilter; - -Object.defineProperties(AsciiFilter.prototype, { - /** - * The pixel size used by the filter. - * - * @member {number} - * @memberof PIXI.filters.AsciiFilter# - */ - size: { - get: function () - { - return this.uniforms.pixelSize; - }, - set: function (value) - { - this.uniforms.pixelSize = value; - } - } -}); diff --git a/src/filters/ascii/ascii.frag b/src/filters/ascii/ascii.frag deleted file mode 100644 index 5608d6e..0000000 --- a/src/filters/ascii/ascii.frag +++ /dev/null @@ -1,70 +0,0 @@ -varying vec2 vTextureCoord; - -uniform vec4 filterArea; -uniform float pixelSize; -uniform sampler2D uSampler; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -vec2 getMod(vec2 coord, vec2 size) -{ - return mod( coord , size) / size; -} - -float character(float n, vec2 p) -{ - p = floor(p*vec2(4.0, -4.0) + 2.5); - if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y) - { - if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; - } - return 0.0; -} - -void main() -{ - vec2 coord = mapCoord(vTextureCoord); - - // get the rounded color.. - vec2 pixCoord = pixelate(coord, vec2(pixelSize)); - pixCoord = unmapCoord(pixCoord); - - vec4 color = texture2D(uSampler, pixCoord); - - // determine the character to use - float gray = (color.r + color.g + color.b) / 3.0; - - float n = 65536.0; // . - if (gray > 0.2) n = 65600.0; // : - if (gray > 0.3) n = 332772.0; // * - if (gray > 0.4) n = 15255086.0; // o - if (gray > 0.5) n = 23385164.0; // & - if (gray > 0.6) n = 15252014.0; // 8 - if (gray > 0.7) n = 13199452.0; // @ - if (gray > 0.8) n = 11512810.0; // # - - // get the mod.. - vec2 modd = getMod(coord, vec2(pixelSize)); - - gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); - -} \ No newline at end of file diff --git a/src/filters/bloom/BloomFilter.js b/src/filters/bloom/BloomFilter.js deleted file mode 100644 index 1a9c713..0000000 --- a/src/filters/bloom/BloomFilter.js +++ /dev/null @@ -1,97 +0,0 @@ -var core = require('../../core'), - BlurXFilter = require('../blur/BlurXFilter'), - BlurYFilter = require('../blur/BlurYFilter'); - VoidFilter = require('../void/VoidFilter'); - -/** - * The BloomFilter applies a Gaussian blur to an object. - * The strength of the blur can be set for x- and y-axis separately. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function BloomFilter() -{ - core.Filter.call(this); - - this.blurXFilter = new BlurXFilter(); - this.blurYFilter = new BlurYFilter(); - - this.blurYFilter.blendMode = core.BLEND_MODES.SCREEN; - - this.defaultFilter = new VoidFilter(); -} - -BloomFilter.prototype = Object.create(core.Filter.prototype); -BloomFilter.prototype.constructor = BloomFilter; -module.exports = BloomFilter; - -BloomFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - //TODO - copyTexSubImage2D could be used here? - this.defaultFilter.apply(filterManager, input, output); - - this.blurXFilter.apply(filterManager, input, renderTarget); - this.blurYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(BloomFilter.prototype, { - /** - * Sets the strength of both the blurX and blurY properties simultaneously - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blur: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = this.blurYFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurX property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurX: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurY property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurY: { - get: function () - { - return this.blurYFilter.blur; - }, - set: function (value) - { - this.blurYFilter.blur = value; - } - } -}); diff --git a/src/filters/convolution/ConvolutionFilter.js b/src/filters/convolution/ConvolutionFilter.js deleted file mode 100644 index 51775ba..0000000 --- a/src/filters/convolution/ConvolutionFilter.js +++ /dev/null @@ -1,87 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ConvolutionFilter class applies a matrix convolution filter effect. - * A convolution combines pixels in the input image with neighboring pixels to produce a new image. - * A wide variety of image effects can be achieved through convolutions, including blurring, edge - * detection, sharpening, embossing, and beveling. The matrix should be specified as a 9 point Array. - * See http://docs.gimp.org/en/plug-in-convmatrix.html for more info. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - * @param matrix {number[]} An array of values used for matrix transformation. Specified as a 9 point Array. - * @param width {number} Width of the object you are transforming - * @param height {number} Height of the object you are transforming - */ -function ConvolutionFilter(matrix, width, height) -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./convolution.frag') - ); - - this.matrix = matrix; - this.width = width; - this.height = height; -} - -ConvolutionFilter.prototype = Object.create(core.Filter.prototype); -ConvolutionFilter.prototype.constructor = ConvolutionFilter; -module.exports = ConvolutionFilter; - -Object.defineProperties(ConvolutionFilter.prototype, { - /** - * An array of values used for matrix transformation. Specified as a 9 point Array. - * - * @member {number[]} - * @memberof PIXI.filters.ConvolutionFilter# - */ - matrix: { - get: function () - { - return this.uniforms.matrix; - }, - set: function (value) - { - this.uniforms.matrix = new Float32Array(value); - } - }, - - /** - * Width of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - width: { - get: function () - { - return 1/this.uniforms.texelSize[0]; - }, - set: function (value) - { - this.uniforms.texelSize[0] = 1/value; - } - }, - - /** - * Height of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - height: { - get: function () - { - return 1/this.uniforms.texelSize[1]; - }, - set: function (value) - { - this.uniforms.texelSize[1] = 1/value; - } - } -}); diff --git a/src/filters/convolution/convolution.frag b/src/filters/convolution/convolution.frag deleted file mode 100644 index e6fe7b5..0000000 --- a/src/filters/convolution/convolution.frag +++ /dev/null @@ -1,29 +0,0 @@ -precision mediump float; - -varying mediump vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec2 texelSize; -uniform float matrix[9]; - -void main(void) -{ - vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left - vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center - vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right - - vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left - vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center - vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right - - vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left - vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center - vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right - - gl_FragColor = - c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] + - c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] + - c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8]; - - gl_FragColor.a = c22.a; -} diff --git a/src/filters/crosshatch/CrossHatchFilter.js b/src/filters/crosshatch/CrossHatchFilter.js deleted file mode 100644 index a8da95d..0000000 --- a/src/filters/crosshatch/CrossHatchFilter.js +++ /dev/null @@ -1,23 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * A Cross Hatch effect filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function CrossHatchFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./crosshatch.frag') - ); -} - -CrossHatchFilter.prototype = Object.create(core.Filter.prototype); -CrossHatchFilter.prototype.constructor = CrossHatchFilter; -module.exports = CrossHatchFilter; diff --git a/src/filters/crosshatch/crosshatch.frag b/src/filters/crosshatch/crosshatch.frag deleted file mode 100644 index 635ba4b..0000000 --- a/src/filters/crosshatch/crosshatch.frag +++ /dev/null @@ -1,44 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -void main(void) -{ - float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb); - - gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); - - if (lum < 1.00) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.75) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.50) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.3) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } -} diff --git a/src/filters/dot/DotFilter.js b/src/filters/dot/DotFilter.js deleted file mode 100644 index d2bc544..0000000 --- a/src/filters/dot/DotFilter.js +++ /dev/null @@ -1,66 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * @author Mat Groves http://matgroves.com/ @Doormat23 - * original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/fun/dotscreen.js - */ - -/** - * This filter applies a dotscreen effect making display objects appear to be made out of - * black and white halftone dots like an old printer. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function DotFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./dot.frag') - ); - - this.scale = 1; - this.angle = 5; -} - -DotFilter.prototype = Object.create(core.Filter.prototype); -DotFilter.prototype.constructor = DotFilter; -module.exports = DotFilter; - -Object.defineProperties(DotFilter.prototype, { - /** - * The scale of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - scale: { - get: function () - { - return this.uniforms.scale; - }, - set: function (value) - { - this.uniforms.scale = value; - } - }, - - /** - * The radius of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - angle: { - get: function () - { - return this.uniforms.angle; - }, - set: function (value) - { - this.uniforms.angle = value; - } - } -}); diff --git a/src/filters/dot/dot.frag b/src/filters/dot/dot.frag deleted file mode 100644 index 91341b1..0000000 --- a/src/filters/dot/dot.frag +++ /dev/null @@ -1,28 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; -varying vec4 vColor; - -uniform vec4 filterArea; -uniform sampler2D uSampler; - -uniform float angle; -uniform float scale; - -float pattern() -{ - float s = sin(angle), c = cos(angle); - vec2 tex = vTextureCoord * filterArea.xy; - vec2 point = vec2( - c * tex.x - s * tex.y, - s * tex.x + c * tex.y - ) * scale; - return (sin(point.x) * sin(point.y)) * 4.0; -} - -void main() -{ - vec4 color = texture2D(uSampler, vTextureCoord); - float average = (color.r + color.g + color.b) / 3.0; - gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a); -} diff --git a/src/filters/emboss/EmbossFilter.js b/src/filters/emboss/EmbossFilter.js deleted file mode 100644 index 0468d1f..0000000 --- a/src/filters/emboss/EmbossFilter.js +++ /dev/null @@ -1,46 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function EmbossFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./emboss.frag') - ); - - this.strength = 5; -} - -EmbossFilter.prototype = Object.create(core.Filter.prototype); -EmbossFilter.prototype.constructor = EmbossFilter; -module.exports = EmbossFilter; - -Object.defineProperties(EmbossFilter.prototype, { - /** - * Strength of Emboss. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.EmbossFilter# - */ - strength: { - get: function () - { - return this.uniforms.strength; - }, - set: function (value) - { - this.uniforms.strength = value; - } - }, - - -}); diff --git a/src/filters/emboss/emboss.frag b/src/filters/emboss/emboss.frag deleted file mode 100644 index 28b14d9..0000000 --- a/src/filters/emboss/emboss.frag +++ /dev/null @@ -1,26 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform float strength; -uniform vec4 filterArea; - - -void main(void) -{ - vec2 onePixel = vec2(1.0 / filterArea); - - vec4 color; - - color.rgb = vec3(0.5); - - color -= texture2D(uSampler, vTextureCoord - onePixel) * strength; - color += texture2D(uSampler, vTextureCoord + onePixel) * strength; - - color.rgb = vec3((color.r + color.g + color.b) / 3.0); - - float alpha = texture2D(uSampler, vTextureCoord).a; - - gl_FragColor = vec4(color.rgb * alpha, alpha); -} diff --git a/src/filters/index.js b/src/filters/index.js index 6709e39..54c1a3b 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -9,28 +9,12 @@ * @namespace PIXI.filters */ module.exports = { - AsciiFilter: require('./ascii/AsciiFilter'), - BloomFilter: require('./bloom/BloomFilter'), - ConvolutionFilter: require('./convolution/ConvolutionFilter'), - CrossHatchFilter: require('./crosshatch/CrossHatchFilter'), - DotFilter: require('./dot/DotFilter'), FXAAFilter: require('./fxaa/FXAAFilter'), - // DropShadowFilter: require('./dropshadow/DropShadowFilter'), NoiseFilter: require('./noise/NoiseFilter'), - PixelateFilter: require('./pixelate/PixelateFilter'), - RGBSplitFilter: require('./rgb/RGBSplitFilter'), - EmbossFilter: require('./emboss/EmbossFilter'), - ShockwaveFilter: require('./shockwave/ShockwaveFilter'), - // SmartBlurFilter: require('./blur/SmartBlurFilter'), - TiltShiftFilter: require('./tiltshift/TiltShiftFilter'), - // TiltShiftXFilter: require('./tiltshift/TiltShiftXFilter'), - //TiltShiftYFilter: require('./tiltshift/TiltShiftYFilter'), DisplacementFilter: require('./displacement/DisplacementFilter'), BlurFilter: require('./blur/BlurFilter'), BlurXFilter: require('./blur/BlurXFilter'), BlurYFilter: require('./blur/BlurYFilter'), - ColorMatrixFilter: require('./colormatrix/ColorMatrixFilter'), - TwistFilter: require('./twist/TwistFilter'), VoidFilter: require('./void/VoidFilter') }; diff --git a/src/filters/pixelate/PixelateFilter.js b/src/filters/pixelate/PixelateFilter.js deleted file mode 100644 index 6d5a1f2..0000000 --- a/src/filters/pixelate/PixelateFilter.js +++ /dev/null @@ -1,47 +0,0 @@ -var core = require('../../core'); -// @see https://github.com/substack/brfs/issues/25 -var glslify = require('glslify'); - -/** - * This filter applies a pixelate effect making display objects appear 'blocky'. - * - * @class - * @extends PIXI.AbstractFilter - * @memberof PIXI.filters - */ -function PixelateFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./pixelate.frag') - ); - - this.size = [0,0]; - -} - -PixelateFilter.prototype = Object.create(core.Filter.prototype); -PixelateFilter.prototype.constructor = PixelateFilter; -module.exports = PixelateFilter; - -Object.defineProperties(PixelateFilter.prototype, { - /** - * This a point that describes the size of the blocks. - * x is the width of the block and y is the height. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.PixelateFilter# - */ - size: { - get: function () - { - return this.uniforms.size; - }, - set: function (value) - { - this.uniforms.size.value = value; - } - } -}); diff --git a/src/filters/pixelate/pixelate.frag b/src/filters/pixelate/pixelate.frag deleted file mode 100644 index 80ad2ee..0000000 --- a/src/filters/pixelate/pixelate.frag +++ /dev/null @@ -1,40 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform vec2 size; -uniform sampler2D uSampler; - -uniform vec4 filterArea; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -void main(void) -{ - vec2 coord = mapCoord(vTextureCoord); - - coord = pixelate(coord, size); - - coord = unmapCoord(coord); - - gl_FragColor = texture2D(uSampler, coord); -} diff --git a/src/filters/rgb/RGBSplitFilter.js b/src/filters/rgb/RGBSplitFilter.js deleted file mode 100644 index 9609514..0000000 --- a/src/filters/rgb/RGBSplitFilter.js +++ /dev/null @@ -1,80 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function RGBSplitFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./rgb-split.frag') - ); - - this.red = [-10, 0]; - this.green = [0, 10]; - this.blue = [0, 0]; -} - -RGBSplitFilter.prototype = Object.create(core.Filter.prototype); -RGBSplitFilter.prototype.constructor = RGBSplitFilter; -module.exports = RGBSplitFilter; - -Object.defineProperties(RGBSplitFilter.prototype, { - /** - * Red channel offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - red: { - get: function () - { - return this.uniforms.red; - }, - set: function (value) - { - this.uniforms.red = value; - } - }, - - /** - * Green channel offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - green: { - get: function () - { - return this.uniforms.green; - }, - set: function (value) - { - this.uniforms.green = value; - } - }, - - /** - * Blue offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - blue: { - get: function () - { - return this.uniforms.blue.value; - }, - set: function (value) - { - this.uniforms.blue.value = value; - } - } -}); diff --git a/src/filters/rgb/rgb-split.frag b/src/filters/rgb/rgb-split.frag deleted file mode 100644 index 46fed0f..0000000 --- a/src/filters/rgb/rgb-split.frag +++ /dev/null @@ -1,17 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec4 filterArea; -uniform vec2 red; -uniform vec2 green; -uniform vec2 blue; - -void main(void) -{ - gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/filterArea.xy).r; - gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/filterArea.xy).g; - gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/filterArea.xy).b; - gl_FragColor.a = texture2D(uSampler, vTextureCoord).a; -} diff --git a/src/filters/shockwave/ShockwaveFilter.js b/src/filters/shockwave/ShockwaveFilter.js deleted file mode 100644 index 709bb86..0000000 --- a/src/filters/shockwave/ShockwaveFilter.js +++ /dev/null @@ -1,89 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ColorMatrixFilter class lets you apply a 4x4 matrix transformation on the RGBA - * color and alpha values of every pixel on your displayObject to produce a result - * with a new set of RGBA color and alpha values. It's pretty powerful! - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function ShockwaveFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./shockwave.frag'), - // custom uniforms - { - center: { type: 'v2', value: { x: 0.5, y: 0.5 } }, - params: { type: 'v3', value: { x: 10, y: 0.8, z: 0.1 } }, - time: { type: '1f', value: 0 } - } - ); - - this.center = [0.5, 0.5]; - this.params = [10, 0.8, 0.1]; - this.time = 0; -} - -ShockwaveFilter.prototype = Object.create(core.Filter.prototype); -ShockwaveFilter.prototype.constructor = ShockwaveFilter; -module.exports = ShockwaveFilter; - -Object.defineProperties(ShockwaveFilter.prototype, { - /** - * Sets the center of the shockwave in normalized screen coords. That is - * (0,0) is the top-left and (1,1) is the bottom right. - * - * @member {object} - * @memberof PIXI.filters.ShockwaveFilter# - */ - center: { - get: function () - { - return this.uniforms.center; - }, - set: function (value) - { - this.uniforms.center = value; - } - }, - /** - * Sets the params of the shockwave. These modify the look and behavior of - * the shockwave as it ripples out. - * - * @member {object} - * @memberof PIXI.filters.ShockwaveFilter# - */ - params: { - get: function () - { - return this.uniforms.params; - }, - set: function (value) - { - this.uniforms.params = value; - } - }, - /** - * Sets the elapsed time of the shockwave. This controls the speed at which - * the shockwave ripples out. - * - * @member {number} - * @memberof PIXI.filters.ShockwaveFilter# - */ - time: { - get: function () - { - return this.uniforms.time; - }, - set: function (value) - { - this.uniforms.time = value; - } - } -}); diff --git a/src/filters/shockwave/shockwave.frag b/src/filters/shockwave/shockwave.frag deleted file mode 100644 index db2642e..0000000 --- a/src/filters/shockwave/shockwave.frag +++ /dev/null @@ -1,27 +0,0 @@ -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -uniform vec2 center; -uniform vec3 params; // 10.0, 0.8, 0.1 -uniform float time; - -void main() -{ - vec2 uv = vTextureCoord; - vec2 texCoord = uv; - - float dist = distance(uv, center); - - if ( (dist <= (time + params.z)) && (dist >= (time - params.z)) ) - { - float diff = (dist - time); - float powDiff = 1.0 - pow(abs(diff*params.x), params.y); - - float diffTime = diff * powDiff; - vec2 diffUV = normalize(uv - center); - texCoord = uv + (diffUV * diffTime); - } - - gl_FragColor = texture2D(uSampler, texCoord); -} diff --git a/src/filters/tiltshift/TiltShiftAxisFilter.js b/src/filters/tiltshift/TiltShiftAxisFilter.js deleted file mode 100644 index 17a2dd5..0000000 --- a/src/filters/tiltshift/TiltShiftAxisFilter.js +++ /dev/null @@ -1,121 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * @author Vico @vicocotea - * original filter https://github.com/evanw/glfx.js/blob/master/src/filters/blur/tiltshift.js by Evan Wallace : http://madebyevan.com/ - */ - -/** - * A TiltShiftAxisFilter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function TiltShiftAxisFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./tilt-shift.frag') - - ); - - this.uniforms.blur = 100; - this.uniforms.gradientBlur = 600; - this.uniforms.start = new PIXI.Point(0, window.innerHeight / 2); - this.uniforms.end = new PIXI.Point(600, window.innerHeight / 2); - this.uniforms.delta = new PIXI.Point(30, 30); - this.uniforms.texSize = new PIXI.Point(window.innerWidth, window.innerHeight); - - this.updateDelta(); -} - -TiltShiftAxisFilter.prototype = Object.create(core.Filter.prototype); -TiltShiftAxisFilter.prototype.constructor = TiltShiftAxisFilter; -module.exports = TiltShiftAxisFilter; - -/** - * Updates the filter delta values. - * This is overridden in the X and Y filters, does nothing for this class. - * - */ -TiltShiftAxisFilter.prototype.updateDelta = function () -{ - this.uniforms.delta.x = 0; - this.uniforms.delta.y = 0; -}; - -Object.defineProperties(TiltShiftAxisFilter.prototype, { - /** - * The strength of the blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - blur: { - get: function () - { - return this.uniforms.blur; - }, - set: function (value) - { - this.uniforms.blur = value; - } - }, - - /** - * The strength of the gradient blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - gradientBlur: { - get: function () - { - return this.uniforms.gradientBlur; - }, - set: function (value) - { - this.uniforms.gradientBlur = value; - } - }, - - /** - * The X value to start the effect at. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - start: { - get: function () - { - return this.uniforms.start; - }, - set: function (value) - { - this.uniforms.start = value; - this.updateDelta(); - } - }, - - /** - * The X value to end the effect at. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - end: { - get: function () - { - return this.uniforms.end; - }, - set: function (value) - { - this.uniforms.end = value; - this.updateDelta(); - } - } -}); diff --git a/src/filters/ascii/AsciiFilter.js b/src/filters/ascii/AsciiFilter.js deleted file mode 100644 index ac64fd1..0000000 --- a/src/filters/ascii/AsciiFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -// TODO (cengler) - The Y is flipped in this shader for some reason. - -/** - * @author Vico @vicocotea - * original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h - */ - -/** - * An ASCII filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function AsciiFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./ascii.frag') - ); - - this.size = 8; -} - -AsciiFilter.prototype = Object.create(core.Filter.prototype); -AsciiFilter.prototype.constructor = AsciiFilter; -module.exports = AsciiFilter; - -Object.defineProperties(AsciiFilter.prototype, { - /** - * The pixel size used by the filter. - * - * @member {number} - * @memberof PIXI.filters.AsciiFilter# - */ - size: { - get: function () - { - return this.uniforms.pixelSize; - }, - set: function (value) - { - this.uniforms.pixelSize = value; - } - } -}); diff --git a/src/filters/ascii/ascii.frag b/src/filters/ascii/ascii.frag deleted file mode 100644 index 5608d6e..0000000 --- a/src/filters/ascii/ascii.frag +++ /dev/null @@ -1,70 +0,0 @@ -varying vec2 vTextureCoord; - -uniform vec4 filterArea; -uniform float pixelSize; -uniform sampler2D uSampler; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -vec2 getMod(vec2 coord, vec2 size) -{ - return mod( coord , size) / size; -} - -float character(float n, vec2 p) -{ - p = floor(p*vec2(4.0, -4.0) + 2.5); - if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y) - { - if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; - } - return 0.0; -} - -void main() -{ - vec2 coord = mapCoord(vTextureCoord); - - // get the rounded color.. - vec2 pixCoord = pixelate(coord, vec2(pixelSize)); - pixCoord = unmapCoord(pixCoord); - - vec4 color = texture2D(uSampler, pixCoord); - - // determine the character to use - float gray = (color.r + color.g + color.b) / 3.0; - - float n = 65536.0; // . - if (gray > 0.2) n = 65600.0; // : - if (gray > 0.3) n = 332772.0; // * - if (gray > 0.4) n = 15255086.0; // o - if (gray > 0.5) n = 23385164.0; // & - if (gray > 0.6) n = 15252014.0; // 8 - if (gray > 0.7) n = 13199452.0; // @ - if (gray > 0.8) n = 11512810.0; // # - - // get the mod.. - vec2 modd = getMod(coord, vec2(pixelSize)); - - gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); - -} \ No newline at end of file diff --git a/src/filters/bloom/BloomFilter.js b/src/filters/bloom/BloomFilter.js deleted file mode 100644 index 1a9c713..0000000 --- a/src/filters/bloom/BloomFilter.js +++ /dev/null @@ -1,97 +0,0 @@ -var core = require('../../core'), - BlurXFilter = require('../blur/BlurXFilter'), - BlurYFilter = require('../blur/BlurYFilter'); - VoidFilter = require('../void/VoidFilter'); - -/** - * The BloomFilter applies a Gaussian blur to an object. - * The strength of the blur can be set for x- and y-axis separately. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function BloomFilter() -{ - core.Filter.call(this); - - this.blurXFilter = new BlurXFilter(); - this.blurYFilter = new BlurYFilter(); - - this.blurYFilter.blendMode = core.BLEND_MODES.SCREEN; - - this.defaultFilter = new VoidFilter(); -} - -BloomFilter.prototype = Object.create(core.Filter.prototype); -BloomFilter.prototype.constructor = BloomFilter; -module.exports = BloomFilter; - -BloomFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - //TODO - copyTexSubImage2D could be used here? - this.defaultFilter.apply(filterManager, input, output); - - this.blurXFilter.apply(filterManager, input, renderTarget); - this.blurYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(BloomFilter.prototype, { - /** - * Sets the strength of both the blurX and blurY properties simultaneously - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blur: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = this.blurYFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurX property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurX: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurY property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurY: { - get: function () - { - return this.blurYFilter.blur; - }, - set: function (value) - { - this.blurYFilter.blur = value; - } - } -}); diff --git a/src/filters/convolution/ConvolutionFilter.js b/src/filters/convolution/ConvolutionFilter.js deleted file mode 100644 index 51775ba..0000000 --- a/src/filters/convolution/ConvolutionFilter.js +++ /dev/null @@ -1,87 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ConvolutionFilter class applies a matrix convolution filter effect. - * A convolution combines pixels in the input image with neighboring pixels to produce a new image. - * A wide variety of image effects can be achieved through convolutions, including blurring, edge - * detection, sharpening, embossing, and beveling. The matrix should be specified as a 9 point Array. - * See http://docs.gimp.org/en/plug-in-convmatrix.html for more info. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - * @param matrix {number[]} An array of values used for matrix transformation. Specified as a 9 point Array. - * @param width {number} Width of the object you are transforming - * @param height {number} Height of the object you are transforming - */ -function ConvolutionFilter(matrix, width, height) -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./convolution.frag') - ); - - this.matrix = matrix; - this.width = width; - this.height = height; -} - -ConvolutionFilter.prototype = Object.create(core.Filter.prototype); -ConvolutionFilter.prototype.constructor = ConvolutionFilter; -module.exports = ConvolutionFilter; - -Object.defineProperties(ConvolutionFilter.prototype, { - /** - * An array of values used for matrix transformation. Specified as a 9 point Array. - * - * @member {number[]} - * @memberof PIXI.filters.ConvolutionFilter# - */ - matrix: { - get: function () - { - return this.uniforms.matrix; - }, - set: function (value) - { - this.uniforms.matrix = new Float32Array(value); - } - }, - - /** - * Width of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - width: { - get: function () - { - return 1/this.uniforms.texelSize[0]; - }, - set: function (value) - { - this.uniforms.texelSize[0] = 1/value; - } - }, - - /** - * Height of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - height: { - get: function () - { - return 1/this.uniforms.texelSize[1]; - }, - set: function (value) - { - this.uniforms.texelSize[1] = 1/value; - } - } -}); diff --git a/src/filters/convolution/convolution.frag b/src/filters/convolution/convolution.frag deleted file mode 100644 index e6fe7b5..0000000 --- a/src/filters/convolution/convolution.frag +++ /dev/null @@ -1,29 +0,0 @@ -precision mediump float; - -varying mediump vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec2 texelSize; -uniform float matrix[9]; - -void main(void) -{ - vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left - vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center - vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right - - vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left - vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center - vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right - - vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left - vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center - vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right - - gl_FragColor = - c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] + - c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] + - c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8]; - - gl_FragColor.a = c22.a; -} diff --git a/src/filters/crosshatch/CrossHatchFilter.js b/src/filters/crosshatch/CrossHatchFilter.js deleted file mode 100644 index a8da95d..0000000 --- a/src/filters/crosshatch/CrossHatchFilter.js +++ /dev/null @@ -1,23 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * A Cross Hatch effect filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function CrossHatchFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./crosshatch.frag') - ); -} - -CrossHatchFilter.prototype = Object.create(core.Filter.prototype); -CrossHatchFilter.prototype.constructor = CrossHatchFilter; -module.exports = CrossHatchFilter; diff --git a/src/filters/crosshatch/crosshatch.frag b/src/filters/crosshatch/crosshatch.frag deleted file mode 100644 index 635ba4b..0000000 --- a/src/filters/crosshatch/crosshatch.frag +++ /dev/null @@ -1,44 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -void main(void) -{ - float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb); - - gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); - - if (lum < 1.00) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.75) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.50) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.3) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } -} diff --git a/src/filters/dot/DotFilter.js b/src/filters/dot/DotFilter.js deleted file mode 100644 index d2bc544..0000000 --- a/src/filters/dot/DotFilter.js +++ /dev/null @@ -1,66 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * @author Mat Groves http://matgroves.com/ @Doormat23 - * original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/fun/dotscreen.js - */ - -/** - * This filter applies a dotscreen effect making display objects appear to be made out of - * black and white halftone dots like an old printer. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function DotFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./dot.frag') - ); - - this.scale = 1; - this.angle = 5; -} - -DotFilter.prototype = Object.create(core.Filter.prototype); -DotFilter.prototype.constructor = DotFilter; -module.exports = DotFilter; - -Object.defineProperties(DotFilter.prototype, { - /** - * The scale of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - scale: { - get: function () - { - return this.uniforms.scale; - }, - set: function (value) - { - this.uniforms.scale = value; - } - }, - - /** - * The radius of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - angle: { - get: function () - { - return this.uniforms.angle; - }, - set: function (value) - { - this.uniforms.angle = value; - } - } -}); diff --git a/src/filters/dot/dot.frag b/src/filters/dot/dot.frag deleted file mode 100644 index 91341b1..0000000 --- a/src/filters/dot/dot.frag +++ /dev/null @@ -1,28 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; -varying vec4 vColor; - -uniform vec4 filterArea; -uniform sampler2D uSampler; - -uniform float angle; -uniform float scale; - -float pattern() -{ - float s = sin(angle), c = cos(angle); - vec2 tex = vTextureCoord * filterArea.xy; - vec2 point = vec2( - c * tex.x - s * tex.y, - s * tex.x + c * tex.y - ) * scale; - return (sin(point.x) * sin(point.y)) * 4.0; -} - -void main() -{ - vec4 color = texture2D(uSampler, vTextureCoord); - float average = (color.r + color.g + color.b) / 3.0; - gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a); -} diff --git a/src/filters/emboss/EmbossFilter.js b/src/filters/emboss/EmbossFilter.js deleted file mode 100644 index 0468d1f..0000000 --- a/src/filters/emboss/EmbossFilter.js +++ /dev/null @@ -1,46 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function EmbossFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./emboss.frag') - ); - - this.strength = 5; -} - -EmbossFilter.prototype = Object.create(core.Filter.prototype); -EmbossFilter.prototype.constructor = EmbossFilter; -module.exports = EmbossFilter; - -Object.defineProperties(EmbossFilter.prototype, { - /** - * Strength of Emboss. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.EmbossFilter# - */ - strength: { - get: function () - { - return this.uniforms.strength; - }, - set: function (value) - { - this.uniforms.strength = value; - } - }, - - -}); diff --git a/src/filters/emboss/emboss.frag b/src/filters/emboss/emboss.frag deleted file mode 100644 index 28b14d9..0000000 --- a/src/filters/emboss/emboss.frag +++ /dev/null @@ -1,26 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform float strength; -uniform vec4 filterArea; - - -void main(void) -{ - vec2 onePixel = vec2(1.0 / filterArea); - - vec4 color; - - color.rgb = vec3(0.5); - - color -= texture2D(uSampler, vTextureCoord - onePixel) * strength; - color += texture2D(uSampler, vTextureCoord + onePixel) * strength; - - color.rgb = vec3((color.r + color.g + color.b) / 3.0); - - float alpha = texture2D(uSampler, vTextureCoord).a; - - gl_FragColor = vec4(color.rgb * alpha, alpha); -} diff --git a/src/filters/index.js b/src/filters/index.js index 6709e39..54c1a3b 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -9,28 +9,12 @@ * @namespace PIXI.filters */ module.exports = { - AsciiFilter: require('./ascii/AsciiFilter'), - BloomFilter: require('./bloom/BloomFilter'), - ConvolutionFilter: require('./convolution/ConvolutionFilter'), - CrossHatchFilter: require('./crosshatch/CrossHatchFilter'), - DotFilter: require('./dot/DotFilter'), FXAAFilter: require('./fxaa/FXAAFilter'), - // DropShadowFilter: require('./dropshadow/DropShadowFilter'), NoiseFilter: require('./noise/NoiseFilter'), - PixelateFilter: require('./pixelate/PixelateFilter'), - RGBSplitFilter: require('./rgb/RGBSplitFilter'), - EmbossFilter: require('./emboss/EmbossFilter'), - ShockwaveFilter: require('./shockwave/ShockwaveFilter'), - // SmartBlurFilter: require('./blur/SmartBlurFilter'), - TiltShiftFilter: require('./tiltshift/TiltShiftFilter'), - // TiltShiftXFilter: require('./tiltshift/TiltShiftXFilter'), - //TiltShiftYFilter: require('./tiltshift/TiltShiftYFilter'), DisplacementFilter: require('./displacement/DisplacementFilter'), BlurFilter: require('./blur/BlurFilter'), BlurXFilter: require('./blur/BlurXFilter'), BlurYFilter: require('./blur/BlurYFilter'), - ColorMatrixFilter: require('./colormatrix/ColorMatrixFilter'), - TwistFilter: require('./twist/TwistFilter'), VoidFilter: require('./void/VoidFilter') }; diff --git a/src/filters/pixelate/PixelateFilter.js b/src/filters/pixelate/PixelateFilter.js deleted file mode 100644 index 6d5a1f2..0000000 --- a/src/filters/pixelate/PixelateFilter.js +++ /dev/null @@ -1,47 +0,0 @@ -var core = require('../../core'); -// @see https://github.com/substack/brfs/issues/25 -var glslify = require('glslify'); - -/** - * This filter applies a pixelate effect making display objects appear 'blocky'. - * - * @class - * @extends PIXI.AbstractFilter - * @memberof PIXI.filters - */ -function PixelateFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./pixelate.frag') - ); - - this.size = [0,0]; - -} - -PixelateFilter.prototype = Object.create(core.Filter.prototype); -PixelateFilter.prototype.constructor = PixelateFilter; -module.exports = PixelateFilter; - -Object.defineProperties(PixelateFilter.prototype, { - /** - * This a point that describes the size of the blocks. - * x is the width of the block and y is the height. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.PixelateFilter# - */ - size: { - get: function () - { - return this.uniforms.size; - }, - set: function (value) - { - this.uniforms.size.value = value; - } - } -}); diff --git a/src/filters/pixelate/pixelate.frag b/src/filters/pixelate/pixelate.frag deleted file mode 100644 index 80ad2ee..0000000 --- a/src/filters/pixelate/pixelate.frag +++ /dev/null @@ -1,40 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform vec2 size; -uniform sampler2D uSampler; - -uniform vec4 filterArea; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -void main(void) -{ - vec2 coord = mapCoord(vTextureCoord); - - coord = pixelate(coord, size); - - coord = unmapCoord(coord); - - gl_FragColor = texture2D(uSampler, coord); -} diff --git a/src/filters/rgb/RGBSplitFilter.js b/src/filters/rgb/RGBSplitFilter.js deleted file mode 100644 index 9609514..0000000 --- a/src/filters/rgb/RGBSplitFilter.js +++ /dev/null @@ -1,80 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function RGBSplitFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./rgb-split.frag') - ); - - this.red = [-10, 0]; - this.green = [0, 10]; - this.blue = [0, 0]; -} - -RGBSplitFilter.prototype = Object.create(core.Filter.prototype); -RGBSplitFilter.prototype.constructor = RGBSplitFilter; -module.exports = RGBSplitFilter; - -Object.defineProperties(RGBSplitFilter.prototype, { - /** - * Red channel offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - red: { - get: function () - { - return this.uniforms.red; - }, - set: function (value) - { - this.uniforms.red = value; - } - }, - - /** - * Green channel offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - green: { - get: function () - { - return this.uniforms.green; - }, - set: function (value) - { - this.uniforms.green = value; - } - }, - - /** - * Blue offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - blue: { - get: function () - { - return this.uniforms.blue.value; - }, - set: function (value) - { - this.uniforms.blue.value = value; - } - } -}); diff --git a/src/filters/rgb/rgb-split.frag b/src/filters/rgb/rgb-split.frag deleted file mode 100644 index 46fed0f..0000000 --- a/src/filters/rgb/rgb-split.frag +++ /dev/null @@ -1,17 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec4 filterArea; -uniform vec2 red; -uniform vec2 green; -uniform vec2 blue; - -void main(void) -{ - gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/filterArea.xy).r; - gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/filterArea.xy).g; - gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/filterArea.xy).b; - gl_FragColor.a = texture2D(uSampler, vTextureCoord).a; -} diff --git a/src/filters/shockwave/ShockwaveFilter.js b/src/filters/shockwave/ShockwaveFilter.js deleted file mode 100644 index 709bb86..0000000 --- a/src/filters/shockwave/ShockwaveFilter.js +++ /dev/null @@ -1,89 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ColorMatrixFilter class lets you apply a 4x4 matrix transformation on the RGBA - * color and alpha values of every pixel on your displayObject to produce a result - * with a new set of RGBA color and alpha values. It's pretty powerful! - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function ShockwaveFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./shockwave.frag'), - // custom uniforms - { - center: { type: 'v2', value: { x: 0.5, y: 0.5 } }, - params: { type: 'v3', value: { x: 10, y: 0.8, z: 0.1 } }, - time: { type: '1f', value: 0 } - } - ); - - this.center = [0.5, 0.5]; - this.params = [10, 0.8, 0.1]; - this.time = 0; -} - -ShockwaveFilter.prototype = Object.create(core.Filter.prototype); -ShockwaveFilter.prototype.constructor = ShockwaveFilter; -module.exports = ShockwaveFilter; - -Object.defineProperties(ShockwaveFilter.prototype, { - /** - * Sets the center of the shockwave in normalized screen coords. That is - * (0,0) is the top-left and (1,1) is the bottom right. - * - * @member {object} - * @memberof PIXI.filters.ShockwaveFilter# - */ - center: { - get: function () - { - return this.uniforms.center; - }, - set: function (value) - { - this.uniforms.center = value; - } - }, - /** - * Sets the params of the shockwave. These modify the look and behavior of - * the shockwave as it ripples out. - * - * @member {object} - * @memberof PIXI.filters.ShockwaveFilter# - */ - params: { - get: function () - { - return this.uniforms.params; - }, - set: function (value) - { - this.uniforms.params = value; - } - }, - /** - * Sets the elapsed time of the shockwave. This controls the speed at which - * the shockwave ripples out. - * - * @member {number} - * @memberof PIXI.filters.ShockwaveFilter# - */ - time: { - get: function () - { - return this.uniforms.time; - }, - set: function (value) - { - this.uniforms.time = value; - } - } -}); diff --git a/src/filters/shockwave/shockwave.frag b/src/filters/shockwave/shockwave.frag deleted file mode 100644 index db2642e..0000000 --- a/src/filters/shockwave/shockwave.frag +++ /dev/null @@ -1,27 +0,0 @@ -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -uniform vec2 center; -uniform vec3 params; // 10.0, 0.8, 0.1 -uniform float time; - -void main() -{ - vec2 uv = vTextureCoord; - vec2 texCoord = uv; - - float dist = distance(uv, center); - - if ( (dist <= (time + params.z)) && (dist >= (time - params.z)) ) - { - float diff = (dist - time); - float powDiff = 1.0 - pow(abs(diff*params.x), params.y); - - float diffTime = diff * powDiff; - vec2 diffUV = normalize(uv - center); - texCoord = uv + (diffUV * diffTime); - } - - gl_FragColor = texture2D(uSampler, texCoord); -} diff --git a/src/filters/tiltshift/TiltShiftAxisFilter.js b/src/filters/tiltshift/TiltShiftAxisFilter.js deleted file mode 100644 index 17a2dd5..0000000 --- a/src/filters/tiltshift/TiltShiftAxisFilter.js +++ /dev/null @@ -1,121 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * @author Vico @vicocotea - * original filter https://github.com/evanw/glfx.js/blob/master/src/filters/blur/tiltshift.js by Evan Wallace : http://madebyevan.com/ - */ - -/** - * A TiltShiftAxisFilter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function TiltShiftAxisFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./tilt-shift.frag') - - ); - - this.uniforms.blur = 100; - this.uniforms.gradientBlur = 600; - this.uniforms.start = new PIXI.Point(0, window.innerHeight / 2); - this.uniforms.end = new PIXI.Point(600, window.innerHeight / 2); - this.uniforms.delta = new PIXI.Point(30, 30); - this.uniforms.texSize = new PIXI.Point(window.innerWidth, window.innerHeight); - - this.updateDelta(); -} - -TiltShiftAxisFilter.prototype = Object.create(core.Filter.prototype); -TiltShiftAxisFilter.prototype.constructor = TiltShiftAxisFilter; -module.exports = TiltShiftAxisFilter; - -/** - * Updates the filter delta values. - * This is overridden in the X and Y filters, does nothing for this class. - * - */ -TiltShiftAxisFilter.prototype.updateDelta = function () -{ - this.uniforms.delta.x = 0; - this.uniforms.delta.y = 0; -}; - -Object.defineProperties(TiltShiftAxisFilter.prototype, { - /** - * The strength of the blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - blur: { - get: function () - { - return this.uniforms.blur; - }, - set: function (value) - { - this.uniforms.blur = value; - } - }, - - /** - * The strength of the gradient blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - gradientBlur: { - get: function () - { - return this.uniforms.gradientBlur; - }, - set: function (value) - { - this.uniforms.gradientBlur = value; - } - }, - - /** - * The X value to start the effect at. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - start: { - get: function () - { - return this.uniforms.start; - }, - set: function (value) - { - this.uniforms.start = value; - this.updateDelta(); - } - }, - - /** - * The X value to end the effect at. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - end: { - get: function () - { - return this.uniforms.end; - }, - set: function (value) - { - this.uniforms.end = value; - this.updateDelta(); - } - } -}); diff --git a/src/filters/tiltshift/TiltShiftFilter.js b/src/filters/tiltshift/TiltShiftFilter.js deleted file mode 100644 index 671ac7a..0000000 --- a/src/filters/tiltshift/TiltShiftFilter.js +++ /dev/null @@ -1,108 +0,0 @@ -var core = require('../../core'), - TiltShiftXFilter = require('./TiltShiftXFilter'), - TiltShiftYFilter = require('./TiltShiftYFilter'); - -/** - * @author Vico @vicocotea - * original filter https://github.com/evanw/glfx.js/blob/master/src/filters/blur/tiltshift.js by Evan Wallace : http://madebyevan.com/ - */ - -/** - * A TiltShift Filter. Manages the pass of both a TiltShiftXFilter and TiltShiftYFilter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function TiltShiftFilter() -{ - core.Filter.call(this); - - this.tiltShiftXFilter = new TiltShiftXFilter(); - this.tiltShiftYFilter = new TiltShiftYFilter(); -} - -TiltShiftFilter.prototype = Object.create(core.Filter.prototype); -TiltShiftFilter.prototype.constructor = TiltShiftFilter; -module.exports = TiltShiftFilter; - -TiltShiftFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - this.tiltShiftXFilter.apply(filterManager, input, renderTarget); - - this.tiltShiftYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(TiltShiftFilter.prototype, { - /** - * The strength of the blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftFilter# - */ - blur: { - get: function () - { - return this.tiltShiftXFilter.blur; - }, - set: function (value) - { - this.tiltShiftXFilter.blur = this.tiltShiftYFilter.blur = value; - } - }, - - /** - * The strength of the gradient blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftFilter# - */ - gradientBlur: { - get: function () - { - return this.tiltShiftXFilter.gradientBlur; - }, - set: function (value) - { - this.tiltShiftXFilter.gradientBlur = this.tiltShiftYFilter.gradientBlur = value; - } - }, - - /** - * The Y value to start the effect at. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftFilter# - */ - start: { - get: function () - { - return this.tiltShiftXFilter.start; - }, - set: function (value) - { - this.tiltShiftXFilter.start = this.tiltShiftYFilter.start = value; - } - }, - - /** - * The Y value to end the effect at. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftFilter# - */ - end: { - get: function () - { - return this.tiltShiftXFilter.end; - }, - set: function (value) - { - this.tiltShiftXFilter.end = this.tiltShiftYFilter.end = value; - } - } -}); diff --git a/src/filters/ascii/AsciiFilter.js b/src/filters/ascii/AsciiFilter.js deleted file mode 100644 index ac64fd1..0000000 --- a/src/filters/ascii/AsciiFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -// TODO (cengler) - The Y is flipped in this shader for some reason. - -/** - * @author Vico @vicocotea - * original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h - */ - -/** - * An ASCII filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function AsciiFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./ascii.frag') - ); - - this.size = 8; -} - -AsciiFilter.prototype = Object.create(core.Filter.prototype); -AsciiFilter.prototype.constructor = AsciiFilter; -module.exports = AsciiFilter; - -Object.defineProperties(AsciiFilter.prototype, { - /** - * The pixel size used by the filter. - * - * @member {number} - * @memberof PIXI.filters.AsciiFilter# - */ - size: { - get: function () - { - return this.uniforms.pixelSize; - }, - set: function (value) - { - this.uniforms.pixelSize = value; - } - } -}); diff --git a/src/filters/ascii/ascii.frag b/src/filters/ascii/ascii.frag deleted file mode 100644 index 5608d6e..0000000 --- a/src/filters/ascii/ascii.frag +++ /dev/null @@ -1,70 +0,0 @@ -varying vec2 vTextureCoord; - -uniform vec4 filterArea; -uniform float pixelSize; -uniform sampler2D uSampler; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -vec2 getMod(vec2 coord, vec2 size) -{ - return mod( coord , size) / size; -} - -float character(float n, vec2 p) -{ - p = floor(p*vec2(4.0, -4.0) + 2.5); - if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y) - { - if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; - } - return 0.0; -} - -void main() -{ - vec2 coord = mapCoord(vTextureCoord); - - // get the rounded color.. - vec2 pixCoord = pixelate(coord, vec2(pixelSize)); - pixCoord = unmapCoord(pixCoord); - - vec4 color = texture2D(uSampler, pixCoord); - - // determine the character to use - float gray = (color.r + color.g + color.b) / 3.0; - - float n = 65536.0; // . - if (gray > 0.2) n = 65600.0; // : - if (gray > 0.3) n = 332772.0; // * - if (gray > 0.4) n = 15255086.0; // o - if (gray > 0.5) n = 23385164.0; // & - if (gray > 0.6) n = 15252014.0; // 8 - if (gray > 0.7) n = 13199452.0; // @ - if (gray > 0.8) n = 11512810.0; // # - - // get the mod.. - vec2 modd = getMod(coord, vec2(pixelSize)); - - gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); - -} \ No newline at end of file diff --git a/src/filters/bloom/BloomFilter.js b/src/filters/bloom/BloomFilter.js deleted file mode 100644 index 1a9c713..0000000 --- a/src/filters/bloom/BloomFilter.js +++ /dev/null @@ -1,97 +0,0 @@ -var core = require('../../core'), - BlurXFilter = require('../blur/BlurXFilter'), - BlurYFilter = require('../blur/BlurYFilter'); - VoidFilter = require('../void/VoidFilter'); - -/** - * The BloomFilter applies a Gaussian blur to an object. - * The strength of the blur can be set for x- and y-axis separately. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function BloomFilter() -{ - core.Filter.call(this); - - this.blurXFilter = new BlurXFilter(); - this.blurYFilter = new BlurYFilter(); - - this.blurYFilter.blendMode = core.BLEND_MODES.SCREEN; - - this.defaultFilter = new VoidFilter(); -} - -BloomFilter.prototype = Object.create(core.Filter.prototype); -BloomFilter.prototype.constructor = BloomFilter; -module.exports = BloomFilter; - -BloomFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - //TODO - copyTexSubImage2D could be used here? - this.defaultFilter.apply(filterManager, input, output); - - this.blurXFilter.apply(filterManager, input, renderTarget); - this.blurYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(BloomFilter.prototype, { - /** - * Sets the strength of both the blurX and blurY properties simultaneously - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blur: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = this.blurYFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurX property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurX: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurY property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurY: { - get: function () - { - return this.blurYFilter.blur; - }, - set: function (value) - { - this.blurYFilter.blur = value; - } - } -}); diff --git a/src/filters/convolution/ConvolutionFilter.js b/src/filters/convolution/ConvolutionFilter.js deleted file mode 100644 index 51775ba..0000000 --- a/src/filters/convolution/ConvolutionFilter.js +++ /dev/null @@ -1,87 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ConvolutionFilter class applies a matrix convolution filter effect. - * A convolution combines pixels in the input image with neighboring pixels to produce a new image. - * A wide variety of image effects can be achieved through convolutions, including blurring, edge - * detection, sharpening, embossing, and beveling. The matrix should be specified as a 9 point Array. - * See http://docs.gimp.org/en/plug-in-convmatrix.html for more info. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - * @param matrix {number[]} An array of values used for matrix transformation. Specified as a 9 point Array. - * @param width {number} Width of the object you are transforming - * @param height {number} Height of the object you are transforming - */ -function ConvolutionFilter(matrix, width, height) -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./convolution.frag') - ); - - this.matrix = matrix; - this.width = width; - this.height = height; -} - -ConvolutionFilter.prototype = Object.create(core.Filter.prototype); -ConvolutionFilter.prototype.constructor = ConvolutionFilter; -module.exports = ConvolutionFilter; - -Object.defineProperties(ConvolutionFilter.prototype, { - /** - * An array of values used for matrix transformation. Specified as a 9 point Array. - * - * @member {number[]} - * @memberof PIXI.filters.ConvolutionFilter# - */ - matrix: { - get: function () - { - return this.uniforms.matrix; - }, - set: function (value) - { - this.uniforms.matrix = new Float32Array(value); - } - }, - - /** - * Width of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - width: { - get: function () - { - return 1/this.uniforms.texelSize[0]; - }, - set: function (value) - { - this.uniforms.texelSize[0] = 1/value; - } - }, - - /** - * Height of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - height: { - get: function () - { - return 1/this.uniforms.texelSize[1]; - }, - set: function (value) - { - this.uniforms.texelSize[1] = 1/value; - } - } -}); diff --git a/src/filters/convolution/convolution.frag b/src/filters/convolution/convolution.frag deleted file mode 100644 index e6fe7b5..0000000 --- a/src/filters/convolution/convolution.frag +++ /dev/null @@ -1,29 +0,0 @@ -precision mediump float; - -varying mediump vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec2 texelSize; -uniform float matrix[9]; - -void main(void) -{ - vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left - vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center - vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right - - vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left - vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center - vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right - - vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left - vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center - vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right - - gl_FragColor = - c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] + - c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] + - c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8]; - - gl_FragColor.a = c22.a; -} diff --git a/src/filters/crosshatch/CrossHatchFilter.js b/src/filters/crosshatch/CrossHatchFilter.js deleted file mode 100644 index a8da95d..0000000 --- a/src/filters/crosshatch/CrossHatchFilter.js +++ /dev/null @@ -1,23 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * A Cross Hatch effect filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function CrossHatchFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./crosshatch.frag') - ); -} - -CrossHatchFilter.prototype = Object.create(core.Filter.prototype); -CrossHatchFilter.prototype.constructor = CrossHatchFilter; -module.exports = CrossHatchFilter; diff --git a/src/filters/crosshatch/crosshatch.frag b/src/filters/crosshatch/crosshatch.frag deleted file mode 100644 index 635ba4b..0000000 --- a/src/filters/crosshatch/crosshatch.frag +++ /dev/null @@ -1,44 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -void main(void) -{ - float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb); - - gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); - - if (lum < 1.00) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.75) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.50) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.3) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } -} diff --git a/src/filters/dot/DotFilter.js b/src/filters/dot/DotFilter.js deleted file mode 100644 index d2bc544..0000000 --- a/src/filters/dot/DotFilter.js +++ /dev/null @@ -1,66 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * @author Mat Groves http://matgroves.com/ @Doormat23 - * original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/fun/dotscreen.js - */ - -/** - * This filter applies a dotscreen effect making display objects appear to be made out of - * black and white halftone dots like an old printer. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function DotFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./dot.frag') - ); - - this.scale = 1; - this.angle = 5; -} - -DotFilter.prototype = Object.create(core.Filter.prototype); -DotFilter.prototype.constructor = DotFilter; -module.exports = DotFilter; - -Object.defineProperties(DotFilter.prototype, { - /** - * The scale of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - scale: { - get: function () - { - return this.uniforms.scale; - }, - set: function (value) - { - this.uniforms.scale = value; - } - }, - - /** - * The radius of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - angle: { - get: function () - { - return this.uniforms.angle; - }, - set: function (value) - { - this.uniforms.angle = value; - } - } -}); diff --git a/src/filters/dot/dot.frag b/src/filters/dot/dot.frag deleted file mode 100644 index 91341b1..0000000 --- a/src/filters/dot/dot.frag +++ /dev/null @@ -1,28 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; -varying vec4 vColor; - -uniform vec4 filterArea; -uniform sampler2D uSampler; - -uniform float angle; -uniform float scale; - -float pattern() -{ - float s = sin(angle), c = cos(angle); - vec2 tex = vTextureCoord * filterArea.xy; - vec2 point = vec2( - c * tex.x - s * tex.y, - s * tex.x + c * tex.y - ) * scale; - return (sin(point.x) * sin(point.y)) * 4.0; -} - -void main() -{ - vec4 color = texture2D(uSampler, vTextureCoord); - float average = (color.r + color.g + color.b) / 3.0; - gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a); -} diff --git a/src/filters/emboss/EmbossFilter.js b/src/filters/emboss/EmbossFilter.js deleted file mode 100644 index 0468d1f..0000000 --- a/src/filters/emboss/EmbossFilter.js +++ /dev/null @@ -1,46 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function EmbossFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./emboss.frag') - ); - - this.strength = 5; -} - -EmbossFilter.prototype = Object.create(core.Filter.prototype); -EmbossFilter.prototype.constructor = EmbossFilter; -module.exports = EmbossFilter; - -Object.defineProperties(EmbossFilter.prototype, { - /** - * Strength of Emboss. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.EmbossFilter# - */ - strength: { - get: function () - { - return this.uniforms.strength; - }, - set: function (value) - { - this.uniforms.strength = value; - } - }, - - -}); diff --git a/src/filters/emboss/emboss.frag b/src/filters/emboss/emboss.frag deleted file mode 100644 index 28b14d9..0000000 --- a/src/filters/emboss/emboss.frag +++ /dev/null @@ -1,26 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform float strength; -uniform vec4 filterArea; - - -void main(void) -{ - vec2 onePixel = vec2(1.0 / filterArea); - - vec4 color; - - color.rgb = vec3(0.5); - - color -= texture2D(uSampler, vTextureCoord - onePixel) * strength; - color += texture2D(uSampler, vTextureCoord + onePixel) * strength; - - color.rgb = vec3((color.r + color.g + color.b) / 3.0); - - float alpha = texture2D(uSampler, vTextureCoord).a; - - gl_FragColor = vec4(color.rgb * alpha, alpha); -} diff --git a/src/filters/index.js b/src/filters/index.js index 6709e39..54c1a3b 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -9,28 +9,12 @@ * @namespace PIXI.filters */ module.exports = { - AsciiFilter: require('./ascii/AsciiFilter'), - BloomFilter: require('./bloom/BloomFilter'), - ConvolutionFilter: require('./convolution/ConvolutionFilter'), - CrossHatchFilter: require('./crosshatch/CrossHatchFilter'), - DotFilter: require('./dot/DotFilter'), FXAAFilter: require('./fxaa/FXAAFilter'), - // DropShadowFilter: require('./dropshadow/DropShadowFilter'), NoiseFilter: require('./noise/NoiseFilter'), - PixelateFilter: require('./pixelate/PixelateFilter'), - RGBSplitFilter: require('./rgb/RGBSplitFilter'), - EmbossFilter: require('./emboss/EmbossFilter'), - ShockwaveFilter: require('./shockwave/ShockwaveFilter'), - // SmartBlurFilter: require('./blur/SmartBlurFilter'), - TiltShiftFilter: require('./tiltshift/TiltShiftFilter'), - // TiltShiftXFilter: require('./tiltshift/TiltShiftXFilter'), - //TiltShiftYFilter: require('./tiltshift/TiltShiftYFilter'), DisplacementFilter: require('./displacement/DisplacementFilter'), BlurFilter: require('./blur/BlurFilter'), BlurXFilter: require('./blur/BlurXFilter'), BlurYFilter: require('./blur/BlurYFilter'), - ColorMatrixFilter: require('./colormatrix/ColorMatrixFilter'), - TwistFilter: require('./twist/TwistFilter'), VoidFilter: require('./void/VoidFilter') }; diff --git a/src/filters/pixelate/PixelateFilter.js b/src/filters/pixelate/PixelateFilter.js deleted file mode 100644 index 6d5a1f2..0000000 --- a/src/filters/pixelate/PixelateFilter.js +++ /dev/null @@ -1,47 +0,0 @@ -var core = require('../../core'); -// @see https://github.com/substack/brfs/issues/25 -var glslify = require('glslify'); - -/** - * This filter applies a pixelate effect making display objects appear 'blocky'. - * - * @class - * @extends PIXI.AbstractFilter - * @memberof PIXI.filters - */ -function PixelateFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./pixelate.frag') - ); - - this.size = [0,0]; - -} - -PixelateFilter.prototype = Object.create(core.Filter.prototype); -PixelateFilter.prototype.constructor = PixelateFilter; -module.exports = PixelateFilter; - -Object.defineProperties(PixelateFilter.prototype, { - /** - * This a point that describes the size of the blocks. - * x is the width of the block and y is the height. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.PixelateFilter# - */ - size: { - get: function () - { - return this.uniforms.size; - }, - set: function (value) - { - this.uniforms.size.value = value; - } - } -}); diff --git a/src/filters/pixelate/pixelate.frag b/src/filters/pixelate/pixelate.frag deleted file mode 100644 index 80ad2ee..0000000 --- a/src/filters/pixelate/pixelate.frag +++ /dev/null @@ -1,40 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform vec2 size; -uniform sampler2D uSampler; - -uniform vec4 filterArea; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -void main(void) -{ - vec2 coord = mapCoord(vTextureCoord); - - coord = pixelate(coord, size); - - coord = unmapCoord(coord); - - gl_FragColor = texture2D(uSampler, coord); -} diff --git a/src/filters/rgb/RGBSplitFilter.js b/src/filters/rgb/RGBSplitFilter.js deleted file mode 100644 index 9609514..0000000 --- a/src/filters/rgb/RGBSplitFilter.js +++ /dev/null @@ -1,80 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function RGBSplitFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./rgb-split.frag') - ); - - this.red = [-10, 0]; - this.green = [0, 10]; - this.blue = [0, 0]; -} - -RGBSplitFilter.prototype = Object.create(core.Filter.prototype); -RGBSplitFilter.prototype.constructor = RGBSplitFilter; -module.exports = RGBSplitFilter; - -Object.defineProperties(RGBSplitFilter.prototype, { - /** - * Red channel offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - red: { - get: function () - { - return this.uniforms.red; - }, - set: function (value) - { - this.uniforms.red = value; - } - }, - - /** - * Green channel offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - green: { - get: function () - { - return this.uniforms.green; - }, - set: function (value) - { - this.uniforms.green = value; - } - }, - - /** - * Blue offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - blue: { - get: function () - { - return this.uniforms.blue.value; - }, - set: function (value) - { - this.uniforms.blue.value = value; - } - } -}); diff --git a/src/filters/rgb/rgb-split.frag b/src/filters/rgb/rgb-split.frag deleted file mode 100644 index 46fed0f..0000000 --- a/src/filters/rgb/rgb-split.frag +++ /dev/null @@ -1,17 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec4 filterArea; -uniform vec2 red; -uniform vec2 green; -uniform vec2 blue; - -void main(void) -{ - gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/filterArea.xy).r; - gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/filterArea.xy).g; - gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/filterArea.xy).b; - gl_FragColor.a = texture2D(uSampler, vTextureCoord).a; -} diff --git a/src/filters/shockwave/ShockwaveFilter.js b/src/filters/shockwave/ShockwaveFilter.js deleted file mode 100644 index 709bb86..0000000 --- a/src/filters/shockwave/ShockwaveFilter.js +++ /dev/null @@ -1,89 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ColorMatrixFilter class lets you apply a 4x4 matrix transformation on the RGBA - * color and alpha values of every pixel on your displayObject to produce a result - * with a new set of RGBA color and alpha values. It's pretty powerful! - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function ShockwaveFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./shockwave.frag'), - // custom uniforms - { - center: { type: 'v2', value: { x: 0.5, y: 0.5 } }, - params: { type: 'v3', value: { x: 10, y: 0.8, z: 0.1 } }, - time: { type: '1f', value: 0 } - } - ); - - this.center = [0.5, 0.5]; - this.params = [10, 0.8, 0.1]; - this.time = 0; -} - -ShockwaveFilter.prototype = Object.create(core.Filter.prototype); -ShockwaveFilter.prototype.constructor = ShockwaveFilter; -module.exports = ShockwaveFilter; - -Object.defineProperties(ShockwaveFilter.prototype, { - /** - * Sets the center of the shockwave in normalized screen coords. That is - * (0,0) is the top-left and (1,1) is the bottom right. - * - * @member {object} - * @memberof PIXI.filters.ShockwaveFilter# - */ - center: { - get: function () - { - return this.uniforms.center; - }, - set: function (value) - { - this.uniforms.center = value; - } - }, - /** - * Sets the params of the shockwave. These modify the look and behavior of - * the shockwave as it ripples out. - * - * @member {object} - * @memberof PIXI.filters.ShockwaveFilter# - */ - params: { - get: function () - { - return this.uniforms.params; - }, - set: function (value) - { - this.uniforms.params = value; - } - }, - /** - * Sets the elapsed time of the shockwave. This controls the speed at which - * the shockwave ripples out. - * - * @member {number} - * @memberof PIXI.filters.ShockwaveFilter# - */ - time: { - get: function () - { - return this.uniforms.time; - }, - set: function (value) - { - this.uniforms.time = value; - } - } -}); diff --git a/src/filters/shockwave/shockwave.frag b/src/filters/shockwave/shockwave.frag deleted file mode 100644 index db2642e..0000000 --- a/src/filters/shockwave/shockwave.frag +++ /dev/null @@ -1,27 +0,0 @@ -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -uniform vec2 center; -uniform vec3 params; // 10.0, 0.8, 0.1 -uniform float time; - -void main() -{ - vec2 uv = vTextureCoord; - vec2 texCoord = uv; - - float dist = distance(uv, center); - - if ( (dist <= (time + params.z)) && (dist >= (time - params.z)) ) - { - float diff = (dist - time); - float powDiff = 1.0 - pow(abs(diff*params.x), params.y); - - float diffTime = diff * powDiff; - vec2 diffUV = normalize(uv - center); - texCoord = uv + (diffUV * diffTime); - } - - gl_FragColor = texture2D(uSampler, texCoord); -} diff --git a/src/filters/tiltshift/TiltShiftAxisFilter.js b/src/filters/tiltshift/TiltShiftAxisFilter.js deleted file mode 100644 index 17a2dd5..0000000 --- a/src/filters/tiltshift/TiltShiftAxisFilter.js +++ /dev/null @@ -1,121 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * @author Vico @vicocotea - * original filter https://github.com/evanw/glfx.js/blob/master/src/filters/blur/tiltshift.js by Evan Wallace : http://madebyevan.com/ - */ - -/** - * A TiltShiftAxisFilter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function TiltShiftAxisFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./tilt-shift.frag') - - ); - - this.uniforms.blur = 100; - this.uniforms.gradientBlur = 600; - this.uniforms.start = new PIXI.Point(0, window.innerHeight / 2); - this.uniforms.end = new PIXI.Point(600, window.innerHeight / 2); - this.uniforms.delta = new PIXI.Point(30, 30); - this.uniforms.texSize = new PIXI.Point(window.innerWidth, window.innerHeight); - - this.updateDelta(); -} - -TiltShiftAxisFilter.prototype = Object.create(core.Filter.prototype); -TiltShiftAxisFilter.prototype.constructor = TiltShiftAxisFilter; -module.exports = TiltShiftAxisFilter; - -/** - * Updates the filter delta values. - * This is overridden in the X and Y filters, does nothing for this class. - * - */ -TiltShiftAxisFilter.prototype.updateDelta = function () -{ - this.uniforms.delta.x = 0; - this.uniforms.delta.y = 0; -}; - -Object.defineProperties(TiltShiftAxisFilter.prototype, { - /** - * The strength of the blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - blur: { - get: function () - { - return this.uniforms.blur; - }, - set: function (value) - { - this.uniforms.blur = value; - } - }, - - /** - * The strength of the gradient blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - gradientBlur: { - get: function () - { - return this.uniforms.gradientBlur; - }, - set: function (value) - { - this.uniforms.gradientBlur = value; - } - }, - - /** - * The X value to start the effect at. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - start: { - get: function () - { - return this.uniforms.start; - }, - set: function (value) - { - this.uniforms.start = value; - this.updateDelta(); - } - }, - - /** - * The X value to end the effect at. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - end: { - get: function () - { - return this.uniforms.end; - }, - set: function (value) - { - this.uniforms.end = value; - this.updateDelta(); - } - } -}); diff --git a/src/filters/tiltshift/TiltShiftFilter.js b/src/filters/tiltshift/TiltShiftFilter.js deleted file mode 100644 index 671ac7a..0000000 --- a/src/filters/tiltshift/TiltShiftFilter.js +++ /dev/null @@ -1,108 +0,0 @@ -var core = require('../../core'), - TiltShiftXFilter = require('./TiltShiftXFilter'), - TiltShiftYFilter = require('./TiltShiftYFilter'); - -/** - * @author Vico @vicocotea - * original filter https://github.com/evanw/glfx.js/blob/master/src/filters/blur/tiltshift.js by Evan Wallace : http://madebyevan.com/ - */ - -/** - * A TiltShift Filter. Manages the pass of both a TiltShiftXFilter and TiltShiftYFilter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function TiltShiftFilter() -{ - core.Filter.call(this); - - this.tiltShiftXFilter = new TiltShiftXFilter(); - this.tiltShiftYFilter = new TiltShiftYFilter(); -} - -TiltShiftFilter.prototype = Object.create(core.Filter.prototype); -TiltShiftFilter.prototype.constructor = TiltShiftFilter; -module.exports = TiltShiftFilter; - -TiltShiftFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - this.tiltShiftXFilter.apply(filterManager, input, renderTarget); - - this.tiltShiftYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(TiltShiftFilter.prototype, { - /** - * The strength of the blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftFilter# - */ - blur: { - get: function () - { - return this.tiltShiftXFilter.blur; - }, - set: function (value) - { - this.tiltShiftXFilter.blur = this.tiltShiftYFilter.blur = value; - } - }, - - /** - * The strength of the gradient blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftFilter# - */ - gradientBlur: { - get: function () - { - return this.tiltShiftXFilter.gradientBlur; - }, - set: function (value) - { - this.tiltShiftXFilter.gradientBlur = this.tiltShiftYFilter.gradientBlur = value; - } - }, - - /** - * The Y value to start the effect at. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftFilter# - */ - start: { - get: function () - { - return this.tiltShiftXFilter.start; - }, - set: function (value) - { - this.tiltShiftXFilter.start = this.tiltShiftYFilter.start = value; - } - }, - - /** - * The Y value to end the effect at. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftFilter# - */ - end: { - get: function () - { - return this.tiltShiftXFilter.end; - }, - set: function (value) - { - this.tiltShiftXFilter.end = this.tiltShiftYFilter.end = value; - } - } -}); diff --git a/src/filters/tiltshift/TiltShiftXFilter.js b/src/filters/tiltshift/TiltShiftXFilter.js deleted file mode 100644 index d6d82ea..0000000 --- a/src/filters/tiltshift/TiltShiftXFilter.js +++ /dev/null @@ -1,36 +0,0 @@ -var TiltShiftAxisFilter = require('./TiltShiftAxisFilter'); - -/** - * @author Vico @vicocotea - * original filter https://github.com/evanw/glfx.js/blob/master/src/filters/blur/tiltshift.js by Evan Wallace : http://madebyevan.com/ - */ - -/** - * A TiltShiftXFilter. - * - * @class - * @extends PIXI.TiltShiftAxisFilter - * @memberof PIXI.filters - */ -function TiltShiftXFilter() -{ - TiltShiftAxisFilter.call(this); -} - -TiltShiftXFilter.prototype = Object.create(TiltShiftAxisFilter.prototype); -TiltShiftXFilter.prototype.constructor = TiltShiftXFilter; -module.exports = TiltShiftXFilter; - -/** - * Updates the filter delta values. - * - */ -TiltShiftXFilter.prototype.updateDelta = function () -{ - var dx = this.uniforms.end.x - this.uniforms.start.x; - var dy = this.uniforms.end.y - this.uniforms.start.y; - var d = Math.sqrt(dx * dx + dy * dy); - - this.uniforms.delta.x = dx / d; - this.uniforms.delta.y = dy / d; -}; diff --git a/src/filters/ascii/AsciiFilter.js b/src/filters/ascii/AsciiFilter.js deleted file mode 100644 index ac64fd1..0000000 --- a/src/filters/ascii/AsciiFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -// TODO (cengler) - The Y is flipped in this shader for some reason. - -/** - * @author Vico @vicocotea - * original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h - */ - -/** - * An ASCII filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function AsciiFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./ascii.frag') - ); - - this.size = 8; -} - -AsciiFilter.prototype = Object.create(core.Filter.prototype); -AsciiFilter.prototype.constructor = AsciiFilter; -module.exports = AsciiFilter; - -Object.defineProperties(AsciiFilter.prototype, { - /** - * The pixel size used by the filter. - * - * @member {number} - * @memberof PIXI.filters.AsciiFilter# - */ - size: { - get: function () - { - return this.uniforms.pixelSize; - }, - set: function (value) - { - this.uniforms.pixelSize = value; - } - } -}); diff --git a/src/filters/ascii/ascii.frag b/src/filters/ascii/ascii.frag deleted file mode 100644 index 5608d6e..0000000 --- a/src/filters/ascii/ascii.frag +++ /dev/null @@ -1,70 +0,0 @@ -varying vec2 vTextureCoord; - -uniform vec4 filterArea; -uniform float pixelSize; -uniform sampler2D uSampler; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -vec2 getMod(vec2 coord, vec2 size) -{ - return mod( coord , size) / size; -} - -float character(float n, vec2 p) -{ - p = floor(p*vec2(4.0, -4.0) + 2.5); - if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y) - { - if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; - } - return 0.0; -} - -void main() -{ - vec2 coord = mapCoord(vTextureCoord); - - // get the rounded color.. - vec2 pixCoord = pixelate(coord, vec2(pixelSize)); - pixCoord = unmapCoord(pixCoord); - - vec4 color = texture2D(uSampler, pixCoord); - - // determine the character to use - float gray = (color.r + color.g + color.b) / 3.0; - - float n = 65536.0; // . - if (gray > 0.2) n = 65600.0; // : - if (gray > 0.3) n = 332772.0; // * - if (gray > 0.4) n = 15255086.0; // o - if (gray > 0.5) n = 23385164.0; // & - if (gray > 0.6) n = 15252014.0; // 8 - if (gray > 0.7) n = 13199452.0; // @ - if (gray > 0.8) n = 11512810.0; // # - - // get the mod.. - vec2 modd = getMod(coord, vec2(pixelSize)); - - gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); - -} \ No newline at end of file diff --git a/src/filters/bloom/BloomFilter.js b/src/filters/bloom/BloomFilter.js deleted file mode 100644 index 1a9c713..0000000 --- a/src/filters/bloom/BloomFilter.js +++ /dev/null @@ -1,97 +0,0 @@ -var core = require('../../core'), - BlurXFilter = require('../blur/BlurXFilter'), - BlurYFilter = require('../blur/BlurYFilter'); - VoidFilter = require('../void/VoidFilter'); - -/** - * The BloomFilter applies a Gaussian blur to an object. - * The strength of the blur can be set for x- and y-axis separately. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function BloomFilter() -{ - core.Filter.call(this); - - this.blurXFilter = new BlurXFilter(); - this.blurYFilter = new BlurYFilter(); - - this.blurYFilter.blendMode = core.BLEND_MODES.SCREEN; - - this.defaultFilter = new VoidFilter(); -} - -BloomFilter.prototype = Object.create(core.Filter.prototype); -BloomFilter.prototype.constructor = BloomFilter; -module.exports = BloomFilter; - -BloomFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - //TODO - copyTexSubImage2D could be used here? - this.defaultFilter.apply(filterManager, input, output); - - this.blurXFilter.apply(filterManager, input, renderTarget); - this.blurYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(BloomFilter.prototype, { - /** - * Sets the strength of both the blurX and blurY properties simultaneously - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blur: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = this.blurYFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurX property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurX: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurY property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurY: { - get: function () - { - return this.blurYFilter.blur; - }, - set: function (value) - { - this.blurYFilter.blur = value; - } - } -}); diff --git a/src/filters/convolution/ConvolutionFilter.js b/src/filters/convolution/ConvolutionFilter.js deleted file mode 100644 index 51775ba..0000000 --- a/src/filters/convolution/ConvolutionFilter.js +++ /dev/null @@ -1,87 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ConvolutionFilter class applies a matrix convolution filter effect. - * A convolution combines pixels in the input image with neighboring pixels to produce a new image. - * A wide variety of image effects can be achieved through convolutions, including blurring, edge - * detection, sharpening, embossing, and beveling. The matrix should be specified as a 9 point Array. - * See http://docs.gimp.org/en/plug-in-convmatrix.html for more info. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - * @param matrix {number[]} An array of values used for matrix transformation. Specified as a 9 point Array. - * @param width {number} Width of the object you are transforming - * @param height {number} Height of the object you are transforming - */ -function ConvolutionFilter(matrix, width, height) -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./convolution.frag') - ); - - this.matrix = matrix; - this.width = width; - this.height = height; -} - -ConvolutionFilter.prototype = Object.create(core.Filter.prototype); -ConvolutionFilter.prototype.constructor = ConvolutionFilter; -module.exports = ConvolutionFilter; - -Object.defineProperties(ConvolutionFilter.prototype, { - /** - * An array of values used for matrix transformation. Specified as a 9 point Array. - * - * @member {number[]} - * @memberof PIXI.filters.ConvolutionFilter# - */ - matrix: { - get: function () - { - return this.uniforms.matrix; - }, - set: function (value) - { - this.uniforms.matrix = new Float32Array(value); - } - }, - - /** - * Width of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - width: { - get: function () - { - return 1/this.uniforms.texelSize[0]; - }, - set: function (value) - { - this.uniforms.texelSize[0] = 1/value; - } - }, - - /** - * Height of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - height: { - get: function () - { - return 1/this.uniforms.texelSize[1]; - }, - set: function (value) - { - this.uniforms.texelSize[1] = 1/value; - } - } -}); diff --git a/src/filters/convolution/convolution.frag b/src/filters/convolution/convolution.frag deleted file mode 100644 index e6fe7b5..0000000 --- a/src/filters/convolution/convolution.frag +++ /dev/null @@ -1,29 +0,0 @@ -precision mediump float; - -varying mediump vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec2 texelSize; -uniform float matrix[9]; - -void main(void) -{ - vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left - vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center - vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right - - vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left - vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center - vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right - - vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left - vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center - vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right - - gl_FragColor = - c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] + - c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] + - c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8]; - - gl_FragColor.a = c22.a; -} diff --git a/src/filters/crosshatch/CrossHatchFilter.js b/src/filters/crosshatch/CrossHatchFilter.js deleted file mode 100644 index a8da95d..0000000 --- a/src/filters/crosshatch/CrossHatchFilter.js +++ /dev/null @@ -1,23 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * A Cross Hatch effect filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function CrossHatchFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./crosshatch.frag') - ); -} - -CrossHatchFilter.prototype = Object.create(core.Filter.prototype); -CrossHatchFilter.prototype.constructor = CrossHatchFilter; -module.exports = CrossHatchFilter; diff --git a/src/filters/crosshatch/crosshatch.frag b/src/filters/crosshatch/crosshatch.frag deleted file mode 100644 index 635ba4b..0000000 --- a/src/filters/crosshatch/crosshatch.frag +++ /dev/null @@ -1,44 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -void main(void) -{ - float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb); - - gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); - - if (lum < 1.00) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.75) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.50) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.3) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } -} diff --git a/src/filters/dot/DotFilter.js b/src/filters/dot/DotFilter.js deleted file mode 100644 index d2bc544..0000000 --- a/src/filters/dot/DotFilter.js +++ /dev/null @@ -1,66 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * @author Mat Groves http://matgroves.com/ @Doormat23 - * original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/fun/dotscreen.js - */ - -/** - * This filter applies a dotscreen effect making display objects appear to be made out of - * black and white halftone dots like an old printer. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function DotFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./dot.frag') - ); - - this.scale = 1; - this.angle = 5; -} - -DotFilter.prototype = Object.create(core.Filter.prototype); -DotFilter.prototype.constructor = DotFilter; -module.exports = DotFilter; - -Object.defineProperties(DotFilter.prototype, { - /** - * The scale of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - scale: { - get: function () - { - return this.uniforms.scale; - }, - set: function (value) - { - this.uniforms.scale = value; - } - }, - - /** - * The radius of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - angle: { - get: function () - { - return this.uniforms.angle; - }, - set: function (value) - { - this.uniforms.angle = value; - } - } -}); diff --git a/src/filters/dot/dot.frag b/src/filters/dot/dot.frag deleted file mode 100644 index 91341b1..0000000 --- a/src/filters/dot/dot.frag +++ /dev/null @@ -1,28 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; -varying vec4 vColor; - -uniform vec4 filterArea; -uniform sampler2D uSampler; - -uniform float angle; -uniform float scale; - -float pattern() -{ - float s = sin(angle), c = cos(angle); - vec2 tex = vTextureCoord * filterArea.xy; - vec2 point = vec2( - c * tex.x - s * tex.y, - s * tex.x + c * tex.y - ) * scale; - return (sin(point.x) * sin(point.y)) * 4.0; -} - -void main() -{ - vec4 color = texture2D(uSampler, vTextureCoord); - float average = (color.r + color.g + color.b) / 3.0; - gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a); -} diff --git a/src/filters/emboss/EmbossFilter.js b/src/filters/emboss/EmbossFilter.js deleted file mode 100644 index 0468d1f..0000000 --- a/src/filters/emboss/EmbossFilter.js +++ /dev/null @@ -1,46 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function EmbossFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./emboss.frag') - ); - - this.strength = 5; -} - -EmbossFilter.prototype = Object.create(core.Filter.prototype); -EmbossFilter.prototype.constructor = EmbossFilter; -module.exports = EmbossFilter; - -Object.defineProperties(EmbossFilter.prototype, { - /** - * Strength of Emboss. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.EmbossFilter# - */ - strength: { - get: function () - { - return this.uniforms.strength; - }, - set: function (value) - { - this.uniforms.strength = value; - } - }, - - -}); diff --git a/src/filters/emboss/emboss.frag b/src/filters/emboss/emboss.frag deleted file mode 100644 index 28b14d9..0000000 --- a/src/filters/emboss/emboss.frag +++ /dev/null @@ -1,26 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform float strength; -uniform vec4 filterArea; - - -void main(void) -{ - vec2 onePixel = vec2(1.0 / filterArea); - - vec4 color; - - color.rgb = vec3(0.5); - - color -= texture2D(uSampler, vTextureCoord - onePixel) * strength; - color += texture2D(uSampler, vTextureCoord + onePixel) * strength; - - color.rgb = vec3((color.r + color.g + color.b) / 3.0); - - float alpha = texture2D(uSampler, vTextureCoord).a; - - gl_FragColor = vec4(color.rgb * alpha, alpha); -} diff --git a/src/filters/index.js b/src/filters/index.js index 6709e39..54c1a3b 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -9,28 +9,12 @@ * @namespace PIXI.filters */ module.exports = { - AsciiFilter: require('./ascii/AsciiFilter'), - BloomFilter: require('./bloom/BloomFilter'), - ConvolutionFilter: require('./convolution/ConvolutionFilter'), - CrossHatchFilter: require('./crosshatch/CrossHatchFilter'), - DotFilter: require('./dot/DotFilter'), FXAAFilter: require('./fxaa/FXAAFilter'), - // DropShadowFilter: require('./dropshadow/DropShadowFilter'), NoiseFilter: require('./noise/NoiseFilter'), - PixelateFilter: require('./pixelate/PixelateFilter'), - RGBSplitFilter: require('./rgb/RGBSplitFilter'), - EmbossFilter: require('./emboss/EmbossFilter'), - ShockwaveFilter: require('./shockwave/ShockwaveFilter'), - // SmartBlurFilter: require('./blur/SmartBlurFilter'), - TiltShiftFilter: require('./tiltshift/TiltShiftFilter'), - // TiltShiftXFilter: require('./tiltshift/TiltShiftXFilter'), - //TiltShiftYFilter: require('./tiltshift/TiltShiftYFilter'), DisplacementFilter: require('./displacement/DisplacementFilter'), BlurFilter: require('./blur/BlurFilter'), BlurXFilter: require('./blur/BlurXFilter'), BlurYFilter: require('./blur/BlurYFilter'), - ColorMatrixFilter: require('./colormatrix/ColorMatrixFilter'), - TwistFilter: require('./twist/TwistFilter'), VoidFilter: require('./void/VoidFilter') }; diff --git a/src/filters/pixelate/PixelateFilter.js b/src/filters/pixelate/PixelateFilter.js deleted file mode 100644 index 6d5a1f2..0000000 --- a/src/filters/pixelate/PixelateFilter.js +++ /dev/null @@ -1,47 +0,0 @@ -var core = require('../../core'); -// @see https://github.com/substack/brfs/issues/25 -var glslify = require('glslify'); - -/** - * This filter applies a pixelate effect making display objects appear 'blocky'. - * - * @class - * @extends PIXI.AbstractFilter - * @memberof PIXI.filters - */ -function PixelateFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./pixelate.frag') - ); - - this.size = [0,0]; - -} - -PixelateFilter.prototype = Object.create(core.Filter.prototype); -PixelateFilter.prototype.constructor = PixelateFilter; -module.exports = PixelateFilter; - -Object.defineProperties(PixelateFilter.prototype, { - /** - * This a point that describes the size of the blocks. - * x is the width of the block and y is the height. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.PixelateFilter# - */ - size: { - get: function () - { - return this.uniforms.size; - }, - set: function (value) - { - this.uniforms.size.value = value; - } - } -}); diff --git a/src/filters/pixelate/pixelate.frag b/src/filters/pixelate/pixelate.frag deleted file mode 100644 index 80ad2ee..0000000 --- a/src/filters/pixelate/pixelate.frag +++ /dev/null @@ -1,40 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform vec2 size; -uniform sampler2D uSampler; - -uniform vec4 filterArea; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -void main(void) -{ - vec2 coord = mapCoord(vTextureCoord); - - coord = pixelate(coord, size); - - coord = unmapCoord(coord); - - gl_FragColor = texture2D(uSampler, coord); -} diff --git a/src/filters/rgb/RGBSplitFilter.js b/src/filters/rgb/RGBSplitFilter.js deleted file mode 100644 index 9609514..0000000 --- a/src/filters/rgb/RGBSplitFilter.js +++ /dev/null @@ -1,80 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function RGBSplitFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./rgb-split.frag') - ); - - this.red = [-10, 0]; - this.green = [0, 10]; - this.blue = [0, 0]; -} - -RGBSplitFilter.prototype = Object.create(core.Filter.prototype); -RGBSplitFilter.prototype.constructor = RGBSplitFilter; -module.exports = RGBSplitFilter; - -Object.defineProperties(RGBSplitFilter.prototype, { - /** - * Red channel offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - red: { - get: function () - { - return this.uniforms.red; - }, - set: function (value) - { - this.uniforms.red = value; - } - }, - - /** - * Green channel offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - green: { - get: function () - { - return this.uniforms.green; - }, - set: function (value) - { - this.uniforms.green = value; - } - }, - - /** - * Blue offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - blue: { - get: function () - { - return this.uniforms.blue.value; - }, - set: function (value) - { - this.uniforms.blue.value = value; - } - } -}); diff --git a/src/filters/rgb/rgb-split.frag b/src/filters/rgb/rgb-split.frag deleted file mode 100644 index 46fed0f..0000000 --- a/src/filters/rgb/rgb-split.frag +++ /dev/null @@ -1,17 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec4 filterArea; -uniform vec2 red; -uniform vec2 green; -uniform vec2 blue; - -void main(void) -{ - gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/filterArea.xy).r; - gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/filterArea.xy).g; - gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/filterArea.xy).b; - gl_FragColor.a = texture2D(uSampler, vTextureCoord).a; -} diff --git a/src/filters/shockwave/ShockwaveFilter.js b/src/filters/shockwave/ShockwaveFilter.js deleted file mode 100644 index 709bb86..0000000 --- a/src/filters/shockwave/ShockwaveFilter.js +++ /dev/null @@ -1,89 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ColorMatrixFilter class lets you apply a 4x4 matrix transformation on the RGBA - * color and alpha values of every pixel on your displayObject to produce a result - * with a new set of RGBA color and alpha values. It's pretty powerful! - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function ShockwaveFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./shockwave.frag'), - // custom uniforms - { - center: { type: 'v2', value: { x: 0.5, y: 0.5 } }, - params: { type: 'v3', value: { x: 10, y: 0.8, z: 0.1 } }, - time: { type: '1f', value: 0 } - } - ); - - this.center = [0.5, 0.5]; - this.params = [10, 0.8, 0.1]; - this.time = 0; -} - -ShockwaveFilter.prototype = Object.create(core.Filter.prototype); -ShockwaveFilter.prototype.constructor = ShockwaveFilter; -module.exports = ShockwaveFilter; - -Object.defineProperties(ShockwaveFilter.prototype, { - /** - * Sets the center of the shockwave in normalized screen coords. That is - * (0,0) is the top-left and (1,1) is the bottom right. - * - * @member {object} - * @memberof PIXI.filters.ShockwaveFilter# - */ - center: { - get: function () - { - return this.uniforms.center; - }, - set: function (value) - { - this.uniforms.center = value; - } - }, - /** - * Sets the params of the shockwave. These modify the look and behavior of - * the shockwave as it ripples out. - * - * @member {object} - * @memberof PIXI.filters.ShockwaveFilter# - */ - params: { - get: function () - { - return this.uniforms.params; - }, - set: function (value) - { - this.uniforms.params = value; - } - }, - /** - * Sets the elapsed time of the shockwave. This controls the speed at which - * the shockwave ripples out. - * - * @member {number} - * @memberof PIXI.filters.ShockwaveFilter# - */ - time: { - get: function () - { - return this.uniforms.time; - }, - set: function (value) - { - this.uniforms.time = value; - } - } -}); diff --git a/src/filters/shockwave/shockwave.frag b/src/filters/shockwave/shockwave.frag deleted file mode 100644 index db2642e..0000000 --- a/src/filters/shockwave/shockwave.frag +++ /dev/null @@ -1,27 +0,0 @@ -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -uniform vec2 center; -uniform vec3 params; // 10.0, 0.8, 0.1 -uniform float time; - -void main() -{ - vec2 uv = vTextureCoord; - vec2 texCoord = uv; - - float dist = distance(uv, center); - - if ( (dist <= (time + params.z)) && (dist >= (time - params.z)) ) - { - float diff = (dist - time); - float powDiff = 1.0 - pow(abs(diff*params.x), params.y); - - float diffTime = diff * powDiff; - vec2 diffUV = normalize(uv - center); - texCoord = uv + (diffUV * diffTime); - } - - gl_FragColor = texture2D(uSampler, texCoord); -} diff --git a/src/filters/tiltshift/TiltShiftAxisFilter.js b/src/filters/tiltshift/TiltShiftAxisFilter.js deleted file mode 100644 index 17a2dd5..0000000 --- a/src/filters/tiltshift/TiltShiftAxisFilter.js +++ /dev/null @@ -1,121 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * @author Vico @vicocotea - * original filter https://github.com/evanw/glfx.js/blob/master/src/filters/blur/tiltshift.js by Evan Wallace : http://madebyevan.com/ - */ - -/** - * A TiltShiftAxisFilter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function TiltShiftAxisFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./tilt-shift.frag') - - ); - - this.uniforms.blur = 100; - this.uniforms.gradientBlur = 600; - this.uniforms.start = new PIXI.Point(0, window.innerHeight / 2); - this.uniforms.end = new PIXI.Point(600, window.innerHeight / 2); - this.uniforms.delta = new PIXI.Point(30, 30); - this.uniforms.texSize = new PIXI.Point(window.innerWidth, window.innerHeight); - - this.updateDelta(); -} - -TiltShiftAxisFilter.prototype = Object.create(core.Filter.prototype); -TiltShiftAxisFilter.prototype.constructor = TiltShiftAxisFilter; -module.exports = TiltShiftAxisFilter; - -/** - * Updates the filter delta values. - * This is overridden in the X and Y filters, does nothing for this class. - * - */ -TiltShiftAxisFilter.prototype.updateDelta = function () -{ - this.uniforms.delta.x = 0; - this.uniforms.delta.y = 0; -}; - -Object.defineProperties(TiltShiftAxisFilter.prototype, { - /** - * The strength of the blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - blur: { - get: function () - { - return this.uniforms.blur; - }, - set: function (value) - { - this.uniforms.blur = value; - } - }, - - /** - * The strength of the gradient blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - gradientBlur: { - get: function () - { - return this.uniforms.gradientBlur; - }, - set: function (value) - { - this.uniforms.gradientBlur = value; - } - }, - - /** - * The X value to start the effect at. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - start: { - get: function () - { - return this.uniforms.start; - }, - set: function (value) - { - this.uniforms.start = value; - this.updateDelta(); - } - }, - - /** - * The X value to end the effect at. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - end: { - get: function () - { - return this.uniforms.end; - }, - set: function (value) - { - this.uniforms.end = value; - this.updateDelta(); - } - } -}); diff --git a/src/filters/tiltshift/TiltShiftFilter.js b/src/filters/tiltshift/TiltShiftFilter.js deleted file mode 100644 index 671ac7a..0000000 --- a/src/filters/tiltshift/TiltShiftFilter.js +++ /dev/null @@ -1,108 +0,0 @@ -var core = require('../../core'), - TiltShiftXFilter = require('./TiltShiftXFilter'), - TiltShiftYFilter = require('./TiltShiftYFilter'); - -/** - * @author Vico @vicocotea - * original filter https://github.com/evanw/glfx.js/blob/master/src/filters/blur/tiltshift.js by Evan Wallace : http://madebyevan.com/ - */ - -/** - * A TiltShift Filter. Manages the pass of both a TiltShiftXFilter and TiltShiftYFilter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function TiltShiftFilter() -{ - core.Filter.call(this); - - this.tiltShiftXFilter = new TiltShiftXFilter(); - this.tiltShiftYFilter = new TiltShiftYFilter(); -} - -TiltShiftFilter.prototype = Object.create(core.Filter.prototype); -TiltShiftFilter.prototype.constructor = TiltShiftFilter; -module.exports = TiltShiftFilter; - -TiltShiftFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - this.tiltShiftXFilter.apply(filterManager, input, renderTarget); - - this.tiltShiftYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(TiltShiftFilter.prototype, { - /** - * The strength of the blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftFilter# - */ - blur: { - get: function () - { - return this.tiltShiftXFilter.blur; - }, - set: function (value) - { - this.tiltShiftXFilter.blur = this.tiltShiftYFilter.blur = value; - } - }, - - /** - * The strength of the gradient blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftFilter# - */ - gradientBlur: { - get: function () - { - return this.tiltShiftXFilter.gradientBlur; - }, - set: function (value) - { - this.tiltShiftXFilter.gradientBlur = this.tiltShiftYFilter.gradientBlur = value; - } - }, - - /** - * The Y value to start the effect at. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftFilter# - */ - start: { - get: function () - { - return this.tiltShiftXFilter.start; - }, - set: function (value) - { - this.tiltShiftXFilter.start = this.tiltShiftYFilter.start = value; - } - }, - - /** - * The Y value to end the effect at. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftFilter# - */ - end: { - get: function () - { - return this.tiltShiftXFilter.end; - }, - set: function (value) - { - this.tiltShiftXFilter.end = this.tiltShiftYFilter.end = value; - } - } -}); diff --git a/src/filters/tiltshift/TiltShiftXFilter.js b/src/filters/tiltshift/TiltShiftXFilter.js deleted file mode 100644 index d6d82ea..0000000 --- a/src/filters/tiltshift/TiltShiftXFilter.js +++ /dev/null @@ -1,36 +0,0 @@ -var TiltShiftAxisFilter = require('./TiltShiftAxisFilter'); - -/** - * @author Vico @vicocotea - * original filter https://github.com/evanw/glfx.js/blob/master/src/filters/blur/tiltshift.js by Evan Wallace : http://madebyevan.com/ - */ - -/** - * A TiltShiftXFilter. - * - * @class - * @extends PIXI.TiltShiftAxisFilter - * @memberof PIXI.filters - */ -function TiltShiftXFilter() -{ - TiltShiftAxisFilter.call(this); -} - -TiltShiftXFilter.prototype = Object.create(TiltShiftAxisFilter.prototype); -TiltShiftXFilter.prototype.constructor = TiltShiftXFilter; -module.exports = TiltShiftXFilter; - -/** - * Updates the filter delta values. - * - */ -TiltShiftXFilter.prototype.updateDelta = function () -{ - var dx = this.uniforms.end.x - this.uniforms.start.x; - var dy = this.uniforms.end.y - this.uniforms.start.y; - var d = Math.sqrt(dx * dx + dy * dy); - - this.uniforms.delta.x = dx / d; - this.uniforms.delta.y = dy / d; -}; diff --git a/src/filters/tiltshift/TiltShiftYFilter.js b/src/filters/tiltshift/TiltShiftYFilter.js deleted file mode 100644 index f8804bb..0000000 --- a/src/filters/tiltshift/TiltShiftYFilter.js +++ /dev/null @@ -1,36 +0,0 @@ -var TiltShiftAxisFilter = require('./TiltShiftAxisFilter'); - -/** - * @author Vico @vicocotea - * original filter https://github.com/evanw/glfx.js/blob/master/src/filters/blur/tiltshift.js by Evan Wallace : http://madebyevan.com/ - */ - -/** - * A TiltShiftYFilter. - * - * @class - * @extends PIXI.TiltShiftAxisFilter - * @memberof PIXI.filters - */ -function TiltShiftYFilter() -{ - TiltShiftAxisFilter.call(this); -} - -TiltShiftYFilter.prototype = Object.create(TiltShiftAxisFilter.prototype); -TiltShiftYFilter.prototype.constructor = TiltShiftYFilter; -module.exports = TiltShiftYFilter; - -/** - * Updates the filter delta values. - * - */ -TiltShiftYFilter.prototype.updateDelta = function () -{ - var dx = this.uniforms.end.x - this.uniforms.start.x; - var dy = this.uniforms.end.y - this.uniforms.start.y; - var d = Math.sqrt(dx * dx + dy * dy); - - this.uniforms.delta.x = -dy / d; - this.uniforms.delta.y = dx / d; -}; diff --git a/src/filters/ascii/AsciiFilter.js b/src/filters/ascii/AsciiFilter.js deleted file mode 100644 index ac64fd1..0000000 --- a/src/filters/ascii/AsciiFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -// TODO (cengler) - The Y is flipped in this shader for some reason. - -/** - * @author Vico @vicocotea - * original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h - */ - -/** - * An ASCII filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function AsciiFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./ascii.frag') - ); - - this.size = 8; -} - -AsciiFilter.prototype = Object.create(core.Filter.prototype); -AsciiFilter.prototype.constructor = AsciiFilter; -module.exports = AsciiFilter; - -Object.defineProperties(AsciiFilter.prototype, { - /** - * The pixel size used by the filter. - * - * @member {number} - * @memberof PIXI.filters.AsciiFilter# - */ - size: { - get: function () - { - return this.uniforms.pixelSize; - }, - set: function (value) - { - this.uniforms.pixelSize = value; - } - } -}); diff --git a/src/filters/ascii/ascii.frag b/src/filters/ascii/ascii.frag deleted file mode 100644 index 5608d6e..0000000 --- a/src/filters/ascii/ascii.frag +++ /dev/null @@ -1,70 +0,0 @@ -varying vec2 vTextureCoord; - -uniform vec4 filterArea; -uniform float pixelSize; -uniform sampler2D uSampler; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -vec2 getMod(vec2 coord, vec2 size) -{ - return mod( coord , size) / size; -} - -float character(float n, vec2 p) -{ - p = floor(p*vec2(4.0, -4.0) + 2.5); - if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y) - { - if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; - } - return 0.0; -} - -void main() -{ - vec2 coord = mapCoord(vTextureCoord); - - // get the rounded color.. - vec2 pixCoord = pixelate(coord, vec2(pixelSize)); - pixCoord = unmapCoord(pixCoord); - - vec4 color = texture2D(uSampler, pixCoord); - - // determine the character to use - float gray = (color.r + color.g + color.b) / 3.0; - - float n = 65536.0; // . - if (gray > 0.2) n = 65600.0; // : - if (gray > 0.3) n = 332772.0; // * - if (gray > 0.4) n = 15255086.0; // o - if (gray > 0.5) n = 23385164.0; // & - if (gray > 0.6) n = 15252014.0; // 8 - if (gray > 0.7) n = 13199452.0; // @ - if (gray > 0.8) n = 11512810.0; // # - - // get the mod.. - vec2 modd = getMod(coord, vec2(pixelSize)); - - gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); - -} \ No newline at end of file diff --git a/src/filters/bloom/BloomFilter.js b/src/filters/bloom/BloomFilter.js deleted file mode 100644 index 1a9c713..0000000 --- a/src/filters/bloom/BloomFilter.js +++ /dev/null @@ -1,97 +0,0 @@ -var core = require('../../core'), - BlurXFilter = require('../blur/BlurXFilter'), - BlurYFilter = require('../blur/BlurYFilter'); - VoidFilter = require('../void/VoidFilter'); - -/** - * The BloomFilter applies a Gaussian blur to an object. - * The strength of the blur can be set for x- and y-axis separately. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function BloomFilter() -{ - core.Filter.call(this); - - this.blurXFilter = new BlurXFilter(); - this.blurYFilter = new BlurYFilter(); - - this.blurYFilter.blendMode = core.BLEND_MODES.SCREEN; - - this.defaultFilter = new VoidFilter(); -} - -BloomFilter.prototype = Object.create(core.Filter.prototype); -BloomFilter.prototype.constructor = BloomFilter; -module.exports = BloomFilter; - -BloomFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - //TODO - copyTexSubImage2D could be used here? - this.defaultFilter.apply(filterManager, input, output); - - this.blurXFilter.apply(filterManager, input, renderTarget); - this.blurYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(BloomFilter.prototype, { - /** - * Sets the strength of both the blurX and blurY properties simultaneously - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blur: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = this.blurYFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurX property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurX: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurY property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurY: { - get: function () - { - return this.blurYFilter.blur; - }, - set: function (value) - { - this.blurYFilter.blur = value; - } - } -}); diff --git a/src/filters/convolution/ConvolutionFilter.js b/src/filters/convolution/ConvolutionFilter.js deleted file mode 100644 index 51775ba..0000000 --- a/src/filters/convolution/ConvolutionFilter.js +++ /dev/null @@ -1,87 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ConvolutionFilter class applies a matrix convolution filter effect. - * A convolution combines pixels in the input image with neighboring pixels to produce a new image. - * A wide variety of image effects can be achieved through convolutions, including blurring, edge - * detection, sharpening, embossing, and beveling. The matrix should be specified as a 9 point Array. - * See http://docs.gimp.org/en/plug-in-convmatrix.html for more info. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - * @param matrix {number[]} An array of values used for matrix transformation. Specified as a 9 point Array. - * @param width {number} Width of the object you are transforming - * @param height {number} Height of the object you are transforming - */ -function ConvolutionFilter(matrix, width, height) -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./convolution.frag') - ); - - this.matrix = matrix; - this.width = width; - this.height = height; -} - -ConvolutionFilter.prototype = Object.create(core.Filter.prototype); -ConvolutionFilter.prototype.constructor = ConvolutionFilter; -module.exports = ConvolutionFilter; - -Object.defineProperties(ConvolutionFilter.prototype, { - /** - * An array of values used for matrix transformation. Specified as a 9 point Array. - * - * @member {number[]} - * @memberof PIXI.filters.ConvolutionFilter# - */ - matrix: { - get: function () - { - return this.uniforms.matrix; - }, - set: function (value) - { - this.uniforms.matrix = new Float32Array(value); - } - }, - - /** - * Width of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - width: { - get: function () - { - return 1/this.uniforms.texelSize[0]; - }, - set: function (value) - { - this.uniforms.texelSize[0] = 1/value; - } - }, - - /** - * Height of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - height: { - get: function () - { - return 1/this.uniforms.texelSize[1]; - }, - set: function (value) - { - this.uniforms.texelSize[1] = 1/value; - } - } -}); diff --git a/src/filters/convolution/convolution.frag b/src/filters/convolution/convolution.frag deleted file mode 100644 index e6fe7b5..0000000 --- a/src/filters/convolution/convolution.frag +++ /dev/null @@ -1,29 +0,0 @@ -precision mediump float; - -varying mediump vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec2 texelSize; -uniform float matrix[9]; - -void main(void) -{ - vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left - vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center - vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right - - vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left - vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center - vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right - - vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left - vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center - vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right - - gl_FragColor = - c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] + - c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] + - c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8]; - - gl_FragColor.a = c22.a; -} diff --git a/src/filters/crosshatch/CrossHatchFilter.js b/src/filters/crosshatch/CrossHatchFilter.js deleted file mode 100644 index a8da95d..0000000 --- a/src/filters/crosshatch/CrossHatchFilter.js +++ /dev/null @@ -1,23 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * A Cross Hatch effect filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function CrossHatchFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./crosshatch.frag') - ); -} - -CrossHatchFilter.prototype = Object.create(core.Filter.prototype); -CrossHatchFilter.prototype.constructor = CrossHatchFilter; -module.exports = CrossHatchFilter; diff --git a/src/filters/crosshatch/crosshatch.frag b/src/filters/crosshatch/crosshatch.frag deleted file mode 100644 index 635ba4b..0000000 --- a/src/filters/crosshatch/crosshatch.frag +++ /dev/null @@ -1,44 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -void main(void) -{ - float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb); - - gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); - - if (lum < 1.00) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.75) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.50) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.3) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } -} diff --git a/src/filters/dot/DotFilter.js b/src/filters/dot/DotFilter.js deleted file mode 100644 index d2bc544..0000000 --- a/src/filters/dot/DotFilter.js +++ /dev/null @@ -1,66 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * @author Mat Groves http://matgroves.com/ @Doormat23 - * original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/fun/dotscreen.js - */ - -/** - * This filter applies a dotscreen effect making display objects appear to be made out of - * black and white halftone dots like an old printer. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function DotFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./dot.frag') - ); - - this.scale = 1; - this.angle = 5; -} - -DotFilter.prototype = Object.create(core.Filter.prototype); -DotFilter.prototype.constructor = DotFilter; -module.exports = DotFilter; - -Object.defineProperties(DotFilter.prototype, { - /** - * The scale of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - scale: { - get: function () - { - return this.uniforms.scale; - }, - set: function (value) - { - this.uniforms.scale = value; - } - }, - - /** - * The radius of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - angle: { - get: function () - { - return this.uniforms.angle; - }, - set: function (value) - { - this.uniforms.angle = value; - } - } -}); diff --git a/src/filters/dot/dot.frag b/src/filters/dot/dot.frag deleted file mode 100644 index 91341b1..0000000 --- a/src/filters/dot/dot.frag +++ /dev/null @@ -1,28 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; -varying vec4 vColor; - -uniform vec4 filterArea; -uniform sampler2D uSampler; - -uniform float angle; -uniform float scale; - -float pattern() -{ - float s = sin(angle), c = cos(angle); - vec2 tex = vTextureCoord * filterArea.xy; - vec2 point = vec2( - c * tex.x - s * tex.y, - s * tex.x + c * tex.y - ) * scale; - return (sin(point.x) * sin(point.y)) * 4.0; -} - -void main() -{ - vec4 color = texture2D(uSampler, vTextureCoord); - float average = (color.r + color.g + color.b) / 3.0; - gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a); -} diff --git a/src/filters/emboss/EmbossFilter.js b/src/filters/emboss/EmbossFilter.js deleted file mode 100644 index 0468d1f..0000000 --- a/src/filters/emboss/EmbossFilter.js +++ /dev/null @@ -1,46 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function EmbossFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./emboss.frag') - ); - - this.strength = 5; -} - -EmbossFilter.prototype = Object.create(core.Filter.prototype); -EmbossFilter.prototype.constructor = EmbossFilter; -module.exports = EmbossFilter; - -Object.defineProperties(EmbossFilter.prototype, { - /** - * Strength of Emboss. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.EmbossFilter# - */ - strength: { - get: function () - { - return this.uniforms.strength; - }, - set: function (value) - { - this.uniforms.strength = value; - } - }, - - -}); diff --git a/src/filters/emboss/emboss.frag b/src/filters/emboss/emboss.frag deleted file mode 100644 index 28b14d9..0000000 --- a/src/filters/emboss/emboss.frag +++ /dev/null @@ -1,26 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform float strength; -uniform vec4 filterArea; - - -void main(void) -{ - vec2 onePixel = vec2(1.0 / filterArea); - - vec4 color; - - color.rgb = vec3(0.5); - - color -= texture2D(uSampler, vTextureCoord - onePixel) * strength; - color += texture2D(uSampler, vTextureCoord + onePixel) * strength; - - color.rgb = vec3((color.r + color.g + color.b) / 3.0); - - float alpha = texture2D(uSampler, vTextureCoord).a; - - gl_FragColor = vec4(color.rgb * alpha, alpha); -} diff --git a/src/filters/index.js b/src/filters/index.js index 6709e39..54c1a3b 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -9,28 +9,12 @@ * @namespace PIXI.filters */ module.exports = { - AsciiFilter: require('./ascii/AsciiFilter'), - BloomFilter: require('./bloom/BloomFilter'), - ConvolutionFilter: require('./convolution/ConvolutionFilter'), - CrossHatchFilter: require('./crosshatch/CrossHatchFilter'), - DotFilter: require('./dot/DotFilter'), FXAAFilter: require('./fxaa/FXAAFilter'), - // DropShadowFilter: require('./dropshadow/DropShadowFilter'), NoiseFilter: require('./noise/NoiseFilter'), - PixelateFilter: require('./pixelate/PixelateFilter'), - RGBSplitFilter: require('./rgb/RGBSplitFilter'), - EmbossFilter: require('./emboss/EmbossFilter'), - ShockwaveFilter: require('./shockwave/ShockwaveFilter'), - // SmartBlurFilter: require('./blur/SmartBlurFilter'), - TiltShiftFilter: require('./tiltshift/TiltShiftFilter'), - // TiltShiftXFilter: require('./tiltshift/TiltShiftXFilter'), - //TiltShiftYFilter: require('./tiltshift/TiltShiftYFilter'), DisplacementFilter: require('./displacement/DisplacementFilter'), BlurFilter: require('./blur/BlurFilter'), BlurXFilter: require('./blur/BlurXFilter'), BlurYFilter: require('./blur/BlurYFilter'), - ColorMatrixFilter: require('./colormatrix/ColorMatrixFilter'), - TwistFilter: require('./twist/TwistFilter'), VoidFilter: require('./void/VoidFilter') }; diff --git a/src/filters/pixelate/PixelateFilter.js b/src/filters/pixelate/PixelateFilter.js deleted file mode 100644 index 6d5a1f2..0000000 --- a/src/filters/pixelate/PixelateFilter.js +++ /dev/null @@ -1,47 +0,0 @@ -var core = require('../../core'); -// @see https://github.com/substack/brfs/issues/25 -var glslify = require('glslify'); - -/** - * This filter applies a pixelate effect making display objects appear 'blocky'. - * - * @class - * @extends PIXI.AbstractFilter - * @memberof PIXI.filters - */ -function PixelateFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./pixelate.frag') - ); - - this.size = [0,0]; - -} - -PixelateFilter.prototype = Object.create(core.Filter.prototype); -PixelateFilter.prototype.constructor = PixelateFilter; -module.exports = PixelateFilter; - -Object.defineProperties(PixelateFilter.prototype, { - /** - * This a point that describes the size of the blocks. - * x is the width of the block and y is the height. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.PixelateFilter# - */ - size: { - get: function () - { - return this.uniforms.size; - }, - set: function (value) - { - this.uniforms.size.value = value; - } - } -}); diff --git a/src/filters/pixelate/pixelate.frag b/src/filters/pixelate/pixelate.frag deleted file mode 100644 index 80ad2ee..0000000 --- a/src/filters/pixelate/pixelate.frag +++ /dev/null @@ -1,40 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform vec2 size; -uniform sampler2D uSampler; - -uniform vec4 filterArea; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -void main(void) -{ - vec2 coord = mapCoord(vTextureCoord); - - coord = pixelate(coord, size); - - coord = unmapCoord(coord); - - gl_FragColor = texture2D(uSampler, coord); -} diff --git a/src/filters/rgb/RGBSplitFilter.js b/src/filters/rgb/RGBSplitFilter.js deleted file mode 100644 index 9609514..0000000 --- a/src/filters/rgb/RGBSplitFilter.js +++ /dev/null @@ -1,80 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function RGBSplitFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./rgb-split.frag') - ); - - this.red = [-10, 0]; - this.green = [0, 10]; - this.blue = [0, 0]; -} - -RGBSplitFilter.prototype = Object.create(core.Filter.prototype); -RGBSplitFilter.prototype.constructor = RGBSplitFilter; -module.exports = RGBSplitFilter; - -Object.defineProperties(RGBSplitFilter.prototype, { - /** - * Red channel offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - red: { - get: function () - { - return this.uniforms.red; - }, - set: function (value) - { - this.uniforms.red = value; - } - }, - - /** - * Green channel offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - green: { - get: function () - { - return this.uniforms.green; - }, - set: function (value) - { - this.uniforms.green = value; - } - }, - - /** - * Blue offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - blue: { - get: function () - { - return this.uniforms.blue.value; - }, - set: function (value) - { - this.uniforms.blue.value = value; - } - } -}); diff --git a/src/filters/rgb/rgb-split.frag b/src/filters/rgb/rgb-split.frag deleted file mode 100644 index 46fed0f..0000000 --- a/src/filters/rgb/rgb-split.frag +++ /dev/null @@ -1,17 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec4 filterArea; -uniform vec2 red; -uniform vec2 green; -uniform vec2 blue; - -void main(void) -{ - gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/filterArea.xy).r; - gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/filterArea.xy).g; - gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/filterArea.xy).b; - gl_FragColor.a = texture2D(uSampler, vTextureCoord).a; -} diff --git a/src/filters/shockwave/ShockwaveFilter.js b/src/filters/shockwave/ShockwaveFilter.js deleted file mode 100644 index 709bb86..0000000 --- a/src/filters/shockwave/ShockwaveFilter.js +++ /dev/null @@ -1,89 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ColorMatrixFilter class lets you apply a 4x4 matrix transformation on the RGBA - * color and alpha values of every pixel on your displayObject to produce a result - * with a new set of RGBA color and alpha values. It's pretty powerful! - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function ShockwaveFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./shockwave.frag'), - // custom uniforms - { - center: { type: 'v2', value: { x: 0.5, y: 0.5 } }, - params: { type: 'v3', value: { x: 10, y: 0.8, z: 0.1 } }, - time: { type: '1f', value: 0 } - } - ); - - this.center = [0.5, 0.5]; - this.params = [10, 0.8, 0.1]; - this.time = 0; -} - -ShockwaveFilter.prototype = Object.create(core.Filter.prototype); -ShockwaveFilter.prototype.constructor = ShockwaveFilter; -module.exports = ShockwaveFilter; - -Object.defineProperties(ShockwaveFilter.prototype, { - /** - * Sets the center of the shockwave in normalized screen coords. That is - * (0,0) is the top-left and (1,1) is the bottom right. - * - * @member {object} - * @memberof PIXI.filters.ShockwaveFilter# - */ - center: { - get: function () - { - return this.uniforms.center; - }, - set: function (value) - { - this.uniforms.center = value; - } - }, - /** - * Sets the params of the shockwave. These modify the look and behavior of - * the shockwave as it ripples out. - * - * @member {object} - * @memberof PIXI.filters.ShockwaveFilter# - */ - params: { - get: function () - { - return this.uniforms.params; - }, - set: function (value) - { - this.uniforms.params = value; - } - }, - /** - * Sets the elapsed time of the shockwave. This controls the speed at which - * the shockwave ripples out. - * - * @member {number} - * @memberof PIXI.filters.ShockwaveFilter# - */ - time: { - get: function () - { - return this.uniforms.time; - }, - set: function (value) - { - this.uniforms.time = value; - } - } -}); diff --git a/src/filters/shockwave/shockwave.frag b/src/filters/shockwave/shockwave.frag deleted file mode 100644 index db2642e..0000000 --- a/src/filters/shockwave/shockwave.frag +++ /dev/null @@ -1,27 +0,0 @@ -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -uniform vec2 center; -uniform vec3 params; // 10.0, 0.8, 0.1 -uniform float time; - -void main() -{ - vec2 uv = vTextureCoord; - vec2 texCoord = uv; - - float dist = distance(uv, center); - - if ( (dist <= (time + params.z)) && (dist >= (time - params.z)) ) - { - float diff = (dist - time); - float powDiff = 1.0 - pow(abs(diff*params.x), params.y); - - float diffTime = diff * powDiff; - vec2 diffUV = normalize(uv - center); - texCoord = uv + (diffUV * diffTime); - } - - gl_FragColor = texture2D(uSampler, texCoord); -} diff --git a/src/filters/tiltshift/TiltShiftAxisFilter.js b/src/filters/tiltshift/TiltShiftAxisFilter.js deleted file mode 100644 index 17a2dd5..0000000 --- a/src/filters/tiltshift/TiltShiftAxisFilter.js +++ /dev/null @@ -1,121 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * @author Vico @vicocotea - * original filter https://github.com/evanw/glfx.js/blob/master/src/filters/blur/tiltshift.js by Evan Wallace : http://madebyevan.com/ - */ - -/** - * A TiltShiftAxisFilter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function TiltShiftAxisFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./tilt-shift.frag') - - ); - - this.uniforms.blur = 100; - this.uniforms.gradientBlur = 600; - this.uniforms.start = new PIXI.Point(0, window.innerHeight / 2); - this.uniforms.end = new PIXI.Point(600, window.innerHeight / 2); - this.uniforms.delta = new PIXI.Point(30, 30); - this.uniforms.texSize = new PIXI.Point(window.innerWidth, window.innerHeight); - - this.updateDelta(); -} - -TiltShiftAxisFilter.prototype = Object.create(core.Filter.prototype); -TiltShiftAxisFilter.prototype.constructor = TiltShiftAxisFilter; -module.exports = TiltShiftAxisFilter; - -/** - * Updates the filter delta values. - * This is overridden in the X and Y filters, does nothing for this class. - * - */ -TiltShiftAxisFilter.prototype.updateDelta = function () -{ - this.uniforms.delta.x = 0; - this.uniforms.delta.y = 0; -}; - -Object.defineProperties(TiltShiftAxisFilter.prototype, { - /** - * The strength of the blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - blur: { - get: function () - { - return this.uniforms.blur; - }, - set: function (value) - { - this.uniforms.blur = value; - } - }, - - /** - * The strength of the gradient blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - gradientBlur: { - get: function () - { - return this.uniforms.gradientBlur; - }, - set: function (value) - { - this.uniforms.gradientBlur = value; - } - }, - - /** - * The X value to start the effect at. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - start: { - get: function () - { - return this.uniforms.start; - }, - set: function (value) - { - this.uniforms.start = value; - this.updateDelta(); - } - }, - - /** - * The X value to end the effect at. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - end: { - get: function () - { - return this.uniforms.end; - }, - set: function (value) - { - this.uniforms.end = value; - this.updateDelta(); - } - } -}); diff --git a/src/filters/tiltshift/TiltShiftFilter.js b/src/filters/tiltshift/TiltShiftFilter.js deleted file mode 100644 index 671ac7a..0000000 --- a/src/filters/tiltshift/TiltShiftFilter.js +++ /dev/null @@ -1,108 +0,0 @@ -var core = require('../../core'), - TiltShiftXFilter = require('./TiltShiftXFilter'), - TiltShiftYFilter = require('./TiltShiftYFilter'); - -/** - * @author Vico @vicocotea - * original filter https://github.com/evanw/glfx.js/blob/master/src/filters/blur/tiltshift.js by Evan Wallace : http://madebyevan.com/ - */ - -/** - * A TiltShift Filter. Manages the pass of both a TiltShiftXFilter and TiltShiftYFilter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function TiltShiftFilter() -{ - core.Filter.call(this); - - this.tiltShiftXFilter = new TiltShiftXFilter(); - this.tiltShiftYFilter = new TiltShiftYFilter(); -} - -TiltShiftFilter.prototype = Object.create(core.Filter.prototype); -TiltShiftFilter.prototype.constructor = TiltShiftFilter; -module.exports = TiltShiftFilter; - -TiltShiftFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - this.tiltShiftXFilter.apply(filterManager, input, renderTarget); - - this.tiltShiftYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(TiltShiftFilter.prototype, { - /** - * The strength of the blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftFilter# - */ - blur: { - get: function () - { - return this.tiltShiftXFilter.blur; - }, - set: function (value) - { - this.tiltShiftXFilter.blur = this.tiltShiftYFilter.blur = value; - } - }, - - /** - * The strength of the gradient blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftFilter# - */ - gradientBlur: { - get: function () - { - return this.tiltShiftXFilter.gradientBlur; - }, - set: function (value) - { - this.tiltShiftXFilter.gradientBlur = this.tiltShiftYFilter.gradientBlur = value; - } - }, - - /** - * The Y value to start the effect at. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftFilter# - */ - start: { - get: function () - { - return this.tiltShiftXFilter.start; - }, - set: function (value) - { - this.tiltShiftXFilter.start = this.tiltShiftYFilter.start = value; - } - }, - - /** - * The Y value to end the effect at. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftFilter# - */ - end: { - get: function () - { - return this.tiltShiftXFilter.end; - }, - set: function (value) - { - this.tiltShiftXFilter.end = this.tiltShiftYFilter.end = value; - } - } -}); diff --git a/src/filters/tiltshift/TiltShiftXFilter.js b/src/filters/tiltshift/TiltShiftXFilter.js deleted file mode 100644 index d6d82ea..0000000 --- a/src/filters/tiltshift/TiltShiftXFilter.js +++ /dev/null @@ -1,36 +0,0 @@ -var TiltShiftAxisFilter = require('./TiltShiftAxisFilter'); - -/** - * @author Vico @vicocotea - * original filter https://github.com/evanw/glfx.js/blob/master/src/filters/blur/tiltshift.js by Evan Wallace : http://madebyevan.com/ - */ - -/** - * A TiltShiftXFilter. - * - * @class - * @extends PIXI.TiltShiftAxisFilter - * @memberof PIXI.filters - */ -function TiltShiftXFilter() -{ - TiltShiftAxisFilter.call(this); -} - -TiltShiftXFilter.prototype = Object.create(TiltShiftAxisFilter.prototype); -TiltShiftXFilter.prototype.constructor = TiltShiftXFilter; -module.exports = TiltShiftXFilter; - -/** - * Updates the filter delta values. - * - */ -TiltShiftXFilter.prototype.updateDelta = function () -{ - var dx = this.uniforms.end.x - this.uniforms.start.x; - var dy = this.uniforms.end.y - this.uniforms.start.y; - var d = Math.sqrt(dx * dx + dy * dy); - - this.uniforms.delta.x = dx / d; - this.uniforms.delta.y = dy / d; -}; diff --git a/src/filters/tiltshift/TiltShiftYFilter.js b/src/filters/tiltshift/TiltShiftYFilter.js deleted file mode 100644 index f8804bb..0000000 --- a/src/filters/tiltshift/TiltShiftYFilter.js +++ /dev/null @@ -1,36 +0,0 @@ -var TiltShiftAxisFilter = require('./TiltShiftAxisFilter'); - -/** - * @author Vico @vicocotea - * original filter https://github.com/evanw/glfx.js/blob/master/src/filters/blur/tiltshift.js by Evan Wallace : http://madebyevan.com/ - */ - -/** - * A TiltShiftYFilter. - * - * @class - * @extends PIXI.TiltShiftAxisFilter - * @memberof PIXI.filters - */ -function TiltShiftYFilter() -{ - TiltShiftAxisFilter.call(this); -} - -TiltShiftYFilter.prototype = Object.create(TiltShiftAxisFilter.prototype); -TiltShiftYFilter.prototype.constructor = TiltShiftYFilter; -module.exports = TiltShiftYFilter; - -/** - * Updates the filter delta values. - * - */ -TiltShiftYFilter.prototype.updateDelta = function () -{ - var dx = this.uniforms.end.x - this.uniforms.start.x; - var dy = this.uniforms.end.y - this.uniforms.start.y; - var d = Math.sqrt(dx * dx + dy * dy); - - this.uniforms.delta.x = -dy / d; - this.uniforms.delta.y = dx / d; -}; diff --git a/src/filters/tiltshift/tilt-shift.frag b/src/filters/tiltshift/tilt-shift.frag deleted file mode 100644 index fff2be0..0000000 --- a/src/filters/tiltshift/tilt-shift.frag +++ /dev/null @@ -1,37 +0,0 @@ -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform float blur; -uniform float gradientBlur; -uniform vec2 start; -uniform vec2 end; -uniform vec2 delta; -uniform vec2 texSize; - -float random(vec3 scale, float seed) -{ - return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed); -} - -void main(void) -{ - vec4 color = vec4(0.0); - float total = 0.0; - - float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0); - vec2 normal = normalize(vec2(start.y - end.y, end.x - start.x)); - float radius = smoothstep(0.0, 1.0, abs(dot(vTextureCoord * texSize - start, normal)) / gradientBlur) * blur; - - for (float t = -30.0; t <= 30.0; t++) - { - float percent = (t + offset - 0.5) / 30.0; - float weight = 1.0 - abs(percent); - vec4 sample = texture2D(uSampler, vTextureCoord + delta / texSize * percent * radius); - sample.rgb *= sample.a; - color += sample * weight; - total += weight; - } - - gl_FragColor = color / total; - gl_FragColor.rgb /= gl_FragColor.a + 0.00001; -} diff --git a/src/filters/ascii/AsciiFilter.js b/src/filters/ascii/AsciiFilter.js deleted file mode 100644 index ac64fd1..0000000 --- a/src/filters/ascii/AsciiFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -// TODO (cengler) - The Y is flipped in this shader for some reason. - -/** - * @author Vico @vicocotea - * original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h - */ - -/** - * An ASCII filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function AsciiFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./ascii.frag') - ); - - this.size = 8; -} - -AsciiFilter.prototype = Object.create(core.Filter.prototype); -AsciiFilter.prototype.constructor = AsciiFilter; -module.exports = AsciiFilter; - -Object.defineProperties(AsciiFilter.prototype, { - /** - * The pixel size used by the filter. - * - * @member {number} - * @memberof PIXI.filters.AsciiFilter# - */ - size: { - get: function () - { - return this.uniforms.pixelSize; - }, - set: function (value) - { - this.uniforms.pixelSize = value; - } - } -}); diff --git a/src/filters/ascii/ascii.frag b/src/filters/ascii/ascii.frag deleted file mode 100644 index 5608d6e..0000000 --- a/src/filters/ascii/ascii.frag +++ /dev/null @@ -1,70 +0,0 @@ -varying vec2 vTextureCoord; - -uniform vec4 filterArea; -uniform float pixelSize; -uniform sampler2D uSampler; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -vec2 getMod(vec2 coord, vec2 size) -{ - return mod( coord , size) / size; -} - -float character(float n, vec2 p) -{ - p = floor(p*vec2(4.0, -4.0) + 2.5); - if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y) - { - if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; - } - return 0.0; -} - -void main() -{ - vec2 coord = mapCoord(vTextureCoord); - - // get the rounded color.. - vec2 pixCoord = pixelate(coord, vec2(pixelSize)); - pixCoord = unmapCoord(pixCoord); - - vec4 color = texture2D(uSampler, pixCoord); - - // determine the character to use - float gray = (color.r + color.g + color.b) / 3.0; - - float n = 65536.0; // . - if (gray > 0.2) n = 65600.0; // : - if (gray > 0.3) n = 332772.0; // * - if (gray > 0.4) n = 15255086.0; // o - if (gray > 0.5) n = 23385164.0; // & - if (gray > 0.6) n = 15252014.0; // 8 - if (gray > 0.7) n = 13199452.0; // @ - if (gray > 0.8) n = 11512810.0; // # - - // get the mod.. - vec2 modd = getMod(coord, vec2(pixelSize)); - - gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); - -} \ No newline at end of file diff --git a/src/filters/bloom/BloomFilter.js b/src/filters/bloom/BloomFilter.js deleted file mode 100644 index 1a9c713..0000000 --- a/src/filters/bloom/BloomFilter.js +++ /dev/null @@ -1,97 +0,0 @@ -var core = require('../../core'), - BlurXFilter = require('../blur/BlurXFilter'), - BlurYFilter = require('../blur/BlurYFilter'); - VoidFilter = require('../void/VoidFilter'); - -/** - * The BloomFilter applies a Gaussian blur to an object. - * The strength of the blur can be set for x- and y-axis separately. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function BloomFilter() -{ - core.Filter.call(this); - - this.blurXFilter = new BlurXFilter(); - this.blurYFilter = new BlurYFilter(); - - this.blurYFilter.blendMode = core.BLEND_MODES.SCREEN; - - this.defaultFilter = new VoidFilter(); -} - -BloomFilter.prototype = Object.create(core.Filter.prototype); -BloomFilter.prototype.constructor = BloomFilter; -module.exports = BloomFilter; - -BloomFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - //TODO - copyTexSubImage2D could be used here? - this.defaultFilter.apply(filterManager, input, output); - - this.blurXFilter.apply(filterManager, input, renderTarget); - this.blurYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(BloomFilter.prototype, { - /** - * Sets the strength of both the blurX and blurY properties simultaneously - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blur: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = this.blurYFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurX property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurX: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurY property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurY: { - get: function () - { - return this.blurYFilter.blur; - }, - set: function (value) - { - this.blurYFilter.blur = value; - } - } -}); diff --git a/src/filters/convolution/ConvolutionFilter.js b/src/filters/convolution/ConvolutionFilter.js deleted file mode 100644 index 51775ba..0000000 --- a/src/filters/convolution/ConvolutionFilter.js +++ /dev/null @@ -1,87 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ConvolutionFilter class applies a matrix convolution filter effect. - * A convolution combines pixels in the input image with neighboring pixels to produce a new image. - * A wide variety of image effects can be achieved through convolutions, including blurring, edge - * detection, sharpening, embossing, and beveling. The matrix should be specified as a 9 point Array. - * See http://docs.gimp.org/en/plug-in-convmatrix.html for more info. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - * @param matrix {number[]} An array of values used for matrix transformation. Specified as a 9 point Array. - * @param width {number} Width of the object you are transforming - * @param height {number} Height of the object you are transforming - */ -function ConvolutionFilter(matrix, width, height) -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./convolution.frag') - ); - - this.matrix = matrix; - this.width = width; - this.height = height; -} - -ConvolutionFilter.prototype = Object.create(core.Filter.prototype); -ConvolutionFilter.prototype.constructor = ConvolutionFilter; -module.exports = ConvolutionFilter; - -Object.defineProperties(ConvolutionFilter.prototype, { - /** - * An array of values used for matrix transformation. Specified as a 9 point Array. - * - * @member {number[]} - * @memberof PIXI.filters.ConvolutionFilter# - */ - matrix: { - get: function () - { - return this.uniforms.matrix; - }, - set: function (value) - { - this.uniforms.matrix = new Float32Array(value); - } - }, - - /** - * Width of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - width: { - get: function () - { - return 1/this.uniforms.texelSize[0]; - }, - set: function (value) - { - this.uniforms.texelSize[0] = 1/value; - } - }, - - /** - * Height of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - height: { - get: function () - { - return 1/this.uniforms.texelSize[1]; - }, - set: function (value) - { - this.uniforms.texelSize[1] = 1/value; - } - } -}); diff --git a/src/filters/convolution/convolution.frag b/src/filters/convolution/convolution.frag deleted file mode 100644 index e6fe7b5..0000000 --- a/src/filters/convolution/convolution.frag +++ /dev/null @@ -1,29 +0,0 @@ -precision mediump float; - -varying mediump vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec2 texelSize; -uniform float matrix[9]; - -void main(void) -{ - vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left - vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center - vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right - - vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left - vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center - vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right - - vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left - vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center - vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right - - gl_FragColor = - c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] + - c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] + - c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8]; - - gl_FragColor.a = c22.a; -} diff --git a/src/filters/crosshatch/CrossHatchFilter.js b/src/filters/crosshatch/CrossHatchFilter.js deleted file mode 100644 index a8da95d..0000000 --- a/src/filters/crosshatch/CrossHatchFilter.js +++ /dev/null @@ -1,23 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * A Cross Hatch effect filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function CrossHatchFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./crosshatch.frag') - ); -} - -CrossHatchFilter.prototype = Object.create(core.Filter.prototype); -CrossHatchFilter.prototype.constructor = CrossHatchFilter; -module.exports = CrossHatchFilter; diff --git a/src/filters/crosshatch/crosshatch.frag b/src/filters/crosshatch/crosshatch.frag deleted file mode 100644 index 635ba4b..0000000 --- a/src/filters/crosshatch/crosshatch.frag +++ /dev/null @@ -1,44 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -void main(void) -{ - float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb); - - gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); - - if (lum < 1.00) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.75) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.50) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.3) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } -} diff --git a/src/filters/dot/DotFilter.js b/src/filters/dot/DotFilter.js deleted file mode 100644 index d2bc544..0000000 --- a/src/filters/dot/DotFilter.js +++ /dev/null @@ -1,66 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * @author Mat Groves http://matgroves.com/ @Doormat23 - * original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/fun/dotscreen.js - */ - -/** - * This filter applies a dotscreen effect making display objects appear to be made out of - * black and white halftone dots like an old printer. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function DotFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./dot.frag') - ); - - this.scale = 1; - this.angle = 5; -} - -DotFilter.prototype = Object.create(core.Filter.prototype); -DotFilter.prototype.constructor = DotFilter; -module.exports = DotFilter; - -Object.defineProperties(DotFilter.prototype, { - /** - * The scale of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - scale: { - get: function () - { - return this.uniforms.scale; - }, - set: function (value) - { - this.uniforms.scale = value; - } - }, - - /** - * The radius of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - angle: { - get: function () - { - return this.uniforms.angle; - }, - set: function (value) - { - this.uniforms.angle = value; - } - } -}); diff --git a/src/filters/dot/dot.frag b/src/filters/dot/dot.frag deleted file mode 100644 index 91341b1..0000000 --- a/src/filters/dot/dot.frag +++ /dev/null @@ -1,28 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; -varying vec4 vColor; - -uniform vec4 filterArea; -uniform sampler2D uSampler; - -uniform float angle; -uniform float scale; - -float pattern() -{ - float s = sin(angle), c = cos(angle); - vec2 tex = vTextureCoord * filterArea.xy; - vec2 point = vec2( - c * tex.x - s * tex.y, - s * tex.x + c * tex.y - ) * scale; - return (sin(point.x) * sin(point.y)) * 4.0; -} - -void main() -{ - vec4 color = texture2D(uSampler, vTextureCoord); - float average = (color.r + color.g + color.b) / 3.0; - gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a); -} diff --git a/src/filters/emboss/EmbossFilter.js b/src/filters/emboss/EmbossFilter.js deleted file mode 100644 index 0468d1f..0000000 --- a/src/filters/emboss/EmbossFilter.js +++ /dev/null @@ -1,46 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function EmbossFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./emboss.frag') - ); - - this.strength = 5; -} - -EmbossFilter.prototype = Object.create(core.Filter.prototype); -EmbossFilter.prototype.constructor = EmbossFilter; -module.exports = EmbossFilter; - -Object.defineProperties(EmbossFilter.prototype, { - /** - * Strength of Emboss. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.EmbossFilter# - */ - strength: { - get: function () - { - return this.uniforms.strength; - }, - set: function (value) - { - this.uniforms.strength = value; - } - }, - - -}); diff --git a/src/filters/emboss/emboss.frag b/src/filters/emboss/emboss.frag deleted file mode 100644 index 28b14d9..0000000 --- a/src/filters/emboss/emboss.frag +++ /dev/null @@ -1,26 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform float strength; -uniform vec4 filterArea; - - -void main(void) -{ - vec2 onePixel = vec2(1.0 / filterArea); - - vec4 color; - - color.rgb = vec3(0.5); - - color -= texture2D(uSampler, vTextureCoord - onePixel) * strength; - color += texture2D(uSampler, vTextureCoord + onePixel) * strength; - - color.rgb = vec3((color.r + color.g + color.b) / 3.0); - - float alpha = texture2D(uSampler, vTextureCoord).a; - - gl_FragColor = vec4(color.rgb * alpha, alpha); -} diff --git a/src/filters/index.js b/src/filters/index.js index 6709e39..54c1a3b 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -9,28 +9,12 @@ * @namespace PIXI.filters */ module.exports = { - AsciiFilter: require('./ascii/AsciiFilter'), - BloomFilter: require('./bloom/BloomFilter'), - ConvolutionFilter: require('./convolution/ConvolutionFilter'), - CrossHatchFilter: require('./crosshatch/CrossHatchFilter'), - DotFilter: require('./dot/DotFilter'), FXAAFilter: require('./fxaa/FXAAFilter'), - // DropShadowFilter: require('./dropshadow/DropShadowFilter'), NoiseFilter: require('./noise/NoiseFilter'), - PixelateFilter: require('./pixelate/PixelateFilter'), - RGBSplitFilter: require('./rgb/RGBSplitFilter'), - EmbossFilter: require('./emboss/EmbossFilter'), - ShockwaveFilter: require('./shockwave/ShockwaveFilter'), - // SmartBlurFilter: require('./blur/SmartBlurFilter'), - TiltShiftFilter: require('./tiltshift/TiltShiftFilter'), - // TiltShiftXFilter: require('./tiltshift/TiltShiftXFilter'), - //TiltShiftYFilter: require('./tiltshift/TiltShiftYFilter'), DisplacementFilter: require('./displacement/DisplacementFilter'), BlurFilter: require('./blur/BlurFilter'), BlurXFilter: require('./blur/BlurXFilter'), BlurYFilter: require('./blur/BlurYFilter'), - ColorMatrixFilter: require('./colormatrix/ColorMatrixFilter'), - TwistFilter: require('./twist/TwistFilter'), VoidFilter: require('./void/VoidFilter') }; diff --git a/src/filters/pixelate/PixelateFilter.js b/src/filters/pixelate/PixelateFilter.js deleted file mode 100644 index 6d5a1f2..0000000 --- a/src/filters/pixelate/PixelateFilter.js +++ /dev/null @@ -1,47 +0,0 @@ -var core = require('../../core'); -// @see https://github.com/substack/brfs/issues/25 -var glslify = require('glslify'); - -/** - * This filter applies a pixelate effect making display objects appear 'blocky'. - * - * @class - * @extends PIXI.AbstractFilter - * @memberof PIXI.filters - */ -function PixelateFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./pixelate.frag') - ); - - this.size = [0,0]; - -} - -PixelateFilter.prototype = Object.create(core.Filter.prototype); -PixelateFilter.prototype.constructor = PixelateFilter; -module.exports = PixelateFilter; - -Object.defineProperties(PixelateFilter.prototype, { - /** - * This a point that describes the size of the blocks. - * x is the width of the block and y is the height. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.PixelateFilter# - */ - size: { - get: function () - { - return this.uniforms.size; - }, - set: function (value) - { - this.uniforms.size.value = value; - } - } -}); diff --git a/src/filters/pixelate/pixelate.frag b/src/filters/pixelate/pixelate.frag deleted file mode 100644 index 80ad2ee..0000000 --- a/src/filters/pixelate/pixelate.frag +++ /dev/null @@ -1,40 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform vec2 size; -uniform sampler2D uSampler; - -uniform vec4 filterArea; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -void main(void) -{ - vec2 coord = mapCoord(vTextureCoord); - - coord = pixelate(coord, size); - - coord = unmapCoord(coord); - - gl_FragColor = texture2D(uSampler, coord); -} diff --git a/src/filters/rgb/RGBSplitFilter.js b/src/filters/rgb/RGBSplitFilter.js deleted file mode 100644 index 9609514..0000000 --- a/src/filters/rgb/RGBSplitFilter.js +++ /dev/null @@ -1,80 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function RGBSplitFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./rgb-split.frag') - ); - - this.red = [-10, 0]; - this.green = [0, 10]; - this.blue = [0, 0]; -} - -RGBSplitFilter.prototype = Object.create(core.Filter.prototype); -RGBSplitFilter.prototype.constructor = RGBSplitFilter; -module.exports = RGBSplitFilter; - -Object.defineProperties(RGBSplitFilter.prototype, { - /** - * Red channel offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - red: { - get: function () - { - return this.uniforms.red; - }, - set: function (value) - { - this.uniforms.red = value; - } - }, - - /** - * Green channel offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - green: { - get: function () - { - return this.uniforms.green; - }, - set: function (value) - { - this.uniforms.green = value; - } - }, - - /** - * Blue offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - blue: { - get: function () - { - return this.uniforms.blue.value; - }, - set: function (value) - { - this.uniforms.blue.value = value; - } - } -}); diff --git a/src/filters/rgb/rgb-split.frag b/src/filters/rgb/rgb-split.frag deleted file mode 100644 index 46fed0f..0000000 --- a/src/filters/rgb/rgb-split.frag +++ /dev/null @@ -1,17 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec4 filterArea; -uniform vec2 red; -uniform vec2 green; -uniform vec2 blue; - -void main(void) -{ - gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/filterArea.xy).r; - gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/filterArea.xy).g; - gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/filterArea.xy).b; - gl_FragColor.a = texture2D(uSampler, vTextureCoord).a; -} diff --git a/src/filters/shockwave/ShockwaveFilter.js b/src/filters/shockwave/ShockwaveFilter.js deleted file mode 100644 index 709bb86..0000000 --- a/src/filters/shockwave/ShockwaveFilter.js +++ /dev/null @@ -1,89 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ColorMatrixFilter class lets you apply a 4x4 matrix transformation on the RGBA - * color and alpha values of every pixel on your displayObject to produce a result - * with a new set of RGBA color and alpha values. It's pretty powerful! - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function ShockwaveFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./shockwave.frag'), - // custom uniforms - { - center: { type: 'v2', value: { x: 0.5, y: 0.5 } }, - params: { type: 'v3', value: { x: 10, y: 0.8, z: 0.1 } }, - time: { type: '1f', value: 0 } - } - ); - - this.center = [0.5, 0.5]; - this.params = [10, 0.8, 0.1]; - this.time = 0; -} - -ShockwaveFilter.prototype = Object.create(core.Filter.prototype); -ShockwaveFilter.prototype.constructor = ShockwaveFilter; -module.exports = ShockwaveFilter; - -Object.defineProperties(ShockwaveFilter.prototype, { - /** - * Sets the center of the shockwave in normalized screen coords. That is - * (0,0) is the top-left and (1,1) is the bottom right. - * - * @member {object} - * @memberof PIXI.filters.ShockwaveFilter# - */ - center: { - get: function () - { - return this.uniforms.center; - }, - set: function (value) - { - this.uniforms.center = value; - } - }, - /** - * Sets the params of the shockwave. These modify the look and behavior of - * the shockwave as it ripples out. - * - * @member {object} - * @memberof PIXI.filters.ShockwaveFilter# - */ - params: { - get: function () - { - return this.uniforms.params; - }, - set: function (value) - { - this.uniforms.params = value; - } - }, - /** - * Sets the elapsed time of the shockwave. This controls the speed at which - * the shockwave ripples out. - * - * @member {number} - * @memberof PIXI.filters.ShockwaveFilter# - */ - time: { - get: function () - { - return this.uniforms.time; - }, - set: function (value) - { - this.uniforms.time = value; - } - } -}); diff --git a/src/filters/shockwave/shockwave.frag b/src/filters/shockwave/shockwave.frag deleted file mode 100644 index db2642e..0000000 --- a/src/filters/shockwave/shockwave.frag +++ /dev/null @@ -1,27 +0,0 @@ -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -uniform vec2 center; -uniform vec3 params; // 10.0, 0.8, 0.1 -uniform float time; - -void main() -{ - vec2 uv = vTextureCoord; - vec2 texCoord = uv; - - float dist = distance(uv, center); - - if ( (dist <= (time + params.z)) && (dist >= (time - params.z)) ) - { - float diff = (dist - time); - float powDiff = 1.0 - pow(abs(diff*params.x), params.y); - - float diffTime = diff * powDiff; - vec2 diffUV = normalize(uv - center); - texCoord = uv + (diffUV * diffTime); - } - - gl_FragColor = texture2D(uSampler, texCoord); -} diff --git a/src/filters/tiltshift/TiltShiftAxisFilter.js b/src/filters/tiltshift/TiltShiftAxisFilter.js deleted file mode 100644 index 17a2dd5..0000000 --- a/src/filters/tiltshift/TiltShiftAxisFilter.js +++ /dev/null @@ -1,121 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * @author Vico @vicocotea - * original filter https://github.com/evanw/glfx.js/blob/master/src/filters/blur/tiltshift.js by Evan Wallace : http://madebyevan.com/ - */ - -/** - * A TiltShiftAxisFilter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function TiltShiftAxisFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./tilt-shift.frag') - - ); - - this.uniforms.blur = 100; - this.uniforms.gradientBlur = 600; - this.uniforms.start = new PIXI.Point(0, window.innerHeight / 2); - this.uniforms.end = new PIXI.Point(600, window.innerHeight / 2); - this.uniforms.delta = new PIXI.Point(30, 30); - this.uniforms.texSize = new PIXI.Point(window.innerWidth, window.innerHeight); - - this.updateDelta(); -} - -TiltShiftAxisFilter.prototype = Object.create(core.Filter.prototype); -TiltShiftAxisFilter.prototype.constructor = TiltShiftAxisFilter; -module.exports = TiltShiftAxisFilter; - -/** - * Updates the filter delta values. - * This is overridden in the X and Y filters, does nothing for this class. - * - */ -TiltShiftAxisFilter.prototype.updateDelta = function () -{ - this.uniforms.delta.x = 0; - this.uniforms.delta.y = 0; -}; - -Object.defineProperties(TiltShiftAxisFilter.prototype, { - /** - * The strength of the blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - blur: { - get: function () - { - return this.uniforms.blur; - }, - set: function (value) - { - this.uniforms.blur = value; - } - }, - - /** - * The strength of the gradient blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - gradientBlur: { - get: function () - { - return this.uniforms.gradientBlur; - }, - set: function (value) - { - this.uniforms.gradientBlur = value; - } - }, - - /** - * The X value to start the effect at. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - start: { - get: function () - { - return this.uniforms.start; - }, - set: function (value) - { - this.uniforms.start = value; - this.updateDelta(); - } - }, - - /** - * The X value to end the effect at. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - end: { - get: function () - { - return this.uniforms.end; - }, - set: function (value) - { - this.uniforms.end = value; - this.updateDelta(); - } - } -}); diff --git a/src/filters/tiltshift/TiltShiftFilter.js b/src/filters/tiltshift/TiltShiftFilter.js deleted file mode 100644 index 671ac7a..0000000 --- a/src/filters/tiltshift/TiltShiftFilter.js +++ /dev/null @@ -1,108 +0,0 @@ -var core = require('../../core'), - TiltShiftXFilter = require('./TiltShiftXFilter'), - TiltShiftYFilter = require('./TiltShiftYFilter'); - -/** - * @author Vico @vicocotea - * original filter https://github.com/evanw/glfx.js/blob/master/src/filters/blur/tiltshift.js by Evan Wallace : http://madebyevan.com/ - */ - -/** - * A TiltShift Filter. Manages the pass of both a TiltShiftXFilter and TiltShiftYFilter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function TiltShiftFilter() -{ - core.Filter.call(this); - - this.tiltShiftXFilter = new TiltShiftXFilter(); - this.tiltShiftYFilter = new TiltShiftYFilter(); -} - -TiltShiftFilter.prototype = Object.create(core.Filter.prototype); -TiltShiftFilter.prototype.constructor = TiltShiftFilter; -module.exports = TiltShiftFilter; - -TiltShiftFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - this.tiltShiftXFilter.apply(filterManager, input, renderTarget); - - this.tiltShiftYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(TiltShiftFilter.prototype, { - /** - * The strength of the blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftFilter# - */ - blur: { - get: function () - { - return this.tiltShiftXFilter.blur; - }, - set: function (value) - { - this.tiltShiftXFilter.blur = this.tiltShiftYFilter.blur = value; - } - }, - - /** - * The strength of the gradient blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftFilter# - */ - gradientBlur: { - get: function () - { - return this.tiltShiftXFilter.gradientBlur; - }, - set: function (value) - { - this.tiltShiftXFilter.gradientBlur = this.tiltShiftYFilter.gradientBlur = value; - } - }, - - /** - * The Y value to start the effect at. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftFilter# - */ - start: { - get: function () - { - return this.tiltShiftXFilter.start; - }, - set: function (value) - { - this.tiltShiftXFilter.start = this.tiltShiftYFilter.start = value; - } - }, - - /** - * The Y value to end the effect at. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftFilter# - */ - end: { - get: function () - { - return this.tiltShiftXFilter.end; - }, - set: function (value) - { - this.tiltShiftXFilter.end = this.tiltShiftYFilter.end = value; - } - } -}); diff --git a/src/filters/tiltshift/TiltShiftXFilter.js b/src/filters/tiltshift/TiltShiftXFilter.js deleted file mode 100644 index d6d82ea..0000000 --- a/src/filters/tiltshift/TiltShiftXFilter.js +++ /dev/null @@ -1,36 +0,0 @@ -var TiltShiftAxisFilter = require('./TiltShiftAxisFilter'); - -/** - * @author Vico @vicocotea - * original filter https://github.com/evanw/glfx.js/blob/master/src/filters/blur/tiltshift.js by Evan Wallace : http://madebyevan.com/ - */ - -/** - * A TiltShiftXFilter. - * - * @class - * @extends PIXI.TiltShiftAxisFilter - * @memberof PIXI.filters - */ -function TiltShiftXFilter() -{ - TiltShiftAxisFilter.call(this); -} - -TiltShiftXFilter.prototype = Object.create(TiltShiftAxisFilter.prototype); -TiltShiftXFilter.prototype.constructor = TiltShiftXFilter; -module.exports = TiltShiftXFilter; - -/** - * Updates the filter delta values. - * - */ -TiltShiftXFilter.prototype.updateDelta = function () -{ - var dx = this.uniforms.end.x - this.uniforms.start.x; - var dy = this.uniforms.end.y - this.uniforms.start.y; - var d = Math.sqrt(dx * dx + dy * dy); - - this.uniforms.delta.x = dx / d; - this.uniforms.delta.y = dy / d; -}; diff --git a/src/filters/tiltshift/TiltShiftYFilter.js b/src/filters/tiltshift/TiltShiftYFilter.js deleted file mode 100644 index f8804bb..0000000 --- a/src/filters/tiltshift/TiltShiftYFilter.js +++ /dev/null @@ -1,36 +0,0 @@ -var TiltShiftAxisFilter = require('./TiltShiftAxisFilter'); - -/** - * @author Vico @vicocotea - * original filter https://github.com/evanw/glfx.js/blob/master/src/filters/blur/tiltshift.js by Evan Wallace : http://madebyevan.com/ - */ - -/** - * A TiltShiftYFilter. - * - * @class - * @extends PIXI.TiltShiftAxisFilter - * @memberof PIXI.filters - */ -function TiltShiftYFilter() -{ - TiltShiftAxisFilter.call(this); -} - -TiltShiftYFilter.prototype = Object.create(TiltShiftAxisFilter.prototype); -TiltShiftYFilter.prototype.constructor = TiltShiftYFilter; -module.exports = TiltShiftYFilter; - -/** - * Updates the filter delta values. - * - */ -TiltShiftYFilter.prototype.updateDelta = function () -{ - var dx = this.uniforms.end.x - this.uniforms.start.x; - var dy = this.uniforms.end.y - this.uniforms.start.y; - var d = Math.sqrt(dx * dx + dy * dy); - - this.uniforms.delta.x = -dy / d; - this.uniforms.delta.y = dx / d; -}; diff --git a/src/filters/tiltshift/tilt-shift.frag b/src/filters/tiltshift/tilt-shift.frag deleted file mode 100644 index fff2be0..0000000 --- a/src/filters/tiltshift/tilt-shift.frag +++ /dev/null @@ -1,37 +0,0 @@ -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform float blur; -uniform float gradientBlur; -uniform vec2 start; -uniform vec2 end; -uniform vec2 delta; -uniform vec2 texSize; - -float random(vec3 scale, float seed) -{ - return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed); -} - -void main(void) -{ - vec4 color = vec4(0.0); - float total = 0.0; - - float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0); - vec2 normal = normalize(vec2(start.y - end.y, end.x - start.x)); - float radius = smoothstep(0.0, 1.0, abs(dot(vTextureCoord * texSize - start, normal)) / gradientBlur) * blur; - - for (float t = -30.0; t <= 30.0; t++) - { - float percent = (t + offset - 0.5) / 30.0; - float weight = 1.0 - abs(percent); - vec4 sample = texture2D(uSampler, vTextureCoord + delta / texSize * percent * radius); - sample.rgb *= sample.a; - color += sample * weight; - total += weight; - } - - gl_FragColor = color / total; - gl_FragColor.rgb /= gl_FragColor.a + 0.00001; -} diff --git a/src/filters/twist/TwistFilter.js b/src/filters/twist/TwistFilter.js deleted file mode 100644 index 90e5b7f..0000000 --- a/src/filters/twist/TwistFilter.js +++ /dev/null @@ -1,80 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * This filter applies a twist effect making display objects appear twisted in the given direction. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function TwistFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./twist.frag') - ); - - this.radius = 200; - this.angle = 4; - this.padding = 20; -} - -TwistFilter.prototype = Object.create(core.Filter.prototype); -TwistFilter.prototype.constructor = TwistFilter; -module.exports = TwistFilter; - -Object.defineProperties(TwistFilter.prototype, { - /** - * This point describes the the offset of the twist. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.TwistFilter# - */ - offset: { - get: function () - { - return this.uniforms.offset; - }, - set: function (value) - { - this.uniforms.offset = value; - } - }, - - /** - * This radius of the twist. - * - * @member {number} - * @memberof PIXI.filters.TwistFilter# - */ - radius: { - get: function () - { - return this.uniforms.radius; - }, - set: function (value) - { - this.uniforms.radius = value; - } - }, - - /** - * This angle of the twist. - * - * @member {number} - * @memberof PIXI.filters.TwistFilter# - */ - angle: { - get: function () - { - return this.uniforms.angle; - }, - set: function (value) - { - this.uniforms.angle = value; - } - } -}); diff --git a/src/filters/ascii/AsciiFilter.js b/src/filters/ascii/AsciiFilter.js deleted file mode 100644 index ac64fd1..0000000 --- a/src/filters/ascii/AsciiFilter.js +++ /dev/null @@ -1,51 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -// TODO (cengler) - The Y is flipped in this shader for some reason. - -/** - * @author Vico @vicocotea - * original shader : https://www.shadertoy.com/view/lssGDj by @movAX13h - */ - -/** - * An ASCII filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function AsciiFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./ascii.frag') - ); - - this.size = 8; -} - -AsciiFilter.prototype = Object.create(core.Filter.prototype); -AsciiFilter.prototype.constructor = AsciiFilter; -module.exports = AsciiFilter; - -Object.defineProperties(AsciiFilter.prototype, { - /** - * The pixel size used by the filter. - * - * @member {number} - * @memberof PIXI.filters.AsciiFilter# - */ - size: { - get: function () - { - return this.uniforms.pixelSize; - }, - set: function (value) - { - this.uniforms.pixelSize = value; - } - } -}); diff --git a/src/filters/ascii/ascii.frag b/src/filters/ascii/ascii.frag deleted file mode 100644 index 5608d6e..0000000 --- a/src/filters/ascii/ascii.frag +++ /dev/null @@ -1,70 +0,0 @@ -varying vec2 vTextureCoord; - -uniform vec4 filterArea; -uniform float pixelSize; -uniform sampler2D uSampler; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -vec2 getMod(vec2 coord, vec2 size) -{ - return mod( coord , size) / size; -} - -float character(float n, vec2 p) -{ - p = floor(p*vec2(4.0, -4.0) + 2.5); - if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y) - { - if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; - } - return 0.0; -} - -void main() -{ - vec2 coord = mapCoord(vTextureCoord); - - // get the rounded color.. - vec2 pixCoord = pixelate(coord, vec2(pixelSize)); - pixCoord = unmapCoord(pixCoord); - - vec4 color = texture2D(uSampler, pixCoord); - - // determine the character to use - float gray = (color.r + color.g + color.b) / 3.0; - - float n = 65536.0; // . - if (gray > 0.2) n = 65600.0; // : - if (gray > 0.3) n = 332772.0; // * - if (gray > 0.4) n = 15255086.0; // o - if (gray > 0.5) n = 23385164.0; // & - if (gray > 0.6) n = 15252014.0; // 8 - if (gray > 0.7) n = 13199452.0; // @ - if (gray > 0.8) n = 11512810.0; // # - - // get the mod.. - vec2 modd = getMod(coord, vec2(pixelSize)); - - gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); - -} \ No newline at end of file diff --git a/src/filters/bloom/BloomFilter.js b/src/filters/bloom/BloomFilter.js deleted file mode 100644 index 1a9c713..0000000 --- a/src/filters/bloom/BloomFilter.js +++ /dev/null @@ -1,97 +0,0 @@ -var core = require('../../core'), - BlurXFilter = require('../blur/BlurXFilter'), - BlurYFilter = require('../blur/BlurYFilter'); - VoidFilter = require('../void/VoidFilter'); - -/** - * The BloomFilter applies a Gaussian blur to an object. - * The strength of the blur can be set for x- and y-axis separately. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function BloomFilter() -{ - core.Filter.call(this); - - this.blurXFilter = new BlurXFilter(); - this.blurYFilter = new BlurYFilter(); - - this.blurYFilter.blendMode = core.BLEND_MODES.SCREEN; - - this.defaultFilter = new VoidFilter(); -} - -BloomFilter.prototype = Object.create(core.Filter.prototype); -BloomFilter.prototype.constructor = BloomFilter; -module.exports = BloomFilter; - -BloomFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - //TODO - copyTexSubImage2D could be used here? - this.defaultFilter.apply(filterManager, input, output); - - this.blurXFilter.apply(filterManager, input, renderTarget); - this.blurYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(BloomFilter.prototype, { - /** - * Sets the strength of both the blurX and blurY properties simultaneously - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blur: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = this.blurYFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurX property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurX: { - get: function () - { - return this.blurXFilter.blur; - }, - set: function (value) - { - this.blurXFilter.blur = value; - } - }, - - /** - * Sets the strength of the blurY property - * - * @member {number} - * @memberOf PIXI.filters.BloomFilter# - * @default 2 - */ - blurY: { - get: function () - { - return this.blurYFilter.blur; - }, - set: function (value) - { - this.blurYFilter.blur = value; - } - } -}); diff --git a/src/filters/convolution/ConvolutionFilter.js b/src/filters/convolution/ConvolutionFilter.js deleted file mode 100644 index 51775ba..0000000 --- a/src/filters/convolution/ConvolutionFilter.js +++ /dev/null @@ -1,87 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ConvolutionFilter class applies a matrix convolution filter effect. - * A convolution combines pixels in the input image with neighboring pixels to produce a new image. - * A wide variety of image effects can be achieved through convolutions, including blurring, edge - * detection, sharpening, embossing, and beveling. The matrix should be specified as a 9 point Array. - * See http://docs.gimp.org/en/plug-in-convmatrix.html for more info. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - * @param matrix {number[]} An array of values used for matrix transformation. Specified as a 9 point Array. - * @param width {number} Width of the object you are transforming - * @param height {number} Height of the object you are transforming - */ -function ConvolutionFilter(matrix, width, height) -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./convolution.frag') - ); - - this.matrix = matrix; - this.width = width; - this.height = height; -} - -ConvolutionFilter.prototype = Object.create(core.Filter.prototype); -ConvolutionFilter.prototype.constructor = ConvolutionFilter; -module.exports = ConvolutionFilter; - -Object.defineProperties(ConvolutionFilter.prototype, { - /** - * An array of values used for matrix transformation. Specified as a 9 point Array. - * - * @member {number[]} - * @memberof PIXI.filters.ConvolutionFilter# - */ - matrix: { - get: function () - { - return this.uniforms.matrix; - }, - set: function (value) - { - this.uniforms.matrix = new Float32Array(value); - } - }, - - /** - * Width of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - width: { - get: function () - { - return 1/this.uniforms.texelSize[0]; - }, - set: function (value) - { - this.uniforms.texelSize[0] = 1/value; - } - }, - - /** - * Height of the object you are transforming - * - * @member {number} - * @memberof PIXI.filters.ConvolutionFilter# - */ - height: { - get: function () - { - return 1/this.uniforms.texelSize[1]; - }, - set: function (value) - { - this.uniforms.texelSize[1] = 1/value; - } - } -}); diff --git a/src/filters/convolution/convolution.frag b/src/filters/convolution/convolution.frag deleted file mode 100644 index e6fe7b5..0000000 --- a/src/filters/convolution/convolution.frag +++ /dev/null @@ -1,29 +0,0 @@ -precision mediump float; - -varying mediump vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec2 texelSize; -uniform float matrix[9]; - -void main(void) -{ - vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left - vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center - vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right - - vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left - vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center - vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right - - vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left - vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center - vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right - - gl_FragColor = - c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] + - c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] + - c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8]; - - gl_FragColor.a = c22.a; -} diff --git a/src/filters/crosshatch/CrossHatchFilter.js b/src/filters/crosshatch/CrossHatchFilter.js deleted file mode 100644 index a8da95d..0000000 --- a/src/filters/crosshatch/CrossHatchFilter.js +++ /dev/null @@ -1,23 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * A Cross Hatch effect filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function CrossHatchFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./crosshatch.frag') - ); -} - -CrossHatchFilter.prototype = Object.create(core.Filter.prototype); -CrossHatchFilter.prototype.constructor = CrossHatchFilter; -module.exports = CrossHatchFilter; diff --git a/src/filters/crosshatch/crosshatch.frag b/src/filters/crosshatch/crosshatch.frag deleted file mode 100644 index 635ba4b..0000000 --- a/src/filters/crosshatch/crosshatch.frag +++ /dev/null @@ -1,44 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -void main(void) -{ - float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb); - - gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); - - if (lum < 1.00) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.75) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.50) - { - if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } - - if (lum < 0.3) - { - if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - } -} diff --git a/src/filters/dot/DotFilter.js b/src/filters/dot/DotFilter.js deleted file mode 100644 index d2bc544..0000000 --- a/src/filters/dot/DotFilter.js +++ /dev/null @@ -1,66 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * @author Mat Groves http://matgroves.com/ @Doormat23 - * original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/fun/dotscreen.js - */ - -/** - * This filter applies a dotscreen effect making display objects appear to be made out of - * black and white halftone dots like an old printer. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function DotFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./dot.frag') - ); - - this.scale = 1; - this.angle = 5; -} - -DotFilter.prototype = Object.create(core.Filter.prototype); -DotFilter.prototype.constructor = DotFilter; -module.exports = DotFilter; - -Object.defineProperties(DotFilter.prototype, { - /** - * The scale of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - scale: { - get: function () - { - return this.uniforms.scale; - }, - set: function (value) - { - this.uniforms.scale = value; - } - }, - - /** - * The radius of the effect. - * @member {number} - * @memberof PIXI.filters.DotFilter# - */ - angle: { - get: function () - { - return this.uniforms.angle; - }, - set: function (value) - { - this.uniforms.angle = value; - } - } -}); diff --git a/src/filters/dot/dot.frag b/src/filters/dot/dot.frag deleted file mode 100644 index 91341b1..0000000 --- a/src/filters/dot/dot.frag +++ /dev/null @@ -1,28 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; -varying vec4 vColor; - -uniform vec4 filterArea; -uniform sampler2D uSampler; - -uniform float angle; -uniform float scale; - -float pattern() -{ - float s = sin(angle), c = cos(angle); - vec2 tex = vTextureCoord * filterArea.xy; - vec2 point = vec2( - c * tex.x - s * tex.y, - s * tex.x + c * tex.y - ) * scale; - return (sin(point.x) * sin(point.y)) * 4.0; -} - -void main() -{ - vec4 color = texture2D(uSampler, vTextureCoord); - float average = (color.r + color.g + color.b) / 3.0; - gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a); -} diff --git a/src/filters/emboss/EmbossFilter.js b/src/filters/emboss/EmbossFilter.js deleted file mode 100644 index 0468d1f..0000000 --- a/src/filters/emboss/EmbossFilter.js +++ /dev/null @@ -1,46 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function EmbossFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./emboss.frag') - ); - - this.strength = 5; -} - -EmbossFilter.prototype = Object.create(core.Filter.prototype); -EmbossFilter.prototype.constructor = EmbossFilter; -module.exports = EmbossFilter; - -Object.defineProperties(EmbossFilter.prototype, { - /** - * Strength of Emboss. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.EmbossFilter# - */ - strength: { - get: function () - { - return this.uniforms.strength; - }, - set: function (value) - { - this.uniforms.strength = value; - } - }, - - -}); diff --git a/src/filters/emboss/emboss.frag b/src/filters/emboss/emboss.frag deleted file mode 100644 index 28b14d9..0000000 --- a/src/filters/emboss/emboss.frag +++ /dev/null @@ -1,26 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform float strength; -uniform vec4 filterArea; - - -void main(void) -{ - vec2 onePixel = vec2(1.0 / filterArea); - - vec4 color; - - color.rgb = vec3(0.5); - - color -= texture2D(uSampler, vTextureCoord - onePixel) * strength; - color += texture2D(uSampler, vTextureCoord + onePixel) * strength; - - color.rgb = vec3((color.r + color.g + color.b) / 3.0); - - float alpha = texture2D(uSampler, vTextureCoord).a; - - gl_FragColor = vec4(color.rgb * alpha, alpha); -} diff --git a/src/filters/index.js b/src/filters/index.js index 6709e39..54c1a3b 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -9,28 +9,12 @@ * @namespace PIXI.filters */ module.exports = { - AsciiFilter: require('./ascii/AsciiFilter'), - BloomFilter: require('./bloom/BloomFilter'), - ConvolutionFilter: require('./convolution/ConvolutionFilter'), - CrossHatchFilter: require('./crosshatch/CrossHatchFilter'), - DotFilter: require('./dot/DotFilter'), FXAAFilter: require('./fxaa/FXAAFilter'), - // DropShadowFilter: require('./dropshadow/DropShadowFilter'), NoiseFilter: require('./noise/NoiseFilter'), - PixelateFilter: require('./pixelate/PixelateFilter'), - RGBSplitFilter: require('./rgb/RGBSplitFilter'), - EmbossFilter: require('./emboss/EmbossFilter'), - ShockwaveFilter: require('./shockwave/ShockwaveFilter'), - // SmartBlurFilter: require('./blur/SmartBlurFilter'), - TiltShiftFilter: require('./tiltshift/TiltShiftFilter'), - // TiltShiftXFilter: require('./tiltshift/TiltShiftXFilter'), - //TiltShiftYFilter: require('./tiltshift/TiltShiftYFilter'), DisplacementFilter: require('./displacement/DisplacementFilter'), BlurFilter: require('./blur/BlurFilter'), BlurXFilter: require('./blur/BlurXFilter'), BlurYFilter: require('./blur/BlurYFilter'), - ColorMatrixFilter: require('./colormatrix/ColorMatrixFilter'), - TwistFilter: require('./twist/TwistFilter'), VoidFilter: require('./void/VoidFilter') }; diff --git a/src/filters/pixelate/PixelateFilter.js b/src/filters/pixelate/PixelateFilter.js deleted file mode 100644 index 6d5a1f2..0000000 --- a/src/filters/pixelate/PixelateFilter.js +++ /dev/null @@ -1,47 +0,0 @@ -var core = require('../../core'); -// @see https://github.com/substack/brfs/issues/25 -var glslify = require('glslify'); - -/** - * This filter applies a pixelate effect making display objects appear 'blocky'. - * - * @class - * @extends PIXI.AbstractFilter - * @memberof PIXI.filters - */ -function PixelateFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./pixelate.frag') - ); - - this.size = [0,0]; - -} - -PixelateFilter.prototype = Object.create(core.Filter.prototype); -PixelateFilter.prototype.constructor = PixelateFilter; -module.exports = PixelateFilter; - -Object.defineProperties(PixelateFilter.prototype, { - /** - * This a point that describes the size of the blocks. - * x is the width of the block and y is the height. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.PixelateFilter# - */ - size: { - get: function () - { - return this.uniforms.size; - }, - set: function (value) - { - this.uniforms.size.value = value; - } - } -}); diff --git a/src/filters/pixelate/pixelate.frag b/src/filters/pixelate/pixelate.frag deleted file mode 100644 index 80ad2ee..0000000 --- a/src/filters/pixelate/pixelate.frag +++ /dev/null @@ -1,40 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform vec2 size; -uniform sampler2D uSampler; - -uniform vec4 filterArea; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 pixelate(vec2 coord, vec2 size) -{ - return floor( coord / size ) * size; -} - -void main(void) -{ - vec2 coord = mapCoord(vTextureCoord); - - coord = pixelate(coord, size); - - coord = unmapCoord(coord); - - gl_FragColor = texture2D(uSampler, coord); -} diff --git a/src/filters/rgb/RGBSplitFilter.js b/src/filters/rgb/RGBSplitFilter.js deleted file mode 100644 index 9609514..0000000 --- a/src/filters/rgb/RGBSplitFilter.js +++ /dev/null @@ -1,80 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * An RGB Split Filter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function RGBSplitFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./rgb-split.frag') - ); - - this.red = [-10, 0]; - this.green = [0, 10]; - this.blue = [0, 0]; -} - -RGBSplitFilter.prototype = Object.create(core.Filter.prototype); -RGBSplitFilter.prototype.constructor = RGBSplitFilter; -module.exports = RGBSplitFilter; - -Object.defineProperties(RGBSplitFilter.prototype, { - /** - * Red channel offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - red: { - get: function () - { - return this.uniforms.red; - }, - set: function (value) - { - this.uniforms.red = value; - } - }, - - /** - * Green channel offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - green: { - get: function () - { - return this.uniforms.green; - }, - set: function (value) - { - this.uniforms.green = value; - } - }, - - /** - * Blue offset. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.RGBSplitFilter# - */ - blue: { - get: function () - { - return this.uniforms.blue.value; - }, - set: function (value) - { - this.uniforms.blue.value = value; - } - } -}); diff --git a/src/filters/rgb/rgb-split.frag b/src/filters/rgb/rgb-split.frag deleted file mode 100644 index 46fed0f..0000000 --- a/src/filters/rgb/rgb-split.frag +++ /dev/null @@ -1,17 +0,0 @@ -precision mediump float; - -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform vec4 filterArea; -uniform vec2 red; -uniform vec2 green; -uniform vec2 blue; - -void main(void) -{ - gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/filterArea.xy).r; - gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/filterArea.xy).g; - gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/filterArea.xy).b; - gl_FragColor.a = texture2D(uSampler, vTextureCoord).a; -} diff --git a/src/filters/shockwave/ShockwaveFilter.js b/src/filters/shockwave/ShockwaveFilter.js deleted file mode 100644 index 709bb86..0000000 --- a/src/filters/shockwave/ShockwaveFilter.js +++ /dev/null @@ -1,89 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * The ColorMatrixFilter class lets you apply a 4x4 matrix transformation on the RGBA - * color and alpha values of every pixel on your displayObject to produce a result - * with a new set of RGBA color and alpha values. It's pretty powerful! - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function ShockwaveFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./shockwave.frag'), - // custom uniforms - { - center: { type: 'v2', value: { x: 0.5, y: 0.5 } }, - params: { type: 'v3', value: { x: 10, y: 0.8, z: 0.1 } }, - time: { type: '1f', value: 0 } - } - ); - - this.center = [0.5, 0.5]; - this.params = [10, 0.8, 0.1]; - this.time = 0; -} - -ShockwaveFilter.prototype = Object.create(core.Filter.prototype); -ShockwaveFilter.prototype.constructor = ShockwaveFilter; -module.exports = ShockwaveFilter; - -Object.defineProperties(ShockwaveFilter.prototype, { - /** - * Sets the center of the shockwave in normalized screen coords. That is - * (0,0) is the top-left and (1,1) is the bottom right. - * - * @member {object} - * @memberof PIXI.filters.ShockwaveFilter# - */ - center: { - get: function () - { - return this.uniforms.center; - }, - set: function (value) - { - this.uniforms.center = value; - } - }, - /** - * Sets the params of the shockwave. These modify the look and behavior of - * the shockwave as it ripples out. - * - * @member {object} - * @memberof PIXI.filters.ShockwaveFilter# - */ - params: { - get: function () - { - return this.uniforms.params; - }, - set: function (value) - { - this.uniforms.params = value; - } - }, - /** - * Sets the elapsed time of the shockwave. This controls the speed at which - * the shockwave ripples out. - * - * @member {number} - * @memberof PIXI.filters.ShockwaveFilter# - */ - time: { - get: function () - { - return this.uniforms.time; - }, - set: function (value) - { - this.uniforms.time = value; - } - } -}); diff --git a/src/filters/shockwave/shockwave.frag b/src/filters/shockwave/shockwave.frag deleted file mode 100644 index db2642e..0000000 --- a/src/filters/shockwave/shockwave.frag +++ /dev/null @@ -1,27 +0,0 @@ -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; - -uniform vec2 center; -uniform vec3 params; // 10.0, 0.8, 0.1 -uniform float time; - -void main() -{ - vec2 uv = vTextureCoord; - vec2 texCoord = uv; - - float dist = distance(uv, center); - - if ( (dist <= (time + params.z)) && (dist >= (time - params.z)) ) - { - float diff = (dist - time); - float powDiff = 1.0 - pow(abs(diff*params.x), params.y); - - float diffTime = diff * powDiff; - vec2 diffUV = normalize(uv - center); - texCoord = uv + (diffUV * diffTime); - } - - gl_FragColor = texture2D(uSampler, texCoord); -} diff --git a/src/filters/tiltshift/TiltShiftAxisFilter.js b/src/filters/tiltshift/TiltShiftAxisFilter.js deleted file mode 100644 index 17a2dd5..0000000 --- a/src/filters/tiltshift/TiltShiftAxisFilter.js +++ /dev/null @@ -1,121 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * @author Vico @vicocotea - * original filter https://github.com/evanw/glfx.js/blob/master/src/filters/blur/tiltshift.js by Evan Wallace : http://madebyevan.com/ - */ - -/** - * A TiltShiftAxisFilter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function TiltShiftAxisFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./tilt-shift.frag') - - ); - - this.uniforms.blur = 100; - this.uniforms.gradientBlur = 600; - this.uniforms.start = new PIXI.Point(0, window.innerHeight / 2); - this.uniforms.end = new PIXI.Point(600, window.innerHeight / 2); - this.uniforms.delta = new PIXI.Point(30, 30); - this.uniforms.texSize = new PIXI.Point(window.innerWidth, window.innerHeight); - - this.updateDelta(); -} - -TiltShiftAxisFilter.prototype = Object.create(core.Filter.prototype); -TiltShiftAxisFilter.prototype.constructor = TiltShiftAxisFilter; -module.exports = TiltShiftAxisFilter; - -/** - * Updates the filter delta values. - * This is overridden in the X and Y filters, does nothing for this class. - * - */ -TiltShiftAxisFilter.prototype.updateDelta = function () -{ - this.uniforms.delta.x = 0; - this.uniforms.delta.y = 0; -}; - -Object.defineProperties(TiltShiftAxisFilter.prototype, { - /** - * The strength of the blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - blur: { - get: function () - { - return this.uniforms.blur; - }, - set: function (value) - { - this.uniforms.blur = value; - } - }, - - /** - * The strength of the gradient blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - gradientBlur: { - get: function () - { - return this.uniforms.gradientBlur; - }, - set: function (value) - { - this.uniforms.gradientBlur = value; - } - }, - - /** - * The X value to start the effect at. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - start: { - get: function () - { - return this.uniforms.start; - }, - set: function (value) - { - this.uniforms.start = value; - this.updateDelta(); - } - }, - - /** - * The X value to end the effect at. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.TiltShiftAxisFilter# - */ - end: { - get: function () - { - return this.uniforms.end; - }, - set: function (value) - { - this.uniforms.end = value; - this.updateDelta(); - } - } -}); diff --git a/src/filters/tiltshift/TiltShiftFilter.js b/src/filters/tiltshift/TiltShiftFilter.js deleted file mode 100644 index 671ac7a..0000000 --- a/src/filters/tiltshift/TiltShiftFilter.js +++ /dev/null @@ -1,108 +0,0 @@ -var core = require('../../core'), - TiltShiftXFilter = require('./TiltShiftXFilter'), - TiltShiftYFilter = require('./TiltShiftYFilter'); - -/** - * @author Vico @vicocotea - * original filter https://github.com/evanw/glfx.js/blob/master/src/filters/blur/tiltshift.js by Evan Wallace : http://madebyevan.com/ - */ - -/** - * A TiltShift Filter. Manages the pass of both a TiltShiftXFilter and TiltShiftYFilter. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function TiltShiftFilter() -{ - core.Filter.call(this); - - this.tiltShiftXFilter = new TiltShiftXFilter(); - this.tiltShiftYFilter = new TiltShiftYFilter(); -} - -TiltShiftFilter.prototype = Object.create(core.Filter.prototype); -TiltShiftFilter.prototype.constructor = TiltShiftFilter; -module.exports = TiltShiftFilter; - -TiltShiftFilter.prototype.apply = function (filterManager, input, output) -{ - var renderTarget = filterManager.getRenderTarget(true); - - this.tiltShiftXFilter.apply(filterManager, input, renderTarget); - - this.tiltShiftYFilter.apply(filterManager, renderTarget, output); - - filterManager.returnRenderTarget(renderTarget); -}; - -Object.defineProperties(TiltShiftFilter.prototype, { - /** - * The strength of the blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftFilter# - */ - blur: { - get: function () - { - return this.tiltShiftXFilter.blur; - }, - set: function (value) - { - this.tiltShiftXFilter.blur = this.tiltShiftYFilter.blur = value; - } - }, - - /** - * The strength of the gradient blur. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftFilter# - */ - gradientBlur: { - get: function () - { - return this.tiltShiftXFilter.gradientBlur; - }, - set: function (value) - { - this.tiltShiftXFilter.gradientBlur = this.tiltShiftYFilter.gradientBlur = value; - } - }, - - /** - * The Y value to start the effect at. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftFilter# - */ - start: { - get: function () - { - return this.tiltShiftXFilter.start; - }, - set: function (value) - { - this.tiltShiftXFilter.start = this.tiltShiftYFilter.start = value; - } - }, - - /** - * The Y value to end the effect at. - * - * @member {number} - * @memberof PIXI.filters.TiltShiftFilter# - */ - end: { - get: function () - { - return this.tiltShiftXFilter.end; - }, - set: function (value) - { - this.tiltShiftXFilter.end = this.tiltShiftYFilter.end = value; - } - } -}); diff --git a/src/filters/tiltshift/TiltShiftXFilter.js b/src/filters/tiltshift/TiltShiftXFilter.js deleted file mode 100644 index d6d82ea..0000000 --- a/src/filters/tiltshift/TiltShiftXFilter.js +++ /dev/null @@ -1,36 +0,0 @@ -var TiltShiftAxisFilter = require('./TiltShiftAxisFilter'); - -/** - * @author Vico @vicocotea - * original filter https://github.com/evanw/glfx.js/blob/master/src/filters/blur/tiltshift.js by Evan Wallace : http://madebyevan.com/ - */ - -/** - * A TiltShiftXFilter. - * - * @class - * @extends PIXI.TiltShiftAxisFilter - * @memberof PIXI.filters - */ -function TiltShiftXFilter() -{ - TiltShiftAxisFilter.call(this); -} - -TiltShiftXFilter.prototype = Object.create(TiltShiftAxisFilter.prototype); -TiltShiftXFilter.prototype.constructor = TiltShiftXFilter; -module.exports = TiltShiftXFilter; - -/** - * Updates the filter delta values. - * - */ -TiltShiftXFilter.prototype.updateDelta = function () -{ - var dx = this.uniforms.end.x - this.uniforms.start.x; - var dy = this.uniforms.end.y - this.uniforms.start.y; - var d = Math.sqrt(dx * dx + dy * dy); - - this.uniforms.delta.x = dx / d; - this.uniforms.delta.y = dy / d; -}; diff --git a/src/filters/tiltshift/TiltShiftYFilter.js b/src/filters/tiltshift/TiltShiftYFilter.js deleted file mode 100644 index f8804bb..0000000 --- a/src/filters/tiltshift/TiltShiftYFilter.js +++ /dev/null @@ -1,36 +0,0 @@ -var TiltShiftAxisFilter = require('./TiltShiftAxisFilter'); - -/** - * @author Vico @vicocotea - * original filter https://github.com/evanw/glfx.js/blob/master/src/filters/blur/tiltshift.js by Evan Wallace : http://madebyevan.com/ - */ - -/** - * A TiltShiftYFilter. - * - * @class - * @extends PIXI.TiltShiftAxisFilter - * @memberof PIXI.filters - */ -function TiltShiftYFilter() -{ - TiltShiftAxisFilter.call(this); -} - -TiltShiftYFilter.prototype = Object.create(TiltShiftAxisFilter.prototype); -TiltShiftYFilter.prototype.constructor = TiltShiftYFilter; -module.exports = TiltShiftYFilter; - -/** - * Updates the filter delta values. - * - */ -TiltShiftYFilter.prototype.updateDelta = function () -{ - var dx = this.uniforms.end.x - this.uniforms.start.x; - var dy = this.uniforms.end.y - this.uniforms.start.y; - var d = Math.sqrt(dx * dx + dy * dy); - - this.uniforms.delta.x = -dy / d; - this.uniforms.delta.y = dx / d; -}; diff --git a/src/filters/tiltshift/tilt-shift.frag b/src/filters/tiltshift/tilt-shift.frag deleted file mode 100644 index fff2be0..0000000 --- a/src/filters/tiltshift/tilt-shift.frag +++ /dev/null @@ -1,37 +0,0 @@ -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform float blur; -uniform float gradientBlur; -uniform vec2 start; -uniform vec2 end; -uniform vec2 delta; -uniform vec2 texSize; - -float random(vec3 scale, float seed) -{ - return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed); -} - -void main(void) -{ - vec4 color = vec4(0.0); - float total = 0.0; - - float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0); - vec2 normal = normalize(vec2(start.y - end.y, end.x - start.x)); - float radius = smoothstep(0.0, 1.0, abs(dot(vTextureCoord * texSize - start, normal)) / gradientBlur) * blur; - - for (float t = -30.0; t <= 30.0; t++) - { - float percent = (t + offset - 0.5) / 30.0; - float weight = 1.0 - abs(percent); - vec4 sample = texture2D(uSampler, vTextureCoord + delta / texSize * percent * radius); - sample.rgb *= sample.a; - color += sample * weight; - total += weight; - } - - gl_FragColor = color / total; - gl_FragColor.rgb /= gl_FragColor.a + 0.00001; -} diff --git a/src/filters/twist/TwistFilter.js b/src/filters/twist/TwistFilter.js deleted file mode 100644 index 90e5b7f..0000000 --- a/src/filters/twist/TwistFilter.js +++ /dev/null @@ -1,80 +0,0 @@ -var core = require('../../core'); -var glslify = require('glslify'); - -/** - * This filter applies a twist effect making display objects appear twisted in the given direction. - * - * @class - * @extends PIXI.Filter - * @memberof PIXI.filters - */ -function TwistFilter() -{ - core.Filter.call(this, - // vertex shader - glslify('../fragments/default.vert'), - // fragment shader - glslify('./twist.frag') - ); - - this.radius = 200; - this.angle = 4; - this.padding = 20; -} - -TwistFilter.prototype = Object.create(core.Filter.prototype); -TwistFilter.prototype.constructor = TwistFilter; -module.exports = TwistFilter; - -Object.defineProperties(TwistFilter.prototype, { - /** - * This point describes the the offset of the twist. - * - * @member {PIXI.Point} - * @memberof PIXI.filters.TwistFilter# - */ - offset: { - get: function () - { - return this.uniforms.offset; - }, - set: function (value) - { - this.uniforms.offset = value; - } - }, - - /** - * This radius of the twist. - * - * @member {number} - * @memberof PIXI.filters.TwistFilter# - */ - radius: { - get: function () - { - return this.uniforms.radius; - }, - set: function (value) - { - this.uniforms.radius = value; - } - }, - - /** - * This angle of the twist. - * - * @member {number} - * @memberof PIXI.filters.TwistFilter# - */ - angle: { - get: function () - { - return this.uniforms.angle; - }, - set: function (value) - { - this.uniforms.angle = value; - } - } -}); diff --git a/src/filters/twist/twist.frag b/src/filters/twist/twist.frag deleted file mode 100644 index 22e1b00..0000000 --- a/src/filters/twist/twist.frag +++ /dev/null @@ -1,56 +0,0 @@ -varying vec2 vTextureCoord; - -uniform sampler2D uSampler; -uniform float radius; -uniform float angle; -uniform vec2 offset; -uniform vec4 filterArea; - -vec2 mapCoord( vec2 coord ) -{ - coord *= filterArea.xy; - coord += filterArea.zw; - - return coord; -} - -vec2 unmapCoord( vec2 coord ) -{ - coord -= filterArea.zw; - coord /= filterArea.xy; - - return coord; -} - -vec2 twist(vec2 coord) -{ - coord -= offset; - - float dist = length(coord); - - if (dist < radius) - { - float ratioDist = (radius - dist) / radius; - float angleMod = ratioDist * ratioDist * angle; - float s = sin(angleMod); - float c = cos(angleMod); - coord = vec2(coord.x * c - coord.y * s, coord.x * s + coord.y * c); - } - - coord += offset; - - return coord; -} - -void main(void) -{ - - vec2 coord = mapCoord(vTextureCoord); - - coord = twist(coord); - - coord = unmapCoord(coord); - - gl_FragColor = texture2D(uSampler, coord ); - -}