Jump to content
  • Advertisement
Sign in to follow this  

Particle Sprite Alpha Blending

This topic is 4234 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 have basic particle system that I am using for explosions and it is causing some problems with the alpha blending. In some cases there is alpha blending and in others there is not. Here are some screenshots: Using a BMP file for particles: Particle Explosion Using a TGA file with an alpha channel using alpha testing to make them circular: Particle Explosion When the particles are about to die off: Particle Explosion As you can see it seems that they blend corrctly against the planets but not against the asteroids or the other particles themselves. Any ideas? Here is the code setting up the alpha blending and alpha testing:
			D3DDevice.RenderState.PointSpriteEnable = true;
			D3DDevice.RenderState.PointScaleEnable = true;
			D3DDevice.RenderState.PointScaleC = 1.0f;
			D3DDevice.RenderState.Lighting = false;
			D3DDevice.RenderState.AlphaBlendEnable = true;
			D3DDevice.RenderState.SourceBlend = Blend.SourceAlpha;
			D3DDevice.RenderState.DestinationBlend = Blend.DestinationAlpha;
			D3DDevice.RenderState.AlphaTestEnable = true;
			D3DDevice.RenderState.ReferenceAlpha = 100;
			D3DDevice.RenderState.AlphaFunction = Compare.Greater;


Thanks for the help

Share this post


Link to post
Share on other sites
Advertisement
It would depend where they fit into the WorldItem list. I just iterate through the WorldItem list and draw them. ParticleExplosion being one WorldItem encapsulating all the explosion's particles. In most cases the explosions will be drawn after the asteroids, unless the asteroids was just created after an explosion.

Share this post


Link to post
Share on other sites
Particles (or anything else that's alpha blended) have to be drawn last after all opaque objects have been drawn and they need to be drawn with z writes turned off. To get totally correct blending between alpha blended particles you need to individually sort the particles and draw them from back to front but that is quite expensive and in many cases people don't bother and just live with the minor artifacts that result.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!