View Full Version : Question about trees (transparent textures)

01-13-2009, 03:50 PM
I implimented some standard trees with the 2 perpendicular quads, using a transparent PNG for the tree texture.

Now, the tree in the foreground correctly shows the transparency through to the skybox, but obscures the other trees like a "cloak of invisibility". But it only does this when viewing the trees from *one direction*, not the other.

The trees are all part of the big "world" object. I am using glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA). Face culling is off.

I must be missing something regarding transparent texturing.. this effect is kinda cool but not the simple thing I'm doing after! Any ideas?

Rosario Leonardi
01-13-2009, 03:56 PM
When you draw transparent object you have to order them back to front to have a correct behavior.

01-13-2009, 04:16 PM
A ha. I was afraid that might be the case.

But, what about the fact that a tree can also obscure itself? How would I depth sort the 2 quads which make the tree? Their centroids would be equal.

01-13-2009, 04:47 PM
You can mitigate zbuffer problems by doing alpha testing on top of blending, at a low threshold.
Or use coverage alpha with multisampling.

01-14-2009, 09:54 AM
Yes, alpha test will work just fine for my purposes. Thanks for mentioning it.