Blur and Alpha Blending

Dear unc,

I think this question is for you.

I’m trying to render to a texture and then apply Blur. Is it somehow possible (maybe) to prevent the ‘leak’ of the background color of the Renderer from the first pass into the next one where Blur is happening? I’ve attached the patch.

I thought that it’s maybe related to the blending options?

Would you please explain a bit about Alpha Blending of the Blend (EX9.RenderState Advanced) ?

What does it do exactly?
And why is it turned off by default in the TextureFX modules like Blur (EX9.Texture Filter), Glow (EX9.Texture Filter) and the likes?

Thank you!

Or anybody?


Blur_And_Alpha.v4p (7.3 kB)

Does this help?

Blur_And_Alpha_mod.v4p (8.6 kB)

Hi h99,

thank you for your reply.
It’s a nice trick, but… the gray Quad in the patch was taken for the sake of simplicity. Imagine an image applied to this Quad, then the pixels of this image will be also Chromakeyed in your solution.


… no text …

Blur_And_Alpha_mod2.v4p (25.2 kB)

Hi h99,

wow. Thank you, it’s again a very nice trick for the background of the solid color. Using Blend with Add… But in more general case there can be an image in the background…

And I’ve noticed that the ‘RGB > ZIP > Minus > Unzip > RGB’ construct in your patch can be replaced with the Complement (Color).

Thank you once again for trying to solve this!


Now that I’m into it, I can’t stop.
P.S. You should post a complete scenario -.-"
P.P.S. Thank you for the Complement!

Blur_And_Alpha_mod3_1.v4p (27.1 kB)


this happens because Blur is operating separately on each channel, and alpha isn’t handled in any special way here
(when for this case one would expect color not mix with fully transparent regions)

blend state is disabled because otherwise it would interfere with the alpha channel of the result texture

here is some hack to try solving this problem

Blur_And_Alpha_workaround.v4p (30.4 kB)

ok, just found a clever way to fix it - and that trick only needed A16B16G16R16F texture inside
will add it to Blur module as a separate technique later (7.0 kB)


@h99: I was just trying to reduce my patch as much as possible to show the general problem. There can be many scenarios, like solid colors, images, etc. My hope was the general solution… and!

@unc: Thank you so much! The BlurAlpha works perfect. It will be great to have this technique inside the standard Blur from TextureFX, hope you have time for that.

I hit this problem, because there is an idea to make some kind of Pack which simplifies a workflow of building scenes AfterEffects-like. At a bit cost of performance a lot of things will be easier.

At the moment I’m not sure if it is the only place where the color “bleeds”, I’ll work further and will report or try to solve on my own.

Thank you!


AH! @unc: High Level Shader Lord!
@robotanton: Please note that unc shader works only for solid background colors, and

still needs a different approach (have a look at this patch).

Hi h99,

sorry, I don’t get it.
May be it was my fault and I couldn’t explain clearly about “the image in the background”. What I meant is just another image lying behind the blurred one.

@unc’s solution works good for me.

I’ve attached the ZIP with @unc’s BlurAlpha and my patch with the Background.

Sorry, may be I just don’t understand your solution!

Anton (9.3 kB)

Ok, got it. A background image after Blur fx.
Sorry, earlier I understood before Blur.
TY for taking the time to answer.