提交 9cf1fe31 编写于 作者: O Olli Etuaho

Remove redundant blit from AfterimagePass

It's much faster to just swap the buffers in AfterimagePass instead of doing a blit to copy them.
上级 9e402e57
...@@ -41,10 +41,8 @@ THREE.AfterimagePass = function ( damp ) { ...@@ -41,10 +41,8 @@ THREE.AfterimagePass = function ( damp ) {
this.compFsQuad = new THREE.Pass.FullScreenQuad( this.shaderMaterial ); this.compFsQuad = new THREE.Pass.FullScreenQuad( this.shaderMaterial );
var material = new THREE.MeshBasicMaterial( { var material = new THREE.MeshBasicMaterial();
map: this.textureComp.texture this.copyFsQuad = new THREE.Pass.FullScreenQuad( material );
} );
this.screenFsQuad = new THREE.Pass.FullScreenQuad( material );
}; };
...@@ -60,13 +58,12 @@ THREE.AfterimagePass.prototype = Object.assign( Object.create( THREE.Pass.protot ...@@ -60,13 +58,12 @@ THREE.AfterimagePass.prototype = Object.assign( Object.create( THREE.Pass.protot
renderer.setRenderTarget( this.textureComp ); renderer.setRenderTarget( this.textureComp );
this.compFsQuad.render( renderer ); this.compFsQuad.render( renderer );
renderer.setRenderTarget( this.textureOld ); this.copyFsQuad.material.map = this.textureComp.texture;
this.screenFsQuad.render( renderer );
if ( this.renderToScreen ) { if ( this.renderToScreen ) {
renderer.setRenderTarget( null ); renderer.setRenderTarget( null );
this.screenFsQuad.render( renderer ); this.copyFsQuad.render( renderer );
} else { } else {
...@@ -74,10 +71,16 @@ THREE.AfterimagePass.prototype = Object.assign( Object.create( THREE.Pass.protot ...@@ -74,10 +71,16 @@ THREE.AfterimagePass.prototype = Object.assign( Object.create( THREE.Pass.protot
if ( this.clear ) renderer.clear(); if ( this.clear ) renderer.clear();
this.screenFsQuad.render( renderer ); this.copyFsQuad.render( renderer );
} }
// Swap buffers.
var temp = this.textureOld;
this.textureOld = this.textureComp;
this.textureComp = temp;
// Now textureOld contains the latest image, ready for the next frame.
}, },
setSize: function ( width, height ) { setSize: function ( width, height ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册