Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

This image describes the problem I'm having: http://i42.tinypic.com/282kzlf.jpg

What you are seeing consists of two images:

  • Image A(with the alien-concept art thingy), depth value .98, the white parts on the image is where the alpha value is 0.0f

  • Image B(with the play game button thingy), depth value .99, one solid image without any transparency value.

Now, when I first set this up, I expected Image A to let the colours of Image B through where Image A is fully transparent. But it doesn't

Question 1 : Why doesn't it?

Question 2 : What can I do to fix it? Are there multiple ways to fix it?

Question 3 : Is this problem different for partial transparency? If so, how do I make it work with partial transparency as well?

Thanks.

share|improve this question
    
Have you enabled blending and set up the proper blend function? In openGL this would be glEnable(GL_BLEND) and glBlendFunc() –  stephelton Feb 23 '12 at 17:16
    
@stephelton yes. I think this has something to do with order-independent blending, but I'm not sure. It would be nice to hear from someone with more experience what the problem exactly is, and methods I can use to fix it –  xcrypt Feb 23 '12 at 17:23
add comment

1 Answer

up vote 1 down vote accepted

Are you rendering the images in the correct order? For blending to work, they need to render back-to-front, so Image B should be drawn first and then Image A should composite over it.

In general, the depth buffer does not work well when combined with blending / transparency; using the two together usually produces undesired results. See this answer to a similar question for a more in-depth explanation and rundown of the different approaches to solving it.

share|improve this answer
    
Ah right, but I just have to sort right? It's not like I need to disable the depth buffer? Because it would be silly to draw pixel (screenpos x,screenpos y) multiple times. I don't want to work with alpha testing because it doesn't allow partial transparency –  xcrypt Feb 23 '12 at 17:44
1  
You don't need to disable the depth buffer in this case, but the depth buffer doesn't help you at all, since if you draw back to front it never culls anything. When using blending you must draw some pixels multiple times, where the quads overlap. –  Nathan Reed Feb 23 '12 at 17:47
add comment

Your Answer

 
discard

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.