未验证 提交 e2f0d96c 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #16036 from Oletus/afterimage-resize

Improved AfterimagePass
...@@ -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,23 @@ THREE.AfterimagePass.prototype = Object.assign( Object.create( THREE.Pass.protot ...@@ -74,10 +71,23 @@ 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 ) {
this.textureComp.setSize( width, height );
this.textureOld.setSize( width, height );
} }
} ); } );
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册