Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

penetrator

depth test concept ...

This topic is 5940 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
glDisable(GL_DEPTH_TEST);
DrawObject_A1();
DrawObject_A2();
DrawObject_Ax();
glEnable(GL_DEPTH_TEST);
DrawObject_B();

?.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!