pmndrs / postprocessing

A post processing library for three.js.
zlib License
2.35k stars 213 forks source link

Better default value for Pass.needsSwap #76

Closed vanruesc closed 6 years ago

vanruesc commented 6 years ago

Passes that render to the provided writeBuffer currently have to set a special needsSwap flag to true. This tells the EffectComposer that the writeBuffer must be swapped with the readBuffer before the next pass can be executed. In reality, though, almost all passes render to the writeBuffer. Passes that don't do it are special cases: TexturePass, RenderPass, ClearPass, MaskPass, ClearMaskPass and SavePass.

Three of these passes, namely the TexturePass, RenderPass and ClearPass, can easily be changed to render to the writeBuffer. The other two passes,ClearMaskPass and SavePass, are the only ones that can't render to the writeBuffer.

To reduce boilerplate code, the default value of the needsSwap flag should be inverted. Then, only the special passes that deviate from the usual input-output flow need to change the flag. It might also be a good idea to rename the readBuffer and writeBuffer to inputBuffer and outputBuffer to further clarify their purpose.

vanruesc commented 6 years ago

Letting the RenderPass and ClearPass render to the inputBuffer turned out to be more useful after all. This way it's easier to render composite scenes using multiple render passes.

vanruesc commented 6 years ago

Implemented in postprocessing@4.5.0.