Archived

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

HP occlusion test question

This topic is 4943 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, according to: http://oss.sgi.com/projects/ogl-sample/registry/HP/occlusion_test.txt it says:
    - disable updates to color and depth buffer (optional)
        glDepthMask(GL_FALSE)
        glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE)
    - enable occlusion test
        glEnable(GL_OCCLUSION_TEST_HP)
    - render bounding geometry
        gl rendering calls
    - disable occlusion test
        glDisable(GL_OCCLUSION_TEST_HP)
    - enable updates to color and depth buffer
        glDepthMask(GL_TRUE)
        glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE)
    - read occlusion test result
        glGetBooleanv(GL_OCCLUSION_TEST_RESULT_HP, &result)
    - if (result) render internal geometry
      else don''t render
if a model is partially behind another model, say a person model''s hand is behind a monster model''s body, will the whole person model be occluded (ie, will the ''result'' variable return true or false)? thanks.

Share this post


Link to post
Share on other sites
I''ve never used the HP version but according to the ARB_occlusion_test documentation:

"The earlier HP_occlusion_test extension defined a similar mechanism,
but it had two major shortcomings.

- It returned the result as a simple GL_TRUE/GL_FALSE result, when in
fact it is often useful to know exactly how many samples were
drawn."


so from this, i guess you can only query true or false using the HP test. i''d assume that the HP version would fail when there is even a bit of occusion and only pass if there is no occulsion at all.

Share this post


Link to post
Share on other sites
quote:
so from this, i guess you can only query true or false using the HP test. i'd assume that the HP version would fail when there is even a bit of occusion and only pass if there is no occulsion at all.

No. The occlusion test returns true if any of the samples in a given query pass the depth test. Generally that's all you need BTW.

To the OP: Good luck getting any performance increase with that extension. Even with the ARB extension, I had trouble getting any significant increase in performance with my card. In the end I had to roll my own software occlusion map renderer to do the job.

[edited by - benjamin bunny on May 28, 2004 11:34:43 PM]

Share this post


Link to post
Share on other sites
I think you can get some performance if you CACHE the results. For example, if the camera doesn''t change, you can cache the results for the static objects (of course, some tricks might be necesary).

Share this post


Link to post
Share on other sites
@benjamin bunny - hmm...i''d think that the hardware extension would make everything faster...how''d you go about creating your own software occlusion map renderer? any links to good tutorials?

thanks!

Share this post


Link to post
Share on other sites
Like I said, with my render code, HW OM was significantly slower than brute force for most scenes. Admittedly I didn''t attempt to optimise it much, but I was sufficiently disgusted with the performance that I decided to write my own solution. The result was much better.

The SW occlusion map renderer is basically a Z-buffer software renderer without a colour buffer, that follows the OpenGL spec to project the vertices. The occlusion querying part works in pretty much the same way as the HP extension.

There aren''t likely to be any tutorials on making a software renderer, because it''s a fairly complex process, and you wouldn''t bother doing it unless you understood the theory first. But if you''re interested then you should get a decent book, such as Computer Graphics Principals and Practice in C (2nd ed), and look up 3D clipping algorithms, polygon filling (scanline) algorithms and projection transformations.

Share this post


Link to post
Share on other sites
Or just hack Mesa into your program
benjamin bunny, when you tested the occlusion test HP extension (or the ARB), did you render your actual object, full texture, or only a colored bounding box?

Share this post


Link to post
Share on other sites
quote:
Original post by Raduprv
Or just hack Mesa into your program
benjamin bunny, when you tested the occlusion test HP extension (or the ARB), did you render your actual object, full texture, or only a colored bounding box?


Obviously I used a bounding box for the occludees in order to perform the query. There wouldn't be much point in rendering the full geometry, would there?

[edited by - benjamin bunny on May 30, 2004 1:59:51 AM]

Share this post


Link to post
Share on other sites
hmmm, i''ve been wondering about this, its all very well doing the FFP in software, but what if you wanted to use a VP to perform the translations for the bounding box? I''m guessing you''d enter the fun works of writing your own emulator in software for VP, so do you bother with that or is it something you dont have to worry about for other reasons?

Share this post


Link to post
Share on other sites
quote:
Original post by benjamin bunny
quote:
Original post by Raduprv
Or just hack Mesa into your program
benjamin bunny, when you tested the occlusion test HP extension (or the ARB), did you render your actual object, full texture, or only a colored bounding box?


Obviously I used a bounding box for the occludees in order to perform the query. There wouldn''t be much point in rendering the full geometry, would there?



Well, some objects can be really small, but have a BIG bounding box. In that case, you can get false hits (ie. an object that is otherwise very visible will fail the test).

Share this post


Link to post
Share on other sites
quote:
hmmm, i've been wondering about this, its all very well doing the FFP in software, but what if you wanted to use a VP to perform the translations for the bounding box? I'm guessing you'd enter the fun works of writing your own emulator in software for VP, so do you bother with that or is it something you dont have to worry about for other reasons?

Hasn't been an issue for me. The only objects that use VPs in my current project are skinned character meshes, and I just use the bounding box for the original pose. This works fine, because the BB is sufficiently large to always be visible when the character is. I guess in general you could just overestimate the size of the bounding box.

For occluders it would be more of a problem, since you need to render the geometry to the OM precisely. But in general it's best to pick large static objects as occluders, so I can't see this being a problem in reality.

[edited by - benjamin bunny on May 30, 2004 2:29:26 AM]

Share this post


Link to post
Share on other sites
I have been using the NV version of the occlusion extension for some time now and I''m getting very good results.
Admitedly, I reckon a SW version would be faster, anyhow this is what I did.

1. Frustum Cull, mark nodes that are visible (octree)
2. Take marked nodes, sort by distance.
3. Traverse the nodes (near to far) start occlusion test and render the nodes aabb.
4. If current node contains occluders render them.
5. Repeat steps 3 and 4 for all marked nodes.
6. Render the scene of previous frame.
7. Get back the occlusion results, store visible surfs for rendering in the next frame.

Ok now with a brute force on my scene I average around 130fps, with the above and a little tweaking (frame to frame coherence) theres a boost to between 300 - 600 FPS.

Ok my scene doesnt really contain a great deal of geometry, so as the geometry becomes more complex, in theory the advantage of the occlusion tests will improve moreso.

Share this post


Link to post
Share on other sites