PDA

View Full Version : Problems with tga and blending



lud2k
10-20-2006, 12:31 PM
Hello,

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 :
http://www.imagehosting.us/index.php?action=show&ident=1691043

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,
Lud2k.

zeoverlord
10-20-2006, 12:44 PM
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.

lud2k
10-20-2006, 12:51 PM
Coool it's working :-)

Thanks for your help zeoverlord !

I used alpha testing and now it works great ^^