Jump to content

  • Log In with Google      Sign In   
  • Create Account


Camera inside walls and use of stencil buffer


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 larspensjo   Members   -  Reputation: 1526

Like
0Likes
Like

Posted 12 September 2012 - 08:01 AM

What I really want to do, is to draw something proper instead of seeing through walls. Given a projection matrix based on a view frustum, is it possible to have bits set in a stencil buffer when a write fails the near plane cut-off?

There is a possibility to control stencil bits from failed depth tests, but I don't know if culling because of being outside the cut-off planes counts.
Current project: Ephenation.
Sharing OpenGL experiences: http://ephenationopengl.blogspot.com/

Sponsor:

#2 Geometrian   Crossbones+   -  Reputation: 1455

Like
1Likes
Like

Posted 12 September 2012 - 11:33 AM

What you mean is "clipping", and yes, it happens before any fragments are produced, so no what you describe is not possible. Can you clarify what it is you want to do?
And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.

#3 larspensjo   Members   -  Reputation: 1526

Like
0Likes
Like

Posted 12 September 2012 - 12:26 PM

What you mean is "clipping", and yes, it happens before any fragments are produced, so no what you describe is not possible. Can you clarify what it is you want to do?

I want to detect fragments that are clipped by the near plane, to make it possible to draw something else. But as you say that clipping is done before fragments are produced, the idea doesn't seem to be possible. Maybe there is another way to get it done?
Current project: Ephenation.
Sharing OpenGL experiences: http://ephenationopengl.blogspot.com/

#4 Ignifex   Members   -  Reputation: 507

Like
0Likes
Like

Posted 13 September 2012 - 02:57 AM

To me at least, it is still not very clear what you are trying to achieve.
As for your direct question, you could have a look at the depth of the fragment you are drawing in your pixel shader, using eg. gl_FragCoord.z. You can compare this value to 0, which will usually be the depth value at the near-plane, possibly shade the fragment in a different way, and then modify the depth that is used to compare it using gl_FragDepth.




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