transparency and the z-buffer

Hi

I have some textures and I want them to be completely transparent at some positions (i.e. for sprites). Now transparency works but I have a little problem. I don´t sort the polys up to now and when I draw a partly transparent polygon and after this I draw a second one, which lies behind the first one it doesn´t shine through. I think this happens because when I draw the first one it updates the z-buffer even at positions, where nothing is drawn.
Now: Is there any way to prevent OpenGL from updating the z-buffer where a pixel is completely transparent? Or do I have to sort the polygons from back to front?

Thanks.

you have to sort them to achieve the effect you want.

however, there is a workaround that works for some types of problem:
if your semitransparent objects are bitmap objects (billboarding) like trees or explosions etc. make sure they are drawn towards the end of your gfx pipeline and place the following:

glDepthMask(GL_FALSE);
// draw your transparent objx here!!
glDepthMask(GL_TRUE);

basically, this switches the z-buffer to READ-only. it works for me, but it depends on your type of problem if this suits you

You can also do this:

glAlphaFunc(GL_LESS, 0.5);
glEnable(GL_ALPHA_TEST);

Then all fragments with alpha of less than 0.5 are culled before they make it into the depth buffer.

j

Originally posted by j:
[b]You can also do this:

glAlphaFunc(GL_LESS, 0.5);
glEnable(GL_ALPHA_TEST);

Then all fragments with alpha of less than 0.5 are culled before they make it into the depth buffer.

j[/b]

That is good for trees because you don’t actualy want it to be transparent.