Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i have a modelmesh that has a image on it. When i draw the modelmesh i get the image but i also get a black bacground. The image is png and transparent and is added in 3ds max(i don't give it coordinates to be drawn, it sits on the modelmesh). How can i make the black background transparent?

Here is my drawing code:

 foreach (BasicEffect effect2 in modelMesh)
     effect2.DiffuseColor = Color.White.ToVector3();
     effect2.LightingEnabled = true;
     effect2.AmbientLightColor = new Vector3(1, 1, 1);
     effect2.Projection = camera.projectionMatrix;
     effect2.View = camera.viewMatrix;
     effect2.World = transforms[modelMesh.ParentBone.Index] * gameobject.orientation;
     effect2.Alpha = 1;

share|improve this question
Can't you switch in property dialog of your model from Basic effect to AlphaTestEffect and also in foreach use AlphaTestEffect instead of BasicEffect? – zacharmarz Feb 15 '12 at 13:30
there is a small problem. If i make the changes you said, i get this error:" ErrorThe mesh "s31", using AlphaTestEffect, contains geometry that is missing texture coordinates for channel 0." note that my images are not included in my model, i have them in my LibContent folder along with my model. – Alex Feb 15 '12 at 13:44
Ok. You can also try to set RenderState alpha blending to enabled: GraphicsDevice.RenderState.AlphaBlendEnable = true; GraphicsDevice.RenderState.SourceBlend = Blend.SourceAlpha; GraphicsDevice.RenderState.DestinationBlend = Blend.InverseSourceAlpha; – zacharmarz Feb 15 '12 at 14:06
that looks to me as xna 3.1. i've used this: SharedGraphicsDeviceManager.Current.GraphicsDevice.BlendState = BlendState.AlphaBlend; and it works. Thanks! – Alex Feb 15 '12 at 14:39

SharedGraphicsDeviceManager.Current.GraphicsDevice.BlendState = BlendState.AlphaBlend; fixed the problem (XNA 4.0)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.