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:

// The vertices of vertices1 are located BEHIND vertices2

// The vertices of vertices2 are located IN FRONT vertices1


//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


My question is, Why does the order in which I call draw matter?

Edit: Added screenshots

Background is drawn, then fighter

Fighter is drawn, then the background

With DepthStencilState.Default, image does behind another image but I can't see what's behind the texture, instead I see the background color

It's like there is no Z buffering at all. this is done with: GraphicsDevice.DepthStencilState = DepthStencilState.DepthRead; I've tried other settings but they don't help

Edit: I think I have to somehow set the BlendState of the graphic card in some way so that the textures behind other textures get rendered.

  • \$\begingroup\$ Can you provide a screenshot? \$\endgroup\$ Sep 13, 2012 at 3:50
  • \$\begingroup\$ @AndrewRussell I've added screenshots, I'll add all the code too if that's necacarry. \$\endgroup\$ Sep 13, 2012 at 6:15

1 Answer 1


The rendering depends mainly on two things:

  • spatial configuration (z-buffer configuration) - closest fragment is written to output pixel usualy
  • blending settings (there is a lot of possible blending configurations)

If you render your planes with same Z-depth, you can experience some z-fighting problems. GPU usualy performs some optimalization in rendering pipeline - for example early Z termination. This could sometimes imply unexpected results...

From what you've posted it's not clear, what shader code are you using and what are the depth buffer and blending states.

(For me it seems that one of the effects (shaders) used (basiceffect1, basiceffect2) is discartign fragments while the other does not...)

But in general: the rendering order MATTERS when handling transparency...


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .