Question

Okay so hopefully a simple fix that I'm just not seeing: I'm trying to implement transparency on a Billboard for an explosion, however the sprite stays solid where there is a pixel not defined transparent in the png file itself. I'm trying to change the transparency by multiplying Color.White by the transparency (a float between the value of 0 and 1)

spriteBatch.Begin(0, BlendState.NonPremultiplied, null, DepthStencilState.DepthRead, RasterizerState.CullNone, basicEffect);

Vector3 viewSpaceTextPosition = Vector3.Transform(this.position, camera.View * invertY);
spriteBatch.Draw(Texture, new Vector2(viewSpaceTextPosition.X, viewSpaceTextPosition.Y), null, Color.White * this.Transparency /*Here's where I try to set the transparency of the image drawn*/, 0, new Vector2(Texture.Bounds.Center.X, Texture.Bounds.Center.Y), this.Scale, SpriteEffects.None, viewSpaceTextPosition.Z);

spriteBatch.End();

Are there any obvious mistakes? Or is XNA for Windows Phone 7 just incapable of rendering transparent things in 3D?

Was it helpful?

Solution

Since you're using BasicEffect instead of the built-in sprite effect, I'm pretty sure you need to set the material alpha:

basicEffect.Alpha = this.Transparency;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top