Fixed the Pixelate filter, changing the dimensions uniform to a 2f and removing un-needed vecs from the fragment src. Also fixed the size getter and added sizeX and sizeY getters/setters (#1780)

This commit is contained in:
photonstorm 2015-05-19 16:09:00 +01:00
parent 8db0bfa377
commit 913ccaf22c

View file

@ -4,27 +4,23 @@
*/
/**
* This filter applies a pixelate effect making display objects appear 'blocky'
* This filter applies a pixelate effect making display objects appear 'blocky'.
* @class PixelateFilter
* @contructor
* @constructor
*/
Phaser.Filter.Pixelate = function(game) {
Phaser.Filter.call(this, game);
this.passes = [this];
this.uniforms.invert = { type: '1f', value: 0 };
this.uniforms.pixelSize = { type: '2f', value: { x: 10, y: 10 } };
this.uniforms.dimensions = { type: '4fv', value: { x: 10000, y: 100, z: 10, w: 10 } };
this.uniforms.pixelSize = { type: '2f', value: { x: 1.0, y: 1.0 } };
this.uniforms.dimensions = { type: '2f', value: { x: 1000.0, y: 1000.0 } };
this.fragmentSrc = [
"precision mediump float;",
"varying vec2 vTextureCoord;",
"varying vec4 vColor;",
"uniform vec2 testDim;",
"uniform vec4 dimensions;",
"uniform vec2 dimensions;",
"uniform vec2 pixelSize;",
"uniform sampler2D uSampler;",
@ -43,11 +39,12 @@ Phaser.Filter.Pixelate.prototype = Object.create(Phaser.Filter.prototype);
Phaser.Filter.Pixelate.prototype.constructor = Phaser.Filter.Pixelate;
/**
* This a point that describes the size of the blocs. x is the width of the block and y is the the height
* @property size
* @type Point
*/
Object.defineProperty(Phaser.Filter.prototype, 'size', {
* An object with visible x and y properties that are used to define the size of the filter effect per pixel.
*
* @property size
* @type Phaser.Point
*/
Object.defineProperty(Phaser.Filter.Pixelate.prototype, 'size', {
get: function() {
@ -63,3 +60,49 @@ Object.defineProperty(Phaser.Filter.prototype, 'size', {
}
});
/**
* A value that defines the horizontal size of the filter effect per pixel.
*
* @property sizeX
* @type number
*/
Object.defineProperty(Phaser.Filter.Pixelate.prototype, 'sizeX', {
get: function() {
return this.uniforms.pixelSize.value.x;
},
set: function(value) {
this.dirty = true;
this.uniforms.pixelSize.value.x = value;
}
});
/**
* A value that defines the vertical size of the filter effect per pixel.
*
* @property sizeY
* @type number
*/
Object.defineProperty(Phaser.Filter.Pixelate.prototype, 'sizeY', {
get: function() {
return this.uniforms.pixelSize.value.y;
},
set: function(value) {
this.dirty = true;
this.uniforms.pixelSize.value.y = value;
}
});