I created a particle system that draws a number of primitives and adds a texture to them. The source sprite is a PNG image with transparency, but when I draw it in XNA using the below code, the transparent areas are replaced with black. How can I preserve this transparency?
effect.View = camera.View;
effect.Projection = camera.Projection;
effect.World = Matrix.CreateBillboard(pos, camera.Pos, camera.Up, camera.Dir);
effect.Texture = texture;
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Apply();
g.DrawUserPrimitives(PrimitiveType.TriangleStrip, verts, 0, 2);
}
Here is the code where I set up the vertices:
float s = 0.25f; ; // initial size of a particle
verts[0].Position = new Vector3(-s, -s, 0);
verts[1].Position = new Vector3(+s, -s, 0);
verts[2].Position = new Vector3(-s, +s, 0);
verts[3].Position = new Vector3(+s, +s, 0);
verts[0].TextureCoordinate = new Vector2(0, 0);
verts[1].TextureCoordinate = new Vector2(1, 0);
verts[2].TextureCoordinate = new Vector2(0, 1);
verts[3].TextureCoordinate = new Vector2(1, 1);
verts[0].Color = Color.White;
verts[1].Color = Color.White;
verts[2].Color = Color.White;
verts[3].Color = Color.White;
Hope someone can help me with this. Thanks.
EDIT: Code for loading image::
smokeParticle = Content.Load<Texture2D>("particle_smoke");