7

I see a lot of projects using CopyShader at the end of a post-processing chain. I cannot find any documentation of it on Three.js. What does it do exactly? Additionally, why is setRenderTarget necessary here? If removed, the effects are not applied. But if it is included, then it will 'freeze' an a-scene in place, stopping all animations. I am able to use tick and setInterval to resume the animation, but the performance takes a huge hit.

For example:

var composer = new THREE.EffectComposer( renderer );

renderer.setRenderTarget( composer.readBuffer );

var renderPass = new THREE.RenderPass( scene, camera );

var copyPass = new THREE.ShaderPass( CopyShader );
composer.addPass( renderPass );

var vignettePass = new ShaderPass( VignetteShader );
vignettePass.uniforms[ "darkness" ].value = 1.0;

composer.addPass( vignettePass );
composer.addPass( copyPass );
composer.render();

this.composer = composer; // To run as composer.render()
Dan
  • 2,455
  • 3
  • 19
  • 53

1 Answers1

8

The postprocessing pipeline renders back and forth between 2 offscreen buffers. When the final pass is complete, the result needs to be copied to the actual screen. That's what the CopyShader does. Conceivably you could architect your passes so that the final pass rendered directly to the visible screen, but in practice, that introduces some complexity.

manthrax
  • 4,918
  • 1
  • 17
  • 16