/** */ THREE.GlitchPass = function ( dt_size ) { if ( THREE.DigitalGlitch === undefined ) console.error( "THREE.GlitchPass relies on THREE.DigitalGlitch" ); var shader = THREE.DigitalGlitch; this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); if(dt_size==undefined) dt_size=64; this.uniforms[ "tDisp"].value=this.generateHeightmap(dt_size); this.material = new THREE.ShaderMaterial({ uniforms: this.uniforms, vertexShader: shader.vertexShader, fragmentShader: shader.fragmentShader }); console.log(this.material); this.enabled = true; this.renderToScreen = false; this.needsSwap = true; this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 ); this.scene = new THREE.Scene(); this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); this.scene.add( this.quad ); this.goWild=false; this.curF=0; this.generateTrigger(); }; THREE.GlitchPass.prototype = { render: function ( renderer, writeBuffer, readBuffer, delta ) { this.uniforms[ "tDiffuse" ].value = readBuffer; this.uniforms[ 'seed' ].value=Math.random();//default seeding this.uniforms[ 'byp' ].value=0; if(this.curF % this.randX ==0 || this.goWild==true) { this.uniforms[ 'amount' ].value=Math.random()/30; this.uniforms[ 'angle' ].value=THREE.Math.randFloat(-Math.PI,Math.PI); this.uniforms[ 'seed_x' ].value=THREE.Math.randFloat(-1,1); this.uniforms[ 'seed_y' ].value=THREE.Math.randFloat(-1,1); this.uniforms[ 'distortion_x' ].value=THREE.Math.randFloat(0,1); this.uniforms[ 'distortion_y' ].value=THREE.Math.randFloat(0,1); this.curF=0; this.generateTrigger(); } else if(this.curF % this.randX