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 60 61 62 63 64 65 66 67 | 1 1 1 1 | /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ PIXI.CrossHatchFilter = function() { PIXI.AbstractFilter.call( this ); this.passes = [this]; // set the uniforms this.uniforms = { blur: {type: '1f', value: 1 / 512}, }; this.fragmentSrc = [ 'precision mediump float;', 'varying vec2 vTextureCoord;', 'varying vec4 vColor;', 'uniform float blur;', '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);', ' }', ' }', '}' ]; }; PIXI.CrossHatchFilter.prototype = Object.create( PIXI.AbstractFilter.prototype ); PIXI.CrossHatchFilter.prototype.constructor = PIXI.BlurYFilter; Object.defineProperty(PIXI.CrossHatchFilter.prototype, 'blur', { get: function() { return this.uniforms.blur.value / (1/7000); }, set: function(value) { //this.padding = value; this.uniforms.blur.value = (1/7000) * value; } }); |