Effective for BlurEffect for many Objects in OpenFl/Haxe

Typically we can construct a blur effect for many objects using the following.

var mcImage = new Image();


//some code to make a duplicate of mcImage, we do this so that we can recover the part of the image not blurred.

var blur = new BlurFilter();
blurX = blurY = 10;
blur.quality = 1;
mcImage.mask = mcBlurArea; //the Area to be blur.
mcImage.filter = [blur];

We see that we make a duplicate of the mcImage we want to blur to recover the whole screen Objects, but this will become a CPU intensive when instead mcImage contains Many MovieClips.

Since Haxe language is now way better than AS3, I believe this is possible. How do we create a CPU friendly BlurEffect that would only blur portion of all Other Clips under the area covered my mcBlurArea (without making a duplicate of mcImage)?

Draw mcImage to a bitmap first. That removes the overhead of having all those children.

I’d like to see shader-based filter support soon, in the meantime, this would only be supported in Flash or legacy (which both use software)

I will try to draw mcImage into bitmap, in case mcImage is animating, I figure I could redraw bitmaps at 60 fps. I will give an update after I got it working, inputs from the community is always welcome :slight_smile:

Then maybe it isn’t such a good idea. The point of drawing to bitmap is so that you don’t have to redraw every frame.

I believe so, it is really bad to do it but how do we deal about animating clips inside mcImage?

What if each child had its own bitmap? (Add a blur filter to the child, draw the child to a bitmap, then get rid of the filter.) That way, you won’t have to redraw the bitmaps every frame, and you can still move them independently.

You can redraw the bitmap to a smaller size, apply the filter, and scale up again for displaying. Maybe not the exact result but its much faster.