Advertisement

depth test concept ...

Started by September 14, 2002 07:35 AM
2 comments, last by penetrator 22 years, 5 months ago
it''s still hard for me to understand. I have several quads, let''s say named A1,A2,Ax and a main object named B. I want depth test disabled between A1,A2,Ax object, but enabled for B. I wrote this routine: glEnable(GL_DEPTH_TEST); DrawObject_B(); glDisable(GL_DEPTH_TEST); DrawObject_A1(); DrawObject_A2(); DrawObject_Ax(); But A1,A2,Ax they always appear in front of B even when they should be hidden. I''m really missing the concept here. Can you help me ?
www.web-discovery.net

glDisable(GL_DEPTH_TEST);
DrawObject_A1();
DrawObject_A2();
DrawObject_Ax();
glEnable(GL_DEPTH_TEST);
DrawObject_B();

?.
Advertisement
penetrator: yes B will be hidden, because :
glEnable(GL_DEPTH_TEST);
DrawObject_B(); // depth-test enabled : only the "closer" triangles of B are visible
glDisable(GL_DEPTH_TEST);
DrawObject_A1(); // depth-test disabled : A1 is rendered no matter the depth buffer is, because the depth test is disabled
DrawObject_A2(); // idem : A2 is rendered everywhere even if Z is farther
DrawObject_Ax(); // idem...

Maybe you want A1, A2 and Ax to test depth but not to WRITE into the depth buffer.
That is, the Ax objects may be hidden by objects that were already rendered (B for instance), but Ax objects may not hide other objects (for instance you never want A1 to hide A2).
In that case, you don''t have to disable DEPTH TESTING, you have to disable DEPTH WRITING

glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
DrawObject_B();
glDepthMask(GL_FALSE);
DrawObject_A1();
DrawObject_A2();
DrawObject_Ax();

This technique is used to render transparent objects, and so forth is very popular for particle systems.
Yes Vincoof, that was it ! Thanks a lot !



www.web-discovery.net

This topic is closed to new replies.

Advertisement