Problems with tga and blending


I’ve a little question…
I’m trying to draw the leaves of a tree but I have a problem (with blending maybe).
The leaves texture is a .tga with transparency.
When i draw only one quad it’s OK. the problem appears when drawing more than one quad…
Aparently, the last one to be drew mask the other one behind. (The part transparent replace what was behind)

I don’t know how to explain it but you can find a screenshot of the problem just under :

T = transparent texture (tga)
B = black texture (tga)

B (behind) + T (front) => T (transparent because T replace the colors behind by “transparency”)
T (behind) + B (front) => B (result is black)

Anyway to resolve this problem ?

Hope you can help me soon :-),
Thanks everybody,

You sir just ran into one of the most classical bugs when it comes to transparency, the thing is even though the texture is transparent, it still draws to the z buffer as if it was fully opaque thus blocking out everything behind it if it’s rendered after the transparent polys.

there are two ways of fixing this, none of them are perfect.

  1. render all fully opaque polygons first, then render the transparent ones sorted back to front, this looks good, but uses up lot’s of CPU and is complicated to say the least.

  2. Use alpha testing, works well but gives jagged edges, this one if the most commonly used.

Coool it’s working :slight_smile:

Thanks for your help zeoverlord !

I used alpha testing and now it works great ^^