View Full Version : setting alpha to zero

03-15-2004, 06:58 PM
Hi, I'm drawing a HUGE number of triangles, all of the same color but with varying alpha. I noticed that if I set all the alpha values to zero, I get a greenish color when there are a large number of triangles overlapping. Should this be happening? Doesn't an alpha value of zero ensure that the primitive will have absolutely no effect on what the user sees?

03-15-2004, 07:17 PM
Here's a code snippet from my initialisation function, maybe I'm doing something wrong here. I've seen that the green color starts appearing if more than (roughly) 10 primitives overlap.


03-16-2004, 11:32 AM
Can you link to a screenshot?

03-16-2004, 10:26 PM
With alpha test enabled, which alpha values are rejected?
There shouldn't be any pixels left to draw if you have something like (greater, 0.01) set.
Are you running in high color R5G6B5?
Green has a higher number of bits here, maybe that's related.
If this is with textures, try specifying a true color internalFormat (e.g. GL_RGBA8).
Or it's just a weird bug and you should try a newer driver.

03-22-2004, 12:16 AM
Thanks for the suggestions, I think it really IS a driver bug. The problem occurs even if I draw black triangles, i.e. glColor4f(0.0f, 0.0f, 0.0f, 0.0f);

Thanks anyway...

03-22-2004, 10:52 AM
This is accumulated rounding errors thanks to the blending math in your implementation.

One workaround would be to use glAlphaFunc(GL_NOTEQUAL, 0.0f); and glEnable(GL_ALPHA_TEST); you could also try other slightly higher reference values and a GL_GREATER alpha test. Having this kind of thing enabled is a good idea anyway because it can mitigate alpha zbuffer problems and save you blended fill performance on most good hardware.