Efficient alpha thresholding?

I have some sprites handeling each one a bitmap with inconstant pixels alpha values (= the transparency is not uniform on the bitmap picture). All these Sprites are childs of a same Sprite and can overlap in space. So the alpha values (and color) of each pixel of each child sprite basically sum up at each overlapping position to get the final visible result. Now I would like to be able to apply some threshold on the alpha value so that if the final alpha value is below a given threshold it is rendered as 0 (so the pixel at this position would not be visible). Of course I could draw all my childs Sprites in a Bitmapdata handeled by the parent Sprite with an additive blendmode function and apply my alpha threshold during this blend function (rater than adding my childs Sprite with addChild() and let them render themselves). But it would not be really effective as the position of each of my child sprites can change at each frame. So I would have to redraw them in the parent bitmapdata for each frame, which would consume some CPU…
Rather than doing that, I was wondering if it would be possible to apply a Shader to the parent Sprite that would apply the alpha threshold directly at the GPU level. Would it work? How are filter shaders applied in the case of a Sprite that contains multiple child Sprites. Does the GPU first render each child and then apply the shader on the resulting “graphics” (so if childs A and B overlap at a specific region, it would apply the shader on the pixels values of A+B) or does it actually apply the shader to each child and then render them?

Last I heard, OpenFL only shades one object at a time, and it doesn’t provide any way to shade a group of objects together.

What you’re looking for is something along the lines of “draw everything to a BitmapData and then process the BitmapData,” except efficient. For that, I’d suggest rendering to texture. By calling a certain function, you can tell OpenGL to draw pixels to a “texture” object instead of the screen.

Once you have a texture, you can put it on a 3D mesh. For instance, if you make a rectangle that covers the screen and apply your texture to that rectangle, it’ll look just like the original render (possibly with some blurriness, but that’s fixable).

The difference is that since everything is already drawn, you can apply entirely different shaders this time around. All you need is a fragment shader that adjusts the alpha value of each pixel.

For more information, look up “OpenGL post-processing.”