Skip to content

renderToScreen is necessary for some workflows (broken in #16033) #20371

@cedemax

Description

@cedemax
Description of the problem

I used a workflow where i first render the scene+SSAA+SSAO etc, and then render some UI elements (that use the depth of the actual scene). I dont want SSAO and other effect affecting the UI elements, so i run them as a separate RenderPass after the rest.

renderModels = new THREE.RenderPass(scene, camera);
renderModels.renderToScreen = true;
composer.addPass(renderModels);

renderHud = new THREE.RenderPass(hudScene, camera);
renderHud.clear = false;
renderHud.renderToScreen = true;
composer.addPass(renderHud);

This was broken by #16033, because it is no longer possible to have many passes with renderToScreen = true. As seen in the fiddle, only the last renderpass is rendered, the blue sphere (with fancy light), is hidden.

The fix which i implemented to get this effect in my project is to comment out this line in EffectComposer.js

...
if ( pass.enabled === false ) continue;

//pass.renderToScreen = ( this.renderToScreen && this.isLastEnabledPass( i ) ); // <- this line
pass.render( this.renderer, this.writeBuffer, this.readBuffer, deltaTime, maskActive );

if ( pass.needsSwap ) {
...

After that everything works as expected for me.

Perhaps a compromise would be to check if there are no "renderToScreen" passes, and only do that "default enabling" if no passes are "renderToScreen"?

Fiddle:
https://jsfiddle.net/z6opysr7/19/

Three.js version
  • Dev
  • [] r120
  • ...
Browser
  • [] All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • [] All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions