Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Clear depth buffer where stencil has specific value


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 floatingwoods   Members   -  Reputation: 292

Like
0Likes
Like

Posted 03 September 2012 - 05:46 AM

Hello,

After getting my mirrors to work almost perfectly, I have a last problem:

I need to clear the depth buffer only where the stencil buffer has a specific value. The problem is that glClear(GL_DEPTH_BUFFER_BIT) does not take into account the stencil buffer settings, and erases my whole depth buffer, not just the part I need to be cleared.
Is there some workaround?

e.g. a mode where writing a polygon will always write the same value to the depth buffer (i.e. very very far away), effectively clearing the depth buffer only where I want?

Sponsor:

#2 Brother Bob   Moderators   -  Reputation: 8979

Like
2Likes
Like

Posted 03 September 2012 - 05:48 AM

You can set the depth test to GL_ALWAYS and draw a planar surface on the far clip plane (or sufficiently far away for your needs).

#3 floatingwoods   Members   -  Reputation: 292

Like
0Likes
Like

Posted 03 September 2012 - 06:12 AM

Thank you Brother Bob!

Actually, I was thinking about that as a last resort, since that would require to compute a new planar surface and it appeared to me as unelegant ;)

#4 Brother Bob   Moderators   -  Reputation: 8979

Like
0Likes
Like

Posted 03 September 2012 - 07:36 AM

You don't have to compute anything. An identity matrix and a quad spanning (-1, -1, 1) to (1, 1, 1) on the Z-plane is all you need.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS