PDA

View Full Version : Transparancy troubles....a little help?



iNsaNEiVaN
06-30-2001, 08:51 PM
I'm having problems drawing something transparent...if any of this is wrong let me know!

What I think I know: I know for a transparent object to show you have to draw it last OR you can disable GL_DEPTH_TEST before you draw the transparent object and place the drawing code in any order..

But something isn't working right...heres my code

glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D, textures[3].texID);
glColor4f(1.0f, 1.0f, 1.0f, 0.5f);

(draw object)

glDisable(GL_BLEND)
glEnable(GL_DEPTH_TEST);

but for some reason this doesn't wanna appear...but if I dont draw my skybox it appears so evidently my glDisable(GL_DEPTH_TEST) theory isn't working...

Whats wrong?

Thanks!!!

ffish
07-01-2001, 03:41 AM
Firstly, you don't need to set the blending function every drawing pass. From looking at your code, I would guess the problem's in your texture function. What function do you use - replace, modulate, blend or decal? You'll have to make sure your texture is correctly blended too.

iNsaNEiVaN
07-01-2001, 04:32 AM
I havent called glTexEnvf() anywhere in my program yet. But as I said..when I removed my skybox the transparent object appeared..so I know they're being rendered but just not shown...

What did you mean by "make sure your texture is blended too"????

07-01-2001, 06:18 AM
Sounds to me like your sky box is drawing over the tranparent polygon. If you change the order so that the transparent polygon is drawn last it might show up. This happens becuase you have disabled the Z-buffer and it dosen't know it's their when the skybox is drawn. Maybe you are drawing in the correct order ???

DFrey
07-01-2001, 06:47 AM
I would agree, however I would also say that when drawing transparent objects, you generally should not disable depth testing. Particularly if there are opaque objects which could lie in front of the transparent objects. Instead, when rendering transparent objects, just disable depth writes. I would draw things in the following order: opaque objects, skybox, transparent objects, overlay (if any).

iNsaNEiVaN
07-01-2001, 10:45 AM
Okay thanks for all the help! You guys are awesome.