Jump to content
  • Advertisement
Sign in to follow this  
portable

Occlusion Culling, ARB_occlusion_query, Near Plane

This topic is 4840 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

Hi! Right now, I try to implement an occlusion culling system using the ARB_occlusion_query extension. It seems to work except for the following case: if the triangle is inside the view frustum but in front of the near plane, nothing gets drawn on the screen. Thus the system is telling me, that the triangle is occluded which is wrong, because it is inside the view frustum. Is there any _fast_ and _reliable_ solution to this problem? Thanks in advance, Phil

Share this post


Link to post
Share on other sites
Advertisement
Well first, if a triangle is in front of the near plane it is not in the view frustum. The frustum is the capped pyramid-type shape from the near plane to the far plane. As for a fast and reliable solution I don't think there is one using ARB_occlusion_query because that will always clip by the near plane - there's no way you can remove the near plane and you don't want to try and move too close to the view point because that will ruin your Z buffer precision. So if you want to solve this problem you're going to have to do it on CPU using a software clipping system of some kind.

What is this triangle you're testing anyway? I thought occlusion systems normally worked by testing the bounding volume of the object, so if it was in front of the near plane counting it as occluded would be correct.

Share this post


Link to post
Share on other sites
Thanks for your answer. The problem is, that a triangle which is located between the viewer and the near plane can contribute to the actual culling. Since it is so close to the viewer chances are high that it acts as a good occluder. That's why I don't want to discard these special cases.

By the way: the triangle I'm testing is part of the bounding box of the object.

Share this post


Link to post
Share on other sites
if the case is bounding box reported invisible when it's visible you can just do simple test. if camera is inside enalrged bounding box you don't test occlusions and report box as visible. bounding box is enlarged by small amount equal to maximum distance from eye to front clipping plane.

Share this post


Link to post
Share on other sites
Hi biki_!

The "camera inside bounding box" - thing is clear. But what do you mean by enlarging the bounding box? I think this wouldn't solve my problem since backface culling is enabled during the test. Or am I wrong?!

Phil

Share this post


Link to post
Share on other sites
I think he's saying if the pyramid which connects the view frustum to the camera point intersects the bounding box. However that's quite a complex test, so if you expand the bounding box by the distance from the camera to the furthest point on the near clip plane you can test the expanded bounding box against the camera position. On the other hand you could calculate the bounding box of the camera and the 4 corners of the near plane and test that against your trial box, and if they intersect assume the object is visible and don't do the occlusion test.

Share this post


Link to post
Share on other sites
well. if i understood correctly your problem is this
you test bbox visibility by using occlusion query
and if box gets clipped by near clipping plane it can be reported invisible
when it's visible.
now solution is that if you get close to box, so close that it can get clipped
and report false invisibility. you assume it as visible (as well as all boxes your
camera is inside.
to do that test you need enlarged bounding box, the amount you enlarge
is equal to maximum distance between camera position and furthest point on projection plane so for example in opengl.

if you define clipping frustum as :

glFrustum(-0.32,0.32,-0.24,0.24,0.3,2500);

then amount you have to enlarge your bounding box is

d=sqrt(0.32^2 + 0.24^2 + 0.3^2);



Share this post


Link to post
Share on other sites
If its a full box, can't you just switch the cull mode when it gets close to the camera. That way it'll render the back faces which aren't clipped (yet).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!