-
-
Notifications
You must be signed in to change notification settings - Fork 36.2k
Description
The current mechanisms for handling render targets in EffectComposer are fairly difficult to use. A lot of the passes write to the "readBuffer" which makes the code a bit hard to follow. The "renderToScreen" flag is also a bit odd - nothing prevents setting it true on a Pass in the middle of the EffectComposer stack, but it ever really makes sense to only set that on the last pass in the stack.
The code would be simpler and more flexible if:
- The final RGBA output render target is passed to EffectComposer's render() function. There's no need for a "renderToScreen" flag on each Pass.
- Passes have a flag for telling if they only need one color buffer (only write or both read/write on the same buffer) or two color buffers, one being the read buffer and other one the write buffer. This could replace the needsSwap flag.
- EffectComposer contains all the logic for managing the intermediate buffers and will pass the right color buffers to each Pass.
This way the EffectComposer render() call would be more similar to regular WebGLRenderer.render(), and it would also be easier to call another EffectComposer from a Pass to set up more complex effects. I've prototyped this kind of changes on a project and they made the EffectComposer much nicer to work with.
This is a breaking change, so it may be necessary to create a separate EffectComposer2 for it, though I'd be happy to change the current EffectComposer as well if others think it's OK.
This is somewhat related to Issue #12115, which outlines some good ideas for a larger overhaul of EffectComposer. These smaller changes would get us a bit closer to that while not being too much work to implement. We could design the new API so that more intermediate buffers like a normal buffer or
a depth buffer could be passed from EffectComposer to Passes in the future.