Sign in to follow this  
JohannesH

XNA alpha overlay problem

Recommended Posts

JohannesH    100
I am a beginner in XNA, but have used MDX a short time. I am in the process of moving a MDX project to XNA and got into a strange painting issue with alpha blending. This was working fine in MDX. I am setting RenderState: GraphicsDevice.RenderState.AlphaBlendEnable = true; GraphicsDevice.RenderState.SourceBlend = Blend.SourceAlpha ; GraphicsDevice.RenderState.DestinationBlend = Blend.InverseSourceAlpha; And all works well until I get to overlay 2 TriangleStrips. I would have expected the color to simply get darker when they are overlaid (alpha channel set to 130 for both). A png to illustrate is here: http://www.farmergps.com/download/test4/XNA-Alpha1.png Had some trouble converting from LH to RH, however I don't think that is related. (you can see the grid shining through, although it was drawn first and has the same 0 z value as the violet drawing) Maybe somebody can point me in the right direction? Thanks, Johannes

Share this post


Link to post
Share on other sites
JohannesH    100
After some more experiments I am thinking that my problem may not be alpha channel related but maybe more to the order of triangles. I have seen some triangles disappear to white....

Share this post


Link to post
Share on other sites
JohannesH    100
Found my problem:

GraphicsDevice.RenderState.DepthBufferEnable = true;
GraphicsDevice.RenderState.DepthBufferWriteEnable = false;

This article did the trick:
http://blogs.msdn.com/shawnhar/archive/2009/02/18/depth-sorting-alpha-blended-objects.aspx

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this