Sign in to follow this  

alpha blending in particle systems

This topic is 4198 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I wrote this particle system class that can be used to make a lot of different effects. The problem is they only work on a black background when they are by themselves. I tried to think of different alpha blending states I could use to get it to work but theres nothing. Right now I use ONE for dest and INVDESTCOLOR for src by default. It shows the particles as brighter when they overlap. I was thinking if there were some way to render the particles to some buffer first, and then render all non-black pixels in the buffer to the screen without alpha blending. I have no idea how to do that tho or even if its the best way around my problem. Any help would be great.

Share this post


Link to post
Share on other sites
Quote:
they only work on a black background when they are by themselves.


What do you mean by 'they don't work'? Is the background not blending through? When using alpha blending you have to draw opaque objects, then sort transparent ones by depth and draw back to front to get correct results.

Share this post


Link to post
Share on other sites
Ya exactly, you have to sort them if you are not using :
add : ONE, ONE
or
Multiply : DST_COLOR, ZERO

if you want to reproduce smoke or stuff like this, you have to sort them, then the best alpha function to use is :
SRC_ALPHA, ONE_MINUS_SRC_ALPHA/INV_SRC_ALPHA (I dont know the exact constant for DX for this, but I know that the RESULTs are the same in OGL and DX.

The transparency will be determined by your alpha channel * alpha color.

Share this post


Link to post
Share on other sites
yea I know u have to sort them when your using alpha values but Im not using alpha values right now. Im adding the dest color * 1 + src color * (1-destcolor). It works great for blending particles together but if the background is white it clearly does work because white + anything = white.

Share this post


Link to post
Share on other sites

This topic is 4198 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

Sign in to follow this