• entries
    743
  • comments
    1924
  • views
    580974

Actually programming...

Sign in to follow this  

116 views



My God, Aardvajk is actually working on his game. Jaws drop.

Something that has been annoying me for a while is how on earth to produce cool effects using additive blending over light backgrounds.

Obviously, additive blending is wonderful when you start on a black or nearly black background, but over the top of anything else it fails.

So, for Squishy, which is always going to be a brightly coloured game, I've been toying with an idea in my mind for about a month that I finally got motivated to try tonight.

Basically, allocate an offscreen texture and clear it to ARGB(0,0,0,0) at the start of each frame. For the particles, set additive blending on and set the render target to this texture, then render them. Unlike normal additive blending where no alpha channel is used, provide alpha as well as colour intensity and add the alpha in the same way as the diffuse values.

Got back to normal blending.

Then, when rendering the final scene in the composition shader, alpha blend the value from the offscreen texture manually in the shader over the top of the existing scene.

Voila. Additive blended particle systems over a light background.

Hope you likey.
Sign in to follow this  


5 Comments


Recommended Comments

That looks great and is a technique to bear in mind. I'm glad to see work on Squishy progressing! [smile]

Share this comment


Link to comment
I can't quite be sure from your image, but it looks like the black background is bleeding into your particles, causing them to have dark halos.

I think you could eliminate this problem by using pre-multiplied alpha for your particles.

Share this comment


Link to comment
Use pre-multiplied alpha like suggested or use the colour intensity as alpha channel instead of it's alpha channel.

i.e alpha = (r+g+b)/3
Or you can also try D3DBLEND_SRCCOLOR which is very similar and should remove the dark halos.

Cheers
Dark Sylinc

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now