mrdoob/three.js — pull request #2006 by danielkaneider (2012-05-29 18:48:13+00:00)
Title: Added support for main pass plugins in WebGLRenderer

Hi,

i wanted to use 3D Sprites (useScreenCoordinates=false) combined with blended particles, such as used in some particles example, and encountered some problems:

As I understood, blending is not compatible with the [z-buffer] (http://www.sjbaker.org/steve/omniv/alpha_sorting.html), which means that *Sprites* need to be rendered before *Particles* (or other blended objects). Since currently *Sprites* are rendered in the *post-plugin* pass, removing all *post-plugins* and adding the *SpritePlugin* to the pre-plugins was one solution. It works, unless *autoClear* is set off, and done manually, since else the clear is done *after* the plugin rendering.
The main problem is, when some *EffectComposer* is used to add some postprocessing effect (preventing of course the forced autoClear in the *RenderPass*), this didn't work cleanly. The problem is that the *setRenderTarget* is again done after the rendering of the *pre-plugins*, which means that bypassing this, is not possible in a clean way IMHO.

My patch adds a possible hook for plugins (similar to the existing pre/post), to render plugins after the *setRenderTarget* and the *clear*, but before other objects. In my case I moved the SpritePlugin from the post-plugin pass to this main pass, and it works fine with *blending* and postprocessing effects.

If there are better approaches to solve this, please let me know. This commit may nevertheless add some future possibilities for plugins...

Cheers,
Daniel