Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

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

OK been googling nonstop for ages...

My problem is, i need transparent models in my game. After a lot of annoying fiddling around with my code, i changed the blendstate to alphablend. This allowed me to start having transparency in my models.

However now i face another problem. Any other part of the same model that is meant to be view THROUGH the transparent part of the model, is not shown.

Basically it is only showing the outermost part of the model, even though an inner part is meant to be seen through the transparent part.

Any help? Thanks

share|improve this question
Do you render first opaque model and than transparent model? Becuase that is the only correct way. – Notabene Jun 13 '11 at 10:37
No they are the same model, i just have parts of the texture than are transparent, and parts that aren't. – Randomman159 Jun 13 '11 at 11:31
For example a window model, with a border around it, but the glass is transparent/semi transparent – Randomman159 Jun 13 '11 at 11:31
up vote 3 down vote accepted

In order to get proper blending you will probably have to break the object up into multiple models. And even then you are still limited since from certain angles you will be able to break the transparant blend again. Transparancy is actually quite difficult to get correct without using some cool but fairly exotic solutions. One that comes to mind is Order Independant Transparancy, unfortunately it requires DX Capabilities that XNA doesnt have yet. My recomendation is to go back into your 3d editor and break your mesh apart so you can sort the transparant and non transparant parts into a correct order.

share|improve this answer
Thankyou! However before i answer, could you tell me this. If you have played Minecraft... How would this be done for something like the glass block? Because it is all still rendered as one chunk as far as i am aware... – Randomman159 Jun 13 '11 at 13:44
Those glass chunks uses 1-bit alpha = 1 opaque, 0 transparent. You can write simple shader, which doesn't need any sorting, which uses something like this: if (1bitAlpha) discard(). That discards fragment(pixel) from rendering and writing to the depth buffer – Notabene Jun 13 '11 at 13:54
If something is fully tansparent it is relatively easy to deal with as Notabene mentioned, just don't allow it to affect the color/depth buffers. Breaking up and sorting will most probably be used only to control the render order of partially transparent (translucent) objects. – exnihilo1031 Jun 13 '11 at 20:49
yeah it was discard i needed. I ended up using if (samplerColor.a == 0) discard; and that did the trick :D – Randomman159 Jun 14 '11 at 12:39

Folow this workflow:

  • Sort your model parts by depth, from the furthest one to the nearest one.
  • Enable depth-writing and draw the opaque ones in order.
  • Disable depth writing and draw the transparent ones in order.
share|improve this answer
it's one mesh. One model.. I can't have different settings for the same mesh. – Randomman159 Jun 13 '11 at 12:26
Why to do sorting on the opaque geometry? – Notabene Jun 13 '11 at 13:55

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.