Hello all.
I’d like to have a console.log() or some kind of trigger when glitch shader activates itself.
Not when he is rendered to the screen, but actually when the glitch appears.
I’ve been reading the js file of the shader in the Three.js folder and it appears to have a function called generateTrigger, can someone help me on this?
Best regards, Luis
Mugen87
January 12, 2019, 12:27pm
2
The glitch starts when the following if condition in GlitchPass.render()
is true
:
THREE.GlitchPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
constructor: THREE.GlitchPass,
render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
this.uniforms[ "tDiffuse" ].value = readBuffer.texture;
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();
I guess this would be the place for your log.
1 Like
Thank you very much for the fast response Mugen.
It works perfectly.
Best, Luis
1 Like