View Full Version : Semisolid polys and z-buffer? (trees...)

08-20-2000, 04:22 AM
If I display a semisolid polygon like a tree the z-buffer writes on every texel of the polygon. But I want it write only on the texels where the aplha value is not zero!

Deactivating the depth buffer is not the solution because there are also solid polys in the scene and my faces are not sorted.

08-20-2000, 07:35 AM
Hmm, the following might work. Never tried it though...

Use glAlphaFunc(GLenum func,GLclampf ref), where func is the function (same function as for depthbuffer tests) you want to use, and ref is the reference value used by func (ref is clamped to the range [0, 1]).

So, by doing glAlphaFunc(GL_GREATER, 0.5f) would mean all incomming pixels with alpha of more that 0.5 will be drawn, and all other will be rejected.

And of course, you need to glEnable(GL_ALPHA_TEST) too.

08-20-2000, 09:17 AM
Thanks!!! It works great!

08-20-2000, 09:55 AM
Note, using alpha testing may prove to be too slow in some instances, on some hardware. At some point, drawing depth sorted, alpha blended billboards (with depth writes disabled), may prove to be faster. You may want to benchmark each method, and see which method is better for a given number of billboards.