Skip to main content
GameDev.net gamedev.net
🔒 Locked

Using Occulusion Query

Started by littlekid Dec 31, 2006 at 5:01 AM 6 replies 1.2k views
Original Post
littlekid
littlekid
When using the hardware occulusion querry, do I have to set up the effect and the neccessary constant, like View Matrix, Light Position etc.

...
Device->SetRenderTarget(OcculusionSurface);
Device->BeginScene();

- Do Occulusion Query 1.
setup effect and constant
Query->Issue(D3DISSUE_BEGIN);
Draw BoundingMesh
Query->Issue(D3DISSUE_END);

Do Occulusion Query 2.
Do Occulusion Query 3.

Device->EndScene();
Is this the correct steps? Can I not use any effect at all?
ET3D
ET3D
The occlusion query counts pixels drawn. Therefore if you just want that tested, and not any actual rendering, you can use a simple pixel shader (single colour, or simple alpha shader, if you use alpha testing), instead of a real pixel shader. You'd still have to use the standard vertex shaders, so triangles will be drawn correctly.
circlesoft
circlesoft
Yea, like ET3D stated, you only have to make sure some arbitrary color gets rendered. This allows us to make some optimizations:

1) You can play around with D3DRS_COLORWRITEENABLE to only write to a single channel

2) Use a lower-precision or lower-channel format

3) Use a smaller surface (ie 320x240 instead of 1024x768)

Remember that if at all possible, wait between 1-3 frames before forcing the retrieval of the query. Otherwise, you are going to stall your application.
littlekid
littlekid
But won't by down sizing the render target clip alway portions that might be drawn in the 1024x768?
I keep having this idea that by down sizing the render target, chunks of the image that is in the 1024x768 surface is lost as the 320x240 would clip to get the necessary portion.

Is it correct? I am sorry but my concept on rendering target is not that good. I do know that in post-processing image, I have to down-sample to reduce the number of pixels to process. Thats about all that I know about render target.

Plus how do I exactly use D3DRS_COLORWRITEENABLE and how does it work? the SDK doc says a set bit result in the color begin updated. Does it means if I set D3DCOLORWRITEENABLE_RED, only the red will get update while the Green and blue will not be written on the surface?

By the way, thanks circlesoft, your kbase article did help me gain alot of new ideas. :)

[Edited by - littlekid on December 31, 2006 9:40:20 PM]
ET3D
ET3D
Your rendering surface will render the same thing, regardless of its size, as long as you use the same transforms (and assuming your viewport is the entire surface). So rendering onto a smaller surface would still show the same objects, just fewer pixels of them. Objects which are just a few pixels can disappear this way, so if you want this kind of accuracy, you might not want to scale down. But normally it shouldn't be a serious problem.

And yes, that's the way D3DRS_COLORWRITEENABLE works.
littlekid
littlekid
Thanks alot ET3D and circlesoft for your replies. [smile]
tgraupmann
tgraupmann
I find it odd that the query lacks support for the option to not count transparent pixels.
*News tagenigma.com is my new domain.
Sneftel
Sneftel
Quote:
Original post by tgraupmann
I find it odd that the query lacks support for the option to not count transparent pixels.

I would assume that if alpha testing is enabled, it won't count them anyway.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.