Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GL_INVALID_OPERATION: Feedback loop formed between Framebuffer and active Texture. using depth in EffectComposer #22938

Closed
amodiopescefaro opened this issue Dec 2, 2021 · 1 comment · Fixed by #23462

Comments

@amodiopescefaro
Copy link

amodiopescefaro commented Dec 2, 2021

Describe the bug
If you initialize an EffectComposer with a RenderTarget with a depthTexture, because you want to use depth information in your Passes, as soon as you have more than 2 passes in the pipeline and any one of them try to write to the depth buffer you'll get an error.

On Chrome you get GL_INVALID_OPERATION: Feedback loop formed between Framebuffer and active Texture.
On Firefox you get WebGL warning: drawArraysInstanced: Texture level 0 would be read by TEXTURE_2D unit 1, but written by framebuffer attachment DEPTH_ATTACHMENT, which would be illegal feedback.

This happens because EffectComposer will clone the RenderTarget to create the secondary RenderTarget, but this clone will not clone the depthTexture, only the texture. So now both the read and write targets will share the same depth texture.

As soon as a render passes try to use and write the depthTexture the code will trigger the error.

To Reproduce

You can open this fiddle
https://jsfiddle.net/zhmoekwa/
And you will se a black screen.
If you uncomment line 147 to manually clone the depthTexture after the EffectComposer is created now the code works

Code

As the code is quite complex because requires an effect composer + a custom Pass please check the fiddle for the code

Live example

https://jsfiddle.net/zhmoekwa/

Expected behavior

The expected behaviour is that if I create a EffectComposer on a target with a depthTexture then I can use read and write depth information in the EffectComposer Passes.

** Possible Solutions**
I think it could make sense to update the WebglRenderTarget clone method to clone the depthTexture if present like is currently doing for the color texture.

Or at least the EffectComposer should properly clone the depthTexture if present in the construction arguments.

Platform:

  • Device: Desktop
  • OS: Windows
  • Browser: Chrome, Firefox, Edge
  • Three.js version: [dev, r135]
@ChaiGusto
Copy link

I ran into this problem too. I fix it temporary by modifying EffectComposer.
After
this.renderTarget2 = renderTarget.clone();
Add
this.renderTarget2.depthTexture = renderTarget.depthTexture.clone();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants