Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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 been searching for this matter for a long time and slowly I begin to think that this option is not available in XNA for Windows Phone.

I am trying to get a 3D-Model to be drawn at 50% opactity/transparency.

The most promising piece I found is following:

//1. Set the alpha blend mode for the graphics device with:

graphics.GraphicsDevice.RenderState.AlphaBlendEnable = true;
graphics.GraphicsDevice.RenderState.SourceBlend = Blend.SourceAlpha; // source rgb * source alpha
graphics.GraphicsDevice.RenderState.AlphaSourceBlend = Blend.One; // don't modify source alpha
graphics.GraphicsDevice.RenderState.DestinationBlend = Blend.InverseSourceAlpha; // dest rgb * (255 - source alpha)
graphics.GraphicsDevice.RenderState.AlphaDestinationBlend = Blend.InverseSourceAlpha; // dest alpha * (255 - source alpha)
graphics.GraphicsDevice.RenderState.BlendFunction = BlendFunction.Add; // add source and dest results

//2. Set the alpha value in the BasicEffect for the model:
effect.Alpha = 0.5f; // Creates a 50% translucent object. 

But GraphicsDevice.RenderState.AlphaBlendEnable isn't even available in XNA for Windows Phone.

So is there any way to achieve that effect?

share|improve this question

Considering the age of this question, you likely have already found an answer, but I thought I would share my approach either way.

Assuming your model has a convex shape, you can try pre-rendering the model's texture to a render target with a SpriteBatch, using the appropriate alpha value. Then apply that render target to your model. That way, you won't have to bother with RenderStates.

RenderTarget2D modelTargetTex; // assuming these are defined elsewhere
SpriteBatch spriteBatch;
// draw your model's texture to a render target, with a specific alpha value.
// put this at the start of your Draw() method
GraphicsDevice.Clear(Color.Transparent); // so the alpha blending will work correctly
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
spriteBatch.Draw(originalModelTexture, Vector2.Zero, Color.White * yourAlphaValue);
GraphicsDevice.SetRenderTarget(null); // don't forget to unset the render target

Once that is done, you can simply assign the render target to your model (basicEffect.Texture = modelTargetTex;) through whatever method you use to draw them. This method would work best on convex models because a concave shape might show graphical artifacts when polys overlap.

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.