Actually programming...

Published July 09, 2010
Advertisement


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.
Previous Entry Tag
Next Entry How to score chicks
0 likes 5 comments

Comments

benryves
That looks great and is a technique to bear in mind. I'm glad to see work on Squishy progressing! [smile]
July 09, 2010 03:36 PM
swiftcoder
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.
July 10, 2010 09:28 AM
Matias Goldberg
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
July 14, 2010 09:22 AM
paul_nicholls
Go Squishy! :)
Looking good...keep it up mate :)

cheers,
Paul
July 18, 2010 05:57 PM
paul_nicholls
I'm looking forward to seeing more of Squishy :)

cheers,
Paul
August 03, 2010 06:02 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement