From 8ebbc3e4ee81f9b0226346e6b6c79b56258d89e5 Mon Sep 17 00:00:00 2001 From: Michael Herzog Date: Tue, 4 Feb 2025 20:03:16 +0100 Subject: [PATCH] Renderer: Disable `autoClear` in the output pass. (#30454) --- src/renderers/common/Renderer.js | 51 ++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/src/renderers/common/Renderer.js b/src/renderers/common/Renderer.js index 942b38d1abd5d1..9ee4cf53b59c3a 100644 --- a/src/renderers/common/Renderer.js +++ b/src/renderers/common/Renderer.js @@ -1408,16 +1408,7 @@ class Renderer { this.setRenderTarget( outputRenderTarget, activeCubeFace, activeMipmapLevel ); - const quad = this._quad; - - if ( this._nodes.hasOutputChange( renderTarget.texture ) ) { - - quad.material.fragmentNode = this._nodes.getOutputNode( renderTarget.texture ); - quad.material.needsUpdate = true; - - } - - this._renderScene( quad, quad.camera, false ); + this._renderOutput( renderTarget ); } @@ -1431,6 +1422,32 @@ class Renderer { } + /** + * The output pass performs tone mapping and color space conversion. + * + * @private + * @param {RenderTarget} renderTarget - The current render target. + */ + _renderOutput( renderTarget ) { + + const quad = this._quad; + + if ( this._nodes.hasOutputChange( renderTarget.texture ) ) { + + quad.material.fragmentNode = this._nodes.getOutputNode( renderTarget.texture ); + quad.material.needsUpdate = true; + + } + + // a clear operation clears the intermediate renderTarget texture, but should not update the screen canvas. + + const currentAutoClear = this.autoClear; + this.autoClear = false; + this._renderScene( quad, quad.camera, false ); + this.autoClear = currentAutoClear; + + } + /** * Returns the maximum available anisotropy for texture filtering. * @@ -1900,19 +1917,7 @@ class Renderer { if ( renderTarget !== null && this._renderTarget === null ) { - // If a color space transform or tone mapping is required, - // the clear operation clears the intermediate renderTarget texture, but does not update the screen canvas. - - const quad = this._quad; - - if ( this._nodes.hasOutputChange( renderTarget.texture ) ) { - - quad.material.fragmentNode = this._nodes.getOutputNode( renderTarget.texture ); - quad.material.needsUpdate = true; - - } - - this._renderScene( quad, quad.camera, false ); + this._renderOutput( renderTarget ); }