you can solve this with one of two methods:
1. Sort your objects back to front: Draw the farthest objects first.
2. Render in 2 passes: opaque stuff first. Then transparent stuff.
This is a little bit misleading or even wrong.
1. You don't need to sort even opaque objects. It's a waste of CPU cycles to do it and it would even damage your overall performance from the GPU side - because opaque objects are better to render front-to-back, not back-to-front. Imagine you have 100 boxes in a row and you are looking at the row from one end, so you actually see only the first box. If you order them and render them back-to-front, you render the 100th box, then completely overwrite all the pixels by the 99th box, then the 98th box etc. You render ALL of them, even if you'll see only the pixels of the closest one.
If you ordered them front-to-back, then you would fully process only the closest one, because all the other 99 boxes will fail the depth test.
The difference is big if you have very complicated pixel shaders, because pixel processing is what you save.
But you don't need to order the objects, the general "random" order will give you some average (usually acceptable) overdraw. But sorting them back-to-front would give you the WORST overdraw possible, plus you would waste time on the sorting for no positive reason.
2. That will fix only the error that you don't see opaque objects through transparent objects. But it won't fix transparent objects not being visible through other transparent objects.
3. Disable z-writes, but leave z-testing enabled. Enable alpha blending.
Why would you want to disable z writes? Aren't you talking about a special scenario - particle systems? When rendering normal transparent objects you of course still need the depth testing to be fully functional, because there is a visual difference if you draw A behind B or B behind A.
It may seem that rendering the objects back-to-front makes it unnecessary to use z-buffering. And in common scenarios it will be true. But what about concave objects? Proper rendering order will make sure that the objects as a whole is rendered in front of other objects, but it won't make sure that front parts of the object are rendered in front of rear parts.
The common procedure is:
1. Draw opaque objects. Ordering is not important, but ordering them front-to-back can improve performace a bit in some cases.
2. Enable alpha blending.
3. Draw transparent objects. Ordering is important and they must be ordered back-to-front.
4. Disable alpha blending.
Edited by Tom KQT, 16 October 2013 - 06:06 AM.