Z-sorting problems have puzzled me from the beginning. From time to time I see this issue discussed on the forums, but I feel the answers are somewhat confusing and diverse. I'd really like that a single page of the manual, or some website, or someone explained accurately and at once what are the problems about writing to the Z buffer, whatever that means, and why it's so complicated.
This is a question from
http://www.conitec.net/beta/afaq.htm Quote:
Q. I have problems with the sorting of transparent or TGA images. For instance, I'm trying to make a tree by crossing two sprite like a 'X. When using TGA sprites, the first sprite always draw before the second sprite. This doesn't happen when I use PCX or BMP sprites.
A. Transparent objects can not write into the z buffer, and thus are simply sorted according to the distance of their origins. This does look wrong when they overlap or are close...
This is probably the best answer I found about this. What it does not say is exactly what is a 'transparent object', other than an entity flagged as 'transparent'.
I think any entity that uses a 32-bit texture (meaning an extra 8-bit channel) is considered as having an Alpha channel, and thus, potentially transparent. Even if the alpha channel is not being used, its polygons won't show properly. Maybe the model polygons are sorted after the distance from the object origin, as this answer suggests?
Even objects with 24-bit TGA textures that I import in MED, end up as 32-bits. Once the model is in mdl7 format, I can change the texture to 24-bit and it will be fixed.
Below is an engine screenshot of a model textured with a TGA image. You can see the arms and legs completely out of order. When it happened first time, I spent several hours at the internet to discover that this is NOT a flipped normals problem.
AS far as I understand, you should use up to 24-bit textures. If you NEED to have an alpha channel (For instance, a car model whose windows are partially transparent, or plants that have smooth transparent edges) then you need to code a material that expressly enables writing on the Z buffer, which is slow to render. So, if making vegetation, the advice is to use a 16-bit texture with hard-looking color-cookie cut, or whatever it's called. Did I get that right this time?
|Emilio|