PDA

View Full Version : texture alpha



mathx
12-28-2001, 04:08 AM
Hello,

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.

Thanks,
Matheus Degiovani.

12-28-2001, 06:10 AM
Hi,

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:
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER ,0.95f);
Only fragments with alpha > 0.95f will pass.

12-28-2001, 06:38 AM
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?

BlackJack
12-30-2001, 01:51 PM
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.

Michael