texture alpha


I’m trying to write my own version of NEHE’s tutorial 19 (the one about particles) but my particles “chew up” the others behind them. The black area of the bitmap hides the particles that are behind it, so my question is how do I enable the texturing alpha? I enabled blending (glEnable(GL_BLEND)), but that didn’t make any difference.

Matheus Degiovani.


I had the same problem some time ago and I solved it by setting glDepthMask(GL_FALSE) so
that the particles can´t cover each other any more.

But you could also use glAlphaFunc to delete the Pixels ,but this sometimes looks very bad:
glAlphaFunc(GL_GREATER ,0.95f);
Only fragments with alpha > 0.95f will pass.

Well perhaps I haven´t understand you correct.Your texture has no alpha value at
all ,or what do you mean with black area?

If so you don´t use GL_RGBA which includes
an alpha value ,but GL_RGB as the external
texture format?

Could you send your code to create the texture?

Yeap, what Phil has written is the right
way for doing alphatesting. For alphablending
simply additional call glEnable(GL_BLEND).
Your particles you should in general sort by
depth, calculate the distance from the
observer to the particles center and sort
them by quicksort then. Then draw them from
back to front. If you have just hard edges
and no transparent particles…what I don’t
believe, because such edgy particles would
look awful…then you don’t need that
sorting, but also have to let blend disabled.