Engine.ColorizeFilter = class extends PIXI.Filter
{
	constructor()
	{
		var frag = 
			`
			precision mediump float;
			
			uniform sampler2D uSampler;
			varying vec2 vTextureCoord;

			uniform float _Amount;
			uniform vec3 _Color;
			
			void main(void)
			{
				vec4 col = texture2D(uSampler, vTextureCoord);
				
				vec4 color;
				color.rgb = vec3(dot(col.rgb, _Color));
				color.a = col.a;

				vec4 fragColor;
				fragColor.rgb = (col.rgb * (1.0 - _Amount)) + (color.rgb * _Amount);
				fragColor.a = col.a;

				gl_FragColor = fragColor;
			}
			`;
		
		super(null, frag);
		
		this.amount = 1;
		this.color = new Color(1, 1, 1);
	}

	init(color)
	{
		this.color = color;
	}

	apply(filterManager, input, output, clear, currentState)
	{
		this.uniforms._Amount = this.amount;
		this.uniforms._Color = [this.color.r, this.color.g, this.color.b];
		
		super.apply(filterManager, input, output, clear, currentState);
	}
}