-
-
Notifications
You must be signed in to change notification settings - Fork 225
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
Feedback loop when using DepthOfFieldEffect
with multiple other effect passes
#416
Comments
Thank you for maintaining this awesome library btw; it's a huge step forward for Three.JS and the whole web graphics ecosystem! |
This is probably related to #225. I'm currently writing up a battle plan for the v7 redesign which will address this issue. |
Alright cool, ty for the quick response! Any ideas for workarounds in the meantime? Do you think it would work to copy the depth buffer to a temp render target after the background render pass, and then bind the copied buffer as a custom uniform for my custom effect? |
Alright I've managed to find a workaround for this: Use two const bgComposer = new EffectComposer(renderer);
// \/ Uncommenting this brings back the feedback loop for some reason
// bgComposer.autoRenderToScreen = false;
bgComposer.addPass(new RenderPass(...));
const bgEffectPass = new EffectPass(camera, new DepthOfFieldPass(...));
bgEffectPass.needsSwap = false;
bgComposer.addPass(bgEffectPass);
const fgComposer = new EffectComposer(renderer);
fgComposer.inputBuffer = bgComposer.outputBuffer;
fgComposer.addPass(new RenderPass(...));
const fgEffectPass = new EffectPass(...);
fgComposer.addPass(fgEffectPass);
function render(tDiffSeconds) {
bgComposer.render(tDiffSeconds);
fgComposer.render(tDiffSeconds);
} Probably suboptimal in some way be it performance or otherwise, but this allows my use-case to work! |
* Copy depth texture to intermediate buffer to prevent binding depth texture to both input and output buffers in compositor shader * See pmndrs/postprocessing#225, pmndrs/postprocessing#416 for additional context
Closing this as it seems to be resolved. Depth texture management is fixed in the |
Description of the bug
When using multiple passes surrounding an
EffectPass
that contains aDepthOfFieldEffect
, chrome + firefox print errors involving feedback loops in the render graph.Chrome error:
[.WebGL-0x13400e82d80] GL_INVALID_OPERATION: Feedback loop formed between Framebuffer and active Texture.
Firefox error:
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.
Interestingly, these errors only seem to happen on Mac laptop. On my Linux desktop, things work fine.
To Reproduce
Repro: https://postprocessing-dof-repro.ameo.design/
Code:
Expected behavior
I have a somewhat complex scene that makes use of two render passes. I render some background objects, apply some effects (notably a custom effect that makes use of depth info and then a
DepthOfFieldEffect
. Then, I render the foreground scene and apply aSMAAEffect
at the end.I'd like to apply the custom depth-based effect, then apply the depth of field, then render the foreground, and finally render some final effects. However, no matter what I do, I either get the feedback loop error or my custom depth-based effect does nothing.
When I include the depth-based effect in the same
EffectsPass
as theDepthOfFieldEffect
, the custom effect is not applied. Here is a demo of that situation: https://postprocessing-dof-repro-2.ameo.design/I'm not sure if that is expected behavior or not for that effect. I looked at the code and it appears to be a highly complex effect with many internal passes, so I'm not completely surprised it doesn't work.
However, when I include the custom effect in a separate
EffectPass
before the effect pass containing theDepthOfFieldPass
, I get the feedback loop errors.Note that these errors only occur on mac; this works fine on my Linux desktop.
Library versions used
Desktop
Mobile
Not tested on mobile
The text was updated successfully, but these errors were encountered: