Alpha blend 3D png texture in XNA
- by ProgrammerAtWork
I'm trying to draw a partly transparent texture a plane, but the problem is that it's incorrectly displaying what is behind that texture.
Pseudo code:
vertices1
basiceffect1
// The vertices of vertices1 are located BEHIND vertices2
vertices2
basiceffect2
// The vertices of vertices2 are located IN FRONT vertices1
GraphicsDevice.Clear(Blue);
PrimitiveBatch.Begin();
//if I draw like this:
PrimitiveBatch.Draw(vertices1, trianglestrip, basiceffect1)
PrimitiveBatch.Draw(vertices2, trianglestrip, basiceffect2)
//Everything gets draw correctly, I can see the texture of vertices2 trough
//the transparent parts of vertices1
//but if I draw like this:
PrimitiveBatch.Draw(vertices2, trianglestrip, basiceffect2)
PrimitiveBatch.Draw(vertices1, trianglestrip, basiceffect1)
//I cannot see the texture of vertices1 in behind the texture of vertices2
//Instead, the texture vertices2 gets drawn, and the transparent parts are blue
//The clear color
PrimitiveBatch.Draw(vertice
PrimitiveBatch.End();
My question is, Why does the order in which I call draw matter?