Feedback loop formed between Framebuffer and active Texture

Hi, I use a custom pass to apply gamma correction to the foreground content and not to the background. I have used the same pattern for some time but a recent update (chrome? or three?) has introduced a warning:
[.WebGL-0x3de001ac3100] GL_INVALID_OPERATION: Feedback loop formed between Framebuffer and active Texture.

Followed by:
WebGL: too many errors, no more errors will be reported to the console for this context.

I’m using three r153.

The custom pass contains a rendertarget, fullscreen quad, copy material and gamma correction material.

The render method:

  1. copies the previously rendered content (accumulated background passes) from the read buffer to the write buffer.

  2. renders the foreground content to the passes own render target

  3. sets the fsquad material to the gamma correction material and the diffuse texture to the passes render target texture

  4. renders the fsquad to the write buffer applying the gamma correction material.

    renderer: THREE.WebGLRenderer,
    writeBuffer: THREE.WebGLRenderTarget,
    readBuffer: THREE.WebGLRenderTarget,
    deltaTime: number,
    maskActive: boolean
  ) {
    // Render the previous pass (readBuffer) to a full screen quad
    this.fsQuad.material = this.materialCopy;
    this.copyUniforms['tDiffuse'].value = readBuffer.texture;

    // render the previous pass to the out buffer
    renderer.setRenderTarget(this.renderToScreen ? null : writeBuffer);

    //// Render the main scene to a new buffer
    // First store previous renderervalues
    const prevClearColour = renderer.getClearColor(new THREE.Color());
    const prevClearAlpha = renderer.getClearAlpha();
    const prevAutoClear = renderer.autoClear;

    // Perform the render
    renderer.autoClear = false;
    renderer.setClearColor(0x000000, 0);

    // perform linear to sRGB on the new buffer and
    // render it over the top of the previous pass
    // with gamma correction and normal blending enabled
    // on the material
    this.fsQuad.material = this.gammaCorrectionMaterial;
    this.gammaUniforms['tDiffuse'].value = this.renderTargetBuffer.texture;

    renderer.setRenderTarget(this.renderToScreen ? null : writeBuffer);

    // restore previous settings to the renderer
    renderer.setClearColor(prevClearColour, prevClearAlpha);
    renderer.autoClear = prevAutoClear;

I’ve seen this pattern used elsewhere, like in the outline pass, and having just checked that example it isn’t producing the same error, so I’m wondering where I’ve gone wrong.

Can you please update to r154? There was a feedback loop in MeshPhysicalMaterial when using transmissive objects without anti-aliasing (the browser default MSAA). This specific anti-aliasing is turned on via antialias: true when creating the renderer and automatically disabled when using post-processing so I could imagine this issue triggered the warning.

Thanks, that must be it. I updated to r155 and it has gone away. Many thanks!

Mind you, I was only turning on anti-alias on the renderer if post-processing is turned on.

options.antialias = appConfig.features.PostProcessing? false: config.antialias;

Does that mean it’s something else?

No, the default anti-aliasing is ignored by WebGL when doing RTT even if you turn it on.

1 Like