PDA

View Full Version : again about transparents textures



honny
12-12-2002, 05:50 AM
hello,i have a problem using transparent textures.
i have a simple code doing this :

-draw_all_opaque_objects();
-glEnable(GL_BLEND);
-draw_all_transparent_objects();
-glDisable(GL_BLEND);

ok, all seems to work correctly, but...

if i have 2 transparent objects intersecting, only a part of transparent object is drawn.

i have read a lot of post talking about disable the depth test so i changed my code as follow :

-draw_all_opaque_objects();
-glEnable(GL_BLEND);
-glDisable(GL_DEPTH_TEST);
-draw_all_transparent_objects();
-glDisable(GL_BLEND);
-glEnable(GL_DEPTH_TEST);

now i can draw transparent objects intersecting correctly , but...

also the opaque objects become transparent !!!

at the moment i so confusing...

can u help a poor dude plese ?

thanks in advance.

Relic
12-12-2002, 05:57 AM
Don't disable depth test, but disable depth writes with glDepthMask(GL_FALSE) for the transparent objects. That means they are depth tested against the opaque objects, but never against each other, because they don't write their own depth into the buffer.

honny
12-12-2002, 11:44 PM
ok thanks,
i have changed glEnable/Disable(DEPTH_TEST) with glDepthMask(GL_FALSE/GL_TRUE) and now all works correctly.

bye