• Advertisement
Sign in to follow this  

Occlusion query

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

is it possible to do an occlusion query that counts each zpass where the existing z value is 1.0 ? that would count the actual number of pixels lit so far and not the overwrites

Share this post


Link to post
Share on other sites
Advertisement
If you want to know the number of pixels lit, you should just start an occlusion query before you begin drawing, and fetch it after you're done.

Fragments that are killed by early-out hacks like hierarchical z never make it into the shader, and aren't counted by the query (unless it's bugged).
On the other hand, fragments that are discarded due to z comparison have already been lit, so it is correct to count them.

If you really want to know the number of pixels that made it throug the z comparison (this is usually significantly less than the number of pixels lit), it is simply the width*height of your render target (assuming there are no "holes").
If there may be "holes" in your scene, and you still want to count the pixels that passed z, you could set the stencil for every pixel that passes to a constant value. After the scene is drawn, start a query, draw a full-screen quad with stencil testing enabled, and fetch the query.

Share this post


Link to post
Share on other sites
hi

thanks for your reply

"If you want to know the number of pixels lit, you should just start an occlusion query before you begin drawing, and fetch it after you're done."

***
***
will also count over-drawn pixels?
so a pixel written at z = 0.9 counts 1
then another pixel drawn over the top at z = 0.5 counts 1 also?
the query might return 1000 but only one pixel lit?
***
***

If there may be "holes" in your scene, and you still want to count the pixels that passed z, you could set the stencil for every pixel that passes to a constant value. After the scene is drawn, start a query, draw a full-screen quad with stencil testing enabled, and fetch the query.

***
***
that is an interesting idea
that could work well with screen tiles
***
***

Share this post


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

  • Advertisement