working with GL_NV_occlusion_query

Hi

I’m tryng to implement a working algorithm using this extension, but i’m having some problems with it…,
If i use my real geometry instead of a bounding box to perform the test , everything works great, but i want to use a bounding box. The problem is that the extension only returns a correct value if i really render the geometry, otherwise it fails.
So, if i do this :

glPushMatrix();
glBeginOcclusionQueryNV(query);
render_bounding_box();
glEndOcclusionQueryNV();
glPopMatrix();

It works, but if i do this, as it is described in the nvidia papers :

glDepthMask(GL_FALSE);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
glPushMatrix();
glBeginOcclusionQueryNV(query);
render_bounding_box();
glEndOcclusionQueryNV();
glPopMatrix();
glDepthMask(GL_TRUE);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);

This fails., i get incorrect results.,
What’s am i doing wrong here ?

thanks,
Bruno

Looks okay to me. What exactly do you mean by “incorrect results”? Do you mean the pixel count is always zero?

– Tom

No, i mean the pixelcount is allways > 0 , much bigger than 0, as if nothing is occluding it.
If i use the first example, my pixelcount returns 0 if the bounding box is occluded, on the second example ( the bounding boxes are not rendered ), but i never have a pixelcount of 0 when occluded.

btw, if i do this :

glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
glPushMatrix();
glBeginOcclusionQueryNV(query);
render_bounding_box();
glEndOcclusionQueryNV();
glPopMatrix();
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);

without disabling the depthmask, i got my scene rendered as if there was no buildings there, all i see is the landscape, but when i move into the location of the buildings, it’s has he his surrounded by an invisible box ( my bounding box ).
When i’m inside this box, my building is rendered.
In this case the occlusion is working, but i can’t see my buildings like this.

Apparently the query is using depth buffer values to establish visibility. Probably the only thing I can think of to fix this situation is to clear your depth buffer before you redraw your scene, or draw those buildings with depth testing turned off, which is probably not what you want to do.

Oi Bruno!

Acho que o problema é que o teste é feito nos fragmentos que passam no teste depth/stencil. Ao colores a mascara ele não escrevo no depth.

Experimenta aproveitares o passe de teste para criares um passe de Z para ficar toda a informação logo lá colocada e depois usa sempre GL_EQUAL como teste… Para isso nao faças render da bounding box

[This message has been edited by KRONOS (edited 05-24-2003).]