# Particle Sprite Alpha Blending

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

## 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: Using a TGA file with an alpha channel using alpha testing to make them circular: When the particles are about to die off: 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 on other sites
are you drawing your particles after the asteroids?

##### Share on other sites
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 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 on other sites
Turning off Z-Buffer writes did the trick. Thanks!

• 10
• 14
• 9
• 9
• 11