1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | 1 1 1 1 | /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ /** * * 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. Its pretty powerful! * @class ColorMatrixFilter * @contructor */ PIXI.ColorMatrixFilter = function() { PIXI.AbstractFilter.call( this ); this.passes = [this]; // set the uniforms this.uniforms = { matrix: {type: 'mat4', value: [1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1]}, }; this.fragmentSrc = [ 'precision mediump float;', 'varying vec2 vTextureCoord;', 'varying vec4 vColor;', 'uniform float invert;', 'uniform mat4 matrix;', 'uniform sampler2D uSampler;', 'void main(void) {', ' gl_FragColor = texture2D(uSampler, vTextureCoord) * matrix;', // ' gl_FragColor = gl_FragColor;', '}' ]; }; PIXI.ColorMatrixFilter.prototype = Object.create( PIXI.AbstractFilter.prototype ); PIXI.ColorMatrixFilter.prototype.constructor = PIXI.ColorMatrixFilter; /** * Sets the matrix of the color matrix filter * * @property matrix * @type Array and array of 26 numbers * @default [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1] */ Object.defineProperty(PIXI.ColorMatrixFilter.prototype, 'matrix', { get: function() { return this.uniforms.matrix.value; }, set: function(value) { this.uniforms.matrix.value = value; } }); |